[emos] 01/05: New upstream 4.3.3

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jan 5 21:56:55 UTC 2016


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

mckinstry pushed a commit to branch debian/master
in repository emos.

commit 08567830c7c1953eb774c1ca98947e9423826214
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Mon Jan 4 03:38:35 2016 +0000

    New upstream 4.3.3
---
 AUTHORS                                            |    6 +
 CMakeLists.txt                                     |  171 +-
 ChangeLog                                          |  107 +
 INSTALL                                            |   35 +
 LICENSE                                            |    2 +-
 VERSION.cmake                                      |    2 +-
 bamboo/CLANG-env.sh                                |    8 +
 bamboo/{opensuse131-INTEL-env.sh => INTEL-env.sh}  |    0
 bamboo/flags.cmake                                 |    9 +-
 bin/CMakeLists.txt                                 |    3 +
 bin/ecbuild                                        |  424 ++++
 bufrdc_wmo/bcmatb.F                                |    0
 bufrdc_wmo/bcmatbc.F                               |    0
 bufrdc_wmo/bcmbef.F                                |    0
 bufrdc_wmo/bcmct.F                                 |    0
 bufrdc_wmo/bcmctc.F                                |    0
 bufrdc_wmo/bcmdefc.F                               |    0
 bufrdc_wmo/bcmel.F                                 |    0
 bufrdc_wmo/bcmoff.F                                |    0
 bufrdc_wmo/bcmroot.F                               |    0
 bufrdc_wmo/bcmrq.F                                 |    0
 bufrdc_wmo/bcmtab.F                                |    0
 bufrdc_wmo/bcmtabc.F                               |    0
 bufrdc_wmo/bcmtabload.F                            |    0
 bufrdc_wmo/bcmwork.F                               |    0
 bufrdc_wmo/bcmwt.F                                 |    0
 bufrdc_wmo/bcmwtc.F                                |    0
 bufrdc_wmo/bcomatb.F                               |    0
 bufrdc_wmo/bcomatbc.F                              |    0
 bufrdc_wmo/bcombef.F                               |    0
 bufrdc_wmo/bcomcom.F                               |    0
 bufrdc_wmo/bcomct.F                                |    0
 bufrdc_wmo/bcomctc.F                               |    0
 bufrdc_wmo/bcomdefc.F                              |    0
 bufrdc_wmo/bcomel.F                                |    0
 bufrdc_wmo/bcomoff.F                               |    0
 bufrdc_wmo/bcomp.F                                 |    0
 bufrdc_wmo/bcomreq.F                               |    0
 bufrdc_wmo/bcomroot.F                              |    0
 bufrdc_wmo/bcomrq.F                                |    0
 bufrdc_wmo/bcomtab.F                               |    0
 bufrdc_wmo/bcomtabc.F                              |    0
 bufrdc_wmo/bcomtabload.F                           |    0
 bufrdc_wmo/bcomtabloadc.F                          |    0
 bufrdc_wmo/bcomunit.F                              |    0
 bufrdc_wmo/bcomwork.F                              |    0
 bufrdc_wmo/bcomwt.F                                |    0
 bufrdc_wmo/bcomwtc.F                               |    0
 bufrdc_wmo/bcprq.F                                 |    0
 bufrdc_wmo/big_endian.F                            |    0
 bufrdc_wmo/btable.F                                |    0
 bufrdc_wmo/btable1.F                               |    0
 bufrdc_wmo/bu_check_s4s.F                          |    0
 bufrdc_wmo/buens4.F                                |    5 +
 bufrdc_wmo/buexs4.F                                |    5 +
 bufrdc_wmo/bustop.F                                |    0
 bufrdc_wmo/ctable.F                                |    0
 bufrdc_wmo/ctable1.F                               |    0
 bufrdc_wmo/dtable.F                                |    0
 bufrdc_wmo/dtable1.F                               |    0
 bufrdc_wmo/getcode.F                               |    0
 bufrdc_wmo/parameter.F                             |    0
 bufrdc_wmo/swap_bytes4.F                           |    0
 bufrdc_wmo/swap_bytes8.F                           |    0
 bufrtables/D0000000000000016000.TXT                |    2 +-
 bufrtables/D0000000000001016001.TXT                |    2 +-
 bufrtables/D0000000000002016001.TXT                |    2 +-
 bufrtables/D0000000000003016001.TXT                |    2 +-
 bufrtables/D0000000000004016001.TXT                |    2 +-
 bufrtables/D0000000000005016001.TXT                |    2 +-
 bufrtables/D0000000000006016001.TXT                |    2 +-
 bufrtables/D0000000000007016001.TXT                |    2 +-
 bufrtables/D0000000000008016001.TXT                |    2 +-
 bufrtables/D0000000000009016001.TXT                |    2 +-
 bufrtables/D0000000000010016001.TXT                |    2 +-
 bufrtables/D0000000000011016001.TXT                |    2 +-
 bufrtables/D0000000000012016001.TXT                |    2 +-
 bufrtables/D0000000000013016001.TXT                |    2 +-
 bufrtables/D0000000000014016001.TXT                |    2 +-
 bufrtables/D0000000000015016001.TXT                |    2 +-
 bufrtables/D0000000000016016001.TXT                |    2 +-
 bufrtables/D0000000000017016001.TXT                |    2 +-
 bufrtables/D0000000000018016001.TXT                |    2 +-
 bufrtables/D0000000000019016001.TXT                |    2 +-
 bufrtables/D0000000000020016001.TXT                |    2 +-
 bufrtables/D0000000000021016001.TXT                |    2 +-
 bufrtables/D0000000000022016001.TXT                |    2 +-
 bufrtables/D0000000000023016001.TXT                |    2 +-
 bufrtables/D0000000000024016001.TXT                |    2 +-
 bufrtables/D0000000000025016001.TXT                |    2 +-
 bufrtables/D0000000000026016001.TXT                |    2 +-
 bufrtables/D0000000000027016001.TXT                |    2 +-
 bufrtables/D0000000000028016001.TXT                |    2 +-
 bufrtables/D0000000000029016001.TXT                |    2 +-
 bufrtables/D0000000000030016001.TXT                |    2 +-
 bufrtables/D0000000000031016001.TXT                |    2 +-
 bufrtables/D0000000000032016001.TXT                |    2 +-
 bufrtables/D0000000000033016001.TXT                |    2 +-
 bufrtables/D0000000000034016001.TXT                |    2 +-
 bufrtables/D0000000000035016001.TXT                |    2 +-
 bufrtables/D0000000000036016001.TXT                |    2 +-
 bufrtables/D0000000000037016001.TXT                |    2 +-
 bufrtables/D0000000000038016001.TXT                |    2 +-
 bufrtables/D0000000000039016001.TXT                |    2 +-
 bufrtables/D0000000000040016001.TXT                |    2 +-
 bufrtables/D0000000000041016001.TXT                |    2 +-
 bufrtables/D0000000000042016001.TXT                |    2 +-
 bufrtables/D0000000000043016001.TXT                |    2 +-
 bufrtables/D0000000000044016001.TXT                |    2 +-
 bufrtables/D0000000000045016001.TXT                |    2 +-
 bufrtables/D0000000000046016001.TXT                |    2 +-
 bufrtables/D0000000000047016001.TXT                |    2 +-
 bufrtables/D0000000000048016001.TXT                |    2 +-
 bufrtables/D0000000000049016001.TXT                |    2 +-
 bufrtables/D0000000000050016001.TXT                |    2 +-
 bufrtables/D0000000000051016001.TXT                |    2 +-
 bufrtables/D0000000000052016001.TXT                |    2 +-
 bufrtables/D0000000000053016001.TXT                |    2 +-
 bufrtables/D0000000000054016001.TXT                |    2 +-
 bufrtables/D0000000000055016001.TXT                |    2 +-
 bufrtables/D0000000000056016001.TXT                |    2 +-
 bufrtables/D0000000000057016001.TXT                |    2 +-
 bufrtables/D0000000000058016001.TXT                |    2 +-
 bufrtables/D0000000000059016001.TXT                |    2 +-
 bufrtables/D0000000000060016001.TXT                |    2 +-
 bufrtables/D0000000000061016001.TXT                |    2 +-
 bufrtables/D0000000000062016001.TXT                |    2 +-
 bufrtables/D0000000000063016001.TXT                |    2 +-
 bufrtables/D0000000000064016001.TXT                |    2 +-
 bufrtables/D0000000000065016001.TXT                |    2 +-
 bufrtables/D0000000000066016001.TXT                |    2 +-
 bufrtables/D0000000000067016001.TXT                |    2 +-
 bufrtables/D0000000000068016001.TXT                |    2 +-
 bufrtables/D0000000000069016001.TXT                |    2 +-
 bufrtables/D0000000000070016001.TXT                |    2 +-
 bufrtables/D0000000000071016001.TXT                |    2 +-
 bufrtables/D0000000000072016001.TXT                |    2 +-
 bufrtables/D0000000000073016001.TXT                |    2 +-
 bufrtables/D0000000000074016001.TXT                |    2 +-
 bufrtables/D0000000000075016001.TXT                |    2 +-
 bufrtables/D0000000000076016001.TXT                |    2 +-
 bufrtables/D0000000000077016001.TXT                |    2 +-
 bufrtables/D0000000000078016001.TXT                |    2 +-
 bufrtables/D0000000000079016001.TXT                |    2 +-
 bufrtables/D0000000000080016001.TXT                |    2 +-
 bufrtables/D0000000000081016001.TXT                |    2 +-
 bufrtables/D0000000000082016001.TXT                |    2 +-
 bufrtables/D0000000000083016001.TXT                |    2 +-
 bufrtables/D0000000000084016001.TXT                |    2 +-
 bufrtables/D0000000000085016001.TXT                |    2 +-
 bufrtables/D0000000000086016001.TXT                |    2 +-
 bufrtables/D0000000000087016001.TXT                |    2 +-
 bufrtables/D0000000000088016001.TXT                |    2 +-
 bufrtables/D0000000000089016001.TXT                |    2 +-
 bufrtables/D0000000000090016001.TXT                |    2 +-
 bufrtables/D0000000000091016001.TXT                |    2 +-
 bufrtables/D0000000000092016001.TXT                |    2 +-
 bufrtables/D0000000000093016001.TXT                |    2 +-
 bufrtables/D0000000000094016001.TXT                |    2 +-
 bufrtables/D0000000000095016001.TXT                |    2 +-
 bufrtables/D0000000000096016001.TXT                |    2 +-
 bufrtables/D0000000000097016001.TXT                |    2 +-
 bufrtables/D0000000000098016001.TXT                |    2 +-
 bufrtables/D0000000000098016101.TXT                |    2 +-
 bufrtables/D0000000000099016001.TXT                |    2 +-
 bufrtables/D0000000000100016001.TXT                |    2 +-
 bufrtables/D0000000000101016001.TXT                |    2 +-
 bufrtables/D0000000000102016001.TXT                |    2 +-
 bufrtables/D0000000000103016001.TXT                |    2 +-
 bufrtables/D0000000000104016001.TXT                |    2 +-
 bufrtables/D0000000000105016001.TXT                |    2 +-
 bufrtables/D0000000000106016001.TXT                |    2 +-
 bufrtables/D0000000000107016001.TXT                |    2 +-
 bufrtables/D0000000000108016001.TXT                |    2 +-
 bufrtables/D0000000000109016001.TXT                |    2 +-
 bufrtables/D0000000000110016001.TXT                |    2 +-
 bufrtables/D0000000000111016001.TXT                |    2 +-
 bufrtables/D0000000000112016001.TXT                |    2 +-
 bufrtables/D0000000000113016001.TXT                |    2 +-
 bufrtables/D0000000000114016001.TXT                |    2 +-
 bufrtables/D0000000000115016001.TXT                |    2 +-
 bufrtables/D0000000000116016001.TXT                |    2 +-
 bufrtables/D0000000000117016001.TXT                |    2 +-
 bufrtables/D0000000000118016001.TXT                |    2 +-
 bufrtables/D0000000000119016001.TXT                |    2 +-
 bufrtables/D0000000000120016001.TXT                |    2 +-
 bufrtables/D0000000000121016001.TXT                |    2 +-
 bufrtables/D0000000000122016001.TXT                |    2 +-
 bufrtables/D0000000000123016001.TXT                |    2 +-
 bufrtables/D0000000000124016001.TXT                |    2 +-
 bufrtables/D0000000000125016001.TXT                |    2 +-
 bufrtables/D0000000000126016001.TXT                |    2 +-
 bufrtables/D0000000000127016001.TXT                |    2 +-
 bufrtables/D0000000000128016001.TXT                |    2 +-
 bufrtables/D0000000000129016001.TXT                |    2 +-
 bufrtables/D0000000000130016001.TXT                |    2 +-
 bufrtables/D0000000000131016001.TXT                |    2 +-
 bufrtables/D0000000000132016001.TXT                |    2 +-
 bufrtables/D0000000000133016001.TXT                |    2 +-
 bufrtables/D0000000000134016001.TXT                |    2 +-
 bufrtables/D0000000000135016001.TXT                |    2 +-
 bufrtables/D0000000000136016001.TXT                |    2 +-
 bufrtables/D0000000000137016001.TXT                |    2 +-
 bufrtables/D0000000000138016001.TXT                |    2 +-
 bufrtables/D0000000000139016001.TXT                |    2 +-
 bufrtables/D0000000000140016001.TXT                |    2 +-
 bufrtables/D0000000000141016001.TXT                |    2 +-
 bufrtables/D0000000000142016001.TXT                |    2 +-
 bufrtables/D0000000000143016001.TXT                |    2 +-
 bufrtables/D0000000000144016001.TXT                |    2 +-
 bufrtables/D0000000000145016001.TXT                |    2 +-
 bufrtables/D0000000000146016001.TXT                |    2 +-
 bufrtables/D0000000000147016001.TXT                |    2 +-
 bufrtables/D0000000000148016001.TXT                |    2 +-
 bufrtables/D0000000000149016001.TXT                |    2 +-
 bufrtables/D0000000000150016001.TXT                |    2 +-
 bufrtables/D0000000000151016001.TXT                |    2 +-
 bufrtables/D0000000000152016001.TXT                |    2 +-
 bufrtables/D0000000000153016001.TXT                |    2 +-
 bufrtables/D0000000000154016001.TXT                |    2 +-
 bufrtables/D0000000000155016001.TXT                |    2 +-
 bufrtables/D0000000000156016001.TXT                |    2 +-
 bufrtables/D0000000000157016001.TXT                |    2 +-
 bufrtables/D0000000000158016001.TXT                |    2 +-
 bufrtables/D0000000000159016001.TXT                |    2 +-
 bufrtables/D0000000000160016001.TXT                |    2 +-
 bufrtables/D0000000000161016001.TXT                |    2 +-
 bufrtables/D0000000000162016001.TXT                |    2 +-
 bufrtables/D0000000000163016001.TXT                |    2 +-
 bufrtables/D0000000000164016001.TXT                |    2 +-
 bufrtables/D0000000000165016001.TXT                |    2 +-
 bufrtables/D0000000000166016001.TXT                |    2 +-
 bufrtables/D0000000000167016001.TXT                |    2 +-
 bufrtables/D0000000000168016001.TXT                |    2 +-
 bufrtables/D0000000000169016001.TXT                |    2 +-
 bufrtables/D0000000000170016001.TXT                |    2 +-
 bufrtables/D0000000000171016001.TXT                |    2 +-
 bufrtables/D0000000000172016001.TXT                |    2 +-
 bufrtables/D0000000000173016001.TXT                |    2 +-
 bufrtables/D0000000000174016001.TXT                |    2 +-
 bufrtables/D0000000000175016001.TXT                |    2 +-
 bufrtables/D0000000000176016001.TXT                |    2 +-
 bufrtables/D0000000000177016001.TXT                |    2 +-
 bufrtables/D0000000000178016001.TXT                |    2 +-
 bufrtables/D0000000000179016001.TXT                |    2 +-
 bufrtables/D0000000000180016001.TXT                |    2 +-
 bufrtables/D0000000000181016001.TXT                |    2 +-
 bufrtables/D0000000000182016001.TXT                |    2 +-
 bufrtables/D0000000000183016001.TXT                |    2 +-
 bufrtables/D0000000000184016001.TXT                |    2 +-
 bufrtables/D0000000000185016001.TXT                |    2 +-
 bufrtables/D0000000000186016001.TXT                |    2 +-
 bufrtables/D0000000000187016001.TXT                |    2 +-
 bufrtables/D0000000000188016001.TXT                |    2 +-
 bufrtables/D0000000000189016001.TXT                |    2 +-
 bufrtables/D0000000000190016001.TXT                |    2 +-
 bufrtables/D0000000000191016001.TXT                |    2 +-
 bufrtables/D0000000000192016001.TXT                |    2 +-
 bufrtables/D0000000000193016001.TXT                |    2 +-
 bufrtables/D0000000000194016001.TXT                |    2 +-
 bufrtables/D0000000000195016001.TXT                |    2 +-
 bufrtables/D0000000000196016001.TXT                |    2 +-
 bufrtables/D0000000000197016001.TXT                |    2 +-
 bufrtables/D0000000000198016001.TXT                |    2 +-
 bufrtables/D0000000000199016001.TXT                |    2 +-
 bufrtables/D0000000000200016001.TXT                |    2 +-
 bufrtables/D0000000000201016001.TXT                |    2 +-
 bufrtables/D0000000000202016001.TXT                |    2 +-
 bufrtables/D0000000000203016001.TXT                |    2 +-
 bufrtables/D0000000000204016001.TXT                |    2 +-
 bufrtables/D0000000000205016001.TXT                |    2 +-
 bufrtables/D0000000000206016001.TXT                |    2 +-
 bufrtables/D0000000000207016001.TXT                |    2 +-
 bufrtables/D0000000000208016001.TXT                |    2 +-
 bufrtables/D0000000000209016001.TXT                |    2 +-
 bufrtables/D0000000000210016001.TXT                |    2 +-
 bufrtables/D0000000000211016001.TXT                |    2 +-
 bufrtables/D0000000000212016001.TXT                |    2 +-
 bufrtables/D0000000000213016001.TXT                |    2 +-
 bufrtables/D0000000000214016001.TXT                |    2 +-
 bufrtables/D0000000000215016001.TXT                |    2 +-
 bufrtables/D0000000000216016001.TXT                |    2 +-
 bufrtables/D0000000000217016001.TXT                |    2 +-
 bufrtables/D0000000000218016001.TXT                |    2 +-
 bufrtables/D0000000000219016001.TXT                |    2 +-
 bufrtables/D0000000000220016001.TXT                |    2 +-
 bufrtables/D0000000000221016001.TXT                |    2 +-
 bufrtables/D0000000000222016001.TXT                |    2 +-
 bufrtables/D0000000000223016001.TXT                |    2 +-
 bufrtables/D0000000000224016001.TXT                |    2 +-
 bufrtables/D0000000000225016001.TXT                |    2 +-
 bufrtables/D0000000000226016001.TXT                |    2 +-
 bufrtables/D0000000000227016001.TXT                |    2 +-
 bufrtables/D0000000000228016001.TXT                |    2 +-
 bufrtables/D0000000000229016001.TXT                |    2 +-
 bufrtables/D0000000000230016001.TXT                |    2 +-
 bufrtables/D0000000000231016001.TXT                |    2 +-
 bufrtables/D0000000000232016001.TXT                |    2 +-
 bufrtables/D0000000000233016001.TXT                |    2 +-
 bufrtables/D0000000000234016001.TXT                |    2 +-
 bufrtables/D0000000000235016001.TXT                |    2 +-
 bufrtables/D0000000000236016001.TXT                |    2 +-
 bufrtables/D0000000000237016001.TXT                |    2 +-
 bufrtables/D0000000000238016001.TXT                |    2 +-
 bufrtables/D0000000000239016001.TXT                |    2 +-
 bufrtables/D0000000000240016001.TXT                |    2 +-
 bufrtables/D0000000000241016001.TXT                |    2 +-
 bufrtables/D0000000000242016001.TXT                |    2 +-
 bufrtables/D0000000000243016001.TXT                |    2 +-
 bufrtables/D0000000000244016001.TXT                |    2 +-
 bufrtables/D0000000000245016001.TXT                |    2 +-
 bufrtables/D0000000000246016001.TXT                |    2 +-
 bufrtables/D0000000000247016001.TXT                |    2 +-
 bufrtables/D0000000000248016001.TXT                |    2 +-
 bufrtables/D0000000000249016001.TXT                |    2 +-
 bufrtables/D0000000000250016001.TXT                |    2 +-
 bufrtables/D0000000000251016001.TXT                |    2 +-
 bufrtables/D0000000000252016001.TXT                |    2 +-
 bufrtables/D0000000000253016001.TXT                |    2 +-
 bufrtables/D0000000000254016001.TXT                |    2 +-
 bufrtables/D0000000000255016001.TXT                |    2 +-
 bufrtables/VERSION.cmake                           |    2 +-
 bufrtables/links.sh                                |  523 ++--
 cmake/FindADSM.cmake                               |    2 +-
 cmake/FindAEC.cmake                                |    2 +-
 cmake/FindAIO.cmake                                |    2 +-
 cmake/FindArmadillo.cmake                          |    2 +-
 cmake/FindCMath.cmake                              |    2 +-
 cmake/FindDl.cmake                                 |    2 +-
 cmake/FindEMOS.cmake                               |    2 +-
 cmake/FindFDB.cmake                                |    2 +-
 cmake/FindHPSS.cmake                               |    2 +-
 cmake/FindLEX.cmake                                |    2 +-
 cmake/FindLegacyFDB.cmake                          |    2 +-
 cmake/FindLibGFortran.cmake                        |   16 +-
 cmake/FindNDBM.cmake                               |    2 +-
 cmake/FindNetCDF.cmake                             |   46 +-
 cmake/FindNetCDF3.cmake                            |    2 +-
 cmake/FindODB.cmake                                |    2 +-
 cmake/FindOpenJPEG.cmake                           |    2 +-
 cmake/FindPGIFortran.cmake                         |    2 +-
 cmake/FindPango.cmake                              |   16 +-
 cmake/FindPangoCairo.cmake                         |   14 +-
 cmake/FindProj4.cmake                              |   18 +-
 cmake/FindREADLINE.cmake                           |    6 +-
 cmake/FindRPCGEN.cmake                             |    2 +-
 cmake/FindRealtime.cmake                           |    2 +-
 cmake/FindSZip.cmake                               |    2 +-
 cmake/FindTrilinos.cmake                           |    2 +-
 cmake/FindXLFortranLibs.cmake                      |    2 +-
 cmake/FindYACC.cmake                               |    2 +-
 cmake/Findgrib_api.cmake                           |   44 +-
 cmake/Findodb_api.cmake                            |    2 +-
 cmake/Findspot.cmake                               |    2 +-
 cmake/VERSION.cmake                                |    6 +-
 cmake/contrib/FindNetCDF4.cmake                    |   40 +-
 cmake/ecbuild_add_c_flags.cmake                    |   80 +
 cmake/ecbuild_add_cxx11_flags.cmake                |   22 +-
 cmake/ecbuild_add_cxx_flags.cmake                  |   80 +
 cmake/ecbuild_add_executable.cmake                 |  205 +-
 cmake/ecbuild_add_extra_search_paths.cmake         |    4 +-
 cmake/ecbuild_add_fortran_flags.cmake              |   86 +
 cmake/ecbuild_add_library.cmake                    |  283 ++-
 cmake/ecbuild_add_option.cmake                     |  117 +-
 cmake/ecbuild_add_persistent.cmake                 |   41 +-
 cmake/ecbuild_add_resources.cmake                  |   47 +-
 cmake/ecbuild_add_test.cmake                       |  145 +-
 cmake/ecbuild_append_to_rpath.cmake                |   27 +-
 cmake/ecbuild_bundle.cmake                         |  344 +--
 cmake/ecbuild_cache.cmake                          |   36 +-
 cmake/ecbuild_check_c_source.cmake                 |  161 --
 cmake/ecbuild_check_c_source_return.cmake          |  154 ++
 cmake/ecbuild_check_compiler.cmake                 |   22 +-
 cmake/ecbuild_check_cxx11.cmake                    |   32 +-
 cmake/ecbuild_check_cxx_source.cmake               |  160 --
 cmake/ecbuild_check_cxx_source_return.cmake        |  163 ++
 cmake/ecbuild_check_fortran_source.cmake           |  157 --
 cmake/ecbuild_check_fortran_source_return.cmake    |  155 ++
 cmake/ecbuild_check_functions.cmake                |   16 +-
 cmake/ecbuild_check_os.cmake                       |   87 +-
 cmake/ecbuild_config.h.in                          |    2 +-
 cmake/ecbuild_debug_var.cmake                      |   47 -
 cmake/ecbuild_declare_project.cmake                |  240 +-
 cmake/ecbuild_define_build_types.cmake             |    2 +-
 cmake/ecbuild_define_options.cmake                 |    6 +-
 cmake/ecbuild_define_paths.cmake                   |    2 +-
 cmake/ecbuild_dont_pack.cmake                      |   24 +-
 cmake/ecbuild_download_resource.cmake              |   14 +-
 cmake/ecbuild_echo_targets.cmake                   |   71 +-
 cmake/ecbuild_enable_fortran.cmake                 |   82 +-
 cmake/ecbuild_features.cmake                       |   51 +-
 cmake/ecbuild_find_fortranlibs.cmake               |   23 +-
 cmake/ecbuild_find_lexyacc.cmake                   |   98 +-
 cmake/ecbuild_find_mpi.cmake                       |  128 +-
 cmake/ecbuild_find_omp.cmake                       |   70 +-
 cmake/ecbuild_find_package.cmake                   |  194 +-
 cmake/ecbuild_find_perl.cmake                      |   30 +-
 cmake/ecbuild_find_python.cmake                    |  124 +-
 cmake/ecbuild_generate_config_headers.cmake        |   64 +-
 cmake/ecbuild_generate_fortran_interfaces.cmake    |  115 +
 cmake/ecbuild_generate_rpc.cmake                   |   33 +-
 cmake/ecbuild_generate_yy.cmake                    |  232 +-
 cmake/ecbuild_get_cxx11_flags.cmake                |   13 +-
 cmake/ecbuild_get_date.cmake                       |   30 +-
 cmake/ecbuild_get_resources.cmake                  |   16 +-
 cmake/ecbuild_get_test_data.cmake                  |  265 +-
 cmake/ecbuild_git.cmake                            |  307 +++
 cmake/ecbuild_install_package.cmake                |  305 ---
 cmake/ecbuild_install_project.cmake                |  387 +++
 cmake/ecbuild_links_target.cmake                   |   10 +-
 cmake/ecbuild_list_add_pattern.cmake               |   94 +
 cmake/ecbuild_list_exclude_pattern.cmake           |   88 +
 cmake/ecbuild_list_extra_search_paths.cmake        |   50 +-
 cmake/ecbuild_list_macros.cmake                    |   40 +-
 cmake/ecbuild_log.cmake                            |  119 +-
 cmake/ecbuild_pkgconfig.cmake                      |  176 +-
 cmake/ecbuild_policies.cmake                       |    8 +-
 cmake/ecbuild_print_summary.cmake                  |  179 +-
 cmake/ecbuild_project_files.cmake                  |   10 +-
 cmake/ecbuild_requires_macro_version.cmake         |   14 +-
 cmake/ecbuild_separate_sources.cmake               |   42 +-
 cmake/ecbuild_setup_test_framework.cmake           |    6 +-
 cmake/ecbuild_source_flags.cmake                   |   30 +
 cmake/ecbuild_system.cmake                         |   35 +-
 cmake/ecbuild_use_package.cmake                    |  170 +-
 cmake/ecbuild_version.h.in                         |    2 +-
 cmake/ecbuild_warn_unused_files.cmake              |   26 +-
 cmake/gen_source_flags.py                          |   70 +
 cmake/include/ecbuild/boost_test_framework.h       |    2 +-
 cmake/sg.pl                                        |    2 +-
 common/CMakeLists.txt                              |    4 +-
 common/JPointer.h                                  |   25 +
 common/fortint.h                                   |   19 +-
 common/fortran.h                                   |   33 -
 common/fortreal.h                                  |   28 +
 {gribex => common}/grprs.h                         |    0
 compile_cray.sh                                    |   16 -
 crextables/B000207                                 |    0
 crextables/D000207                                 |    0
 data/F640.grib                                     |  Bin 0 -> 6555000 bytes
 data/ISMD01_OKPR.bufr                              |  Bin
 data/N640.grib                                     |  Bin 0 -> 4284072 bytes
 data/O640.grib                                     |  Bin 0 -> 3325552 bytes
 data/intf2_F640_to_F48.grib                        |  Bin 0 -> 38164 bytes
 data/intf2_F640_to_F80.grib                        |  Bin 0 -> 103700 bytes
 data/intf2_F640_to_regular_ll.grib                 |  Bin 0 -> 521140 bytes
 data/intf2_F640_to_rotated_regular_ll.grib         |  Bin 0 -> 521874 bytes
 data/intf2_N640_to_F48.grib                        |  Bin 0 -> 36972 bytes
 data/intf2_N640_to_F80.grib                        |  Bin 0 -> 102508 bytes
 data/intf2_N640_to_N80.grib                        |  Bin 0 -> 71864 bytes
 data/intf2_N640_to_O80.grib                        |  Bin 0 -> 57388 bytes
 data/intf2_N640_to_regular_ll.grib                 |  Bin 0 -> 519948 bytes
 data/intf2_N640_to_rotated_regular_ll.grib         |  Bin 0 -> 520680 bytes
 data/intf2_O640_to_F48.grib                        |  Bin 0 -> 36976 bytes
 data/intf2_O640_to_F80.grib                        |  Bin 0 -> 102512 bytes
 data/intf2_O640_to_N80.grib                        |  Bin 0 -> 71868 bytes
 data/intf2_O640_to_O80.grib                        |  Bin 0 -> 57392 bytes
 data/intf2_O640_to_regular_ll.grib                 |  Bin 0 -> 519952 bytes
 data/intf2_O640_to_rotated_regular_ll.grib         |  Bin 0 -> 520684 bytes
 data/intf2_regular_ll_to_F48.grib                  |  Bin 0 -> 1980 bytes
 data/intf2_regular_ll_to_F80.grib                  |  Bin 0 -> 5308 bytes
 data/intf2_regular_ll_to_regular_ll.grib           |  Bin 0 -> 24758 bytes
 data/intf2_sh_vod_to_F48.grib                      |  Bin 0 -> 73944 bytes
 data/intf2_sh_vod_to_F80.grib                      |  Bin 0 -> 205016 bytes
 data/intf2_sh_vod_to_N80.grib                      |  Bin 0 -> 143728 bytes
 data/intf2_sh_vod_to_O80.grib                      |  Bin 0 -> 114776 bytes
 data/intf2_sh_vod_to_regular_ll.grib               |  Bin 0 -> 1039896 bytes
 data/intf2_sh_vod_to_rotated_regular_ll.grib       |  Bin 0 -> 1041360 bytes
 data/intf2_sh_z_to_F48.grib                        |  Bin 0 -> 36972 bytes
 data/intf2_sh_z_to_F80.grib                        |  Bin 0 -> 102508 bytes
 data/intf2_sh_z_to_N80.grib                        |  Bin 0 -> 71864 bytes
 data/intf2_sh_z_to_O80.grib                        |  Bin 0 -> 57388 bytes
 data/intf2_sh_z_to_regular_ll.grib                 |  Bin 0 -> 519948 bytes
 data/intf2_sh_z_to_rotated_regular_ll.grib         |  Bin 0 -> 520680 bytes
 data/intuvp2_sh_vod_to_F80.grib                    |  Bin 0 -> 205016 bytes
 data/intuvp2_sh_vod_to_N80.grib                    |  Bin 0 -> 143728 bytes
 data/intuvp2_sh_vod_to_O80.grib                    |  Bin 0 -> 114776 bytes
 data/intuvp2_sh_vod_to_regular_ll.grib             |  Bin 0 -> 29496 bytes
 data/latlon.grib                                   |  Bin 960 -> 0 bytes
 data/regular_ll.grib                               |  Bin 0 -> 858 bytes
 data/sh_vod.grib                                   |  Bin 0 -> 6560796 bytes
 data/sh_z.grib                                     |  Bin 0 -> 3280398 bytes
 .../surface_gaussian_reduced.grib1                 |  Bin
 {tests/data_in => data}/surface_latlon.grib1       |  Bin
 data/tigge.grib2                                   |  Bin
 .../tracks_05W_PEIPAH_2014041000.eps.bufr          |  Bin
 .../tracks_05W_PEIPAH_2014041000.eps.bufr4         |  Bin
 .../tracks_05W_PEIPAH_2014041000.fm                |    0
 .../tracks_15U_ITA_2014041000.eps.bufr             |  Bin
 .../tracks_15U_ITA_2014041000.eps.bufr4            |  Bin
 .../tracks_15U_ITA_2014041000.fm                   |    0
 .../tracks_15U_ITA_2014041012.det.bufr             |  Bin
 .../tracks_15U_ITA_2014041012.det.bufr4            |  Bin
 .../tracks_15U_ITA_2014041012.fm                   |    0
 grib_api_merging/CMakeLists.txt                    |   19 -
 grib_api_merging/copy_spec_from_ksec.c             |  249 --
 grib_api_merging/emos.c                            |  125 -
 grib_api_merging/emos.h                            |   41 -
 grib_api_merging/example.c                         |  184 --
 grib_api_merging/fortint.h                         |   30 -
 grib_api_merging/intf2.c                           |  301 ---
 grib_api_merging/intuvp2.c                         |  435 ----
 gribex/0-INDEX-0                                   |    2 +
 gribex/CMakeLists.txt                              |  111 +-
 gribex/ECMWFdefinitions.h                          |   10 +-
 gribex/abortx.F                                    |    2 +-
 gribex/bt_cray.F                                   |    0
 gribex/bt_cyber.F                                  |    0
 gribex/bt_ibm.F                                    |    0
 gribex/bt_ibm_bal.bal                              |    0
 gribex/bt_sun.F                                    |    0
 gribex/bt_sun_c.c                                  |    0
 gribex/bt_vax.F                                    |    0
 gribex/bt_vax_mar.mar                              |    0
 gribex/c2bitw.F                                    |    0
 gribex/c2cwid.F                                    |    2 +-
 gribex/c2dosd.F                                    |    2 +-
 gribex/c2gene.F                                    |    2 +-
 gribex/c2ordr.F                                    |    2 +-
 gribex/c2pack.F                                    |    2 +-
 gribex/c2pkvw.F                                    |    2 +-
 gribex/c2rnge.F                                    |    0
 gribex/c2rows.F                                    |    2 +-
 gribex/calcop.F                                    |    2 +-
 gribex/confp3.F                                    |    2 +-
 gribex/csect4.F                                    |    2 +-
 gribex/csgnbt.c                                    |    8 +-
 gribex/d2ordr.F                                    |    2 +-
 gribex/d2rosd.F                                    |    2 +-
 gribex/decfp2.F                                    |    2 +-
 gribex/decops2.F                                   |    2 +-
 gribex/dggsec2.F                                   |    2 +-
 gribex/dlasec2.F                                   |    2 +-
 gribex/dllsec2.F                                   |    2 +-
 gribex/dmesec2.F                                   |    2 +-
 gribex/docsec2.F                                   |    2 +-
 gribex/dpssec2.F                                   |    2 +-
 gribex/dsect4a.F                                   |    2 +-
 gribex/dsgnbt.c                                    |    8 +-
 gribex/dshsec2.F                                   |    2 +-
 gribex/dsvsec2.F                                   |    2 +-
 gribex/ecdef1.F                                    |    2 +-
 gribex/ecdef1.h                                    |    0
 gribex/ecdef10.F                                   |    2 +-
 gribex/ecdef10.h                                   |    0
 gribex/ecdef11.F                                   |    2 +-
 gribex/ecdef11.h                                   |    0
 gribex/ecdef12.F                                   |    2 +-
 gribex/ecdef12.h                                   |    0
 gribex/ecdef13.F                                   |    2 +-
 gribex/ecdef13.h                                   |    0
 gribex/ecdef14.F                                   |    2 +-
 gribex/ecdef14.h                                   |    0
 gribex/ecdef15.F                                   |    2 +-
 gribex/ecdef15.h                                   |    0
 gribex/ecdef16.F                                   |    2 +-
 gribex/ecdef16.h                                   |    0
 gribex/ecdef17.F                                   |    2 +-
 gribex/ecdef17.h                                   |    0
 gribex/ecdef18.F                                   |    2 +-
 gribex/ecdef19.F                                   |    2 +-
 gribex/ecdef2.F                                    |    2 +-
 gribex/ecdef2.h                                    |    0
 gribex/ecdef3.F                                    |    2 +-
 gribex/ecdef3.h                                    |    0
 gribex/ecdef4.F                                    |    2 +-
 gribex/ecdef4.h                                    |    0
 gribex/ecdef5.F                                    |    2 +-
 gribex/ecdef5.h                                    |    0
 gribex/ecdef6.F                                    |    2 +-
 gribex/ecdef6.h                                    |    0
 gribex/ecdef7.F                                    |    2 +-
 gribex/ecdef7.h                                    |    0
 gribex/ecdef8.F                                    |    2 +-
 gribex/ecdef8.h                                    |    0
 gribex/ecdef9.F                                    |    2 +-
 gribex/ecdef9.h                                    |    0
 gribex/ecloc1.F                                    |    2 +-
 gribex/eggsec2.F                                   |    2 +-
 gribex/elasec2.F                                   |    2 +-
 gribex/ellsec2.F                                   |    2 +-
 gribex/emesec2.F                                   |    2 +-
 gribex/emoscyc.F                                   |    2 +-
 gribex/emoslibVersion.c                            |    0
 gribex/eocsec2.F                                   |    2 +-
 gribex/eocsec2.h                                   |    0
 gribex/epssec2.F                                   |    2 +-
 gribex/eshsec2.F                                   |    2 +-
 gribex/esvsec2.F                                   |    2 +-
 gribex/extmap.F                                    |    2 +-
 gribex/findLocalDefinitionFile.c                   |   22 +-
 gribex/fortint.h                                   |   35 -
 gribex/fortranInterface.c                          |   29 +-
 gribex/fortvalues.h                                |    8 +-
 gribex/gbitmap.F                                   |    2 +-
 gribex/gdecode.h                                   |    7 +-
 gribex/grchk1.F                                    |    2 +-
 gribex/grchk2.F                                    |    2 +-
 gribex/grchk3.F                                    |    2 +-
 gribex/grchk4.F                                    |    2 +-
 gribex/grib_int_t.h                                |    9 +-
 gribex/gribex.F                                    |    2 +-
 gribex/gribex.h                                    |    0
 gribex/gribnum.F                                   |    2 +-
 gribex/groutpt.F                                   |    2 +-
 gribex/grpr190.c                                   |    8 +-
 gribex/grprs0.F                                    |    2 +-
 gribex/grprs1.F                                    |    2 +-
 gribex/grprs1b.F                                   |    2 +-
 gribex/grprs2.F                                    |    2 +-
 gribex/grprs3.F                                    |    2 +-
 gribex/grprs4.F                                    |    2 +-
 gribex/grprs4w.F                                   |    2 +-
 gribex/grsdef.F                                    |    2 +-
 gribex/grsmax.F                                    |    0
 gribex/grsmkp.F                                    |    0
 gribex/grsmok.F                                    |    0
 gribex/grsn2o.F                                    |    0
 gribex/grsubc.F                                    |    0
 gribex/grsx2o.F                                    |    0
 gribex/gscale.F                                    |    2 +-
 gribex/inscal.F                                    |    2 +-
 gribex/insmp1.F                                    |    2 +-
 gribex/insmp2.F                                    |    2 +-
 gribex/inxbit.F                                    |    2 +-
 gribex/inxmap.F                                    |    2 +-
 gribex/jabort.c                                    |    0
 gribex/jfree.c                                     |    0
 gribex/jmalloc.c                                   |   10 +-
 gribex/kwchk1.F                                    |    2 +-
 gribex/kwloc1.F                                    |    2 +-
 gribex/kwprs1.F                                    |    2 +-
 gribex/maxmni.F                                    |    0
 gribex/offset2.F                                   |    2 +-
 gribex/orefdat.c                                   |    8 +-
 gribex/packcf.F                                    |    2 +-
 gribex/prtbin.F                                    |    2 +-
 gribex/ptquasi.F                                   |    2 +-
 gribex/qu2reg2.F                                   |    0
 gribex/qu2reg3.F                                   |    2 +-
 gribex/ref2grb.F                                   |    2 +-
 gribex/revero.F                                    |    2 +-
 gribex/rowina2.F                                   |    0
 gribex/rowina3.F                                   |    2 +-
 gribex/sencode.h                                   |    8 +-
 gribex/setpar.F                                    |    2 +-
 gribex/tab2fil.F                                   |    2 +-
 gribex/unpkcf.F                                    |    2 +-
 gribex/valpina.c                                   |    8 +-
 gribtables/cen080/local_table_2_version_201        |    0
 gribtables/local_table_2_version_128               |    0
 gribtables/local_table_2_version_129               |    0
 gribtables/local_table_2_version_130               |    0
 gribtables/local_table_2_version_131               |    0
 gribtables/local_table_2_version_132               |    0
 gribtables/local_table_2_version_140               |    0
 gribtables/local_table_2_version_150               |    0
 gribtables/local_table_2_version_151               |    0
 gribtables/local_table_2_version_160               |    0
 gribtables/local_table_2_version_162               |    0
 gribtables/local_table_2_version_170               |    0
 gribtables/local_table_2_version_171               |    0
 gribtables/local_table_2_version_172               |    0
 gribtables/local_table_2_version_173               |    0
 gribtables/local_table_2_version_174               |    0
 gribtables/local_table_2_version_175               |    0
 gribtables/local_table_2_version_180               |    0
 gribtables/local_table_2_version_190               |    0
 gribtables/local_table_2_version_200               |    0
 gribtables/local_table_2_version_201               |    0
 gribtables/local_table_2_version_210               |    0
 gribtables/local_table_2_version_211               |    0
 gribtables/local_table_2_version_220               |    0
 gribtables/local_table_2_version_228               |    0
 gribtables/local_table_2_version_230               |    0
 .../localDefinitionTemplate_098_000_027.old        |    0
 gribtemplates/localDefinitionTemplate_098_000_030  |    0
 gribtemplates/localDefinitionTemplate_098_000_031  |    0
 gribtemplates/localDefinitionTemplate_098_000_032  |    0
 gribtemplates/localDefinitionTemplate_098_000_035  |    0
 interpolation/0-INDEX-0                            |  521 ++--
 interpolation/CMakeLists.txt                       |   85 +-
 interpolation/Imakefile                            |   17 -
 interpolation/areachk.F                            |   44 +-
 interpolation/auresol.F                            |   92 +-
 interpolation/bitmap.h                             |   15 +-
 interpolation/clear_c.F                            |   21 +-
 interpolation/consint.F90                          |  424 ----
 interpolation/copy_spec_from_ksec.c                |  239 ++
 interpolation/csum.F                               |   80 -
 interpolation/current.h                            |   12 +-
 interpolation/debug.h                              |   97 -
 .../describe_input_field.c                         |    0
 interpolation/dpath_tables_interpol.F              |  129 -
 interpolation/dpath_tables_interpol.F90            |  129 +
 interpolation/dssarea.F                            |   37 +-
 interpolation/dummy.F                              |   18 -
 interpolation/dummy2.F                             |   18 -
 interpolation/emos.c                               |  125 +
 interpolation/emos.h                               |   41 +
 interpolation/estima.F                             |   29 +-
 interpolation/eulavgg.F                            |  145 --
 interpolation/fixarea.F                            |   86 +-
 interpolation/forced_fftw.F                        |   29 +
 interpolation/fortdefs.h                           |   22 -
 interpolation/gasetup.F                            |  165 +-
 interpolation/gb2gb.F                              |  367 ---
 interpolation/gghtype.F                            |   73 +
 interpolation/ggintrp.F                            |   58 +-
 interpolation/ggrotat.F                            |   48 +-
 interpolation/ggvalue.F                            |   44 +-
 interpolation/gmapbit.c                            |    7 +-
 interpolation/grprs.h                              |   16 -
 interpolation/hgengg.F                             |   44 +-
 interpolation/hgenllw.F                            |  257 --
 interpolation/hgetlsm.F                            |   27 +-
 interpolation/hirlam.F                             |  130 +-
 interpolation/hirlamw.F                            |  117 +-
 interpolation/hirlsm.F                             |  118 +-
 interpolation/hneill.F                             |   16 +-
 interpolation/hntfaph.F                            |  334 +--
 interpolation/hntfaps.F                            |   63 +-
 interpolation/hntfau.F                             |   26 +-
 interpolation/hntfauh.F                            |  567 +++--
 interpolation/hntfaus.F                            |   72 +-
 interpolation/hntfbu.F                             |  434 ----
 interpolation/hrg2gg.F                             |   92 +-
 interpolation/hrg2ggw.F                            |  115 +-
 interpolation/hrg2ll.F                             |  443 ----
 interpolation/hrg2llw.F                            |  520 ----
 interpolation/hsh2gg.F                             |  262 ++
 interpolation/hsp2gg.F                             |  183 --
 interpolation/hsp2gg2.F                            |  232 --
 interpolation/hsp2gg3.F                            |  193 --
 interpolation/iagcntl.F                            |   28 +-
 interpolation/iaidef.F                             |  553 -----
 interpolation/iaintgg.F                            |  552 -----
 interpolation/iaintll.F                            |  577 -----
 interpolation/iaogdef.F                            |  421 ----
 interpolation/iaoldef.F                            |  471 ----
 interpolation/iarcntl.F                            |   19 +-
 interpolation/iareset.F                            |  307 ---
 interpolation/iarmem.F                             |  237 --
 interpolation/ibasini.F                            |    3 +-
 interpolation/igdiwe.F                             |  538 ++---
 interpolation/iggrid.F                             |    2 +-
 interpolation/iglrev.F                             |  242 --
 interpolation/iglsmb.F                             |  175 +-
 interpolation/iglsmd.F                             |   59 +-
 interpolation/iglsmst.F                            |    8 +-
 interpolation/igscan.F                             |  359 ---
 interpolation/igsetup.F                            |   65 +-
 interpolation/igsize.F                             |    7 +-
 interpolation/igtog.F                              |    1 -
 interpolation/igtogr.F                             |  253 --
 interpolation/igtran.F                             |  345 ---
 interpolation/init_cm.F                            |  309 ---
 interpolation/insane.F                             |   23 +-
 interpolation/intf.F                               |   19 +-
 interpolation/intf2.c                              |  321 +++
 interpolation/intfa.F                              |  182 --
 interpolation/intfap.F                             |   14 +-
 interpolation/intfau.F                             |   14 +-
 interpolation/intfb.F                              |  146 +-
 interpolation/intfbp.F                             |  469 ----
 interpolation/intfbu.F                             |   59 +-
 interpolation/intfc.F                              |  125 -
 interpolation/intin.F                              |  279 ++-
 interpolation/intisl.F                             |    6 +-
 interpolation/intlog.F                             |    2 +-
 interpolation/intlogr.F                            |    4 +-
 interpolation/intout.F                             |  246 +-
 interpolation/intpnum.F                            |   14 +-
 interpolation/intuvdh.F                            |    9 +-
 interpolation/intuvf.F                             |  324 ---
 interpolation/intuvgh.F                            |   33 +-
 interpolation/intuvp.F                             |   40 +-
 interpolation/intuvp2.c                            |  445 ++++
 interpolation/intuvph.F                            |  552 -----
 {grib_api_merging => interpolation}/intuvs2.c      |    0
 interpolation/intuvu.F                             |  177 +-
 interpolation/intuvxh.F                            |   60 +-
 interpolation/intvect.F                            |  511 ----
 {grib_api_merging => interpolation}/intvect2.c     |    0
 interpolation/intvecy.F                            |  110 +-
 interpolation/intwave.F                            |  544 -----
 interpolation/intwave2.F                           |   24 +-
 interpolation/intwavu.F                            |   58 +-
 interpolation/irdiwe.F                             |  267 +-
 interpolation/irgmem.F                             |   26 +-
 interpolation/irlrev.F                             |  244 --
 interpolation/irlsmb.F                             |  124 +-
 interpolation/irscan.F                             |  306 ---
 interpolation/is_wave_direction.F                  |   31 +
 interpolation/iscrsz.F                             |   33 +-
 interpolation/isggvalid.F                          |   65 +
 interpolation/isoctahedral.F                       |   63 +
 interpolation/issame.F                             |   77 +-
 interpolation/issameiarray.F                       |   51 +
 interpolation/issamerarray.F                       |   51 +
 interpolation/ixtract.c                            |  112 -
 interpolation/jacobif.F                            |  836 -------
 interpolation/jagggp.F                             |  188 +-
 interpolation/jallgp.F                             |   38 +-
 interpolation/jgetgg.F                             |  107 +-
 interpolation/jintend.F                            |  129 -
 interpolation/jintgg.F                             |  415 ----
 interpolation/jintll.F                             |  364 ---
 interpolation/jmakll.F                             |   20 +-
 interpolation/jmemhan.F                            |   10 +-
 interpolation/jmemhan2.F                           |    4 +-
 interpolation/jmkofgg.F                            |   52 +-
 interpolation/jmovgg.F                             |   18 +-
 interpolation/jnumgg.F                             |   21 +-
 interpolation/jnumggq.F                            |  119 -
 interpolation/jopngg.F                             |   72 +-
 interpolation/jopnggf.F                            |   52 +-
 interpolation/jopnggsm.c                           |   74 +-
 interpolation/jopnll.F                             |   12 +-
 interpolation/jopnllsm.c                           |  108 +-
 interpolation/jparam2.h                            |    3 +-
 interpolation/jparams.h                            |   13 +-
 interpolation/jsgggp.F                             |   46 +-
 interpolation/jstrll.F                             |    2 +-
 interpolation/jstrwll.F                            |    2 +-
 interpolation/jsymgg.F                             |  154 +-
 interpolation/jsymll.F                             |    7 +-
 interpolation/jtimer.c                             |   56 -
 interpolation/juvpole.F                            |   15 +-
 interpolation/jwindll.F                            |    2 +-
 interpolation/kintrg.F                             |   11 +-
 interpolation/knfrom4.F                            |    3 +-
 interpolation/krg2rg.F                             |   22 +-
 interpolation/krg2rgd.F                            |   32 +-
 interpolation/krg2rgu.F                            |   45 +-
 interpolation/krg2rgy.F                            |   66 +-
 interpolation/krg2rgz.F                            |   50 +-
 interpolation/lgrpr4.F                             |  225 --
 interpolation/lrekam.F                             |  191 --
 interpolation/lsmfld.F                             |   11 +-
 interpolation/makemap.c                            |    7 +-
 interpolation/makerl.F                             |  192 --
 interpolation/my_ialloc.c                          |   28 -
 interpolation/ngintrp.F                            |   54 +-
 interpolation/ngrotat.F                            |   44 +-
 interpolation/ngvalue.F                            |   24 +-
 interpolation/nptwe32.F                            |  128 -
 interpolation/oceanp.F                             |    7 +-
 interpolation/oceanu.F                             |   42 +-
 interpolation/old/createSharedMemoryCoefficients.c |  195 --
 interpolation/old/sharedMemoryCharacteristics.c    |  175 --
 interpolation/old/smread.c                         |  225 --
 interpolation/ouspace.h                            |   84 -
 interpolation/parim.h                              |   19 +-
 interpolation/pddefs.F                             |    4 -
 interpolation/ppallow.F                            |  227 --
 interpolation/psizes.F                             |   13 -
 interpolation/qgoct.F                              |   32 +
 interpolation/rddefs.c                             |  479 ----
 interpolation/rename_unlink.c                      |    2 +-
 interpolation/reset_c.F                            |   23 +-
 interpolation/rgauss_080_19980130.h                |   31 -
 interpolation/rgauss_640_octahedral_not_used.h     |  139 --
 interpolation/rgauss_8000.h                        | 1611 -------------
 interpolation/rphi.F                               |    2 +-
 interpolation/shareddt.c                           |   11 +-
 interpolation/sharedgg.c                           |   27 +-
 interpolation/sharedll.c                           |   25 +-
 interpolation/sharedmemory.h                       |   42 -
 interpolation/showmap.c                            |   53 -
 interpolation/soffset.c                            |  200 --
 interpolation/sprotat.F                            |  229 --
 interpolation/strlat.F                             |    2 +-
 interpolation/tatorgg.F                            |  225 --
 interpolation/valpina.c                            |  243 --
 interpolation/w251idx.F                            |    4 +-
 interpolation/waveidx.F                            |   29 +-
 interpolation/wavexx1.F                            |  663 -----
 interpolation/wavexx2.F                            |  165 +-
 interpolation/wavexxx.F                            |  645 -----
 interpolation/wv2di32.F                            |  342 ---
 interpolation/wv2didx.F                            |   12 +-
 interpolation/wv2dint.F                            |   14 +-
 interpolation/wv2dppp.F                            |  156 --
 interpolation/wv2dx32.F                            |  484 ----
 interpolation/wv2dxx2.F                            |  119 +-
 interpolation/wv2dxxx.F                            |  496 ----
 interpolation/wvqlidx.F                            |   46 +-
 interpolation/wvqlin2.F                            |   97 +-
 interpolation/wvqlint.F                            |   92 +-
 interpolation/xrotate.F                            |   84 -
 land_sea_mask/0-INDEX-0                            |   30 -
 land_sea_mask/LSM_GG_0048                          |  Bin 106240 -> 0 bytes
 land_sea_mask/LSM_GG_0080                          |  Bin 285744 -> 0 bytes
 land_sea_mask/LSM_GG_0128                          |  Bin 710704 -> 0 bytes
 land_sea_mask/LSM_GG_0160                          |  Bin 1106768 -> 0 bytes
 land_sea_mask/LSM_GG_0200                          |  Bin 1711904 -> 0 bytes
 land_sea_mask/LSM_GG_0256                          |  Bin 2788224 -> 0 bytes
 land_sea_mask/LSM_GG_0400                          |  Bin 6747920 -> 0 bytes
 land_sea_mask/LSM_GG_0640                          |  Bin 17125616 -> 0 bytes
 land_sea_mask/defaults_for_table_001               |   11 -
 land_sea_mask/defaults_for_table_128               |   14 -
 land_sea_mask/defaults_for_table_129               |   14 -
 land_sea_mask/ksm_xx_lsm0p5deg                     |  Bin 32490 -> 0 bytes
 land_sea_mask/lsm_xx_lsm0p25deg                    |  Bin 129780 -> 0 bytes
 land_sea_mask/lsm_xx_lsm0p5deg                     |  Bin 32568 -> 0 bytes
 land_sea_mask/lsm_xx_lsm10m01                      |  Bin 293760 -> 0 bytes
 land_sea_mask/lsm_xx_lsmn080                       |  Bin 6440 -> 0 bytes
 land_sea_mask/lsm_xx_lsmr160                       |  Bin 17296 -> 0 bytes
 land_sea_mask/parameter_processing_defaults        |   27 -
 land_sea_mask/r160_xx_19790930                     |    1 -
 land_sea_mask/r160_xx_19910917                     |  Bin 16836 -> 0 bytes
 land_sea_mask/r160_xx_19930804                     |    1 -
 land_sea_mask/r160_xx_19940302                     |    1 -
 land_sea_mask/r160_xx_19940823                     |    1 -
 land_sea_mask/r160_xx_19950404                     |    1 -
 libemos-dp/CMakeLists.txt                          |   15 +-
 libemos-sp/CMakeLists.txt                          |   21 +-
 libemos.dox                                        | 2381 ------------------
 pbio/CMakeLists.txt                                |    1 -
 pbio/PBGroutines.c                                 |    0
 pbio/PBGroutines.h                                 |    0
 pbio/blokex.F                                      |    0
 pbio/bufrgrib.h                                    |    0
 pbio/emosnum.F                                     |    4 +-
 pbio/extras.c                                      |    0
 pbio/fileRead.h                                    |    0
 pbio/fort2c.c                                      |    0
 pbio/fort2c.h                                      |    0
 pbio/fortint.h                                     |   24 -
 pbio/fortran.h                                     |   44 +
 pbio/gbyte.c                                       |   18 +-
 pbio/grprs.h                                       |   16 -
 pbio/lwsize.c                                      |    8 +-
 pbio/mvchars.c                                     |   10 +-
 pbio/newpbio.c                                     |  104 +-
 pbio/pbbufr.F                                      |    0
 pbio/pbcrex.F                                      |    0
 pbio/pbgrib.F                                      |    0
 pbio/pbio.c                                        |   66 +-
 pbio/pbio_alpha.c                                  |   42 +-
 pbio/pbionum.F                                     |    2 +-
 pbio/pbpseu.F                                      |    0
 pbio/pbsize.c                                      |   14 +-
 pbio/readany.c                                     |   16 +-
 pbio/readbufr.c                                    |   16 +-
 pbio/readcrex.c                                    |   16 +-
 pbio/readgrib.c                                    |   16 +-
 pbio/readnext.c                                    |   22 +-
 pbio/readprod.c                                    |   96 +-
 pbio/readprod_alpha.c                              |   42 +-
 pbio/setpar.c                                      |   10 +-
 sandbox/CMakeLists.txt                             |   21 +
 sandbox/emos_tool.c                                | 1062 ++++++++
 share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake     |   81 +
 share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake      |   73 +
 share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake    |   76 +
 tables/interpol/0-INDEX-0                          |  130 +-
 tables/interpol/LSM_GG_0032                        |    1 +
 tables/interpol/LSM_GG_0032_CY41R1                 |    1 +
 tables/interpol/LSM_GG_0048                        |  Bin 106240 -> 16 bytes
 tables/interpol/LSM_GG_0048_CY41R1                 |  Bin 106240 -> 16 bytes
 tables/interpol/LSM_GG_0080                        |  Bin 285744 -> 16 bytes
 tables/interpol/LSM_GG_0080_CY41R1                 |  Bin 285744 -> 16 bytes
 tables/interpol/LSM_GG_0096                        |    1 +
 tables/interpol/LSM_GG_0096_CY41R1                 |    1 +
 tables/interpol/LSM_GG_0128                        |  Bin 710704 -> 17 bytes
 tables/interpol/LSM_GG_0128_CY41R1                 |  Bin 710704 -> 17 bytes
 tables/interpol/LSM_GG_0160                        |  Bin 1106768 -> 17 bytes
 tables/interpol/LSM_GG_0160_CY41R1                 |  Bin 1106768 -> 17 bytes
 tables/interpol/LSM_GG_0200                        |  Bin 1711904 -> 17 bytes
 tables/interpol/LSM_GG_0200_CY41R1                 |  Bin 1711904 -> 17 bytes
 tables/interpol/LSM_GG_0256                        |  Bin 2788224 -> 17 bytes
 tables/interpol/LSM_GG_0256_CY41R1                 |  Bin 2788224 -> 17 bytes
 tables/interpol/LSM_GG_0320                        |  Bin 4336640 -> 17 bytes
 tables/interpol/LSM_GG_0320_CY41R1                 |  Bin 4336640 -> 17 bytes
 tables/interpol/LSM_GG_0400                        |  Bin 6747920 -> 17 bytes
 tables/interpol/LSM_GG_0400.lxab                   |  Bin 6747920 -> 0 bytes
 tables/interpol/LSM_GG_0400_CY41R1                 |  Bin 6747920 -> 17 bytes
 tables/interpol/LSM_GG_0512                        |    1 +
 tables/interpol/LSM_GG_0512_CY41R1                 |    1 +
 tables/interpol/LSM_GG_0640                        |  Bin 17125616 -> 17 bytes
 tables/interpol/LSM_GG_0640_CY41R1                 |  Bin 17125616 -> 17 bytes
 tables/interpol/LSM_GG_1024                        |  Bin 43576944 -> 18 bytes
 tables/interpol/LSM_GG_1024_CY41R1                 |  Bin 43576944 -> 18 bytes
 tables/interpol/LSM_GG_1280                        |    1 +
 tables/interpol/LSM_GG_1280_CY41R1                 |    1 +
 tables/interpol/LSM_O1024                          |    1 +
 tables/interpol/LSM_O1024_CY41R1                   |    1 +
 tables/interpol/LSM_O128                           |    1 +
 tables/interpol/LSM_O1280                          |    1 +
 tables/interpol/LSM_O1280_CY41R1                   |    1 +
 tables/interpol/LSM_O128_CY41R1                    |    1 +
 tables/interpol/LSM_O160                           |    1 +
 tables/interpol/LSM_O160_CY41R1                    |    1 +
 tables/interpol/LSM_O200                           |    1 +
 tables/interpol/LSM_O200_CY41R1                    |    1 +
 tables/interpol/LSM_O256                           |    1 +
 tables/interpol/LSM_O256_CY41R1                    |    1 +
 tables/interpol/LSM_O320                           |    1 +
 tables/interpol/LSM_O320_CY41R1                    |    1 +
 tables/interpol/LSM_O400                           |    1 +
 tables/interpol/LSM_O400_CY41R1                    |    1 +
 tables/interpol/LSM_O512                           |    1 +
 tables/interpol/LSM_O512_CY41R1                    |    1 +
 tables/interpol/LSM_O64                            |    1 +
 tables/interpol/LSM_O640                           |    1 +
 tables/interpol/LSM_O640_CY41R1                    |    1 +
 tables/interpol/LSM_O64_CY41R1                     |    1 +
 tables/interpol/LSM_O80                            |    1 +
 tables/interpol/LSM_O80_CY41R1                     |    1 +
 tables/interpol/LSM_O96                            |    1 +
 tables/interpol/LSM_O96_CY41R1                     |    1 +
 tables/interpol/climate.v014/N1024                 |  Bin 0 -> 43576944 bytes
 tables/interpol/climate.v014/N128                  |  Bin 0 -> 710704 bytes
 tables/interpol/climate.v014/N1280                 |  Bin 0 -> 68047248 bytes
 tables/interpol/climate.v014/N160                  |  Bin 0 -> 1106768 bytes
 tables/interpol/climate.v014/N200                  |  Bin 0 -> 1711904 bytes
 tables/interpol/climate.v014/N256                  |  Bin 0 -> 2788224 bytes
 tables/interpol/climate.v014/N32                   |  Bin 0 -> 48912 bytes
 tables/interpol/climate.v014/N320                  |  Bin 0 -> 4336640 bytes
 tables/interpol/climate.v014/N400                  |  Bin 0 -> 6747920 bytes
 tables/interpol/climate.v014/N48                   |  Bin 0 -> 106240 bytes
 tables/interpol/climate.v014/N512                  |  Bin 0 -> 10988992 bytes
 tables/interpol/climate.v014/N640                  |  Bin 0 -> 17125616 bytes
 tables/interpol/climate.v014/N80                   |  Bin 0 -> 285744 bytes
 tables/interpol/climate.v014/N96                   |  Bin 0 -> 405296 bytes
 tables/interpol/climate.v014/O1024                 |  Bin 0 -> 33849344 bytes
 tables/interpol/climate.v014/O128                  |  Bin 0 -> 561152 bytes
 tables/interpol/climate.v014/O1280                 |  Bin 0 -> 52797440 bytes
 tables/interpol/climate.v014/O160                  |  Bin 0 -> 865280 bytes
 tables/interpol/climate.v014/O200                  |  Bin 0 -> 1337600 bytes
 tables/interpol/climate.v014/O256                  |  Bin 0 -> 2170880 bytes
 tables/interpol/climate.v014/O320                  |  Bin 0 -> 3368960 bytes
 tables/interpol/climate.v014/O400                  |  Bin 0 -> 5235200 bytes
 tables/interpol/climate.v014/O512                  |  Bin 0 -> 8536064 bytes
 tables/interpol/climate.v014/O64                   |  Bin 0 -> 149504 bytes
 tables/interpol/climate.v014/O640                  |  Bin 0 -> 13291520 bytes
 tables/interpol/climate.v014/O80                   |  Bin 0 -> 227840 bytes
 tables/interpol/climate.v014/O96                   |  Bin 0 -> 322560 bytes
 tables/interpol/ksm_xx_lsm0p5deg                   |  Bin 32490 -> 0 bytes
 tests/CMakeLists.txt                               |  595 +++--
 tests/bufr/README                                  |   74 -
 tests/bufr/bufr2crex.F                             |  605 -----
 tests/bufr/bufr_decode.c                           |  182 --
 tests/bufr/create_bufr.F                           |  417 ----
 tests/bufr/crex2bufr.F                             |  499 ----
 tests/bufr/decode_bufr.F                           |  623 -----
 tests/bufr/decode_bufr_image.F                     |  262 --
 tests/bufr/tdexp.F                                 |  187 --
 tests/bufr/test.sh                                 |   12 -
 tests/bufr_data_files.txt                          |    1 +
 tests/bufr_demo.f90                                |  267 --
 tests/crex/Makefile                                |   40 -
 tests/crex/Makefile.in                             |   46 -
 tests/crex/bufr2crex.F                             |  605 -----
 tests/crex/create_crex.F                           |  296 ---
 tests/crex/crex2bufr.F                             |  499 ----
 tests/crex/crextdexp.F                             |  167 --
 tests/crex/decode_crex.F                           |  280 ---
 tests/crex/test.sh                                 |   12 -
 tests/data_in/spectral.grib                        |  Bin 6560880 -> 0 bytes
 tests/data_ref/spectral-ll.grib                    |  Bin 4159584 -> 0 bytes
 tests/data_ref/spectral-rg.grib                    |  Bin 574912 -> 0 bytes
 tests/fft.F                                        |   31 -
 tests/fft99.F                                      |   31 +
 tests/fftw.F                                       |   77 +
 tests/gribex/Makefile                              |   26 -
 tests/gribex/Makefile.in                           |   30 -
 tests/gribex/README                                |   36 -
 tests/gribex/agrdemo.F                             |  265 --
 tests/gribex/find_t.F                              |  101 -
 tests/gribex/test.sh                               |   14 -
 tests/gribex_demo.F                                |  268 +++
 tests/include.sh.in                                |   10 -
 tests/interpolation.F                              |  144 --
 tests/interpolation.sh                             |   38 -
 tests/interpolation_example_grib_api.F             |  163 --
 tests/interpolation_example_gribex.F               |  152 --
 tests/interpolation_example_wind.F                 |  104 -
 tests/link_mars.F                                  |   42 +
 tests/link_prodgen.F                               |   48 +
 tests/tc_tracks.sh                                 |   20 -
 tools/CMakeLists.txt                               |   49 +-
 tools/Dchange_grib/Dchange_grib.f                  |  212 --
 tools/Dchange_grib/Makefile.cluster                |   34 -
 tools/Dchange_grib/Makefile.clusterA64             |   34 -
 tools/Dchange_grib/Makefile.hpia64                 |   32 -
 tools/Dchange_grib/Makefile.ibm_power4             |   36 -
 tools/Dchange_grib/Makefile.linux                  |   34 -
 tools/Dchange_grib/Makefile.linuxA64               |   34 -
 tools/Dchange_grib/Makefile.rs6000                 |   31 -
 tools/Dchange_grib/Makefile.sgimips                |   29 -
 tools/Dchange_grib/changeList                      |   13 -
 tools/bufr_exports/synop2bufr/Makefile             |   32 -
 tools/bufr_exports/synop2bufr/Makefile.in          |   32 -
 tools/bufr_exports/synop2bufr/README               |    0
 tools/bufr_exports/synop2bufr/create_gts_header.f  |    0
 .../bufr_exports/synop2bufr/station_list/Makefile  |   32 -
 .../synop2bufr/station_list/Makefile.in            |   30 -
 .../synop2bufr/station_list/important_stations.dat |    0
 .../station_list/make_synop2bufr_station.f         |    0
 .../synop2bufr/station_list/read_station.f         |    0
 .../synop2bufr/station_list/wmo_make_station.f     |    0
 tools/bufr_exports/synop2bufr/synop2bufr.f         |    0
 tools/bufrtools_wmo/CMakeLists.txt                 |   13 +-
 tools/bufrtools_wmo/bufr_add_bias.F90              |    1 +
 tools/changeExpver/Makefile.hpca                   |   15 -
 tools/changeExpver/Makefile.vpp                    |   11 -
 tools/changeExpver/changeExpver.c                  |  105 -
 tools/changeExpver/fortint.h                       |   14 -
 tools/changeExpver/makefile                        |   14 -
 tools/changeGrib/Makefile                          |   11 -
 tools/changeGrib/Makefile.vpp                      |   11 -
 tools/changeGrib/changeGrib.c                      |  395 ---
 tools/changeStream/Makefile.hpca                   |   18 -
 tools/changeStream/changeStream.c                  |  108 -
 tools/changeStream/fortint.h                       |   14 -
 tools/changeStream/movebytes.h                     |    7 -
 tools/compareGribFiles/Makefile.FUJITSU            |   33 -
 tools/compareGribFiles/Makefile.VPP5000            |   33 -
 tools/compareGribFiles/Makefile.cluster            |   34 -
 tools/compareGribFiles/Makefile.clusterA64         |   34 -
 tools/compareGribFiles/Makefile.hpia64             |   39 -
 tools/compareGribFiles/Makefile.hppa               |   43 -
 tools/compareGribFiles/Makefile.ibm_power4         |   36 -
 tools/compareGribFiles/Makefile.linux              |   34 -
 tools/compareGribFiles/Makefile.rs6000             |   32 -
 tools/compareGribFiles/Makefile.sgimips            |   28 -
 tools/compareGribFiles/PBGroutines.c               | 2545 --------------------
 tools/compareGribFiles/PBGroutines.h               |  180 --
 tools/compareGribFiles/PBXroutines.c               | 1210 ----------
 tools/compareGribFiles/PBXroutines.h               |  100 -
 tools/compareGribFiles/compareGribFiles.F          |  637 -----
 tools/compareGribFiles/dsgnbt.c                    |   30 -
 tools/compareGribFiles/fortint.h                   |    9 -
 tools/compareGribFiles/hash.h                      |   12 -
 tools/compareGribFiles/jdcexit.c                   |   10 -
 tools/compareGribFiles/jmemcmp.c                   |   33 -
 tools/except.c                                     |   24 +
 tools/getGaussianLatitudes/Makefile                |   29 -
 tools/getGaussianLatitudes/grfixed.h               |   68 -
 tools/getGaussianLatitudes/igbess.F                |  169 --
 tools/getGaussianLatitudes/igglat.F                |  272 ---
 tools/getGaussianLatitudes/intf.h                  |   25 -
 tools/getGaussianLatitudes/intlog.F                |  191 --
 tools/getGaussianLatitudes/intlog.h                |    5 -
 tools/getGaussianLatitudes/jgetgg.F                |  289 ---
 tools/getGaussianLatitudes/jparam2.h               |    8 -
 tools/getGaussianLatitudes/jparams.h               |   34 -
 tools/getGaussianLatitudes/parim.h                 |  602 -----
 tools/getGaussianLatitudes/rgauss_1024.h           |  207 --
 tools/getGaussianLatitudes/rgauss_200.h            |   52 -
 tools/getGaussianLatitudes/rgauss_400.h            |   82 -
 tools/getGaussianLatitudes/rgauss_512.h            |  105 -
 tools/getGaussianLatitudes/run                     |    4 -
 tools/gg_gridname.c                                |  211 ++
 tools/gg_latitudes.F                               |  131 +
 tools/grib1profile/GRIB_profile.c                  |  168 --
 tools/grib1profile/Makefile.cluster                |   62 -
 tools/grib1profile/Makefile.hpia64                 |   68 -
 tools/grib1profile/Makefile.hppa                   |   69 -
 tools/grib1profile/Makefile.ibm_power4             |   75 -
 tools/grib1profile/Makefile.linux                  |   62 -
 tools/grib1profile/Makefile.rs6000                 |   75 -
 tools/grib1profile/Makefile.sgimips                |   53 -
 tools/grib1profile/callbacks.c                     |  853 -------
 tools/grib1profile/fortint.h                       |   25 -
 tools/grib1profile/gdecode.h                       |  422 ----
 tools/grib1profile/gdecodeStruct.h                 |  356 ---
 tools/grib1profile/grib.h                          |   18 -
 tools/grib1profile/grib1profile.c                  |  618 -----
 tools/grib1profile/grib1profile.h                  |   22 -
 tools/grib1profile/grib1profile_externs.c          |   57 -
 tools/grib1profile/grib1profile_help               |   63 -
 tools/grib1profile/grprs1.F.dead                   | 1084 ---------
 tools/grib1profile/grprs4n.F                       |  305 ---
 tools/grib1profile/grprs4n.f.dead                  |  271 ---
 tools/grib1profile/jpgrib.c                        |  391 ---
 tools/grib1profile/mars.h                          |    2 -
 tools/grib1profile/mygribex.F                      |   21 -
 tools/grib1profile/pseudoprt.c                     |  299 ---
 tools/grib1profile/sencode1.h                      |   21 -
 tools/int.F                                        |  343 +++
 tools/loadReducedGaussian.pl                       |   53 +-
 tools/lsmReducedGaussian/CMakeLists.txt            |    9 +
 tools/lsmReducedGaussian/LSM_GG_xxxx.generate.sh   |   45 -
 tools/lsmReducedGaussian/Makefile                  |   37 -
 tools/lsmReducedGaussian/broj.F                    |  130 -
 tools/lsmReducedGaussian/ginout.F                  |  125 -
 tools/lsmReducedGaussian/ginout_c.F                |  160 --
 tools/lsmReducedGaussian/land-sea-mask.mars        |   19 -
 tools/lsmReducedGaussian/lsm.mars                  |   85 +
 tools/lsmReducedGaussian/lsmN1024.mars             |   17 -
 tools/lsmReducedGaussian/lsmN320.mars              |   14 -
 tools/lsmReducedGaussian/lsmN400.mars              |   16 -
 tools/lsmReducedGaussian/lsmN640.mars              |   17 -
 tools/lsmReducedGaussian/run                       |    4 -
 tools/lsmReducedGaussian/run.sh                    |   49 +
 tools/modify_grib/Makefile.old                     |   14 -
 tools/modify_grib/chgrib.c                         |  515 ----
 tools/modify_grib/modify_grib.F90                  |  411 ----
 tools/singlePointInterpolation/CMakeLists.txt      |    4 +-
 .../singlePointInterpolation.F                     |   33 +-
 version.c                                          |   20 +-
 1205 files changed, 15728 insertions(+), 54702 deletions(-)

diff --git a/AUTHORS b/AUTHORS
old mode 100755
new mode 100644
index a8db325..732b25e
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,12 @@
+Pedro Maciel
+Tiago Quintino
+
+* past contributors *
 John Hennessy
 John Chambers
 Sinisa Curic
 Milan Dragosavac
 Keith Fielding
 Jean Clochard
+Peter Bispham
+Stephan Siemen
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 421f920..754e82a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,15 +17,22 @@ enable_language( Fortran )
 
 set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake")
 
-include( ecbuild_system )
+include( ecbuild_system NO_POLICY_SCOPE )
 
-ecbuild_requires_macro_version( 1.6 )
+ecbuild_requires_macro_version( 1.9 )
 
-ecbuild_add_option( FEATURE INSTALL_TABLES   DESCRIPTION "enable the installations of BUFR/GRIBex tables and LSM"                       DEFAULT ON )
-ecbuild_add_option( FEATURE INSTALL_TOOLS    DESCRIPTION "enable the installations of BUFR/GRIBex tools"                                DEFAULT ON )
+ecbuild_add_option( FEATURE INSTALL_TABLES   DESCRIPTION "install BUFR/GRIBex/LSM tables"                                               DEFAULT ON )
+ecbuild_add_option( FEATURE INSTALL_TOOLS    DESCRIPTION "install BUFR/GRIBex tools"                                                    DEFAULT ON )
 ecbuild_add_option( FEATURE FORTRAN90        DESCRIPTION "enable tools which need Fortran 90 (only required for FC=pgf77)"              DEFAULT ON )
 ecbuild_add_option( FEATURE SINGLE_PRECISION DESCRIPTION "enable single precision version of library (in addition to double precision)" DEFAULT ON )
-ecbuild_add_option( FEATURE GRIBEX_ABORT     DESCRIPTION "abort execution on GRIBEX calls"                                              DEFAULT ON )
+ecbuild_add_option( FEATURE GRIBEX_ABORT     DESCRIPTION "abort execution on GRIBex calls"                                              DEFAULT ON )
+
+ecbuild_add_option( FEATURE FFTW             DESCRIPTION "Fastest Fourier Transform in the West"                                        DEFAULT ON REQUIRED_PACKAGES FFTW )
+set_package_properties( FFTW PROPERTIES TYPE RECOMMENDED PURPOSE "allows interpolation of spectral to octahedral reduced Gaussian grid" )
+
+ecbuild_add_option( FEATURE LIBEMOS_BUFRDC        DESCRIPTION "enable BUFR decoding functionality" DEFAULT ON )
+ecbuild_add_option( FEATURE LIBEMOS_INTERPOLATION DESCRIPTION "enable interpolation functionality" DEFAULT ON )
+ecbuild_add_option( FEATURE LIBEMOS_GRIBEX        DESCRIPTION "enable GRIBex functionality"        DEFAULT ON )
 
 
 ################################################################################
@@ -39,16 +46,12 @@ endif()
 
 get_filename_component(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
 
-message(">>> CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
-message(">>> CMAKE_Fortran_COMPILER name:      " ${Fortran_COMPILER_NAME})
-message(">>> CMAKE_Fortran_COMPILER ID:        " ${CMAKE_Fortran_COMPILER_ID})
-
 # double precision flags: only for d.p. Fortran-based targets (compiling & linking)
 if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
   set(emos_double_precision_flags "-fdefault-real-8 -fdefault-double-8")
 elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
   set(emos_double_precision_flags "-r8 -i4")
-elseif( CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
+elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
   set(emos_double_precision_flags "-r8 -i4")
 elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
   set(emos_double_precision_flags "-s integer32 -s real64")
@@ -58,56 +61,65 @@ endif()
 
 # build type flags
 if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
-  set(CMAKE_Fortran_FLAGS         "-ffixed-line-length-none -fcray-pointer -fno-second-underscore -Wuninitialized -DSHAREDMEMORY")
-  set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -mtune=native")
-  set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -O2 -mtune=native")
-  set(CMAKE_Fortran_FLAGS_DEBUG   "-g")
+  ecbuild_add_fortran_flags("-ffixed-line-length-none -fcray-pointer -fno-second-underscore -Wuninitialized -Wunused-variable -DSHAREDMEMORY")
+  ecbuild_add_fortran_flags("-O2 -mtune=native"    BUILD RELEASE)
+  ecbuild_add_fortran_flags("-g -O2 -mtune=native" BUILD RELWITHDEBINFO)
+  ecbuild_add_fortran_flags("-g"                   BUILD DEBUG)
   set(emos_special_compiler_def   "gfortran")
 elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
-  set(CMAKE_Fortran_FLAGS         "-DSHAREDMEMORY")
-  set(CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3")
-  set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-f77rtl -O2 -g")
-  set(CMAKE_Fortran_FLAGS_DEBUG   "-f77rtl -O0 -g")
+  ecbuild_add_fortran_flags("-DSHAREDMEMORY")
+  ecbuild_add_fortran_flags("-f77rtl"    BUILD RELEASE)
+  ecbuild_add_fortran_flags("-f77rtl -g" BUILD RELWITHDEBINFO)
+  ecbuild_add_fortran_flags("-f77rtl -g" BUILD DEBUG)
+  if(HAVE_LIBEMOS_GRIBEX)
+    ecbuild_add_fortran_flags("-O1" BUILD RELEASE)         # otherwise breaks GRIBex second-order packing
+    ecbuild_add_fortran_flags("-O1" BUILD RELWITHDEBINFO)  # otherwise breaks GRIBex second-order packing
+    ecbuild_add_fortran_flags("-O0" BUILD DEBUG)
+  else()
+    ecbuild_add_fortran_flags("-O3" BUILD RELEASE)
+    ecbuild_add_fortran_flags("-O2" BUILD RELWITHDEBINFO)
+    ecbuild_add_fortran_flags("-O0" BUILD DEBUG)
+  endif()
 elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
-  set(CMAKE_Fortran_FLAGS         "-fast -Kieee -Mvect=prefetch -noswitcherror -Mextend")
-  set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
-  set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -O2")
-  set(CMAKE_Fortran_FLAGS_DEBUG   "-g")
+  ecbuild_add_fortran_flags("-fast -Kieee -Mvect=prefetch -noswitcherror -Mextend")
+  ecbuild_add_fortran_flags("-O2"    BUILD RELEASE)
+  ecbuild_add_fortran_flags("-g -O2" BUILD RELWITHDEBINFO)
+  ecbuild_add_fortran_flags("-g"     BUILD DEBUG)
 elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
-  set(CMAKE_Fortran_FLAGS         "-ev -Wl,--as-needed -h PIC -emf -hflex_mp=conservative -hfp1 -hadd_paren -DSHAREDMEMORY")
-  set(CMAKE_Fortran_FLAGS_RELEASE "")
-  set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-G2")
-  set(CMAKE_Fortran_FLAGS_DEBUG   "-G0 -hfp0")
-  set(CMAKE_C_FLAGS               "-Wl,--as-needed -h PIC -DSHAREDMEMORY")
-  set(CMAKE_SKIP_RPATH TRUE)
+  ecbuild_add_fortran_flags("-ev -Wl,--as-needed -h PIC -emf -hflex_mp=conservative -hfp1 -hadd_paren -DSHAREDMEMORY")
+  ecbuild_add_fortran_flags("-G2"       BUILD RELWITHDEBINFO)
+  ecbuild_add_fortran_flags("-G0 -hfp0" BUILD DEBUG)
+  ecbuild_add_c_flags("-Wl,--as-needed -h PIC -DSHAREDMEMORY")
 else()
   message("No optimized Fortran compiler flags are known, we just try -O2...")
-  set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
-  set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O2 -g")
-  set(CMAKE_Fortran_FLAGS_DEBUG   "-O0 -g")
+  ecbuild_add_fortran_flags("-O2"    BUILD RELEASE)
+  ecbuild_add_fortran_flags("-O2 -g" BUILD RELWITHDEBINFO)
+  ecbuild_add_fortran_flags("-O0 -g" BUILD DEBUG)
 endif()
 
 
 ################################################################################
-# projects
+# extra packages and projects
 
-ecbuild_use_package( PROJECT grib_api VERSION 1.9.16 REQUIRED )
+ecbuild_use_package( PROJECT grib_api VERSION 1.14.3 REQUIRED )
 
 ecbuild_declare_project()
 
+
 ################################################################################
 # contents
 
 # project export variables
+set( LIBEMOS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
+set( LIBEMOS_LIBRARIES    emos ${GRIB_API_LIBRARIES} )
 
-set( LIBEMOS_INCLUDE_DIRS   ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
-set( LIBEMOS_LIBRARIES      emos )
-set( LIBEMOS_TPLS           grib_api )
-
-set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ECKIT_DEFINITIONS};${GRIB_API_DEFINITIONS}" )
+set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${GRIB_API_DEFINITIONS}" )
 
 include_directories( ${LIBEMOS_INCLUDE_DIRS}  )
 include_directories( ${GRIB_API_INCLUDE_DIRS} )
+if( HAVE_FFTW )
+  include_directories( ${FFTW_INCLUDES} )
+endif()
 
 if( BUFR_TABLES_PATH )
   if( NOT IS_ABSOLUTE "${BUFR_TABLES_PATH}" )
@@ -122,7 +134,6 @@ message( STATUS "BUFR_TABLES_PATH: ${BUFR_TABLES_PATH}" )
 # get_directory_property( LIBEMOS_DEFINITIONS COMPILE_DEFINITIONS ) # don't export libemos definitions
 
 # config header
-
 ecbuild_generate_config_headers( DESTINATION ${INSTALL_INCLUDE_DIR}/libemos )
 
 configure_file( libemos_config.h.in  libemos_config.h  @ONLY )
@@ -139,22 +150,39 @@ install(FILES
 ################################################################################
 # sources
 
+if( HAVE_LIBEMOS_INTERPOLATION AND NOT HAVE_LIBEMOS_GRIBEX )
+  message( FATAL_ERROR "\nCannot build libemos interpolation without GRIBex support!\nPlease pass option to cmake -DENABLE_LIBEMOS_GRIBEX=ON")
+endif()
+
 add_subdirectory( common )
-add_subdirectory( gribex )
-add_subdirectory( interpolation )
-add_subdirectory( bufrdc_wmo )
 add_subdirectory( pbio )
-add_subdirectory( grib_api_merging )
-add_subdirectory( tests )
+
+if( HAVE_LIBEMOS_GRIBEX )
+  add_subdirectory( gribex )
+endif()
+
+if( HAVE_LIBEMOS_INTERPOLATION )
+  add_subdirectory( interpolation )
+  add_subdirectory( sandbox )
+endif()
+
+if( HAVE_LIBEMOS_BUFRDC )
+  add_subdirectory( bufrdc_wmo )
+endif()
+
 if( ENABLE_INSTALL_TOOLS )
   add_subdirectory( tools )
 endif()
 
+add_subdirectory( tests )
+
 #DEFINITIONS  FORTRAN_NO_UNDERSCORE
 
-if( ${Fortran_COMPILER_NAME} MATCHES "ifort" OR CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
-  set_source_files_properties( ${gribex_srcs} PROPERTIES COMPILE_FLAGS "-O0" )
-endif()
+if( HAVE_LIBEMOS_GRIBEX )
+  if( ${Fortran_COMPILER_NAME} MATCHES "ifort" OR CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
+    set_source_files_properties( ${gribex_srcs} PROPERTIES COMPILE_FLAGS "-O0" )
+  endif()
+endif( HAVE_LIBEMOS_GRIBEX )
 
 
 list( APPEND libemos_srcs
@@ -162,8 +190,7 @@ list( APPEND libemos_srcs
   ${interpolation_srcs}
   ${gribex_srcs}
   ${bufrdc_wmo_srcs}
-  ${pbio_srcs}
-  ${grib_api_merging_srcs} )
+  ${pbio_srcs} )
 
 
 ################################################################################
@@ -177,7 +204,6 @@ if( ENABLE_INSTALL_TABLES )
       bufrtables
       gribtables
       gribtemplates
-      land_sea_mask
     DESTINATION ${INSTALL_DATA_DIR}/tables
     FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
 endif()
@@ -201,12 +227,13 @@ file( COPY tables/interpol DESTINATION ${CMAKE_BINARY_DIR}/${INSTALL_DATA_DIR}/t
 
 # always install tables/interpol
 install( DIRECTORY tables/interpol DESTINATION "${INTERPOL_TABLES_PATH}" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
+install( CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink interpol ${CMAKE_INSTALL_PREFIX}/${INSTALL_DATA_DIR}/tables/land_sea_mask)" )
+
 
 ################################################################################
 # final definitions
 
 list( APPEND LIBEMOS_DEFINITIONS
-  ${emos_interpol_tables_def}
   ${emos_special_compiler_def}
   ${emos_special_system_def}
   REAL_8
@@ -218,6 +245,10 @@ list( APPEND LIBEMOS_DEFINITIONS
   INTEGER_IS_INT
   ${GRIB_API_DEFINITIONS} )
 
+# FIXME: LITTLE_ENDIAN is not portable!
+# (EMOS-172: remove this flag, only used in GRIBEX, temporarily enabled for now)
+
+
 ################################################################################
 # targets: libraries (single & douple p.) and version-check executable
 
@@ -228,30 +259,42 @@ if( HAVE_SINGLE_PRECISION )
 endif()
 add_subdirectory( libemos-dp )
 
-ecbuild_add_executable(
-  TARGET      libemos_version
-  DEFINITIONS ${LIBEMOS_DEFINITIONS}
-  LIBS        emos
-  SOURCES     version.c )
+if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" )
+  set_source_files_properties( version.c PROPERTIES COMPILE_DEFINITIONS "FORTRAN_LINKER_PGI" )
+  ecbuild_add_executable(
+    TARGET      libemos_version
+    DEFINITIONS ${LIBEMOS_DEFINITIONS}
+    LIBS        emos
+    SOURCES     version.c
+    LINKER_LANGUAGE Fortran )
+else()
+  ecbuild_add_executable(
+    TARGET      libemos_version
+    DEFINITIONS ${LIBEMOS_DEFINITIONS}
+    LIBS        emos
+    SOURCES     version.c )
+endif()
 
 ecbuild_add_resources( TARGET libemos_rcs SOURCES_DONT_PACK compile.sh )
 
+
 ################################################################################
 # finalize
 
 ecbuild_pkgconfig(
-  NAME        emosR64
+  NAME        libemosR64
   URL         "https://software.ecmwf.int/wiki/display/EMOS/"
   DESCRIPTION "Interpolation library, including BUFR & CREX encoding/decoding routines"
   LANGUAGES   C FORTRAN
-  LIBRARIES   emosR64 )
+  LIBRARIES   emos )  # (double p. target)
+
 if( HAVE_SINGLE_PRECISION )
-ecbuild_pkgconfig(
-  NAME        emos
-  URL         "https://software.ecmwf.int/wiki/display/EMOS/"
-  DESCRIPTION "Interpolation library, including BUFR & CREX encoding/decoding routines (single precision)"
-  LANGUAGES   C FORTRAN
-  LIBRARIES   emos )
+  ecbuild_pkgconfig(
+    NAME        libemos
+    URL         "https://software.ecmwf.int/wiki/display/EMOS/"
+    DESCRIPTION "Interpolation library, including BUFR & CREX encoding/decoding routines (single precision)"
+    LANGUAGES   C FORTRAN
+    LIBRARIES   emos_sp )  # (single p. target)
 endif()
 
 ecbuild_install_project( NAME libemos )
diff --git a/ChangeLog b/ChangeLog
index c02f81b..8ffdd3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,109 @@
+000433
+
+	Improvement
+		* [EMOS-232 - include climate.v014 land-sea masks
+
+000432
+
+	Bug Fixes
+		* [EMOS-216] - interpolations from regular/reduced global grids to regular (lat/lon and F-grids) local grids use old algorithm
+		* [EMOS-230] - fixed some tests failure when calling grib_compare, when grib_api is not installed 
+
+000431
+
+	Bug Fixes
+		* [EMOS-220] - fixed interpolation of wave model parameters sub-areas straddling the Greenwich meridian
+
+000430
+
+	Notes
+		* This release includes corrections related to regular_ll/regular_gg/reduced_gg to regular_ll/regular_gg (performance improvements)
+
+	Improvement
+		* [EMOS-205] - smaller memory allocation for interpolations of u/v on reduced_gg grids
+		* [DAPP-249] - drifting buoys with new BUFR template (subtype 182)
+
+	Bug fixes
+		* [EMOS-188] - HIRLAMW memory allocation issue under very specific conditions
+		* [EMOS-216] - HRES corrections and performance improvement for West-most longitudes and high North/South latitudes, including LSM
+
+000422
+
+	Bug Fixes
+		* [EMOS-220] - fixed interpolation of wave model parameters sub-areas straddling the Greenwich meridian
+
+000421
+
+	Notes
+		* This release is part of ECMWF Development Section Synchronised Release 2015.11
+		* This release requires grib_api/1.14.3
+
+	Improvement
+		* [EMOS-214] - encoding GRIB1 interpolation results with resolution up to 1/16 degrees
+		* [EMOS-226] - removed obsolete GRIBex-based tools (changeExpver, changeGrib, changeStream, compareGribFiles, Dchange_grib, ginout, ginout_c, modify_grib)
+		* Metadata set in double precision (grib_util_grid_spec)
+		* F-grids with arbitrary latitude lines between pole and equator
+		* Unit testing improvements
+		* Fix configuration when -DENABLE_TESTS=OFF
+		* Fix for PGI/GNU mixed compiler builds
+
+000420
+
+	Notes
+		* This release provides support for octahedral reduced Gaussian grids
+		* This release requires grib_api/1.14.2
+		* Tested against BUFR tables version 000406, please check also changes of the previous version 000405
+		* Changes to HIRLAM functions interface, CHARACTER*1 HTYPE as new argument as follows:
+			* HIRLAM(L12PNT,OLDFLD,KOUNT,KGAUSS,HTYPE,AREA,POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
+			* HIRLSM(L12PNT,OLDFLD,KOUNT,KGAUSS,HTYPE,AREA,POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
+			* HIRLAMW(L12PNT,OLDFLDU,OLDFLDV,KOUNT,KGAUSS,HTYPE,AREA,POLE,GRID,NEWFLDU,NEWFLDV,KSIZE,NLON,NLAT)
+		  HTYPE should be one of:
+			* 'R' for "quasi-regular" reduced Gaussian grid (equivalent to 'N')
+			* 'O' for octahedral reduced Gaussian grid, or
+			* 'F' for regular Gaussian grid
+			* 'U' for a user-defined gaussian grid
+		* New HSH2GG function, controlling SH interpolation to Gaussian grids, replaces:
+			* HSP2GG
+			* HSP2GG2
+			* HSP2GG3
+		* New INTOUT parameter name CHARACTER*(*) HPARN "gridname", interpreting parameter value CHARACTER*(*) CHARV, describing a list of supported grids as in [https://software.ecmwf.int/wiki/display/USS/Gaussian+Grids+supported+by+MARS+and+ProdGen]. This is the available method to set interpolation to octahedral reduced Gaussian grids.
+		* Build system:
+			* conditional compilation of components (interpolation, GRIBEX and BUFR)
+			* revision of definitions and code reusing, stricter compilation options
+		* FFTW is an optional Fast Fourier Transform library dependency, required for SH to octahedral reduced Gaussian grid interpolations
+		* Improved interpolation testing
+		* Added new HIRLAM LSM masks for specific reduced Gaussian grids:
+			* N64, N96, N512, N128
+			* O64, O80, O96, O128, O160, O200, O256, O320, O400, O512, O640, O1024, O1280
+		* When using INTF2  (e.g. via MARS),  GRIB "latitudeOfLastGridPoint" for wave model interpolations in some cases was encoded wrongly to -79.0xx and is now corrected to be -90+0.5*inc (see MARS-492)
+
+	Known issues
+		* This release is a preview release, and fails some unit tests. The failures happen when comparing interpolation results to reference data (bundled with the package), where the results GRIB header (wrong) are different from the reference data (correct). This is a known issue with grib_api/1.14.2 and will be resolved on grib_api/1.14.3. The affected tests are:
+			* 8 - intuvp2_sh_vod_to_O80_compare (Failed)
+			* 19 - intf2_sh_2t_to_O80_compare_cmp (Failed)
+			* 30 - intf2_sh_vod_to_O80_compare_cmp (Failed)
+			* 41 - intf2_sh_z_to_O80_compare_cmp (Failed)
+			* 57 - intf2_N640_to_O80_compare (Failed)
+			* 68 - intf2_O640_to_O80_compare_cmp (Failed)
+
+	Improvement
+		* [EMOS-112] - add support for new octahedral reduced gaussian grid - MARS and Metview
+		* [EMOS-159] - add support for new octahedral reduced gaussian grid (as output)
+		* [EMOS-177] - support RGG/octahedral grids (non-rotated)
+		* [EMOS-178] - support RGG/octahedral grids (HIRLAM)
+		* [EMOS-179] - support RGG/octahedral grids (LSM-dependant parameters)
+		* [EMOS-183] - support gridname keyword
+		* [EMOS-185] - add sh to octahedral interpolation
+		* [EMOS-190] - tested interpolation on N64 grid
+		* [EMOS-201] - tested against BUFR tables version 000406
+
+	Bug Fixes
+		* [EMOS-168] - bufr_demo was removed (obsolete)
+		* [EMOS-173] - build fix for emoslib on powerpc (partial fix: consistent types and declarations)
+		* [EMOS-175] - fortint error in EMOSLIB (fix: consistent types and declarations)
+		* [EMOS-186] - memory fault in libemos using fftw
+		* [EMOS-200] - incorrect information in pkg-config files
+
 000411
 
 	Notes
@@ -37,6 +143,7 @@
 
 	Improvement
 		* [EMOS-106] - static memory allocation reduced significantly (BSS)
+		* Support to convert octahedral grids to reduced Gaussian (conversion to LatLong and full Gaussian grid works since 000395)
 
 	Bug Fixes
 		* improved grib_api detection
diff --git a/INSTALL b/INSTALL
new file mode 100755
index 0000000..3748668
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,35 @@
+How to build and install Emoslib library
+========================================
+
+Building and installation has been tested on several platforms and with several compilers.
+However for some platforms modifications to the installation engine may be required.
+If you encounter any problems during the installation procedure please send an e-mail
+with your problem to:
+
+    Software.Support at ecmwf.int
+
+
+Installation using CMake
+------------------------
+Requires that cmake be installed on your system.
+
+1. Download Emoslib from https://software.ecmwf.int/wiki/display/EMOS/Releases
+
+2. Unpack distribution:
+   > tar -xzf libemos-x.y.z-Source.tar.gz
+
+3. Create a separate directory for the build:
+   > mkdir build
+   > cd build
+
+4. Run cmake pointing to the source and specify the installation location
+   > cmake  ../libemos-x.y.z-Source -DCMAKE_INSTALL_PREFIX=/path/to/where/you/install/emoslib
+
+5. Compile, test and install:
+   > make
+   > make test
+   > make install
+
+
+For more details, please see:
+https://software.ecmwf.int/wiki/display/EMOS/Installation+Guide
diff --git a/LICENSE b/LICENSE
index db2bda5..988d1d2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
      same "printed page" as the copyright notice for easier
      identification within third-party archives.
 
-  Copyright 1981-2012 European Centre for Medium-Range Weather Forecasts (ECMWF
+  Copyright 1981-2015 European Centre for Medium-Range Weather Forecasts (ECMWF)
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
diff --git a/VERSION.cmake b/VERSION.cmake
index b4802ab..1c8fa0c 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -2,4 +2,4 @@
 #  Do NOT forget to update  pbio/emosnum.F
 #
 #
-set( ${PROJECT_NAME}_VERSION_STR  "4.1.1" )
+set( ${PROJECT_NAME}_VERSION_STR  "4.3.3" )
diff --git a/bamboo/CLANG-env.sh b/bamboo/CLANG-env.sh
new file mode 100644
index 0000000..32fa108
--- /dev/null
+++ b/bamboo/CLANG-env.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Initialise module environment if it is not
+if [[ ! $(command -v module > /dev/null 2>&1) ]]; then
+  . /usr/local/apps/module/init/bash
+fi
+module unload grib_api
+module switch gnu clang/3.6.2
diff --git a/bamboo/opensuse131-INTEL-env.sh b/bamboo/INTEL-env.sh
similarity index 100%
rename from bamboo/opensuse131-INTEL-env.sh
rename to bamboo/INTEL-env.sh
diff --git a/bamboo/flags.cmake b/bamboo/flags.cmake
index a0372cb..2b2f117 100644
--- a/bamboo/flags.cmake
+++ b/bamboo/flags.cmake
@@ -1,13 +1,10 @@
 set( BUFR_TABLES_PATH "bufr/text" CACHE STRING "" )
 
-SET(CMAKE_Fortran_COMPILER 
-	gfortran 
-	CACHE STRING "Fortran compiler")
-
 SET(CMAKE_C_FLAGS 
-	"-DTABLE_PATH=\\\"emos\\\" -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -Dgfortran -DLITTLE_ENDIAN"
+	"-Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -DLITTLE_ENDIAN"
 	CACHE STRING "C flags")
 
 SET(CMAKE_Fortran_FLAGS 
-	"-DTABLE_PATH=\\\"emos\\\" -fcray-pointer -fdefault-real-8 -fdefault-double-8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -Dgfortran -DLITTLE_ENDIAN"
+	"-fcray-pointer -fdefault-real-8 -fdefault-double-8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -DLITTLE_ENDIAN"
 	CACHE STRING "Fortran flags")
+
diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt
new file mode 100644
index 0000000..24a12cf
--- /dev/null
+++ b/bin/CMakeLists.txt
@@ -0,0 +1,3 @@
+if( ENABLE_INSTALL )
+	install( PROGRAMS ecbuild DESTINATION ${INSTALL_BIN_DIR} )
+endif()
diff --git a/bin/ecbuild b/bin/ecbuild
new file mode 100755
index 0000000..1876fbd
--- /dev/null
+++ b/bin/ecbuild
@@ -0,0 +1,424 @@
+#!/bin/bash
+
+set -eua
+
+CMAKE_MIN_REQUIRED=2.8.10
+CMAKE_BUILD_VERSION=3.3.2
+
+usage()
+{
+  echo "Usage: ecbuild [--help] [--version]"
+  exit $1
+}
+
+help()
+{
+    cat <<EOF
+USAGE:
+
+  ecbuild [--help] [--version] [--toolchains]
+  ecbuild [option...] [--] [cmake-argument...] <path-to-source>
+  ecbuild [option...] [--] [cmake-argument...] <path-to-existing-build>
+
+DESCRIPTION:
+
+  ecbuild is a build system based on CMake, but providing a lot of macro's
+  to make it easier to work with. Upon execution,
+  the equivalent cmake command is printed.
+
+  ecbuild/cmake must be called from an out-of-source build directory and
+  forbids in-source builds.
+
+SYNOPSIS:
+
+    --help         Display this help
+    --version      Display ecbuild version
+    --toolchains   Display list of pre-installed toolchains (see below)
+
+
+Available values for "option":
+
+    --cmakebin=<path>
+          Set which cmake binary to use. Default is 'cmake'
+
+    --prefix=<prefix>
+          Set the install path to <prefix>.
+          Equivalent to cmake argument "-DCMAKE_INSTALL_PREFIX=<prefix>"
+
+    --build=<build-type>
+          Set the build-type to <build-type>.
+          Equivalent to cmake argument "-DCMAKE_BUILD_TYPE=<build-type>"
+          <build-type> can be any of:
+             - debug : Lowest optimization level, useful for debugging
+             - release : Highest optimization level, for best performance
+             - bit : Highest optimization level while staying bit-reproducible
+             - ...others depending on project
+
+    --log=<log-level>
+          Set the ecbuild log-level
+          Equivalent to "-DECBUILD_LOG_LEVEL=<log-level>"
+          <log-level> can be any of:
+             - DEBUG
+             - INFO
+             - WARN
+             - ERROR
+             - CRITICAL
+             - OFF
+          Every choice outputs also the log-levels listed below itself
+
+    --static
+          Build static libraries.
+          Equivalent to "-DBUILD_SHARED_LIBS=OFF"
+
+    --dynamic
+          Build dynamic libraries (usually the default).
+          Equivalent to "-DBUILD_SHARED_LIBS=ON"
+
+    --shared     (same option as --dynamic)
+          Build dynamic libraries (usually the default).
+          Equivalent to "-DBUILD_SHARED_LIBS=ON"
+
+    --toolchain=<toolchain>
+          Use a platform specific toolchain, containing settings such
+          as compilation flags, locations of commonly used dependencies.
+          <toolchain> can be the path to a custom toolchain file, or a
+          pre-installed toolchain provided with ecbuild. For a list of
+          pre-installed toolchains, run "ecbuild --toolchains".
+          Equivalent to cmake argument "-DCMAKE_TOOLCHAIN_FILE=<toolchain-file>"
+
+    --cache=<ecbuild-cache-file>    (advanced)
+          A file called "ecbuild-cache.cmake" is generated during configuration.
+          This file can be moved to a safe location, and specified for future
+          builds to speed up checking of compiler/platform capabilities. Note
+          that this is only accelerating fresh builds, as cmake internally
+          caches also. Therefore this option is *not* recommended.
+
+    --build-cmake
+          Automatically download and build CMake version $CMAKE_BUILD_VERSION if the CMake
+          version found does not meet the minimum requirements (version $CMAKE_MIN_REQUIRED
+          is required). Requires an internet connection and may take a while.
+
+    --dryrun
+          Don't actually execute the cmake call, just print what would have
+          been executed.
+
+
+Available values for "cmake-argument":
+
+    Any value that can be usually passed to cmake to (re)configure the build.
+    Typically these values start with "-D".
+        example:  -DENABLE_TESTS=ON  -DENABLE_MPI=OFF  -DECKIT_PATH=...
+
+    They can be explicitly separated from [option...] with a "--", for the case
+    there is a conflicting option with the "cmake" executable, and the latter's
+    option is requested.
+
+------------------------------------------------------------------------
+
+NOTE: When reconfiguring a build, it is only necessary to change the relevant
+options, as everything stays cached. For example:
+  > ecbuild --prefix=PREFIX .
+  > ecbuild -DENABLE_TESTS=ON .
+
+------------------------------------------------------------------------
+
+Compiling:
+
+  To compile the project with <N> threads:
+    > make -j<N>
+
+  To get verbose compilation/linking output:
+    > make VERBOSE=1
+
+Testing:
+
+  To run the project's tests
+    > ctest
+
+  Also check the ctest manual/help for more options on running tests
+
+Installing:
+
+  To install the project in location PREFIX with
+       "--prefix=PREFIX" or
+       "-DCMAKE_INSTALL_PREFIX=PREFIX"
+    > make install
+
+------------------------------------------------------------------------
+ECMWF"
+
+EOF
+    exit $1
+}
+
+INSTALL_DIR="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"
+ECBUILD_MODULE_PATH=""
+# If there is a directory share/ecbuild/cmake relative to the parent directory
+# (as in an install tree), add it to CMAKE_MODULE_PATH
+if [ -d $INSTALL_DIR/../share/ecbuild/cmake ]; then
+  ECBUILD_MODULE_PATH="$( cd "$INSTALL_DIR/../share/ecbuild/cmake" && pwd -P )"
+# If there is a cmake subdirectory relative to the script directory (as in a
+# tarball), add it to CMAKE_MODULE_PATH
+elif [ -d $INSTALL_DIR/../cmake ]; then
+  ECBUILD_MODULE_PATH="$( cd "$INSTALL_DIR/../cmake" && pwd -P )"
+fi
+
+# Fail if we couldn't find ecBuild modules
+if [ ! -f "$ECBUILD_MODULE_PATH/VERSION.cmake" ]; then
+  echo "FATAL: ecBuild modules could not be found in either $INSTALL_DIR/../share/ecbuild/cmake or $INSTALL_DIR/../cmake" >&2
+  exit 1
+fi
+
+ADD_ECBUILD_OPTIONS="-DCMAKE_MODULE_PATH=$ECBUILD_MODULE_PATH"
+
+if [ -d $INSTALL_DIR/../share/ecbuild/toolchains ]; then
+  ECBUILD_TOOLCHAIN_DIR="$( cd "$INSTALL_DIR/../share/ecbuild/toolchains" && pwd -P )"
+elif [ -d $INSTALL_DIR/share/ecbuild/toolchains ]; then
+  ECBUILD_TOOLCHAIN_DIR="$( cd "$INSTALL_DIR/share/ecbuild/toolchains" && pwd -P )"
+fi
+
+version()
+{
+  ecbuild_version=$(cat ${ECBUILD_MODULE_PATH}/VERSION.cmake | grep ECBUILD_VERSION_STR |  perl -p -e 's/.*([\d]\.[\d]\.[\d]).*/\1/' )
+  echo "ecbuild version ${ecbuild_version}"
+  command -v cmake >/dev/null 2>&1 || { exit 0; }
+  cmake --version | head -1
+  exit 0
+}
+
+log()
+{
+  log_level=$(sed 's/.*/\U&/' <<< "$1")
+  ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DECBUILD_LOG_LEVEL=${log_level}"
+}
+
+toolchains()
+{
+  if [ -d $ECBUILD_TOOLCHAIN_DIR ]; then
+    cd $ECBUILD_TOOLCHAIN_DIR
+    echo "Available toolchains:"
+    ls | while read fname
+    do
+        echo "  - ${fname%%.*}"
+    done
+    exit 0
+  else
+    echo "No toolchains available."
+    exit 1
+  fi
+}
+
+prefix()
+{
+  ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DCMAKE_INSTALL_PREFIX=${1/#\~\//$HOME/}"
+}
+
+toolchain()
+{
+  arg=${1/#\~\//$HOME/}
+  if [ -f $arg ]; then
+    toolchain_file=$arg
+  else
+    if [ -f $ECBUILD_TOOLCHAIN_DIR/$arg.cmake ]; then
+      toolchain_file=$ECBUILD_TOOLCHAIN_DIR/$arg.cmake
+    fi
+  fi
+  if [ -z ${toolchain_file+x} ]; then
+    echo "Error:"
+    echo "   Toolchain [$arg] is not valid: [$arg.cmake] cannot be"
+    echo "   found in [$ECBUILD_TOOLCHAIN_DIR]"
+    exit 1
+  else
+    ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${toolchain_file}"
+  fi
+}
+
+cache()
+{
+  arg=$1
+  if [ -f $arg ]; then
+    cache_file=$( cd "$arg" && pwd -P )
+  else
+    echo "Error:"
+    echo "   Cache file [$arg] is not found or is not a file."
+    exit 1
+  fi
+  ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DECBUILD_CACHE=${cache_file}"
+}
+
+if test $# -eq 0; then
+    usage 1
+fi
+
+while test $# -gt 0; do
+
+    # Split --option=value in $opt="--option" and $val="value"
+
+    opt=""
+    val=""
+
+    case "$1" in
+    --*=*)
+      opt=`echo "$1" | sed 's/=.*//'`
+      val=`echo "$1" | sed 's/--[_a-zA-Z0-9]*=//'`
+      ;;
+    --*)
+      opt=$1
+      ;;
+    # -D*)
+    #   ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS $1"
+    #   ;;
+    *)
+      break
+      ;;
+    esac
+
+    # echo "debug opt: $opt $val"
+
+    # Parse options
+    case "$opt" in
+      --help)
+        help 0
+  	    ;;
+      --version)
+        version
+        ;;
+      --dryrun)
+        dryrun="yes"
+        ;;
+      --toolchains)
+        toolchains
+        ;;
+      --cmakebin)
+        cmakebin="$val"
+        ;;
+      --prefix)
+        prefix "$val"
+        ;;
+      --build)
+        ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DCMAKE_BUILD_TYPE=$val"
+        ;;
+      --log)
+        log $val
+        ;;
+      --static)
+        ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DBUILD_SHARED_LIBS=OFF"
+        ;;
+      --dynamic)
+        ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DBUILD_SHARED_LIBS=ON"
+        ;;
+      --shared)
+        ADD_ECBUILD_OPTIONS="$ADD_ECBUILD_OPTIONS -DBUILD_SHARED_LIBS=ON"
+        ;;
+      --toolchain)
+        toolchain $val
+        ;;
+      --cache)
+        cache $val
+        ;;
+      --build-cmake)
+        build_cmake="yes"
+        ;;
+      --)
+        shift
+        break
+        ;;
+      *)
+        echo "unknown option: $opt"
+	      usage 1
+        ;;
+    esac
+    shift
+done
+
+# If no arguments remain, set srcARG to "."
+if [ $# -eq 0 ]; then
+  srcARG="."
+fi
+
+src=${srcARG:=""}
+cmake=${cmakebin:=cmake}
+dryrun=${dryrun:=no}
+build_cmake=${build_cmake:=""}
+cmake_found=""
+cmake_version_sufficient=""
+
+
+# Check that version $1 satisfies $2
+# CMake versions have no more than 4 fields
+# (adapted from http://stackoverflow.com/a/25731924/396967)
+version_gte() {
+    [  "$2" = "$(echo -e "$1\n$2" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | head -n1)" ]
+}
+
+# Check if the cmake version is sufficient
+check_cmake() {
+  # Check if cmake is available
+  if $(command -v $cmake >/dev/null 2>&1); then
+    cmake_found="yes"
+    cmake_version=$($cmake --version | head -n1 | awk '{ print $3 }')
+    echo "Found CMake version $cmake_version" >& 2
+    if version_gte $cmake_version $CMAKE_MIN_REQUIRED; then
+      cmake_version_sufficient="yes"
+    fi
+  fi
+}
+check_cmake
+# Use already built CMake if any
+if [[ ! $cmake_version_sufficient && -x bin/cmake ]]; then
+  echo "Using already built CMake in $PWD/bin/cmake" >&2
+  cmake=bin/cmake
+  check_cmake
+fi
+
+# Build CMake if requested and no sufficient version found
+if [[ ! $cmake_version_sufficient && $build_cmake ]]; then
+  echo "CMake version $CMAKE_MIN_REQUIRED is required but only $cmake_version was found." >&2
+  echo "Building CMake version ${CMAKE_BUILD_VERSION} ..." >&2
+  tarball=cmake-${CMAKE_BUILD_VERSION}.tar.gz
+  if [[ ! -r $tarball ]]; then
+    url=http://www.cmake.org/files/v${CMAKE_BUILD_VERSION:0:3}/$tarball
+    # -N          Download only if the remote version of the file is newer
+    # --continue  Continue an interrupted download
+    # -T 60       Time out a download attempt after 60 seconds
+    # -t 3        Only make 3 download attempts
+    wget -N --continue -T 60 -t 3 $url || {
+      echo "Failed to download CMake release $CMAKE_BUILD_VERSION." >&2
+      echo "Please download from $url" >&2
+      echo "and place $tarball in $PWD" >&2
+      exit 1
+    }
+  fi
+  tar xzf cmake-${CMAKE_BUILD_VERSION}.tar.gz
+  (
+    mkdir -p build_cmake
+    cd build_cmake
+    ../cmake-${CMAKE_BUILD_VERSION}/bootstrap --prefix=.. && make && make install
+  )
+  cmake=bin/cmake
+  check_cmake
+fi
+
+# Fail if we don't have a sufficient CMake
+if [[ ! $cmake_version_sufficient ]]; then
+  if [[ ! $cmake_found ]]; then
+    echo "CMake is required and cannot be found in the PATH." >&2
+  else
+    echo "CMake version $CMAKE_MIN_REQUIRED is required but only $cmake_version was found." >&2
+  fi
+  echo "" >&2
+  echo "  Try 'module load cmake', specify a CMake binary with --cmakebin=/path/to/cmake" >&2
+  echo "  or  let ecbuild download and build CMake with the --build-cmake option." >&2
+  exit 1
+fi
+
+echo ""
+echo "$cmake ${ADD_ECBUILD_OPTIONS} $@ $src"
+echo ""
+
+if [ ${dryrun} == "yes" ]; then
+  echo "[DRYRUN] -- not executing"
+  exit 0
+fi
+
+$cmake ${ADD_ECBUILD_OPTIONS} "$@" $src
diff --git a/bufrdc_wmo/bcmatb.F b/bufrdc_wmo/bcmatb.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmatbc.F b/bufrdc_wmo/bcmatbc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmbef.F b/bufrdc_wmo/bcmbef.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmct.F b/bufrdc_wmo/bcmct.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmctc.F b/bufrdc_wmo/bcmctc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmdefc.F b/bufrdc_wmo/bcmdefc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmel.F b/bufrdc_wmo/bcmel.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmoff.F b/bufrdc_wmo/bcmoff.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmroot.F b/bufrdc_wmo/bcmroot.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmrq.F b/bufrdc_wmo/bcmrq.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmtab.F b/bufrdc_wmo/bcmtab.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmtabc.F b/bufrdc_wmo/bcmtabc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmtabload.F b/bufrdc_wmo/bcmtabload.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmwork.F b/bufrdc_wmo/bcmwork.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmwt.F b/bufrdc_wmo/bcmwt.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcmwtc.F b/bufrdc_wmo/bcmwtc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomatb.F b/bufrdc_wmo/bcomatb.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomatbc.F b/bufrdc_wmo/bcomatbc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcombef.F b/bufrdc_wmo/bcombef.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomcom.F b/bufrdc_wmo/bcomcom.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomct.F b/bufrdc_wmo/bcomct.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomctc.F b/bufrdc_wmo/bcomctc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomdefc.F b/bufrdc_wmo/bcomdefc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomel.F b/bufrdc_wmo/bcomel.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomoff.F b/bufrdc_wmo/bcomoff.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomp.F b/bufrdc_wmo/bcomp.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomreq.F b/bufrdc_wmo/bcomreq.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomroot.F b/bufrdc_wmo/bcomroot.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomrq.F b/bufrdc_wmo/bcomrq.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomtab.F b/bufrdc_wmo/bcomtab.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomtabc.F b/bufrdc_wmo/bcomtabc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomtabload.F b/bufrdc_wmo/bcomtabload.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomtabloadc.F b/bufrdc_wmo/bcomtabloadc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomunit.F b/bufrdc_wmo/bcomunit.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomwork.F b/bufrdc_wmo/bcomwork.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomwt.F b/bufrdc_wmo/bcomwt.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcomwtc.F b/bufrdc_wmo/bcomwtc.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bcprq.F b/bufrdc_wmo/bcprq.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/big_endian.F b/bufrdc_wmo/big_endian.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/btable.F b/bufrdc_wmo/btable.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/btable1.F b/bufrdc_wmo/btable1.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/bu_check_s4s.F b/bufrdc_wmo/bu_check_s4s.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/buens4.F b/bufrdc_wmo/buens4.F
index b50acdb..9e0c893 100644
--- a/bufrdc_wmo/buens4.F
+++ b/bufrdc_wmo/buens4.F
@@ -140,8 +140,13 @@ C               ------------------------------------
 C
       IF(KERR.GT.0) RETURN
 C
+#if defined(gfortran)
+      R4=HUGE(R4)
+      R8=HUGE(R8)
+#else
       R4=3.4028235e+38
       R8=1.7976931348623157D+308
+#endif
 C
 C*          1.1  KEEP POINTERS TO THE BEGINING OF THE SECTION.
 C                ---------------------------------------------
diff --git a/bufrdc_wmo/buexs4.F b/bufrdc_wmo/buexs4.F
index f42feb6..d0ab442 100644
--- a/bufrdc_wmo/buexs4.F
+++ b/bufrdc_wmo/buexs4.F
@@ -150,8 +150,13 @@ C                JNS - POINTER TO VALUES ARRAY FOR SUB-SETS.
 C
       IF(KERR.GT.0) RETURN
 C
+#if defined(gfortran)
+      R4=HUGE(R4)
+      R8=HUGE(R8)
+#else
       R4=3.4028235e+38
       R8=1.7976931348623157D+308
+#endif
 C
       IF(OMULTI) THEN
          IF(NSUBSET.EQ.1) JCV = 0
diff --git a/bufrdc_wmo/bustop.F b/bufrdc_wmo/bustop.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/ctable.F b/bufrdc_wmo/ctable.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/ctable1.F b/bufrdc_wmo/ctable1.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/dtable.F b/bufrdc_wmo/dtable.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/dtable1.F b/bufrdc_wmo/dtable1.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/getcode.F b/bufrdc_wmo/getcode.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/parameter.F b/bufrdc_wmo/parameter.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/swap_bytes4.F b/bufrdc_wmo/swap_bytes4.F
old mode 100755
new mode 100644
diff --git a/bufrdc_wmo/swap_bytes8.F b/bufrdc_wmo/swap_bytes8.F
old mode 100755
new mode 100644
diff --git a/bufrtables/D0000000000000016000.TXT b/bufrtables/D0000000000000016000.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000000016000.TXT
+++ b/bufrtables/D0000000000000016000.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000001016001.TXT b/bufrtables/D0000000000001016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000001016001.TXT
+++ b/bufrtables/D0000000000001016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000002016001.TXT b/bufrtables/D0000000000002016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000002016001.TXT
+++ b/bufrtables/D0000000000002016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000003016001.TXT b/bufrtables/D0000000000003016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000003016001.TXT
+++ b/bufrtables/D0000000000003016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000004016001.TXT b/bufrtables/D0000000000004016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000004016001.TXT
+++ b/bufrtables/D0000000000004016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000005016001.TXT b/bufrtables/D0000000000005016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000005016001.TXT
+++ b/bufrtables/D0000000000005016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000006016001.TXT b/bufrtables/D0000000000006016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000006016001.TXT
+++ b/bufrtables/D0000000000006016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000007016001.TXT b/bufrtables/D0000000000007016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000007016001.TXT
+++ b/bufrtables/D0000000000007016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000008016001.TXT b/bufrtables/D0000000000008016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000008016001.TXT
+++ b/bufrtables/D0000000000008016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000009016001.TXT b/bufrtables/D0000000000009016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000009016001.TXT
+++ b/bufrtables/D0000000000009016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000010016001.TXT b/bufrtables/D0000000000010016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000010016001.TXT
+++ b/bufrtables/D0000000000010016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000011016001.TXT b/bufrtables/D0000000000011016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000011016001.TXT
+++ b/bufrtables/D0000000000011016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000012016001.TXT b/bufrtables/D0000000000012016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000012016001.TXT
+++ b/bufrtables/D0000000000012016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000013016001.TXT b/bufrtables/D0000000000013016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000013016001.TXT
+++ b/bufrtables/D0000000000013016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000014016001.TXT b/bufrtables/D0000000000014016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000014016001.TXT
+++ b/bufrtables/D0000000000014016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000015016001.TXT b/bufrtables/D0000000000015016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000015016001.TXT
+++ b/bufrtables/D0000000000015016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000016016001.TXT b/bufrtables/D0000000000016016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000016016001.TXT
+++ b/bufrtables/D0000000000016016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000017016001.TXT b/bufrtables/D0000000000017016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000017016001.TXT
+++ b/bufrtables/D0000000000017016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000018016001.TXT b/bufrtables/D0000000000018016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000018016001.TXT
+++ b/bufrtables/D0000000000018016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000019016001.TXT b/bufrtables/D0000000000019016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000019016001.TXT
+++ b/bufrtables/D0000000000019016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000020016001.TXT b/bufrtables/D0000000000020016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000020016001.TXT
+++ b/bufrtables/D0000000000020016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000021016001.TXT b/bufrtables/D0000000000021016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000021016001.TXT
+++ b/bufrtables/D0000000000021016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000022016001.TXT b/bufrtables/D0000000000022016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000022016001.TXT
+++ b/bufrtables/D0000000000022016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000023016001.TXT b/bufrtables/D0000000000023016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000023016001.TXT
+++ b/bufrtables/D0000000000023016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000024016001.TXT b/bufrtables/D0000000000024016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000024016001.TXT
+++ b/bufrtables/D0000000000024016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000025016001.TXT b/bufrtables/D0000000000025016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000025016001.TXT
+++ b/bufrtables/D0000000000025016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000026016001.TXT b/bufrtables/D0000000000026016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000026016001.TXT
+++ b/bufrtables/D0000000000026016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000027016001.TXT b/bufrtables/D0000000000027016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000027016001.TXT
+++ b/bufrtables/D0000000000027016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000028016001.TXT b/bufrtables/D0000000000028016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000028016001.TXT
+++ b/bufrtables/D0000000000028016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000029016001.TXT b/bufrtables/D0000000000029016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000029016001.TXT
+++ b/bufrtables/D0000000000029016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000030016001.TXT b/bufrtables/D0000000000030016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000030016001.TXT
+++ b/bufrtables/D0000000000030016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000031016001.TXT b/bufrtables/D0000000000031016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000031016001.TXT
+++ b/bufrtables/D0000000000031016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000032016001.TXT b/bufrtables/D0000000000032016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000032016001.TXT
+++ b/bufrtables/D0000000000032016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000033016001.TXT b/bufrtables/D0000000000033016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000033016001.TXT
+++ b/bufrtables/D0000000000033016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000034016001.TXT b/bufrtables/D0000000000034016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000034016001.TXT
+++ b/bufrtables/D0000000000034016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000035016001.TXT b/bufrtables/D0000000000035016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000035016001.TXT
+++ b/bufrtables/D0000000000035016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000036016001.TXT b/bufrtables/D0000000000036016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000036016001.TXT
+++ b/bufrtables/D0000000000036016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000037016001.TXT b/bufrtables/D0000000000037016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000037016001.TXT
+++ b/bufrtables/D0000000000037016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000038016001.TXT b/bufrtables/D0000000000038016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000038016001.TXT
+++ b/bufrtables/D0000000000038016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000039016001.TXT b/bufrtables/D0000000000039016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000039016001.TXT
+++ b/bufrtables/D0000000000039016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000040016001.TXT b/bufrtables/D0000000000040016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000040016001.TXT
+++ b/bufrtables/D0000000000040016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000041016001.TXT b/bufrtables/D0000000000041016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000041016001.TXT
+++ b/bufrtables/D0000000000041016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000042016001.TXT b/bufrtables/D0000000000042016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000042016001.TXT
+++ b/bufrtables/D0000000000042016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000043016001.TXT b/bufrtables/D0000000000043016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000043016001.TXT
+++ b/bufrtables/D0000000000043016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000044016001.TXT b/bufrtables/D0000000000044016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000044016001.TXT
+++ b/bufrtables/D0000000000044016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000045016001.TXT b/bufrtables/D0000000000045016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000045016001.TXT
+++ b/bufrtables/D0000000000045016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000046016001.TXT b/bufrtables/D0000000000046016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000046016001.TXT
+++ b/bufrtables/D0000000000046016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000047016001.TXT b/bufrtables/D0000000000047016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000047016001.TXT
+++ b/bufrtables/D0000000000047016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000048016001.TXT b/bufrtables/D0000000000048016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000048016001.TXT
+++ b/bufrtables/D0000000000048016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000049016001.TXT b/bufrtables/D0000000000049016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000049016001.TXT
+++ b/bufrtables/D0000000000049016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000050016001.TXT b/bufrtables/D0000000000050016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000050016001.TXT
+++ b/bufrtables/D0000000000050016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000051016001.TXT b/bufrtables/D0000000000051016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000051016001.TXT
+++ b/bufrtables/D0000000000051016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000052016001.TXT b/bufrtables/D0000000000052016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000052016001.TXT
+++ b/bufrtables/D0000000000052016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000053016001.TXT b/bufrtables/D0000000000053016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000053016001.TXT
+++ b/bufrtables/D0000000000053016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000054016001.TXT b/bufrtables/D0000000000054016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000054016001.TXT
+++ b/bufrtables/D0000000000054016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000055016001.TXT b/bufrtables/D0000000000055016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000055016001.TXT
+++ b/bufrtables/D0000000000055016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000056016001.TXT b/bufrtables/D0000000000056016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000056016001.TXT
+++ b/bufrtables/D0000000000056016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000057016001.TXT b/bufrtables/D0000000000057016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000057016001.TXT
+++ b/bufrtables/D0000000000057016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000058016001.TXT b/bufrtables/D0000000000058016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000058016001.TXT
+++ b/bufrtables/D0000000000058016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000059016001.TXT b/bufrtables/D0000000000059016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000059016001.TXT
+++ b/bufrtables/D0000000000059016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000060016001.TXT b/bufrtables/D0000000000060016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000060016001.TXT
+++ b/bufrtables/D0000000000060016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000061016001.TXT b/bufrtables/D0000000000061016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000061016001.TXT
+++ b/bufrtables/D0000000000061016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000062016001.TXT b/bufrtables/D0000000000062016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000062016001.TXT
+++ b/bufrtables/D0000000000062016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000063016001.TXT b/bufrtables/D0000000000063016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000063016001.TXT
+++ b/bufrtables/D0000000000063016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000064016001.TXT b/bufrtables/D0000000000064016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000064016001.TXT
+++ b/bufrtables/D0000000000064016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000065016001.TXT b/bufrtables/D0000000000065016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000065016001.TXT
+++ b/bufrtables/D0000000000065016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000066016001.TXT b/bufrtables/D0000000000066016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000066016001.TXT
+++ b/bufrtables/D0000000000066016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000067016001.TXT b/bufrtables/D0000000000067016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000067016001.TXT
+++ b/bufrtables/D0000000000067016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000068016001.TXT b/bufrtables/D0000000000068016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000068016001.TXT
+++ b/bufrtables/D0000000000068016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000069016001.TXT b/bufrtables/D0000000000069016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000069016001.TXT
+++ b/bufrtables/D0000000000069016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000070016001.TXT b/bufrtables/D0000000000070016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000070016001.TXT
+++ b/bufrtables/D0000000000070016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000071016001.TXT b/bufrtables/D0000000000071016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000071016001.TXT
+++ b/bufrtables/D0000000000071016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000072016001.TXT b/bufrtables/D0000000000072016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000072016001.TXT
+++ b/bufrtables/D0000000000072016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000073016001.TXT b/bufrtables/D0000000000073016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000073016001.TXT
+++ b/bufrtables/D0000000000073016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000074016001.TXT b/bufrtables/D0000000000074016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000074016001.TXT
+++ b/bufrtables/D0000000000074016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000075016001.TXT b/bufrtables/D0000000000075016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000075016001.TXT
+++ b/bufrtables/D0000000000075016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000076016001.TXT b/bufrtables/D0000000000076016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000076016001.TXT
+++ b/bufrtables/D0000000000076016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000077016001.TXT b/bufrtables/D0000000000077016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000077016001.TXT
+++ b/bufrtables/D0000000000077016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000078016001.TXT b/bufrtables/D0000000000078016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000078016001.TXT
+++ b/bufrtables/D0000000000078016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000079016001.TXT b/bufrtables/D0000000000079016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000079016001.TXT
+++ b/bufrtables/D0000000000079016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000080016001.TXT b/bufrtables/D0000000000080016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000080016001.TXT
+++ b/bufrtables/D0000000000080016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000081016001.TXT b/bufrtables/D0000000000081016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000081016001.TXT
+++ b/bufrtables/D0000000000081016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000082016001.TXT b/bufrtables/D0000000000082016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000082016001.TXT
+++ b/bufrtables/D0000000000082016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000083016001.TXT b/bufrtables/D0000000000083016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000083016001.TXT
+++ b/bufrtables/D0000000000083016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000084016001.TXT b/bufrtables/D0000000000084016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000084016001.TXT
+++ b/bufrtables/D0000000000084016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000085016001.TXT b/bufrtables/D0000000000085016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000085016001.TXT
+++ b/bufrtables/D0000000000085016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000086016001.TXT b/bufrtables/D0000000000086016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000086016001.TXT
+++ b/bufrtables/D0000000000086016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000087016001.TXT b/bufrtables/D0000000000087016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000087016001.TXT
+++ b/bufrtables/D0000000000087016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000088016001.TXT b/bufrtables/D0000000000088016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000088016001.TXT
+++ b/bufrtables/D0000000000088016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000089016001.TXT b/bufrtables/D0000000000089016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000089016001.TXT
+++ b/bufrtables/D0000000000089016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000090016001.TXT b/bufrtables/D0000000000090016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000090016001.TXT
+++ b/bufrtables/D0000000000090016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000091016001.TXT b/bufrtables/D0000000000091016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000091016001.TXT
+++ b/bufrtables/D0000000000091016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000092016001.TXT b/bufrtables/D0000000000092016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000092016001.TXT
+++ b/bufrtables/D0000000000092016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000093016001.TXT b/bufrtables/D0000000000093016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000093016001.TXT
+++ b/bufrtables/D0000000000093016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000094016001.TXT b/bufrtables/D0000000000094016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000094016001.TXT
+++ b/bufrtables/D0000000000094016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000095016001.TXT b/bufrtables/D0000000000095016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000095016001.TXT
+++ b/bufrtables/D0000000000095016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000096016001.TXT b/bufrtables/D0000000000096016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000096016001.TXT
+++ b/bufrtables/D0000000000096016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000097016001.TXT b/bufrtables/D0000000000097016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000097016001.TXT
+++ b/bufrtables/D0000000000097016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000098016001.TXT b/bufrtables/D0000000000098016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000098016001.TXT
+++ b/bufrtables/D0000000000098016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000098016101.TXT b/bufrtables/D0000000000098016101.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000098016101.TXT
+++ b/bufrtables/D0000000000098016101.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000099016001.TXT b/bufrtables/D0000000000099016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000099016001.TXT
+++ b/bufrtables/D0000000000099016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000100016001.TXT b/bufrtables/D0000000000100016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000100016001.TXT
+++ b/bufrtables/D0000000000100016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000101016001.TXT b/bufrtables/D0000000000101016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000101016001.TXT
+++ b/bufrtables/D0000000000101016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000102016001.TXT b/bufrtables/D0000000000102016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000102016001.TXT
+++ b/bufrtables/D0000000000102016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000103016001.TXT b/bufrtables/D0000000000103016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000103016001.TXT
+++ b/bufrtables/D0000000000103016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000104016001.TXT b/bufrtables/D0000000000104016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000104016001.TXT
+++ b/bufrtables/D0000000000104016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000105016001.TXT b/bufrtables/D0000000000105016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000105016001.TXT
+++ b/bufrtables/D0000000000105016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000106016001.TXT b/bufrtables/D0000000000106016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000106016001.TXT
+++ b/bufrtables/D0000000000106016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000107016001.TXT b/bufrtables/D0000000000107016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000107016001.TXT
+++ b/bufrtables/D0000000000107016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000108016001.TXT b/bufrtables/D0000000000108016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000108016001.TXT
+++ b/bufrtables/D0000000000108016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000109016001.TXT b/bufrtables/D0000000000109016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000109016001.TXT
+++ b/bufrtables/D0000000000109016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000110016001.TXT b/bufrtables/D0000000000110016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000110016001.TXT
+++ b/bufrtables/D0000000000110016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000111016001.TXT b/bufrtables/D0000000000111016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000111016001.TXT
+++ b/bufrtables/D0000000000111016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000112016001.TXT b/bufrtables/D0000000000112016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000112016001.TXT
+++ b/bufrtables/D0000000000112016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000113016001.TXT b/bufrtables/D0000000000113016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000113016001.TXT
+++ b/bufrtables/D0000000000113016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000114016001.TXT b/bufrtables/D0000000000114016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000114016001.TXT
+++ b/bufrtables/D0000000000114016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000115016001.TXT b/bufrtables/D0000000000115016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000115016001.TXT
+++ b/bufrtables/D0000000000115016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000116016001.TXT b/bufrtables/D0000000000116016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000116016001.TXT
+++ b/bufrtables/D0000000000116016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000117016001.TXT b/bufrtables/D0000000000117016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000117016001.TXT
+++ b/bufrtables/D0000000000117016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000118016001.TXT b/bufrtables/D0000000000118016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000118016001.TXT
+++ b/bufrtables/D0000000000118016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000119016001.TXT b/bufrtables/D0000000000119016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000119016001.TXT
+++ b/bufrtables/D0000000000119016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000120016001.TXT b/bufrtables/D0000000000120016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000120016001.TXT
+++ b/bufrtables/D0000000000120016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000121016001.TXT b/bufrtables/D0000000000121016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000121016001.TXT
+++ b/bufrtables/D0000000000121016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000122016001.TXT b/bufrtables/D0000000000122016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000122016001.TXT
+++ b/bufrtables/D0000000000122016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000123016001.TXT b/bufrtables/D0000000000123016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000123016001.TXT
+++ b/bufrtables/D0000000000123016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000124016001.TXT b/bufrtables/D0000000000124016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000124016001.TXT
+++ b/bufrtables/D0000000000124016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000125016001.TXT b/bufrtables/D0000000000125016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000125016001.TXT
+++ b/bufrtables/D0000000000125016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000126016001.TXT b/bufrtables/D0000000000126016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000126016001.TXT
+++ b/bufrtables/D0000000000126016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000127016001.TXT b/bufrtables/D0000000000127016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000127016001.TXT
+++ b/bufrtables/D0000000000127016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000128016001.TXT b/bufrtables/D0000000000128016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000128016001.TXT
+++ b/bufrtables/D0000000000128016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000129016001.TXT b/bufrtables/D0000000000129016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000129016001.TXT
+++ b/bufrtables/D0000000000129016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000130016001.TXT b/bufrtables/D0000000000130016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000130016001.TXT
+++ b/bufrtables/D0000000000130016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000131016001.TXT b/bufrtables/D0000000000131016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000131016001.TXT
+++ b/bufrtables/D0000000000131016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000132016001.TXT b/bufrtables/D0000000000132016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000132016001.TXT
+++ b/bufrtables/D0000000000132016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000133016001.TXT b/bufrtables/D0000000000133016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000133016001.TXT
+++ b/bufrtables/D0000000000133016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000134016001.TXT b/bufrtables/D0000000000134016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000134016001.TXT
+++ b/bufrtables/D0000000000134016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000135016001.TXT b/bufrtables/D0000000000135016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000135016001.TXT
+++ b/bufrtables/D0000000000135016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000136016001.TXT b/bufrtables/D0000000000136016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000136016001.TXT
+++ b/bufrtables/D0000000000136016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000137016001.TXT b/bufrtables/D0000000000137016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000137016001.TXT
+++ b/bufrtables/D0000000000137016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000138016001.TXT b/bufrtables/D0000000000138016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000138016001.TXT
+++ b/bufrtables/D0000000000138016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000139016001.TXT b/bufrtables/D0000000000139016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000139016001.TXT
+++ b/bufrtables/D0000000000139016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000140016001.TXT b/bufrtables/D0000000000140016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000140016001.TXT
+++ b/bufrtables/D0000000000140016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000141016001.TXT b/bufrtables/D0000000000141016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000141016001.TXT
+++ b/bufrtables/D0000000000141016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000142016001.TXT b/bufrtables/D0000000000142016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000142016001.TXT
+++ b/bufrtables/D0000000000142016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000143016001.TXT b/bufrtables/D0000000000143016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000143016001.TXT
+++ b/bufrtables/D0000000000143016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000144016001.TXT b/bufrtables/D0000000000144016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000144016001.TXT
+++ b/bufrtables/D0000000000144016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000145016001.TXT b/bufrtables/D0000000000145016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000145016001.TXT
+++ b/bufrtables/D0000000000145016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000146016001.TXT b/bufrtables/D0000000000146016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000146016001.TXT
+++ b/bufrtables/D0000000000146016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000147016001.TXT b/bufrtables/D0000000000147016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000147016001.TXT
+++ b/bufrtables/D0000000000147016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000148016001.TXT b/bufrtables/D0000000000148016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000148016001.TXT
+++ b/bufrtables/D0000000000148016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000149016001.TXT b/bufrtables/D0000000000149016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000149016001.TXT
+++ b/bufrtables/D0000000000149016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000150016001.TXT b/bufrtables/D0000000000150016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000150016001.TXT
+++ b/bufrtables/D0000000000150016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000151016001.TXT b/bufrtables/D0000000000151016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000151016001.TXT
+++ b/bufrtables/D0000000000151016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000152016001.TXT b/bufrtables/D0000000000152016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000152016001.TXT
+++ b/bufrtables/D0000000000152016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000153016001.TXT b/bufrtables/D0000000000153016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000153016001.TXT
+++ b/bufrtables/D0000000000153016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000154016001.TXT b/bufrtables/D0000000000154016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000154016001.TXT
+++ b/bufrtables/D0000000000154016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000155016001.TXT b/bufrtables/D0000000000155016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000155016001.TXT
+++ b/bufrtables/D0000000000155016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000156016001.TXT b/bufrtables/D0000000000156016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000156016001.TXT
+++ b/bufrtables/D0000000000156016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000157016001.TXT b/bufrtables/D0000000000157016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000157016001.TXT
+++ b/bufrtables/D0000000000157016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000158016001.TXT b/bufrtables/D0000000000158016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000158016001.TXT
+++ b/bufrtables/D0000000000158016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000159016001.TXT b/bufrtables/D0000000000159016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000159016001.TXT
+++ b/bufrtables/D0000000000159016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000160016001.TXT b/bufrtables/D0000000000160016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000160016001.TXT
+++ b/bufrtables/D0000000000160016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000161016001.TXT b/bufrtables/D0000000000161016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000161016001.TXT
+++ b/bufrtables/D0000000000161016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000162016001.TXT b/bufrtables/D0000000000162016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000162016001.TXT
+++ b/bufrtables/D0000000000162016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000163016001.TXT b/bufrtables/D0000000000163016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000163016001.TXT
+++ b/bufrtables/D0000000000163016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000164016001.TXT b/bufrtables/D0000000000164016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000164016001.TXT
+++ b/bufrtables/D0000000000164016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000165016001.TXT b/bufrtables/D0000000000165016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000165016001.TXT
+++ b/bufrtables/D0000000000165016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000166016001.TXT b/bufrtables/D0000000000166016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000166016001.TXT
+++ b/bufrtables/D0000000000166016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000167016001.TXT b/bufrtables/D0000000000167016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000167016001.TXT
+++ b/bufrtables/D0000000000167016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000168016001.TXT b/bufrtables/D0000000000168016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000168016001.TXT
+++ b/bufrtables/D0000000000168016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000169016001.TXT b/bufrtables/D0000000000169016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000169016001.TXT
+++ b/bufrtables/D0000000000169016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000170016001.TXT b/bufrtables/D0000000000170016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000170016001.TXT
+++ b/bufrtables/D0000000000170016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000171016001.TXT b/bufrtables/D0000000000171016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000171016001.TXT
+++ b/bufrtables/D0000000000171016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000172016001.TXT b/bufrtables/D0000000000172016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000172016001.TXT
+++ b/bufrtables/D0000000000172016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000173016001.TXT b/bufrtables/D0000000000173016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000173016001.TXT
+++ b/bufrtables/D0000000000173016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000174016001.TXT b/bufrtables/D0000000000174016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000174016001.TXT
+++ b/bufrtables/D0000000000174016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000175016001.TXT b/bufrtables/D0000000000175016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000175016001.TXT
+++ b/bufrtables/D0000000000175016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000176016001.TXT b/bufrtables/D0000000000176016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000176016001.TXT
+++ b/bufrtables/D0000000000176016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000177016001.TXT b/bufrtables/D0000000000177016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000177016001.TXT
+++ b/bufrtables/D0000000000177016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000178016001.TXT b/bufrtables/D0000000000178016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000178016001.TXT
+++ b/bufrtables/D0000000000178016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000179016001.TXT b/bufrtables/D0000000000179016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000179016001.TXT
+++ b/bufrtables/D0000000000179016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000180016001.TXT b/bufrtables/D0000000000180016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000180016001.TXT
+++ b/bufrtables/D0000000000180016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000181016001.TXT b/bufrtables/D0000000000181016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000181016001.TXT
+++ b/bufrtables/D0000000000181016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000182016001.TXT b/bufrtables/D0000000000182016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000182016001.TXT
+++ b/bufrtables/D0000000000182016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000183016001.TXT b/bufrtables/D0000000000183016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000183016001.TXT
+++ b/bufrtables/D0000000000183016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000184016001.TXT b/bufrtables/D0000000000184016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000184016001.TXT
+++ b/bufrtables/D0000000000184016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000185016001.TXT b/bufrtables/D0000000000185016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000185016001.TXT
+++ b/bufrtables/D0000000000185016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000186016001.TXT b/bufrtables/D0000000000186016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000186016001.TXT
+++ b/bufrtables/D0000000000186016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000187016001.TXT b/bufrtables/D0000000000187016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000187016001.TXT
+++ b/bufrtables/D0000000000187016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000188016001.TXT b/bufrtables/D0000000000188016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000188016001.TXT
+++ b/bufrtables/D0000000000188016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000189016001.TXT b/bufrtables/D0000000000189016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000189016001.TXT
+++ b/bufrtables/D0000000000189016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000190016001.TXT b/bufrtables/D0000000000190016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000190016001.TXT
+++ b/bufrtables/D0000000000190016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000191016001.TXT b/bufrtables/D0000000000191016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000191016001.TXT
+++ b/bufrtables/D0000000000191016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000192016001.TXT b/bufrtables/D0000000000192016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000192016001.TXT
+++ b/bufrtables/D0000000000192016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000193016001.TXT b/bufrtables/D0000000000193016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000193016001.TXT
+++ b/bufrtables/D0000000000193016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000194016001.TXT b/bufrtables/D0000000000194016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000194016001.TXT
+++ b/bufrtables/D0000000000194016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000195016001.TXT b/bufrtables/D0000000000195016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000195016001.TXT
+++ b/bufrtables/D0000000000195016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000196016001.TXT b/bufrtables/D0000000000196016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000196016001.TXT
+++ b/bufrtables/D0000000000196016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000197016001.TXT b/bufrtables/D0000000000197016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000197016001.TXT
+++ b/bufrtables/D0000000000197016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000198016001.TXT b/bufrtables/D0000000000198016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000198016001.TXT
+++ b/bufrtables/D0000000000198016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000199016001.TXT b/bufrtables/D0000000000199016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000199016001.TXT
+++ b/bufrtables/D0000000000199016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000200016001.TXT b/bufrtables/D0000000000200016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000200016001.TXT
+++ b/bufrtables/D0000000000200016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000201016001.TXT b/bufrtables/D0000000000201016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000201016001.TXT
+++ b/bufrtables/D0000000000201016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000202016001.TXT b/bufrtables/D0000000000202016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000202016001.TXT
+++ b/bufrtables/D0000000000202016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000203016001.TXT b/bufrtables/D0000000000203016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000203016001.TXT
+++ b/bufrtables/D0000000000203016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000204016001.TXT b/bufrtables/D0000000000204016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000204016001.TXT
+++ b/bufrtables/D0000000000204016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000205016001.TXT b/bufrtables/D0000000000205016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000205016001.TXT
+++ b/bufrtables/D0000000000205016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000206016001.TXT b/bufrtables/D0000000000206016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000206016001.TXT
+++ b/bufrtables/D0000000000206016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000207016001.TXT b/bufrtables/D0000000000207016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000207016001.TXT
+++ b/bufrtables/D0000000000207016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000208016001.TXT b/bufrtables/D0000000000208016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000208016001.TXT
+++ b/bufrtables/D0000000000208016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000209016001.TXT b/bufrtables/D0000000000209016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000209016001.TXT
+++ b/bufrtables/D0000000000209016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000210016001.TXT b/bufrtables/D0000000000210016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000210016001.TXT
+++ b/bufrtables/D0000000000210016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000211016001.TXT b/bufrtables/D0000000000211016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000211016001.TXT
+++ b/bufrtables/D0000000000211016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000212016001.TXT b/bufrtables/D0000000000212016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000212016001.TXT
+++ b/bufrtables/D0000000000212016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000213016001.TXT b/bufrtables/D0000000000213016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000213016001.TXT
+++ b/bufrtables/D0000000000213016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000214016001.TXT b/bufrtables/D0000000000214016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000214016001.TXT
+++ b/bufrtables/D0000000000214016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000215016001.TXT b/bufrtables/D0000000000215016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000215016001.TXT
+++ b/bufrtables/D0000000000215016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000216016001.TXT b/bufrtables/D0000000000216016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000216016001.TXT
+++ b/bufrtables/D0000000000216016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000217016001.TXT b/bufrtables/D0000000000217016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000217016001.TXT
+++ b/bufrtables/D0000000000217016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000218016001.TXT b/bufrtables/D0000000000218016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000218016001.TXT
+++ b/bufrtables/D0000000000218016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000219016001.TXT b/bufrtables/D0000000000219016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000219016001.TXT
+++ b/bufrtables/D0000000000219016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000220016001.TXT b/bufrtables/D0000000000220016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000220016001.TXT
+++ b/bufrtables/D0000000000220016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000221016001.TXT b/bufrtables/D0000000000221016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000221016001.TXT
+++ b/bufrtables/D0000000000221016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000222016001.TXT b/bufrtables/D0000000000222016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000222016001.TXT
+++ b/bufrtables/D0000000000222016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000223016001.TXT b/bufrtables/D0000000000223016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000223016001.TXT
+++ b/bufrtables/D0000000000223016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000224016001.TXT b/bufrtables/D0000000000224016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000224016001.TXT
+++ b/bufrtables/D0000000000224016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000225016001.TXT b/bufrtables/D0000000000225016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000225016001.TXT
+++ b/bufrtables/D0000000000225016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000226016001.TXT b/bufrtables/D0000000000226016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000226016001.TXT
+++ b/bufrtables/D0000000000226016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000227016001.TXT b/bufrtables/D0000000000227016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000227016001.TXT
+++ b/bufrtables/D0000000000227016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000228016001.TXT b/bufrtables/D0000000000228016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000228016001.TXT
+++ b/bufrtables/D0000000000228016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000229016001.TXT b/bufrtables/D0000000000229016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000229016001.TXT
+++ b/bufrtables/D0000000000229016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000230016001.TXT b/bufrtables/D0000000000230016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000230016001.TXT
+++ b/bufrtables/D0000000000230016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000231016001.TXT b/bufrtables/D0000000000231016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000231016001.TXT
+++ b/bufrtables/D0000000000231016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000232016001.TXT b/bufrtables/D0000000000232016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000232016001.TXT
+++ b/bufrtables/D0000000000232016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000233016001.TXT b/bufrtables/D0000000000233016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000233016001.TXT
+++ b/bufrtables/D0000000000233016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000234016001.TXT b/bufrtables/D0000000000234016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000234016001.TXT
+++ b/bufrtables/D0000000000234016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000235016001.TXT b/bufrtables/D0000000000235016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000235016001.TXT
+++ b/bufrtables/D0000000000235016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000236016001.TXT b/bufrtables/D0000000000236016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000236016001.TXT
+++ b/bufrtables/D0000000000236016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000237016001.TXT b/bufrtables/D0000000000237016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000237016001.TXT
+++ b/bufrtables/D0000000000237016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000238016001.TXT b/bufrtables/D0000000000238016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000238016001.TXT
+++ b/bufrtables/D0000000000238016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000239016001.TXT b/bufrtables/D0000000000239016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000239016001.TXT
+++ b/bufrtables/D0000000000239016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000240016001.TXT b/bufrtables/D0000000000240016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000240016001.TXT
+++ b/bufrtables/D0000000000240016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000241016001.TXT b/bufrtables/D0000000000241016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000241016001.TXT
+++ b/bufrtables/D0000000000241016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000242016001.TXT b/bufrtables/D0000000000242016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000242016001.TXT
+++ b/bufrtables/D0000000000242016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000243016001.TXT b/bufrtables/D0000000000243016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000243016001.TXT
+++ b/bufrtables/D0000000000243016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000244016001.TXT b/bufrtables/D0000000000244016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000244016001.TXT
+++ b/bufrtables/D0000000000244016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000245016001.TXT b/bufrtables/D0000000000245016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000245016001.TXT
+++ b/bufrtables/D0000000000245016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000246016001.TXT b/bufrtables/D0000000000246016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000246016001.TXT
+++ b/bufrtables/D0000000000246016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000247016001.TXT b/bufrtables/D0000000000247016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000247016001.TXT
+++ b/bufrtables/D0000000000247016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000248016001.TXT b/bufrtables/D0000000000248016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000248016001.TXT
+++ b/bufrtables/D0000000000248016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000249016001.TXT b/bufrtables/D0000000000249016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000249016001.TXT
+++ b/bufrtables/D0000000000249016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000250016001.TXT b/bufrtables/D0000000000250016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000250016001.TXT
+++ b/bufrtables/D0000000000250016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000251016001.TXT b/bufrtables/D0000000000251016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000251016001.TXT
+++ b/bufrtables/D0000000000251016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000252016001.TXT b/bufrtables/D0000000000252016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000252016001.TXT
+++ b/bufrtables/D0000000000252016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000253016001.TXT b/bufrtables/D0000000000253016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000253016001.TXT
+++ b/bufrtables/D0000000000253016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000254016001.TXT b/bufrtables/D0000000000254016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000254016001.TXT
+++ b/bufrtables/D0000000000254016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/D0000000000255016001.TXT b/bufrtables/D0000000000255016001.TXT
index f464c7a..edeb645 120000
--- a/bufrtables/D0000000000255016001.TXT
+++ b/bufrtables/D0000000000255016001.TXT
@@ -1 +1 @@
-D_97904881abf209f200d7dab466e706ce.distinct
\ No newline at end of file
+D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct
\ No newline at end of file
diff --git a/bufrtables/VERSION.cmake b/bufrtables/VERSION.cmake
index 9121071..a04687c 100644
--- a/bufrtables/VERSION.cmake
+++ b/bufrtables/VERSION.cmake
@@ -1 +1 @@
-set( ${PROJECT_NAME}_VERSION_STR  "4.0.5" )
+set( ${PROJECT_NAME}_VERSION_STR  "4.0.6" )
diff --git a/bufrtables/links.sh b/bufrtables/links.sh
index 8fb8d49..7d396ff 100755
--- a/bufrtables/links.sh
+++ b/bufrtables/links.sh
@@ -2,7 +2,6 @@ ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000000000000000000.TXT
 ln -s B_7854bdfd1d0b55c438ec71990fbea158.distinct B0000000000000002000.TXT
 ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000000000000004000.TXT
 ln -s B_172495a28a33e613f0ab1cae797bdb8a.distinct B0000000000000006000.TXT
-ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000300098012001.TXT
 ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000000000007000.TXT
 ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000000000008000.TXT
 ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000000000009000.TXT
@@ -854,6 +853,7 @@ ln -s B_050f4028a43495e52440d17656e5700c.distinct B0000000000098022001.TXT
 ln -s B_3361ffd966dd04d2cce360361fde7fa5.distinct B0000000000098023001.TXT
 ln -s B_e8f55a23bedb304f90efcb46fed782bf.distinct B0000000000098024001.TXT
 ln -s B_d519a21cc26558fbfbcae5e5aae942dd.distinct B0000000000098024002.TXT
+ln -s B_4c2fd16b160e3e8368bae800b4737531.distinct B0000000000098024003.TXT
 ln -s B_ddbe264d6831c71bf60f55118905d5eb.distinct B0000000000098024101.TXT
 ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000000099010001.TXT
 ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000000099011001.TXT
@@ -2123,6 +2123,7 @@ ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000000065535011004.TXT
 ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000000065535011005.TXT
 ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000000300000013000.TXT
 ln -s B_44c107f676c47571380f64395b24bcd2.distinct B0000000300007004001.TXT
+ln -s B_47972c7924f05d5facc57044fc806c61.distinct B0000000300098012001.TXT
 ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000000300098013001.TXT
 ln -s B_44c107f676c47571380f64395b24bcd2.distinct B0000000300160011001.TXT
 ln -s B_feb89e9c2ae53afd3b24750c7eb1e117.distinct B0000001000000011000.TXT
@@ -2364,7 +2365,6 @@ ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000000000000000.TXT
 ln -s C_04362165948206fb63f9e2634c70505e.distinct C0000000000000002000.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000000000004000.TXT
 ln -s C_b448ea22562d565d0953118c4b7f96ac.distinct C0000000000000006000.TXT
-ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000300098012001.TXT
 ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000000000007000.TXT
 ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000000000008000.TXT
 ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000000000009000.TXT
@@ -3210,6 +3210,7 @@ ln -s C_b7fa1a7727369ecf09b368eae9f63585.distinct C0000000000098022001.TXT
 ln -s C_23e15e256920aab5bc58e30ff88a0acb.distinct C0000000000098023001.TXT
 ln -s C_e684b84693944aad209ef258bc0a38f3.distinct C0000000000098024001.TXT
 ln -s C_6c72ae004019317bfff1a124a7d22982.distinct C0000000000098024002.TXT
+ln -s C_6471810f3864afa93fb3e1759e4b2415.distinct C0000000000098024003.TXT
 ln -s C_dd5c45a988eac89a8e8e692d3ec13ad3.distinct C0000000000098024101.TXT
 ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000000099010001.TXT
 ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000000099011001.TXT
@@ -4478,6 +4479,7 @@ ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000065535002004.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000065535011004.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000065535011005.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000300000013000.TXT
+ln -s C_09898434dcb4dc98ec72b1bc92727b4c.distinct C0000000300098012001.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000000300098013001.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000001000000011000.TXT
 ln -s C_11e6c727e6c8b510348d0df2e86e7f8f.distinct C0000001000000013000.TXT
@@ -4671,7 +4673,6 @@ ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000000000000.TXT
 ln -s D_1fc62821c0515bf144d84a4100bb53f8.distinct D0000000000000002000.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000000004000.TXT
 ln -s D_a189cf1bd6fbda79986901f4333f0112.distinct D0000000000000006000.TXT
-ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000300098012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000000007000.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000000008000.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000000009000.TXT
@@ -4681,7 +4682,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000000012000.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000000013000.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000000014000.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000000015000.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000000016000.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000000016000.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000000017000.TXT
 ln -s D_5abc7b52b7bc04875961cf145f45319b.distinct D0000000000000018000.TXT
 ln -s D_e6f39b79d79a88eadc362af9ee725054.distinct D0000000000000019000.TXT
@@ -4696,7 +4697,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000001012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000001013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000001014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000001015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000001016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000001016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000001017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000002010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000002011001.TXT
@@ -4704,7 +4705,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000002012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000002013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000002014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000002015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000002016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000002016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000002017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000003010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000003011001.TXT
@@ -4712,7 +4713,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000003012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000003013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000003014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000003015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000003016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000003016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000003017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000004010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000004011001.TXT
@@ -4720,7 +4721,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000004012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000004013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000004014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000004015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000004016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000004016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000004017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000005010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000005011001.TXT
@@ -4728,7 +4729,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000005012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000005013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000005014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000005015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000005016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000005016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000005017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000006010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000006011001.TXT
@@ -4736,7 +4737,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000006012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000006013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000006014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000006015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000006016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000006016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000006017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000007002001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000007010001.TXT
@@ -4745,7 +4746,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000007012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000007013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000007014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000007015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000007016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000007016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000007017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000008010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000008011001.TXT
@@ -4753,7 +4754,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000008012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000008013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000008014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000008015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000008016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000008016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000008017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000009010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000009011001.TXT
@@ -4761,7 +4762,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000009012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000009013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000009014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000009015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000009016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000009016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000009017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000010010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000010011001.TXT
@@ -4769,7 +4770,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000010012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000010013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000010014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000010015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000010016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000010016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000010017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000011010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000011011001.TXT
@@ -4777,7 +4778,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000011012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000011013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000011014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000011015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000011016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000011016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000011017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000012010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000012011001.TXT
@@ -4785,7 +4786,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000012012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000012013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000012014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000012015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000012016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000012016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000012017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000013010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000013011001.TXT
@@ -4793,7 +4794,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000013012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000013013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000013014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000013015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000013016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000013016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000013017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000014010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000014011001.TXT
@@ -4801,7 +4802,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000014012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000014013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000014014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000014015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000014016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000014016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000014017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000015010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000015011001.TXT
@@ -4809,7 +4810,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000015012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000015013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000015014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000015015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000015016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000015016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000015017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000016010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000016011001.TXT
@@ -4817,7 +4818,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000016012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000016013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000016014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000016015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000016016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000016016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000016017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000017010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000017011001.TXT
@@ -4825,7 +4826,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000017012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000017013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000017014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000017015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000017016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000017016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000017017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000018010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000018011001.TXT
@@ -4833,7 +4834,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000018012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000018013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000018014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000018015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000018016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000018016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000018017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000019010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000019011001.TXT
@@ -4841,7 +4842,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000019012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000019013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000019014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000019015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000019016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000019016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000019017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000020010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000020011001.TXT
@@ -4849,7 +4850,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000020012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000020013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000020014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000020015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000020016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000020016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000020017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000021010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000021011001.TXT
@@ -4857,7 +4858,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000021012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000021013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000021014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000021015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000021016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000021016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000021017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000022010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000022011001.TXT
@@ -4865,7 +4866,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000022012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000022013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000022014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000022015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000022016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000022016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000022017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000023010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000023011001.TXT
@@ -4873,7 +4874,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000023012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000023013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000023014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000023015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000023016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000023016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000023017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000024010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000024011001.TXT
@@ -4881,7 +4882,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000024012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000024013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000024014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000024015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000024016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000024016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000024017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000025010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000025011001.TXT
@@ -4889,7 +4890,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000025012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000025013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000025014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000025015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000025016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000025016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000025017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000026010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000026011001.TXT
@@ -4897,7 +4898,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000026012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000026013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000026014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000026015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000026016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000026016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000026017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000027010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000027011001.TXT
@@ -4905,7 +4906,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000027012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000027013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000027014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000027015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000027016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000027016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000027017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000028010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000028011001.TXT
@@ -4913,7 +4914,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000028012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000028013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000028014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000028015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000028016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000028016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000028017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000029010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000029011001.TXT
@@ -4921,7 +4922,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000029012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000029013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000029014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000029015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000029016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000029016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000029017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000030010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000030011001.TXT
@@ -4929,7 +4930,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000030012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000030013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000030014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000030015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000030016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000030016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000030017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000031010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000031011001.TXT
@@ -4937,7 +4938,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000031012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000031013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000031014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000031015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000031016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000031016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000031017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000032010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000032011001.TXT
@@ -4945,7 +4946,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000032012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000032013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000032014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000032015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000032016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000032016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000032017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000033010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000033011001.TXT
@@ -4953,7 +4954,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000033012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000033013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000033014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000033015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000033016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000033016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000033017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000034010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000034011001.TXT
@@ -4961,7 +4962,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000034012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000034013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000034014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000034015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000034016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000034016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000034017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000035010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000035011001.TXT
@@ -4969,7 +4970,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000035012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000035013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000035014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000035015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000035016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000035016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000035017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000036010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000036011001.TXT
@@ -4977,7 +4978,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000036012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000036013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000036014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000036015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000036016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000036016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000036017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000037010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000037011001.TXT
@@ -4985,7 +4986,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000037012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000037013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000037014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000037015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000037016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000037016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000037017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000038010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000038011001.TXT
@@ -4993,7 +4994,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000038012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000038013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000038014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000038015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000038016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000038016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000038017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000039010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000039011001.TXT
@@ -5001,7 +5002,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000039012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000039013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000039014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000039015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000039016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000039016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000039017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000040010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000040011001.TXT
@@ -5009,7 +5010,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000040012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000040013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000040014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000040015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000040016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000040016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000040017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000041010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000041011001.TXT
@@ -5017,7 +5018,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000041012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000041013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000041014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000041015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000041016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000041016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000041017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000042010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000042011001.TXT
@@ -5025,7 +5026,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000042012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000042013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000042014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000042015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000042016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000042016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000042017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000043010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000043011001.TXT
@@ -5033,7 +5034,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000043012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000043013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000043014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000043015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000043016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000043016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000043017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000044010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000044011001.TXT
@@ -5041,7 +5042,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000044012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000044013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000044014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000044015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000044016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000044016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000044017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000045010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000045011001.TXT
@@ -5049,7 +5050,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000045012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000045013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000045014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000045015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000045016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000045016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000045017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000046010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000046011001.TXT
@@ -5057,7 +5058,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000046012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000046013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000046014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000046015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000046016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000046016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000046017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000047010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000047011001.TXT
@@ -5065,7 +5066,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000047012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000047013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000047014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000047015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000047016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000047016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000047017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000048010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000048011001.TXT
@@ -5073,7 +5074,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000048012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000048013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000048014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000048015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000048016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000048016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000048017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000049010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000049011001.TXT
@@ -5081,7 +5082,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000049012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000049013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000049014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000049015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000049016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000049016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000049017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000050010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000050011001.TXT
@@ -5089,7 +5090,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000050012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000050013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000050014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000050015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000050016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000050016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000050017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000051010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000051011001.TXT
@@ -5097,7 +5098,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000051012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000051013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000051014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000051015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000051016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000051016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000051017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000052010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000052011001.TXT
@@ -5105,7 +5106,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000052012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000052013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000052014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000052015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000052016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000052016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000052017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000053010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000053011001.TXT
@@ -5113,7 +5114,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000053012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000053013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000053014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000053015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000053016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000053016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000053017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000054010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000054011001.TXT
@@ -5121,7 +5122,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000054012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000054013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000054014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000054015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000054016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000054016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000054017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000055010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000055011001.TXT
@@ -5129,7 +5130,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000055012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000055013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000055014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000055015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000055016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000055016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000055017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000056005000.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000056005005.TXT
@@ -5139,7 +5140,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000056012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000056013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000056014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000056015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000056016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000056016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000056017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000057010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000057011001.TXT
@@ -5147,7 +5148,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000057012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000057013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000057014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000057015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000057016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000057016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000057017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000058010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000058011001.TXT
@@ -5155,7 +5156,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000058012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000058013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000058014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000058015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000058016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000058016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000058017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000059003001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000059003003.TXT
@@ -5166,7 +5167,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000059012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000059013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000059014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000059015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000059016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000059016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000059017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000060007001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000060010001.TXT
@@ -5175,7 +5176,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000060012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000060013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000060014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000060015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000060016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000060016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000060017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000061010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000061011001.TXT
@@ -5183,7 +5184,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000061012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000061013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000061014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000061015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000061016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000061016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000061017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000062010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000062011001.TXT
@@ -5191,7 +5192,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000062012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000062013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000062014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000062015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000062016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000062016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000062017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000063010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000063011001.TXT
@@ -5199,7 +5200,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000063012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000063013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000063014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000063015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000063016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000063016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000063017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000064010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000064011001.TXT
@@ -5207,7 +5208,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000064012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000064013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000064014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000064015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000064016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000064016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000064017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000065010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000065011001.TXT
@@ -5215,7 +5216,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000065012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000065013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000065014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000065015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000065016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000065016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000065017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000066010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000066011001.TXT
@@ -5223,7 +5224,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000066012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000066013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000066014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000066015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000066016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000066016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000066017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000067010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000067011001.TXT
@@ -5231,7 +5232,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000067012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000067013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000067014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000067015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000067016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000067016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000067017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000068010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000068011001.TXT
@@ -5239,7 +5240,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000068012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000068013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000068014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000068015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000068016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000068016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000068017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000069010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000069011001.TXT
@@ -5247,7 +5248,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000069012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000069013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000069014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000069015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000069016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000069016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000069017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000070010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000070011001.TXT
@@ -5255,7 +5256,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000070012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000070013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000070014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000070015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000070016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000070016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000070017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000071010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000071011001.TXT
@@ -5263,7 +5264,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000071012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000071013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000071014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000071015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000071016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000071016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000071017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000072010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000072011001.TXT
@@ -5271,7 +5272,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000072012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000072013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000072014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000072015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000072016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000072016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000072017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000073010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000073011001.TXT
@@ -5279,7 +5280,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000073012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000073013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000073014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000073015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000073016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000073016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000073017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000074002001.TXT
 ln -s D_721b028d58d7913b23b93bba60bb73e0.distinct D0000000000074002032.TXT
@@ -5293,7 +5294,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000074013001.TXT
 ln -s D_721b028d58d7913b23b93bba60bb73e0.distinct D0000000000074013008.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000074014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000074015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000074016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000074016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000074017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000075010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000075011001.TXT
@@ -5301,7 +5302,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000075012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000075013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000075014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000075015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000075016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000075016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000075017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000076010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000076011001.TXT
@@ -5309,7 +5310,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000076012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000076013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000076014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000076015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000076016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000076016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000076017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000077010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000077011001.TXT
@@ -5317,7 +5318,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000077012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000077013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000077014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000077015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000077016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000077016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000077017001.TXT
 ln -s D_721b028d58d7913b23b93bba60bb73e0.distinct D0000000000078008008.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000078010001.TXT
@@ -5330,7 +5331,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000078013001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000078013008.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000078014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000078015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000078016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000078016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000078017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000079010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000079011001.TXT
@@ -5338,7 +5339,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000079012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000079013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000079014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000079015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000079016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000079016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000079017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000080010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000080011001.TXT
@@ -5346,7 +5347,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000080012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000080013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000080014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000080015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000080016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000080016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000080017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000081010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000081011001.TXT
@@ -5354,7 +5355,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000081012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000081013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000081014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000081015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000081016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000081016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000081017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000082010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000082011001.TXT
@@ -5363,7 +5364,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000082012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000082013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000082014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000082015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000082016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000082016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000082017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000083010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000083011001.TXT
@@ -5371,7 +5372,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000083012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000083013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000083014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000083015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000083016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000083016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000083017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000084010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000084011001.TXT
@@ -5379,7 +5380,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000084012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000084013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000084014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000084015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000084016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000084016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000084017001.TXT
 ln -s D_721b028d58d7913b23b93bba60bb73e0.distinct D0000000000085005004.TXT
 ln -s D_721b028d58d7913b23b93bba60bb73e0.distinct D0000000000085009003.TXT
@@ -5389,7 +5390,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000085012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000085013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000085014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000085015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000085016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000085016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000085017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000086010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000086011001.TXT
@@ -5398,7 +5399,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000086012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000086013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000086014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000086015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000086016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000086016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000086017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000087010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000087011001.TXT
@@ -5406,7 +5407,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000087012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000087013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000087014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000087015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000087016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000087016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000087017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000088010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000088011001.TXT
@@ -5414,7 +5415,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000088012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000088013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000088014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000088015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000088016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000088016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000088017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000089010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000089011001.TXT
@@ -5423,7 +5424,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000089012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000089013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000089014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000089015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000089016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000089016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000089017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000090010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000090011001.TXT
@@ -5431,7 +5432,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000090012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000090013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000090014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000090015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000090016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000090016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000090017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000091010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000091011001.TXT
@@ -5439,7 +5440,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000091012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000091013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000091014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000091015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000091016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000091016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000091017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000092010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000092011001.TXT
@@ -5447,7 +5448,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000092012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000092013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000092014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000092015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000092016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000092016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000092017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000093010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000093011001.TXT
@@ -5455,7 +5456,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000093012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000093013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000093014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000093015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000093016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000093016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000093017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000094010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000094011001.TXT
@@ -5463,7 +5464,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000094012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000094013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000094014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000094015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000094016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000094016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000094017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000095010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000095011001.TXT
@@ -5471,7 +5472,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000095012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000095013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000095014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000095015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000095016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000095016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000095017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000096010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000096011001.TXT
@@ -5479,7 +5480,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000096012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000096013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000096014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000096015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000096016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000096016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000096017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000097010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000097011001.TXT
@@ -5487,7 +5488,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000097012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000097013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000097014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000097015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000097016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000097016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000097017001.TXT
 ln -s D_c70df4b3fa64fea39cbecbd4ca4ddd2b.distinct D0000000000098000000.TXT
 ln -s D_1fc62821c0515bf144d84a4100bb53f8.distinct D0000000000098002001.TXT
@@ -5509,8 +5510,8 @@ ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000098014001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000098014101.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000098015001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000098015101.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000098016001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000098016101.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000098016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000098016101.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000098017001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000098017101.TXT
 ln -s D_5abc7b52b7bc04875961cf145f45319b.distinct D0000000000098018001.TXT
@@ -5523,6 +5524,7 @@ ln -s D_bb99e30d62bf95ef8f97567958d44e1c.distinct D0000000000098022001.TXT
 ln -s D_0c24ef206464d74a80b7a2ba12bb9c8f.distinct D0000000000098023001.TXT
 ln -s D_a315a8ea0a25105ecc2beed878b20d2c.distinct D0000000000098024001.TXT
 ln -s D_d1336aa38690b760533d2b96352e2130.distinct D0000000000098024002.TXT
+ln -s D_ef9057f8866d2ad1d22cfc09fd15cd2a.distinct D0000000000098024003.TXT
 ln -s D_d87c60652ddb0d347b093ac29d37caad.distinct D0000000000098024101.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000099010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000099011001.TXT
@@ -5530,7 +5532,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000099012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000099013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000099014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000099015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000099016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000099016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000099017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000100010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000100011001.TXT
@@ -5538,7 +5540,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000100012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000100013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000100014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000100015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000100016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000100016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000100017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000101010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000101011001.TXT
@@ -5546,7 +5548,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000101012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000101013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000101014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000101015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000101016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000101016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000101017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000102010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000102011001.TXT
@@ -5554,7 +5556,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000102012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000102013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000102014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000102015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000102016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000102016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000102017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000103010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000103011001.TXT
@@ -5562,7 +5564,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000103012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000103013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000103014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000103015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000103016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000103016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000103017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000104010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000104011001.TXT
@@ -5570,7 +5572,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000104012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000104013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000104014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000104015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000104016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000104016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000104017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000105010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000105011001.TXT
@@ -5578,7 +5580,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000105012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000105013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000105014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000105015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000105016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000105016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000105017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000106010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000106011001.TXT
@@ -5586,7 +5588,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000106012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000106013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000106014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000106015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000106016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000106016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000106017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000107010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000107011001.TXT
@@ -5594,7 +5596,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000107012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000107013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000107014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000107015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000107016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000107016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000107017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000108010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000108011001.TXT
@@ -5602,7 +5604,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000108012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000108013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000108014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000108015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000108016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000108016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000108017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000109010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000109011001.TXT
@@ -5610,7 +5612,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000109012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000109013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000109014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000109015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000109016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000109016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000109017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000110010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000110011001.TXT
@@ -5618,7 +5620,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000110012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000110013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000110014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000110015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000110016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000110016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000110017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000111010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000111011001.TXT
@@ -5626,7 +5628,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000111012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000111013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000111014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000111015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000111016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000111016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000111017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000112010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000112011001.TXT
@@ -5634,7 +5636,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000112012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000112013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000112014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000112015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000112016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000112016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000112017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000113010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000113011001.TXT
@@ -5642,7 +5644,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000113012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000113013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000113014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000113015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000113016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000113016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000113017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000114010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000114011001.TXT
@@ -5650,7 +5652,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000114012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000114013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000114014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000114015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000114016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000114016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000114017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000115010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000115011001.TXT
@@ -5658,7 +5660,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000115012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000115013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000115014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000115015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000115016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000115016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000115017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000116010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000116011001.TXT
@@ -5666,7 +5668,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000116012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000116013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000116014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000116015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000116016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000116016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000116017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000117010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000117011001.TXT
@@ -5674,7 +5676,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000117012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000117013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000117014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000117015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000117016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000117016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000117017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000118010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000118011001.TXT
@@ -5682,7 +5684,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000118012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000118013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000118014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000118015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000118016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000118016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000118017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000119010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000119011001.TXT
@@ -5690,7 +5692,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000119012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000119013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000119014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000119015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000119016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000119016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000119017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000120010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000120011001.TXT
@@ -5698,7 +5700,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000120012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000120013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000120014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000120015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000120016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000120016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000120017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000121010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000121011001.TXT
@@ -5706,7 +5708,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000121012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000121013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000121014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000121015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000121016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000121016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000121017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000122010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000122011001.TXT
@@ -5714,7 +5716,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000122012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000122013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000122014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000122015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000122016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000122016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000122017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000123010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000123011001.TXT
@@ -5722,7 +5724,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000123012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000123013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000123014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000123015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000123016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000123016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000123017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000124010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000124011001.TXT
@@ -5730,7 +5732,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000124012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000124013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000124014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000124015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000124016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000124016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000124017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000125010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000125011001.TXT
@@ -5738,7 +5740,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000125012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000125013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000125014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000125015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000125016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000125016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000125017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000126010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000126011001.TXT
@@ -5746,7 +5748,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000126012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000126013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000126014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000126015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000126016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000126016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000126017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000127010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000127011001.TXT
@@ -5754,7 +5756,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000127012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000127013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000127014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000127015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000127016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000127016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000127017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000128010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000128011001.TXT
@@ -5762,7 +5764,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000128012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000128013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000128014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000128015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000128016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000128016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000128017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000129010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000129011001.TXT
@@ -5770,7 +5772,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000129012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000129013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000129014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000129015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000129016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000129016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000129017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000130010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000130011001.TXT
@@ -5778,7 +5780,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000130012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000130013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000130014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000130015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000130016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000130016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000130017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000131010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000131011001.TXT
@@ -5786,7 +5788,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000131012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000131013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000131014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000131015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000131016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000131016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000131017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000132010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000132011001.TXT
@@ -5794,7 +5796,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000132012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000132013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000132014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000132015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000132016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000132016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000132017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000133010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000133011001.TXT
@@ -5802,7 +5804,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000133012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000133013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000133014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000133015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000133016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000133016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000133017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000134010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000134011001.TXT
@@ -5810,7 +5812,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000134012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000134013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000134014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000134015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000134016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000134016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000134017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000135010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000135011001.TXT
@@ -5818,7 +5820,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000135012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000135013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000135014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000135015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000135016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000135016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000135017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000136010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000136011001.TXT
@@ -5826,7 +5828,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000136012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000136013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000136014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000136015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000136016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000136016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000136017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000137010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000137011001.TXT
@@ -5834,7 +5836,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000137012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000137013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000137014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000137015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000137016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000137016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000137017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000138010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000138011001.TXT
@@ -5842,7 +5844,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000138012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000138013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000138014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000138015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000138016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000138016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000138017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000139010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000139011001.TXT
@@ -5850,7 +5852,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000139012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000139013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000139014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000139015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000139016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000139016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000139017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000140010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000140011001.TXT
@@ -5858,7 +5860,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000140012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000140013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000140014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000140015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000140016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000140016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000140017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000141010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000141011001.TXT
@@ -5866,7 +5868,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000141012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000141013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000141014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000141015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000141016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000141016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000141017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000142010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000142011001.TXT
@@ -5874,7 +5876,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000142012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000142013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000142014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000142015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000142016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000142016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000142017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000143010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000143011001.TXT
@@ -5882,7 +5884,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000143012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000143013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000143014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000143015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000143016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000143016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000143017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000144010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000144011001.TXT
@@ -5890,7 +5892,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000144012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000144013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000144014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000144015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000144016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000144016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000144017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000145010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000145011001.TXT
@@ -5898,7 +5900,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000145012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000145013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000145014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000145015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000145016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000145016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000145017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000146010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000146011001.TXT
@@ -5906,7 +5908,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000146012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000146013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000146014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000146015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000146016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000146016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000146017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000147010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000147011001.TXT
@@ -5914,7 +5916,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000147012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000147013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000147014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000147015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000147016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000147016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000147017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000148010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000148011001.TXT
@@ -5922,7 +5924,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000148012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000148013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000148014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000148015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000148016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000148016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000148017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000149010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000149011001.TXT
@@ -5930,7 +5932,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000149012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000149013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000149014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000149015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000149016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000149016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000149017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000150010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000150011001.TXT
@@ -5938,7 +5940,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000150012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000150013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000150014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000150015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000150016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000150016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000150017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000151010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000151011001.TXT
@@ -5946,7 +5948,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000151012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000151013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000151014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000151015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000151016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000151016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000151017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000152010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000152011001.TXT
@@ -5954,7 +5956,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000152012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000152013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000152014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000152015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000152016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000152016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000152017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000153010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000153011001.TXT
@@ -5962,7 +5964,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000153012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000153013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000153014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000153015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000153016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000153016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000153017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000154010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000154011001.TXT
@@ -5970,7 +5972,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000154012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000154013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000154014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000154015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000154016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000154016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000154017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000155010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000155011001.TXT
@@ -5978,7 +5980,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000155012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000155013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000155014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000155015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000155016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000155016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000155017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000156010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000156011001.TXT
@@ -5986,7 +5988,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000156012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000156013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000156014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000156015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000156016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000156016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000156017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000157010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000157011001.TXT
@@ -5994,7 +5996,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000157012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000157013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000157014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000157015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000157016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000157016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000157017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000158010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000158011001.TXT
@@ -6002,7 +6004,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000158012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000158013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000158014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000158015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000158016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000158016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000158017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000159010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000159011001.TXT
@@ -6010,7 +6012,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000159012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000159013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000159014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000159015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000159016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000159016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000159017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000160006001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000160010001.TXT
@@ -6019,7 +6021,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000160012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000160013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000160014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000160015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000160016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000160016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000160017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000161010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000161011001.TXT
@@ -6027,7 +6029,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000161012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000161013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000161014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000161015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000161016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000161016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000161017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000162010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000162011001.TXT
@@ -6035,7 +6037,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000162012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000162013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000162014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000162015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000162016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000162016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000162017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000163010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000163011001.TXT
@@ -6043,7 +6045,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000163012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000163013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000163014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000163015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000163016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000163016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000163017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000164010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000164011001.TXT
@@ -6051,7 +6053,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000164012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000164013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000164014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000164015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000164016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000164016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000164017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000165010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000165011001.TXT
@@ -6059,7 +6061,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000165012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000165013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000165014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000165015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000165016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000165016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000165017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000166010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000166011001.TXT
@@ -6067,7 +6069,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000166012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000166013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000166014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000166015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000166016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000166016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000166017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000167010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000167011001.TXT
@@ -6075,7 +6077,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000167012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000167013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000167014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000167015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000167016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000167016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000167017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000168010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000168011001.TXT
@@ -6083,7 +6085,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000168012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000168013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000168014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000168015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000168016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000168016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000168017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000169010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000169011001.TXT
@@ -6091,7 +6093,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000169012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000169013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000169014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000169015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000169016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000169016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000169017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000170010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000170011001.TXT
@@ -6099,7 +6101,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000170012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000170013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000170014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000170015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000170016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000170016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000170017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000171010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000171011001.TXT
@@ -6107,7 +6109,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000171012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000171013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000171014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000171015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000171016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000171016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000171017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000172010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000172011001.TXT
@@ -6115,7 +6117,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000172012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000172013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000172014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000172015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000172016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000172016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000172017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000173010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000173011001.TXT
@@ -6123,7 +6125,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000173012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000173013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000173014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000173015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000173016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000173016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000173017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000174010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000174011001.TXT
@@ -6131,7 +6133,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000174012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000174013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000174014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000174015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000174016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000174016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000174017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000175010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000175011001.TXT
@@ -6139,7 +6141,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000175012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000175013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000175014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000175015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000175016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000175016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000175017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000176010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000176011001.TXT
@@ -6147,7 +6149,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000176012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000176013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000176014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000176015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000176016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000176016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000176017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000177010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000177011001.TXT
@@ -6155,7 +6157,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000177012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000177013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000177014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000177015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000177016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000177016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000177017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000178010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000178011001.TXT
@@ -6163,7 +6165,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000178012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000178013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000178014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000178015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000178016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000178016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000178017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000179010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000179011001.TXT
@@ -6171,7 +6173,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000179012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000179013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000179014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000179015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000179016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000179016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000179017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000180010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000180011001.TXT
@@ -6179,7 +6181,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000180012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000180013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000180014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000180015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000180016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000180016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000180017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000181010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000181011001.TXT
@@ -6187,7 +6189,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000181012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000181013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000181014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000181015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000181016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000181016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000181017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000182010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000182011001.TXT
@@ -6195,7 +6197,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000182012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000182013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000182014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000182015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000182016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000182016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000182017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000183010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000183011001.TXT
@@ -6203,7 +6205,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000183012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000183013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000183014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000183015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000183016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000183016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000183017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000184010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000184011001.TXT
@@ -6211,7 +6213,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000184012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000184013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000184014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000184015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000184016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000184016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000184017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000185010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000185011001.TXT
@@ -6219,7 +6221,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000185012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000185013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000185014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000185015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000185016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000185016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000185017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000186010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000186011001.TXT
@@ -6227,7 +6229,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000186012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000186013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000186014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000186015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000186016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000186016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000186017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000187010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000187011001.TXT
@@ -6235,7 +6237,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000187012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000187013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000187014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000187015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000187016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000187016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000187017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000188010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000188011001.TXT
@@ -6243,7 +6245,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000188012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000188013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000188014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000188015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000188016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000188016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000188017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000189010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000189011001.TXT
@@ -6251,7 +6253,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000189012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000189013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000189014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000189015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000189016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000189016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000189017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000190010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000190011001.TXT
@@ -6259,7 +6261,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000190012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000190013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000190014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000190015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000190016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000190016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000190017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000191010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000191011001.TXT
@@ -6267,7 +6269,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000191012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000191013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000191014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000191015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000191016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000191016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000191017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000192010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000192011001.TXT
@@ -6275,7 +6277,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000192012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000192013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000192014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000192015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000192016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000192016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000192017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000193010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000193011001.TXT
@@ -6283,7 +6285,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000193012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000193013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000193014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000193015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000193016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000193016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000193017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000194010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000194011001.TXT
@@ -6291,7 +6293,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000194012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000194013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000194014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000194015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000194016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000194016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000194017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000195010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000195011001.TXT
@@ -6299,7 +6301,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000195012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000195013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000195014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000195015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000195016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000195016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000195017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000196010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000196011001.TXT
@@ -6307,7 +6309,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000196012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000196013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000196014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000196015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000196016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000196016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000196017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000197010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000197011001.TXT
@@ -6315,7 +6317,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000197012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000197013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000197014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000197015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000197016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000197016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000197017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000198010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000198011001.TXT
@@ -6323,7 +6325,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000198012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000198013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000198014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000198015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000198016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000198016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000198017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000199010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000199011001.TXT
@@ -6331,7 +6333,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000199012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000199013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000199014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000199015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000199016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000199016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000199017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000200010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000200011001.TXT
@@ -6339,7 +6341,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000200012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000200013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000200014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000200015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000200016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000200016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000200017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000201010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000201011001.TXT
@@ -6347,7 +6349,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000201012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000201013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000201014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000201015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000201016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000201016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000201017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000202010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000202011001.TXT
@@ -6355,7 +6357,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000202012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000202013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000202014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000202015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000202016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000202016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000202017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000203010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000203011001.TXT
@@ -6363,7 +6365,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000203012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000203013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000203014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000203015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000203016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000203016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000203017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000204010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000204011001.TXT
@@ -6371,7 +6373,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000204012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000204013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000204014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000204015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000204016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000204016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000204017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000205010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000205011001.TXT
@@ -6379,7 +6381,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000205012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000205013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000205014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000205015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000205016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000205016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000205017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000206010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000206011001.TXT
@@ -6387,7 +6389,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000206012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000206013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000206014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000206015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000206016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000206016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000206017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000207010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000207011001.TXT
@@ -6395,7 +6397,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000207012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000207013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000207014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000207015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000207016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000207016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000207017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000208010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000208011001.TXT
@@ -6403,7 +6405,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000208012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000208013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000208014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000208015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000208016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000208016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000208017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000209010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000209011001.TXT
@@ -6411,7 +6413,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000209012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000209013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000209014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000209015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000209016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000209016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000209017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000210010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000210011001.TXT
@@ -6419,7 +6421,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000210012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000210013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000210014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000210015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000210016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000210016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000210017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000211010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000211011001.TXT
@@ -6427,7 +6429,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000211012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000211013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000211014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000211015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000211016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000211016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000211017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000212010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000212011001.TXT
@@ -6435,7 +6437,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000212012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000212013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000212014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000212015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000212016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000212016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000212017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000213010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000213011001.TXT
@@ -6443,7 +6445,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000213012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000213013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000213014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000213015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000213016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000213016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000213017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000214010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000214011001.TXT
@@ -6451,7 +6453,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000214012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000214013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000214014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000214015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000214016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000214016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000214017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000215009003.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000215010001.TXT
@@ -6461,7 +6463,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000215013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000215014001.TXT
 ln -s D_99cbfdf89904aeca4a5aabcfaad382db.distinct D0000000000215014008.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000215015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000215016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000215016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000215017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000216010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000216011001.TXT
@@ -6469,7 +6471,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000216012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000216013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000216014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000216015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000216016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000216016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000216017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000217010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000217011001.TXT
@@ -6477,7 +6479,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000217012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000217013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000217014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000217015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000217016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000217016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000217017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000218010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000218011001.TXT
@@ -6485,7 +6487,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000218012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000218013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000218014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000218015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000218016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000218016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000218017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000219010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000219011001.TXT
@@ -6493,7 +6495,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000219012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000219013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000219014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000219015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000219016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000219016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000219017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000220010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000220011001.TXT
@@ -6501,7 +6503,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000220012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000220013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000220014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000220015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000220016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000220016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000220017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000221010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000221011001.TXT
@@ -6509,7 +6511,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000221012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000221013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000221014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000221015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000221016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000221016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000221017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000222010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000222011001.TXT
@@ -6517,7 +6519,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000222012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000222013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000222014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000222015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000222016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000222016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000222017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000223010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000223011001.TXT
@@ -6525,7 +6527,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000223012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000223013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000223014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000223015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000223016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000223016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000223017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000224010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000224011001.TXT
@@ -6533,7 +6535,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000224012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000224013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000224014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000224015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000224016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000224016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000224017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000225010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000225011001.TXT
@@ -6541,7 +6543,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000225012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000225013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000225014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000225015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000225016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000225016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000225017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000226010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000226011001.TXT
@@ -6549,7 +6551,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000226012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000226013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000226014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000226015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000226016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000226016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000226017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000227010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000227011001.TXT
@@ -6557,7 +6559,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000227012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000227013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000227014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000227015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000227016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000227016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000227017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000228010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000228011001.TXT
@@ -6565,7 +6567,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000228012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000228013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000228014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000228015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000228016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000228016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000228017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000229010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000229011001.TXT
@@ -6573,7 +6575,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000229012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000229013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000229014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000229015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000229016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000229016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000229017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000230010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000230011001.TXT
@@ -6581,7 +6583,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000230012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000230013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000230014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000230015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000230016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000230016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000230017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000231010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000231011001.TXT
@@ -6589,7 +6591,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000231012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000231013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000231014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000231015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000231016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000231016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000231017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000232010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000232011001.TXT
@@ -6597,7 +6599,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000232012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000232013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000232014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000232015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000232016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000232016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000232017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000233010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000233011001.TXT
@@ -6605,7 +6607,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000233012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000233013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000233014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000233015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000233016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000233016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000233017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000234010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000234011001.TXT
@@ -6613,7 +6615,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000234012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000234013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000234014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000234015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000234016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000234016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000234017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000235010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000235011001.TXT
@@ -6621,7 +6623,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000235012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000235013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000235014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000235015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000235016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000235016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000235017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000236010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000236011001.TXT
@@ -6629,7 +6631,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000236012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000236013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000236014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000236015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000236016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000236016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000236017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000237010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000237011001.TXT
@@ -6637,7 +6639,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000237012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000237013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000237014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000237015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000237016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000237016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000237017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000238010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000238011001.TXT
@@ -6645,7 +6647,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000238012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000238013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000238014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000238015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000238016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000238016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000238017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000239010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000239011001.TXT
@@ -6653,7 +6655,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000239012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000239013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000239014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000239015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000239016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000239016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000239017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000240010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000240011001.TXT
@@ -6661,7 +6663,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000240012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000240013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000240014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000240015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000240016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000240016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000240017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000241010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000241011001.TXT
@@ -6669,7 +6671,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000241012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000241013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000241014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000241015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000241016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000241016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000241017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000242010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000242011001.TXT
@@ -6677,7 +6679,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000242012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000242013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000242014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000242015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000242016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000242016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000242017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000243010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000243011001.TXT
@@ -6685,7 +6687,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000243012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000243013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000243014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000243015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000243016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000243016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000243017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000244010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000244011001.TXT
@@ -6693,7 +6695,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000244012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000244013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000244014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000244015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000244016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000244016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000244017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000245010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000245011001.TXT
@@ -6701,7 +6703,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000245012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000245013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000245014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000245015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000245016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000245016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000245017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000246010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000246011001.TXT
@@ -6709,7 +6711,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000246012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000246013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000246014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000246015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000246016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000246016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000246017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000247010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000247011001.TXT
@@ -6717,7 +6719,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000247012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000247013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000247014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000247015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000247016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000247016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000247017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000248010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000248011001.TXT
@@ -6725,7 +6727,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000248012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000248013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000248014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000248015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000248016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000248016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000248017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000249010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000249011001.TXT
@@ -6733,7 +6735,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000249012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000249013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000249014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000249015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000249016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000249016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000249017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000250010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000250011001.TXT
@@ -6741,7 +6743,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000250012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000250013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000250014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000250015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000250016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000250016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000250017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000251010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000251011001.TXT
@@ -6749,7 +6751,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000251012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000251013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000251014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000251015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000251016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000251016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000251017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000252010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000252011001.TXT
@@ -6757,7 +6759,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000252012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000252013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000252014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000252015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000252016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000252016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000252017001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000253010001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000253011001.TXT
@@ -6765,7 +6767,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000253012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000253013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000253014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000253015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000253016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000253016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000253017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000254006001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000000254010000.TXT
@@ -6775,7 +6777,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000254012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000254013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000254014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000254015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000254016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000254016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000254017001.TXT
 ln -s D_163528c9416c4e586d5646ecdfae2cbd.distinct D0000000000254019001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000255010001.TXT
@@ -6784,7 +6786,7 @@ ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000255012001.TXT
 ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000000255013001.TXT
 ln -s D_1b430bccf004fff784a904a211c075bd.distinct D0000000000255014001.TXT
 ln -s D_282e48b64107e2fd90c5d9e7f1f6a349.distinct D0000000000255015001.TXT
-ln -s D_97904881abf209f200d7dab466e706ce.distinct D0000000000255016001.TXT
+ln -s D_37f24485fa8f2c4abd0c02a2b42ee3fc.distinct D0000000000255016001.TXT
 ln -s D_173e9169eaed3807be0f5fdad3111fed.distinct D0000000000255017001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000065535002001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000065535002004.TXT
@@ -6792,6 +6794,7 @@ ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000065535011004.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000065535011005.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000300000013000.TXT
 ln -s D_aac4646403e0b6b4d7f4af7786d40a24.distinct D0000000300007004001.TXT
+ln -s D_df21a931ba159c58c3b9b00236baac59.distinct D0000000300098012001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000000300098013001.TXT
 ln -s D_aac4646403e0b6b4d7f4af7786d40a24.distinct D0000000300160011001.TXT
 ln -s D_1a04522fbc85dad28a197e988a256c72.distinct D0000001000000011000.TXT
diff --git a/cmake/FindADSM.cmake b/cmake/FindADSM.cmake
index 76140b6..7af6723 100644
--- a/cmake/FindADSM.cmake
+++ b/cmake/FindADSM.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindAEC.cmake b/cmake/FindAEC.cmake
index 28d086d..8a59037 100644
--- a/cmake/FindAEC.cmake
+++ b/cmake/FindAEC.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/FindAIO.cmake b/cmake/FindAIO.cmake
index 61fdcc0..c27b795 100644
--- a/cmake/FindAIO.cmake
+++ b/cmake/FindAIO.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindArmadillo.cmake b/cmake/FindArmadillo.cmake
index 4183306..a3628a5 100644
--- a/cmake/FindArmadillo.cmake
+++ b/cmake/FindArmadillo.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake
index 7cf6f58..cf80f85 100644
--- a/cmake/FindCMath.cmake
+++ b/cmake/FindCMath.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindDl.cmake b/cmake/FindDl.cmake
index 305fff0..30db9c6 100644
--- a/cmake/FindDl.cmake
+++ b/cmake/FindDl.cmake
@@ -1,4 +1,4 @@
-# © Copyright 1996-2014 ECMWF.
+# © Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindEMOS.cmake b/cmake/FindEMOS.cmake
index 56ee334..70028ca 100644
--- a/cmake/FindEMOS.cmake
+++ b/cmake/FindEMOS.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindFDB.cmake b/cmake/FindFDB.cmake
index 6624544..9608a54 100644
--- a/cmake/FindFDB.cmake
+++ b/cmake/FindFDB.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindHPSS.cmake b/cmake/FindHPSS.cmake
index 50f95cc..a96b8d4 100644
--- a/cmake/FindHPSS.cmake
+++ b/cmake/FindHPSS.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindLEX.cmake b/cmake/FindLEX.cmake
index 34ea36c..00335c2 100644
--- a/cmake/FindLEX.cmake
+++ b/cmake/FindLEX.cmake
@@ -44,7 +44,7 @@
 # This file is based on the FindFLEX CMake macro, and adapted by ECMWF
 
 #=============================================================================
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/FindLegacyFDB.cmake b/cmake/FindLegacyFDB.cmake
index 0136299..f461a0e 100644
--- a/cmake/FindLegacyFDB.cmake
+++ b/cmake/FindLegacyFDB.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindLibGFortran.cmake b/cmake/FindLibGFortran.cmake
index bf9e168..95b6036 100644
--- a/cmake/FindLibGFortran.cmake
+++ b/cmake/FindLibGFortran.cmake
@@ -1,8 +1,8 @@
-# © Copyright 1996-2014 ECMWF.
-# 
+# © Copyright 1996-2015 ECMWF.
+#
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
@@ -23,16 +23,16 @@ if( GFORTRAN_EXECUTABLE )
 		ERROR_VARIABLE _GFORTRAN_ERROR_VALUE
 		OUTPUT_STRIP_TRAILING_WHITESPACE)
 
-#	debug_var(_GFORTRAN_SEARCH_SUCCESS)
-#	debug_var(_GFORTRAN_VALUES_OUTPUT)
-#	debug_var(_GFORTRAN_ERROR_VALUE)
+#	ecbuild_debug_var(_GFORTRAN_SEARCH_SUCCESS)
+#	ecbuild_debug_var(_GFORTRAN_VALUES_OUTPUT)
+#	ecbuild_debug_var(_GFORTRAN_ERROR_VALUE)
 
 	if(_GFORTRAN_SEARCH_SUCCESS MATCHES 0)
 		string(REGEX REPLACE ".*libraries: =(.*)" "\\1" _result  ${_GFORTRAN_VALUES_OUTPUT})
 		string(REGEX REPLACE ":" ";" _gfortran_hints ${_result} )
 	endif()
 
-	debug_var( _gfortran_hints )
+	ecbuild_debug_var( _gfortran_hints )
 
 endif()
 
diff --git a/cmake/FindNDBM.cmake b/cmake/FindNDBM.cmake
index 21cf1cf..5203ee9 100644
--- a/cmake/FindNDBM.cmake
+++ b/cmake/FindNDBM.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindNetCDF.cmake b/cmake/FindNetCDF.cmake
index b214d27..822ecf0 100644
--- a/cmake/FindNetCDF.cmake
+++ b/cmake/FindNetCDF.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -76,7 +76,7 @@ if( PREFER_NETCDF4 )
 
   ## hdf5
 
-  # Note: Only the HDF5 C-library is required for NetCDF 
+  # Note: Only the HDF5 C-library is required for NetCDF
   #       ( even for Fortan and CXX bindings)
   find_package( HDF5 COMPONENTS C QUIET )
 
@@ -87,24 +87,24 @@ if( PREFER_NETCDF4 )
   # Find NetCDF4
 
   # message( "NETCDF CMAKE_PREFIX_PATH = [${CMAKE_PREFIX_PATH}]")
-  # debug_var( NETCDF_ROOT )
-  # debug_var( NETCDF_FIND_COMPONENTS )
-  # debug_var( NETCDF_FIND_QUIETLY )
-  # debug_var( NETCDF_FIND_REQUIRED )
+  # ecbuild_debug_var( NETCDF_ROOT )
+  # ecbuild_debug_var( NETCDF_FIND_COMPONENTS )
+  # ecbuild_debug_var( NETCDF_FIND_QUIETLY )
+  # ecbuild_debug_var( NETCDF_FIND_REQUIRED )
   find_package( NetCDF4 COMPONENTS ${NETCDF_FIND_COMPONENTS} )
-  # debug_var( NETCDF4_FOUND )
-  # debug_var( NETCDF_FOUND )
-  # debug_var( NETCDF_LIBRARIES )
-  # debug_var( NETCDF_INCLUDE_DIRS )
+  # ecbuild_debug_var( NETCDF4_FOUND )
+  # ecbuild_debug_var( NETCDF_FOUND )
+  # ecbuild_debug_var( NETCDF_LIBRARIES )
+  # ecbuild_debug_var( NETCDF_INCLUDE_DIRS )
 
   list( APPEND NETCDF_Fortran_LIBRARIES ${NETCDF_FORTRAN_LIBRARIES} ${NETCDF_F90_LIBRARIES} )
   if( NETCDF_Fortran_LIBRARIES )
     list( REMOVE_DUPLICATES NETCDF_Fortran_LIBRARIES )
   endif()
 
-  # debug_var( NETCDF_Fortran_LIBRARIES )
-  # debug_var( NETCDF_C_LIBRARIES )
-  # debug_var( NETCDF_CXX_LIBRARIES )
+  # ecbuild_debug_var( NETCDF_Fortran_LIBRARIES )
+  # ecbuild_debug_var( NETCDF_C_LIBRARIES )
+  # ecbuild_debug_var( NETCDF_CXX_LIBRARIES )
 
 
   set_package_properties( NetCDF4 PROPERTIES TYPE RECOMMENDED PURPOSE "support for NetCDF4 file format" )
@@ -115,13 +115,13 @@ if( PREFER_NETCDF4 )
     list( APPEND NETCDF_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} )
   endif()
 
-  #debug_var( NETCDF_FOUND )
-  #debug_var( NETCDF_LIBRARIES )
-  #debug_var( NETCDF_INCLUDE_DIRS )
-  #debug_var( HDF5_FOUND )
-  #debug_var( HDF5_INCLUDE_DIRS )
-  #debug_var( HDF5_HL_LIBRARIES )
-  #debug_var( HDF5_LIBRARIES )
+  #ecbuild_debug_var( NETCDF_FOUND )
+  #ecbuild_debug_var( NETCDF_LIBRARIES )
+  #ecbuild_debug_var( NETCDF_INCLUDE_DIRS )
+  #ecbuild_debug_var( HDF5_FOUND )
+  #ecbuild_debug_var( HDF5_INCLUDE_DIRS )
+  #ecbuild_debug_var( HDF5_HL_LIBRARIES )
+  #ecbuild_debug_var( HDF5_LIBRARIES )
 
 endif()
 
@@ -131,9 +131,9 @@ if( PREFER_NETCDF3 )
 
   ecbuild_debug( "FindNetCDF: looking for NetCDF3" )
 
-  # debug_var( NetCDF_FIND_COMPONENTS )
-  # debug_var( NetCDF_FIND_QUIETLY )
-  # debug_var( NetCDF_FIND_REQUIRED )
+  # ecbuild_debug_var( NetCDF_FIND_COMPONENTS )
+  # ecbuild_debug_var( NetCDF_FIND_QUIETLY )
+  # ecbuild_debug_var( NetCDF_FIND_REQUIRED )
 
   list(FIND NetCDF_FIND_COMPONENTS "CXX" _index)
   if(${_index} GREATER -1)
diff --git a/cmake/FindNetCDF3.cmake b/cmake/FindNetCDF3.cmake
index 20a5396..40e6bc0 100644
--- a/cmake/FindNetCDF3.cmake
+++ b/cmake/FindNetCDF3.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindODB.cmake b/cmake/FindODB.cmake
index bfa6905..3a1fa12 100644
--- a/cmake/FindODB.cmake
+++ b/cmake/FindODB.cmake
@@ -1,4 +1,4 @@
-# © Copyright 1996-2014 ECMWF.
+# © Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/FindOpenJPEG.cmake b/cmake/FindOpenJPEG.cmake
index d692f35..82d19fb 100644
--- a/cmake/FindOpenJPEG.cmake
+++ b/cmake/FindOpenJPEG.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindPGIFortran.cmake b/cmake/FindPGIFortran.cmake
index ae2221b..7308e49 100644
--- a/cmake/FindPGIFortran.cmake
+++ b/cmake/FindPGIFortran.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindPango.cmake b/cmake/FindPango.cmake
index 0105d7f..9f183b9 100644
--- a/cmake/FindPango.cmake
+++ b/cmake/FindPango.cmake
@@ -1,8 +1,8 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
+# (C) Copyright 1996-2015 ECMWF.
+#
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
@@ -17,10 +17,10 @@ find_package(PkgConfig)
 
 pkg_check_modules(PC_LIBPANGO QUIET pango)
 
-debug_var( PC_LIBPANGO_FOUND )
-debug_var( PC_LIBPANGO_VERSION )
-debug_var( PC_LIBPANGO_LIBRARIES )
-debug_var( PC_LIBPANGO_INCLUDE_DIRS )
+ecbuild_debug_var( PC_LIBPANGO_FOUND )
+ecbuild_debug_var( PC_LIBPANGO_VERSION )
+ecbuild_debug_var( PC_LIBPANGO_LIBRARIES )
+ecbuild_debug_var( PC_LIBPANGO_INCLUDE_DIRS )
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args( pango DEFAULT_MSG PC_LIBPANGO_LIBRARIES PC_LIBPANGO_INCLUDE_DIRS )
diff --git a/cmake/FindPangoCairo.cmake b/cmake/FindPangoCairo.cmake
index 611e269..7d7750e 100644
--- a/cmake/FindPangoCairo.cmake
+++ b/cmake/FindPangoCairo.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -18,12 +18,12 @@ find_package(PkgConfig)
 
 pkg_check_modules(PC_LIBPANGOCAIRO QUIET pangocairo)
 
-#debug_var( PC_LIBPANGOCAIRO_FOUND )
-#debug_var( PC_LIBPANGOCAIRO_VERSION )
-#debug_var( PC_LIBPANGOCAIRO_LIBRARIES )
-#debug_var( PC_LIBPANGOCAIRO_LDFLAGS )
-#debug_var( PC_LIBPANGOCAIRO_LDFLAGS_OTHER )
-#debug_var( PC_LIBPANGOCAIRO_INCLUDE_DIRS )
+#ecbuild_debug_var( PC_LIBPANGOCAIRO_FOUND )
+#ecbuild_debug_var( PC_LIBPANGOCAIRO_VERSION )
+#ecbuild_debug_var( PC_LIBPANGOCAIRO_LIBRARIES )
+#ecbuild_debug_var( PC_LIBPANGOCAIRO_LDFLAGS )
+#ecbuild_debug_var( PC_LIBPANGOCAIRO_LDFLAGS_OTHER )
+#ecbuild_debug_var( PC_LIBPANGOCAIRO_INCLUDE_DIRS )
 
 if(PC_LIBPANGOCAIRO_FOUND)
 
diff --git a/cmake/FindProj4.cmake b/cmake/FindProj4.cmake
index e748536..64eab79 100644
--- a/cmake/FindProj4.cmake
+++ b/cmake/FindProj4.cmake
@@ -7,8 +7,12 @@
 #
 # Define PROJ4_MIN_VERSION for which version desired.
 
-if( NOT PROJ4_PATH AND NOT "$ENV{PROJ4_PATH}" STREQUAL "" )
-    set( PROJ4_PATH "$ENV{PROJ4_PATH}" )
+if( NOT PROJ4_PATH )
+    if ( NOT "$ENV{PROJ4_PATH}" STREQUAL "" )
+        set( PROJ4_PATH "$ENV{PROJ4_PATH}" )
+    elseif ( NOT "$ENV{PROJ4_DIR}" STREQUAL "" )
+        set( PROJ4_PATH "$ENV{PROJ4_DIR}" )
+    endif()
 endif()
 
 if( NOT PROJ4_PATH )
@@ -34,9 +38,9 @@ if( NOT PROJ4_PATH )
 
     endif()
 
-#    debug_var( PKG_CONFIG_FOUND )
-#    debug_var( PKPROJ4_FOUND )
-#    debug_var( PROJ4_MIN_VERSION )
+#    ecbuild_debug_var( PKG_CONFIG_FOUND )
+#    ecbuild_debug_var( PKPROJ4_FOUND )
+#    ecbuild_debug_var( PROJ4_MIN_VERSION )
 
 endif()
 
@@ -51,8 +55,8 @@ find_path(PROJ4_INCLUDE_DIR NAMES proj_api.h PATHS PATH_SUFFIXES proj4 )
 find_library( PROJ4_LIBRARY NAMES proj       PATHS PATH_SUFFIXES proj4 )
 
 
-# debug_var( PROJ4_INCLUDE_DIR )
-# debug_var( PROJ4_LIBRARY )
+# ecbuild_debug_var( PROJ4_INCLUDE_DIR )
+# ecbuild_debug_var( PROJ4_LIBRARY )
 
 # handle the QUIETLY and REQUIRED arguments and set GRIBAPI_FOUND
 include(FindPackageHandleStandardArgs)
diff --git a/cmake/FindREADLINE.cmake b/cmake/FindREADLINE.cmake
index 9477026..c6ae778 100644
--- a/cmake/FindREADLINE.cmake
+++ b/cmake/FindREADLINE.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -47,8 +47,8 @@ cmake_push_check_state()
 
 cmake_pop_check_state()
 
-# debug_var( readline_version )
-# debug_var( __readline_version_out )
+# ecbuild_debug_var( readline_version )
+# ecbuild_debug_var( __readline_version_out )
 
 set( __readline_fail 0 )
 if( __readline_version_out )
diff --git a/cmake/FindRPCGEN.cmake b/cmake/FindRPCGEN.cmake
index 98c4a98..3e25daf 100644
--- a/cmake/FindRPCGEN.cmake
+++ b/cmake/FindRPCGEN.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindRealtime.cmake b/cmake/FindRealtime.cmake
index b46b9b7..2c2a7b2 100644
--- a/cmake/FindRealtime.cmake
+++ b/cmake/FindRealtime.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindSZip.cmake b/cmake/FindSZip.cmake
index d7d6026..6e9b1a2 100644
--- a/cmake/FindSZip.cmake
+++ b/cmake/FindSZip.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/FindTrilinos.cmake b/cmake/FindTrilinos.cmake
index 9cc6132..a1cabce 100644
--- a/cmake/FindTrilinos.cmake
+++ b/cmake/FindTrilinos.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindXLFortranLibs.cmake b/cmake/FindXLFortranLibs.cmake
index 7be0070..10a68aa 100644
--- a/cmake/FindXLFortranLibs.cmake
+++ b/cmake/FindXLFortranLibs.cmake
@@ -1,4 +1,4 @@
-# © Copyright 1996-2014 ECMWF.
+# © Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/FindYACC.cmake b/cmake/FindYACC.cmake
index dbdb191..a410c6f 100644
--- a/cmake/FindYACC.cmake
+++ b/cmake/FindYACC.cmake
@@ -41,7 +41,7 @@
 # This file is based on the FindFLEX CMake macro, and adapted by ECMWF
 
 #=============================================================================
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/Findgrib_api.cmake b/cmake/Findgrib_api.cmake
index 32a01e9..3150039 100644
--- a/cmake/Findgrib_api.cmake
+++ b/cmake/Findgrib_api.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -20,16 +20,16 @@ option( GRIB_API_JPG "use jpg with grib_api" ON )
 if( NOT grib_api_FOUND AND NOT NO_GRIB_API_BINARIES )
 
     if( GRIB_API_JPG ) # jpeg support
-        
+
         find_package( JPEG     QUIET ) # grib_api might be a static .a library in which
-    
+
         if( NOT "$ENV{JASPER_PATH}" STREQUAL "" )
             list( APPEND CMAKE_PREFIX_PATH "$ENV{JASPER_PATH}" )
         endif()
         find_package( Jasper   QUIET ) # case we don't know if which jpeg library was used
-    
-        find_package( OpenJPEG QUIET ) # so we try to find all jpeg libs and link to them 
-        
+
+        find_package( OpenJPEG QUIET ) # so we try to find all jpeg libs and link to them
+
         if(JPEG_FOUND)
             list( APPEND _grib_api_jpg_incs ${JPEG_INCLUDE_DIR} )
             list( APPEND _grib_api_jpg_libs ${JPEG_LIBRARIES} )
@@ -44,18 +44,18 @@ if( NOT grib_api_FOUND AND NOT NO_GRIB_API_BINARIES )
         endif()
 
     endif()
-    
+
     if( GRIB_API_PNG ) # png support
-    
+
         find_package(PNG)
-    
+
         if( DEFINED PNG_PNG_INCLUDE_DIR AND NOT DEFINED PNG_INCLUDE_DIRS )
           set( PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR}  CACHE INTERNAL "PNG include dirs" )
         endif()
         if( DEFINED PNG_LIBRARY AND NOT DEFINED PNG_LIBRARIES )
           set( PNG_LIBRARIES ${PNG_LIBRARY} CACHE INTERNAL "PNG libraries" )
         endif()
-        
+
         if(PNG_FOUND)
             list( APPEND _grib_api_png_defs ${PNG_DEFINITIONS} )
             list( APPEND _grib_api_png_incs ${PNG_INCLUDE_DIRS} )
@@ -85,22 +85,22 @@ if( NOT grib_api_FOUND AND NOT NO_GRIB_API_BINARIES )
         find_library(GRIB_API_LIB_F77  NAMES grib_api_f77 PATHS ${GRIB_API_PATH} ${GRIB_API_PATH}/lib     PATH_SUFFIXES grib_api  NO_DEFAULT_PATH)
         find_program(GRIB_API_INFO     NAMES grib_info  PATHS ${GRIB_API_PATH} ${GRIB_API_PATH}/bin     PATH_SUFFIXES grib_api  NO_DEFAULT_PATH)
     endif()
-    
+
     find_path(GRIB_API_INCLUDE_DIR NAMES grib_api.h PATHS PATH_SUFFIXES grib_api )
     find_library( GRIB_API_LIBRARY NAMES grib_api   PATHS PATH_SUFFIXES grib_api )
     find_library( GRIB_API_LIB_F90 NAMES grib_api_f90 PATHS PATH_SUFFIXES grib_api )
     find_library( GRIB_API_LIB_F77 NAMES grib_api_f77 PATHS PATH_SUFFIXES grib_api )
     find_program(GRIB_API_INFO     NAMES grib_info  PATHS PATH_SUFFIXES grib_api )
-    
+
     list( APPEND GRIB_API_LIBRARIES    ${GRIB_API_LIBRARY} ${GRIB_API_LIB_F90} ${GRIB_API_LIB_F77} )
     set( GRIB_API_INCLUDE_DIRS ${GRIB_API_INCLUDE_DIR} )
 
     if( GRIB_API_INFO )
-        
+
         execute_process( COMMAND ${GRIB_API_INFO} -v  OUTPUT_VARIABLE _grib_info_out ERROR_VARIABLE _grib_info_err OUTPUT_STRIP_TRAILING_WHITESPACE )
-        
-        # debug_var( _grib_info_out )
-    
+
+        # ecbuild_debug_var( _grib_info_out )
+
         string( REPLACE "." " " _version_list ${_grib_info_out} ) # dots to spaces
         separate_arguments( _version_list )
 
@@ -108,22 +108,22 @@ if( NOT grib_api_FOUND AND NOT NO_GRIB_API_BINARIES )
         list( GET _version_list 1 GRIB_API_MINOR_VERSION )
         list( GET _version_list 2 GRIB_API_PATCH_VERSION )
 
-        set( GRIB_API_VERSION     "${GRIB_API_MAJOR_VERSION}.${GRIB_API_MINOR_VERSION}.${GRIB_API_PATCH_VERSION}" ) 
+        set( GRIB_API_VERSION     "${GRIB_API_MAJOR_VERSION}.${GRIB_API_MINOR_VERSION}.${GRIB_API_PATCH_VERSION}" )
         set( GRIB_API_VERSION_STR "${_grib_info_out}" )
 
-        set( grib_api_VERSION     "${GRIB_API_VERSION}" ) 
+        set( grib_api_VERSION     "${GRIB_API_VERSION}" )
         set( grib_api_VERSION_STR "${GRIB_API_VERSION_STR}" )
 
     endif()
-    
+
     include(FindPackageHandleStandardArgs)
-    
+
     # handle the QUIETLY and REQUIRED arguments and set GRIB_API_FOUND to TRUE
     find_package_handle_standard_args( grib_api DEFAULT_MSG
                                        GRIB_API_LIBRARY GRIB_API_INCLUDE_DIR GRIB_API_INFO )
-    
+
     mark_as_advanced( GRIB_API_INCLUDE_DIR GRIB_API_LIBRARY GRIB_API_INFO )
-    
+
     list( APPEND GRIB_API_DEFINITIONS  ${_grib_api_jpg_defs} ${_grib_api_png_defs} )
     list( APPEND GRIB_API_INCLUDE_DIRS ${_grib_api_jpg_incs} ${_grib_api_png_incs} )
 	list( APPEND GRIB_API_LIBRARIES    ${_grib_api_jpg_libs} ${_grib_api_png_libs} )
diff --git a/cmake/Findodb_api.cmake b/cmake/Findodb_api.cmake
index 5cd2a10..2b8e800 100644
--- a/cmake/Findodb_api.cmake
+++ b/cmake/Findodb_api.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/Findspot.cmake b/cmake/Findspot.cmake
index 1edb2cd..cad0e33 100644
--- a/cmake/Findspot.cmake
+++ b/cmake/Findspot.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2012 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/VERSION.cmake b/cmake/VERSION.cmake
index a07bd4a..e7ac9ad 100644
--- a/cmake/VERSION.cmake
+++ b/cmake/VERSION.cmake
@@ -1,7 +1,7 @@
-set( ECBUILD_MAJOR_VERSION "1" )
-set( ECBUILD_MINOR_VERSION "9" )
+set( ECBUILD_MAJOR_VERSION "2" )
+set( ECBUILD_MINOR_VERSION "0" )
 set( ECBUILD_PATCH_VERSION "0" )
 
-set( ECBUILD_VERSION_STR  "1.9.0" )
+set( ECBUILD_VERSION_STR  "2.0.0" )
 
 set( ECBUILD_MACRO_VERSION "${ECBUILD_MAJOR_VERSION}.${ECBUILD_MINOR_VERSION}" )
diff --git a/cmake/contrib/FindNetCDF4.cmake b/cmake/contrib/FindNetCDF4.cmake
index adf232e..2afff21 100644
--- a/cmake/contrib/FindNetCDF4.cmake
+++ b/cmake/contrib/FindNetCDF4.cmake
@@ -22,8 +22,9 @@
 # NETCDF_USE_STATIC_LIBRARIES variable is set before the call to find_package.
 #
 # To provide the module with a hint about where to find your NETCDF installation,
-# set the environment variable NETCDF_ROOT or NETCDF_DIR. The Find module will then
-# look in this path when searching for NETCDF executables, paths, and libraries.
+# set the CMake or environment variable NETCDF_ROOT, NETCDF_DIR, NETCDF_PATH or
+# NETCDF4_DIR. The Find module will then look in this path when searching for
+# NETCDF executables, paths, and libraries.
 #
 # In addition to finding the includes and libraries required to compile an NETCDF
 # client application, this module also makes an effort to find tools that come
@@ -90,11 +91,12 @@ endmacro()
 # try to find the NETCDF wrapper compilers
 find_program( NETCDF_CONFIG_EXECUTABLE
     NAMES nc-config
-    HINTS ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF4_DIR
-    PATHS
+    HINTS ${NETCDF_ROOT} ${NETCDF_DIR} ${NETCDF_PATH} ${NETCDF4_DIR}
+          ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF_PATH ENV NETCDF4_DIR
     PATH_SUFFIXES bin Bin
     DOC "NETCDF CONFIG PROGRAM.  Used only to detect NETCDF compile flags." )
 mark_as_advanced( NETCDF_CONFIG_EXECUTABLE )
+ecbuild_debug("FindNetCDF4: nc-config executable = ${NETCDF_CONFIG_EXECUTABLE}")
 
 set(output "no")
 _NETCDF_CONFIG (--has-hdf5 output return)
@@ -156,20 +158,19 @@ else()
     foreach( LANGUAGE ${NETCDF_LANGUAGE_BINDINGS} )
         ecbuild_debug("FindNetCDF4: looking for ${LANGUAGE} language bindings")
         set( NETCDF_${LANGUAGE}_FOUND 1 ) # disable this in following if necessary
-      
+
         # find the NETCDF includes
         foreach( INC ${NETCDF_${LANGUAGE}_INCLUDE_NAMES} )
           find_path( NETCDF_${INC}_INCLUDE_DIR ${INC}
-              HINTS
-                  ${NETCDF_${LANGUAGE}_INCLUDE_FLAGS}
-                  ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF4_DIR
-              PATHS
+              HINTS ${NETCDF_${LANGUAGE}_INCLUDE_FLAGS}
+                    ${NETCDF_ROOT} ${NETCDF_DIR} ${NETCDF_PATH} ${NETCDF4_DIR}
+                    ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF_PATH ENV NETCDF4_DIR
               PATH_SUFFIXES
                   include
                   Include
           )
           mark_as_advanced( NETCDF_${INC}_INCLUDE_DIR )
-          # debug_var( NETCDF_${INC}_INCLUDE_DIR)
+          # ecbuild_debug_var( NETCDF_${INC}_INCLUDE_DIR)
           if (NETCDF_${INC}_INCLUDE_DIR)
             list( APPEND NETCDF_INCLUDE_DIRS ${NETCDF_${INC}_INCLUDE_DIR} )
           else()
@@ -203,14 +204,14 @@ else()
             find_library( NETCDF_${LIB}_LIBRARY_DEBUG
                 NAMES ${THIS_LIBRARY_SEARCH_DEBUG}
                 HINTS ${NETCDF_${LANGUAGE}_LIBRARY_DIRS}
-                ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF4_DIR
-                PATHS
+                      ${NETCDF_ROOT} ${NETCDF_DIR} ${NETCDF_PATH} ${NETCDF4_DIR}
+                      ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF_PATH ENV NETCDF4_DIR
                 PATH_SUFFIXES lib64 Lib64 lib Lib)
             find_library( NETCDF_${LIB}_LIBRARY_RELEASE
                 NAMES ${THIS_LIBRARY_SEARCH_RELEASE}
                 HINTS ${NETCDF_${LANGUAGE}_LIBRARY_DIRS}
-                ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF4_DIR
-                PATHS
+                      ${NETCDF_ROOT} ${NETCDF_DIR} ${NETCDF_PATH} ${NETCDF4_DIR}
+                      ENV NETCDF_ROOT ENV NETCDF_DIR ENV NETCDF_PATH ENV NETCDF4_DIR
                 PATH_SUFFIXES lib64 Lib64 lib Lib )
             select_library_configurations( NETCDF_${LIB} )
             # even though we adjusted the individual library names in
@@ -231,7 +232,6 @@ else()
           endif()
           if (NETCDF_${LIB}_LIBRARY_RELEASE OR NETCDF_${LIB}_LIBRARY_DEBUG )
           else()
-            # message( STATUS "\"${LIB}\" is not found." )
             list( FIND NETCDF_REQUIRED ${LIB} location )
             if( ${location} EQUAL -1 )
             else()
@@ -249,19 +249,19 @@ else()
 
         # Append the libraries for this language binding to the list of all
         # required libraries.
-        
+
         if( NETCDF_${LANGUAGE}_FOUND )
             ecbuild_debug( "FindNetCDF4: ${LANGUAGE} language bindings found" )
             if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
-                list( APPEND NETCDF_${LANGUAGE}_LIBRARIES 
+                list( APPEND NETCDF_${LANGUAGE}_LIBRARIES
                     debug ${NETCDF_${LANGUAGE}_LIBRARIES_DEBUG}
                     optimized ${NETCDF_${LANGUAGE}_LIBRARIES_RELEASE} )
             else()
-                list( APPEND NETCDF_${LANGUAGE}_LIBRARIES 
-                    ${NETCDF_${LANGUAGE}_LIBRARIES_RELEASE} )                  
+                list( APPEND NETCDF_${LANGUAGE}_LIBRARIES
+                    ${NETCDF_${LANGUAGE}_LIBRARIES_RELEASE} )
             endif()
         endif()
-        # debug_var( NETCDF_${LANGUAGE}_LIBRARIES )
+        # ecbuild_debug_var( NETCDF_${LANGUAGE}_LIBRARIES )
         list( APPEND NETCDF_FOUND_REQUIRED_VARS NETCDF_${LANGUAGE}_FOUND )
     endforeach()
 
diff --git a/cmake/ecbuild_add_c_flags.cmake b/cmake/ecbuild_add_c_flags.cmake
new file mode 100644
index 0000000..bef1d34
--- /dev/null
+++ b/cmake/ecbuild_add_c_flags.cmake
@@ -0,0 +1,80 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_add_c_flags
+# ===================
+#
+# Add C compiler flags to CMAKE_C_FLAGS only if supported by the compiler. ::
+#
+#   ecbuild_add_c_flags( <flag1> [ <flag2> ... ]
+#                        [ BUILD <build> ]
+#                        [ NAME <name> ] )
+#
+# Options
+# -------
+#
+# BUILD : optional
+#   add flags to ``CMAKE_C_FLAGS_<build>`` instead of ``CMAKE_C_FLAGS``
+#
+# NAME : optional
+#   name of the check (if omitted, checks are enumerated)
+#
+##############################################################################
+
+macro( ecbuild_add_c_flags m_c_flags )
+
+  set( _flags ${m_c_flags} )
+
+  if( _flags AND CMAKE_C_COMPILER_LOADED )
+    set( options )
+    set( single_value_args BUILD NAME )
+    set( multi_value_args )
+
+    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if( NOT DEFINED N_CFLAG )
+      set( N_CFLAG 0 )
+    endif()
+
+    math( EXPR N_CFLAG '${N_CFLAG}+1' )
+
+    if( NOT ECBUILD_TRUST_FLAGS )
+      if( DEFINED _PAR_NAME )
+        check_c_compiler_flag( ${_flags} ${_PAR_NAME} )
+        set( _flag_ok ${${_PAR_NAME}} )
+      else()
+        check_c_compiler_flag( ${_flags} C_FLAG_TEST_${N_CFLAG} )
+        set( _flag_ok ${C_FLAG_TEST_${N_CFLAG}} )
+      endif()
+    else()
+      set( _flag_ok 1 )
+    endif()
+
+    if( _flag_ok )
+      if( _PAR_BUILD )
+        set( CMAKE_C_FLAGS_${_PAR_BUILD} "${CMAKE_C_FLAGS_${_PAR_BUILD}} ${_flags}" )
+        ecbuild_debug( "C FLAG [${_flags}] added for build type ${_PAR_BUILD}" )
+      else()
+        set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flags}" )
+        ecbuild_debug( "C FLAG [${_flags}] added" )
+      endif()
+    else()
+      message( WARNING "Unrecognised C flag [${_flags}] -- skipping" )
+    endif()
+  endif()
+  unset( _flags )
+  unset( _flag_ok )
+endmacro()
+
+macro( cmake_add_c_flags m_c_flags )
+  message( DEPRECATION " cmake_add_c_flags is deprecated, use ecbuild_add_c_flags instead." )
+  ecbuild_add_c_flags( ${m_c_flags} )
+endmacro()
diff --git a/cmake/ecbuild_add_cxx11_flags.cmake b/cmake/ecbuild_add_cxx11_flags.cmake
index 414f39f..a4cce91 100644
--- a/cmake/ecbuild_add_cxx11_flags.cmake
+++ b/cmake/ecbuild_add_cxx11_flags.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,17 +6,27 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to add cxx11 flags to compilation
-# uses macros from the project github.com/UCL/GreatCMakeCookOff
+##############################################################################
+#.rst:
+#
+# ecbuild_add_cxx11_flags
+# =======================
+#
+# Add cxx11 flags to CXX compilation flags. ::
+#
+#   ecbuild_add_cxx11_flags()
+#
+# This macro uses macros from http://github.com/UCL/GreatCMakeCookOff.
+#
+##############################################################################
 
 macro( ecbuild_add_cxx11_flags )
 
 	# if( CMAKE_COMPILER_IS_GNUCXX )
 	# 	if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7 )
-	# 		cmake_add_cxx_flags("-std=c++0x")
+	# 		ecbuild_add_cxx_flags("-std=c++0x")
 	# 	else()
-	# 		cmake_add_cxx_flags("-std=c++11")
+	# 		ecbuild_add_cxx_flags("-std=c++11")
 	# 	endif()
 	# endif()
 
diff --git a/cmake/ecbuild_add_cxx_flags.cmake b/cmake/ecbuild_add_cxx_flags.cmake
new file mode 100644
index 0000000..8393572
--- /dev/null
+++ b/cmake/ecbuild_add_cxx_flags.cmake
@@ -0,0 +1,80 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_add_cxx_flags
+# =====================
+#
+# Add C++ compiler flags to CMAKE_CXX_FLAGS only if supported by compiler. ::
+#
+#   ecbuild_add_cxx_flags( <flag1> [ <flag2> ... ]
+#                          [ BUILD <build> ]
+#                          [ NAME <name> ] )
+#
+# Options
+# -------
+#
+# BUILD : optional
+#   add flags to ``CMAKE_CXX_FLAGS_<build>`` instead of ``CMAKE_CXX_FLAGS``
+#
+# NAME : optional
+#   name of the check (if omitted, checks are enumerated)
+#
+##############################################################################
+
+macro( ecbuild_add_cxx_flags m_cxx_flags )
+
+  set( _flags ${m_cxx_flags} )
+  if( _flags AND CMAKE_CXX_COMPILER_LOADED )
+    set( options )
+    set( single_value_args BUILD NAME )
+    set( multi_value_args )
+
+    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if( NOT DEFINED N_CXXFLAG )
+      set( N_CXXFLAG 0 )
+    endif()
+
+    math( EXPR N_CXXFLAG '${N_CXXFLAG}+1' )
+
+    if( NOT ECBUILD_TRUST_FLAGS )
+      if( DEFINED _PAR_NAME )
+        check_cxx_compiler_flag( ${_flags} ${_PAR_NAME} )
+        set( _flag_ok ${${_PAR_NAME}} )
+      else()
+        check_cxx_compiler_flag( ${_flags} CXX_FLAG_TEST_${N_CXXFLAG} )
+        set( _flag_ok CXX_FLAG_TEST_${N_CXXFLAG} )
+      endif()
+    else()
+      set( _flag_ok 1 )
+    endif()
+
+    if( _flag_ok )
+      if( _PAR_BUILD )
+        set( CMAKE_CXX_FLAGS_${_PAR_BUILD} "${CMAKE_CXX_FLAGS_${_PAR_BUILD}} ${_flags}" )
+        ecbuild_debug( "C++ FLAG [${_flags}] added for build type ${_PAR_BUILD}" )
+      else()
+        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flags}" )
+        ecbuild_debug( "C++ FLAG [${_flags}] added" )
+      endif()
+    else()
+      message( STATUS "Unrecognised CXX flag [${_flags}] -- skipping" )
+    endif()
+  endif()
+  unset( _flags )
+  unset( _flag_ok )
+
+endmacro()
+
+macro( cmake_add_cxx_flags m_cxx_flags )
+  message( DEPRECATION " cmake_add_cxx_flags is deprecated, use ecbuild_add_cxx_flags instead." )
+  ecbuild_add_cxx_flags( ${m_cxx_flags} )
+endmacro()
diff --git a/cmake/ecbuild_add_executable.cmake b/cmake/ecbuild_add_executable.cmake
index 16b79b5..9cc3d30 100644
--- a/cmake/ecbuild_add_executable.cmake
+++ b/cmake/ecbuild_add_executable.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,14 +7,110 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for adding a test
+#.rst:
+#
+# ecbuild_add_executable
+# ======================
+#
+# Add an executable with a given list of source files. ::
+#
+#   ecbuild_add_executable( TARGET <name>
+#                           SOURCES <source1> [<source2> ...]
+#                           [ SOURCES_GLOB <glob1> [<glob2> ...] ]
+#                           [ SOURCES_EXCLUDE_REGEX <regex1> [<regex2> ...] ]
+#                           [ OBJECTS <obj1> [<obj2> ...] ]
+#                           [ TEMPLATES <template1> [<template2> ...] ]
+#                           [ LIBS <library1> [<library2> ...] ]
+#                           [ INCLUDES <path1> [<path2> ...] ]
+#                           [ DEFINITIONS <definition1> [<definition2> ...] ]
+#                           [ PERSISTENT <file1> [<file2> ...] ]
+#                           [ GENERATED <file1> [<file2> ...] ]
+#                           [ DEPENDS <target1> [<target2> ...] ]
+#                           [ CONDITION <condition1> [<condition2> ...] ]
+#                           [ NOINSTALL ]
+#                           [ VERSION <version> | AUTO_VERSION ]
+#                           [ CFLAGS <flag1> [<flag2> ...] ]
+#                           [ CXXFLAGS <flag1> [<flag2> ...] ]
+#                           [ FFLAGS <flag1> [<flag2> ...] ]
+#                           [ LINKER_LANGUAGE <lang> ]
+#                           [ OUTPUT_NAME <name> ] )
+#
+# Options
+# -------
+#
+# TARGET : required
+#   target name
+#
+# SOURCES : required
+#   list of source files
+#
+# SOURCES_GLOB : optional
+#   search pattern to find source files to compile (note: not recommend according to CMake guidelines)
+#   it is usually better to explicitly list the source files in the CMakeList.txt
+#
+# SOURCES_EXCLUDE_REGEX : optional
+#   search pattern to exclude source files from compilation, applies o the results of SOURCES_GLOB
+#
+# OBJECTS : optional
+#   list of object libraries to add to this target
+#
+# TEMPLATES : optional
+#   list of files specified as SOURCES which are not to be compiled separately
+#   (these are commonly template implementation files included in a header)
+#
+# LIBS : optional
+#   list of libraries to link against (CMake targets or external libraries)
+#
+# INCLUDES : optional
+#   list of paths to add to include directories
+#
+# DEFINITIONS : optional
+#   list of definitions to add to preprocessor defines
+#
+# PERSISTENT : optional
+#   list of persistent layer object files
+#
+# GENERATED : optional
+#   list of files to mark as generated (sets GENERATED source file property)
+#
+# DEPENDS : optional
+#   list of targets to be built before this target
+#
+# CONDITION : optional
+#   conditional expression which must evaluate to true for this target to be
+#   built (must be valid in a CMake ``if`` statement)
+#
+# NOINSTALL : optional
+#   do not install the executable
+#
+# VERSION : optional, AUTO_VERSION or LIBS_VERSION is used if not specified
+#   version to use as executable version
+#
+# AUTO_VERSION : optional, ignored if VERSION is specified
+#   automatically version the executable with the package version
+#
+# CFLAGS : optional
+#   list of C compiler flags to use for all C source files
+#
+# CXXFLAGS : optional
+#   list of C++ compiler flags to use for all C++ source files
+#
+# FFLAGS : optional
+#   list of Fortran compiler flags to use for all Fortran source files
+#
+# LINKER_LANGUAGE : optional
+#   sets the LINKER_LANGUAGE property on the target
+#
+# OUTPUT_NAME : optional
+#   sets the OUTPUT_NAME property on the target
+#
 ##############################################################################
 
 macro( ecbuild_add_executable )
 
   set( options NOINSTALL AUTO_VERSION )
   set( single_value_args TARGET COMPONENT LINKER_LANGUAGE VERSION OUTPUT_NAME )
-  set( multi_value_args  SOURCES TEMPLATES LIBS INCLUDES DEPENDS PERSISTENT DEFINITIONS CFLAGS CXXFLAGS FFLAGS GENERATED CONDITION )
+  set( multi_value_args  SOURCES SOURCES_GLOB SOURCES_EXCLUDE_REGEX OBJECTS TEMPLATES LIBS INCLUDES DEPENDS PERSISTENT DEFINITIONS CFLAGS CXXFLAGS FFLAGS GENERATED CONDITION )
 
   cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
@@ -26,8 +122,8 @@ macro( ecbuild_add_executable )
     message(FATAL_ERROR "The call to ecbuild_add_executable() doesn't specify the TARGET.")
   endif()
 
-  if( NOT _PAR_SOURCES )
-    message(FATAL_ERROR "The call to ecbuild_add_executable() doesn't specify the SOURCES.")
+  if( NOT _PAR_SOURCES AND NOT _PAR_OBJECTS AND NOT _PAR_SOURCES_GLOB )
+    message(FATAL_ERROR "The call to ecbuild_add_executable() specifies neither SOURCES nor OBJECTS nor SOURCES_GLOB.")
   endif()
 
   ### conditional build
@@ -75,8 +171,25 @@ macro( ecbuild_add_executable )
       add_custom_target( ${_PAR_TARGET}_templates SOURCES ${_PAR_TEMPLATES} )
     endif()
 
-    # add the executable target
-    add_executable( ${_PAR_TARGET} ${_PAR_SOURCES} )
+    # glob sources
+    unset( _glob_srcs )
+    foreach( pattern ${_PAR_SOURCES_GLOB} )
+        ecbuild_list_add_pattern( LIST _glob_srcs GLOB "${pattern}" )
+    endforeach()
+
+    foreach( pattern ${_PAR_SOURCES_EXCLUDE_REGEX} )
+        ecbuild_list_exclude_pattern( LIST _glob_srcs REGEX "${pattern}" )
+    endforeach()
+
+    # insert already compiled objects (from OBJECT libraries)
+    unset( _all_objects )
+    foreach( _obj ${_PAR_OBJECTS} )
+      list( APPEND _all_objects $<TARGET_OBJECTS:${_obj}> )
+    endforeach()
+
+    add_executable( ${_PAR_TARGET} ${_PAR_SOURCES} ${_glob_srcs} ${_all_objects} )
+
+    # ecbuild_echo_target( ${_PAR_TARGET} )
 
     # set OUTPUT_NAME
 
@@ -107,24 +220,71 @@ macro( ecbuild_add_executable )
     endif()
 
     # filter sources
+
     ecbuild_separate_sources( TARGET ${_PAR_TARGET} SOURCES ${_PAR_SOURCES} )
 
+    #   ecbuild_debug_var( ${_PAR_TARGET}_h_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_c_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_cxx_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_f_srcs )
+
     # add local flags
-    if( DEFINED _PAR_CFLAGS )
-      ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
-      set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
-    endif()
-    if( DEFINED _PAR_CXXFLAGS )
-      ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
-      set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
+
+    if( ${_PAR_TARGET}_c_srcs )
+
+      if( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${_PAR_TARGET}_C_SOURCE_FLAGS
+                              ${_PAR_TARGET}_c
+                              "${_PAR_CFLAGS}"
+                              "${${_PAR_TARGET}_c_srcs}" )
+
+        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): setting source file C flags from ${${_PAR_TARGET}_C_SOURCE_FLAGS}")
+        include( ${${_PAR_TARGET}_C_SOURCE_FLAGS} )
+
+      elseif( DEFINED _PAR_CFLAGS )
+
+        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
+        set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
+
+      endif()
     endif()
-    if( DEFINED _PAR_FFLAGS )
-      ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
-      set_source_files_properties( ${${_PAR_TARGET}_f_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
+
+    if( ${_PAR_TARGET}_cxx_srcs )
+
+      if( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${_PAR_TARGET}_CXX_SOURCE_FLAGS
+                              ${_PAR_TARGET}_cxx
+                              "${_PAR_CXXFLAGS}"
+                              "${${_PAR_TARGET}_cxx_srcs}" )
+
+        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): setting source file CXX flags from ${${_PAR_TARGET}_CXX_SOURCE_FLAGS}")
+        include( ${${_PAR_TARGET}_CXX_SOURCE_FLAGS} )
+
+      elseif( DEFINED _PAR_CXXFLAGS )
+
+        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
+        set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
+
+      endif()
     endif()
-    if( DEFINED _PAR_GENERATED )
-      ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): mark as generated ${_PAR_GENERATED}")
-      set_source_files_properties( ${_PAR_GENERATED} PROPERTIES GENERATED 1 )
+
+    if( ${_PAR_TARGET}_f_srcs )
+
+      if( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${_PAR_TARGET}_Fortran_SOURCE_FLAGS
+                              ${_PAR_TARGET}_f
+                              "${_PAR_FFLAGS}"
+                              "${${_PAR_TARGET}_f_srcs}" )
+
+        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): setting source file Fortran flags from ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS}")
+        include( ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS} )
+
+      elseif( DEFINED _PAR_FFLAGS )
+
+        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
+        set_source_files_properties( ${${_PAR_TARGET}_f_srcs}  PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
+
+      endif()
     endif()
 
     # define VERSION if requested
@@ -138,11 +298,6 @@ macro( ecbuild_add_executable )
       endif()
     endif()
 
-    #    debug_var( ${_PAR_TARGET}_h_srcs )
-    #    debug_var( ${_PAR_TARGET}_c_srcs )
-    #    debug_var( ${_PAR_TARGET}_cxx_srcs )
-    #    debug_var( ${_PAR_TARGET}_f_srcs )
-
     # installation
 
     if( NOT _PAR_NOINSTALL )
diff --git a/cmake/ecbuild_add_extra_search_paths.cmake b/cmake/ecbuild_add_extra_search_paths.cmake
index c8a7a77..9404f74 100644
--- a/cmake/ecbuild_add_extra_search_paths.cmake
+++ b/cmake/ecbuild_add_extra_search_paths.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -28,6 +28,6 @@ function( ecbuild_add_extra_search_paths pkg )
   ecbuild_list_extra_search_paths( ${pkg} CMAKE_PREFIX_PATH )
 
   set( CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE )
-  # debug_var( CMAKE_PREFIX_PATH )
+  # ecbuild_debug_var( CMAKE_PREFIX_PATH )
 
 endfunction()
diff --git a/cmake/ecbuild_add_fortran_flags.cmake b/cmake/ecbuild_add_fortran_flags.cmake
new file mode 100644
index 0000000..f0da53f
--- /dev/null
+++ b/cmake/ecbuild_add_fortran_flags.cmake
@@ -0,0 +1,86 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_add_fortran_flags
+# =========================
+#
+# Add Fortran compiler flags to CMAKE_Fortran_FLAGS only if supported by the
+# compiler. ::
+#
+#   ecbuild_add_fortran_flags( <flag1> [ <flag2> ... ]
+#                              [ BUILD <build> ]
+#                              [ NAME <name> ] )
+#
+# Options
+# -------
+#
+# BUILD : optional
+#   add flags to ``CMAKE_Fortran_FLAGS_<build>`` instead of
+#   ``CMAKE_Fortran_FLAGS``
+#
+# NAME : optional
+#   name of the check (if omitted, checks are enumerated)
+#
+##############################################################################
+
+include( CheckFortranCompilerFlag )
+macro( ecbuild_add_fortran_flags m_fortran_flags )
+
+  set( _flags ${m_fortran_flags} )
+
+  if( _flags AND CMAKE_Fortran_COMPILER_LOADED )
+
+    set( options )
+    set( single_value_args BUILD NAME )
+    set( multi_value_args )
+
+    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if( NOT DEFINED N_FortranFLAG )
+      set( N_FortranFLAG 0 )
+    endif()
+
+    math( EXPR N_FortranFLAG '${N_FortranFLAG}+1' )
+
+    if( NOT ECBUILD_TRUST_FLAGS )
+      if( DEFINED _PAR_NAME )
+        check_fortran_compiler_flag( ${_flags} ${_PAR_NAME} )
+        set( _flag_ok ${${_PAR_NAME}} )
+      else()
+        check_fortran_compiler_flag( ${_flags} Fortran_FLAG_TEST_${N_FortranFLAG} )
+        set( _flag_ok ${Fortran_FLAG_TEST_${N_FortranFLAG}} )
+      endif()
+    else()
+      set( _flag_ok 1 )
+    endif()
+
+    if( _flag_ok )
+      if( _PAR_BUILD )
+        set( CMAKE_Fortran_FLAGS_${_PAR_BUILD} "${CMAKE_Fortran_FLAGS_${_PAR_BUILD}} ${_flags}" )
+        ecbuild_debug( "Fortran FLAG [${_flags}] added for build type ${_PAR_BUILD}" )
+      else()
+        set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${_flags}" )
+        ecbuild_debug( "Fortran FLAG [${_flags}] added" )
+      endif()
+    else()
+      message( STATUS "Unrecognised Fortran flag [${_flags}] -- skipping" )
+    endif()
+  endif()
+
+  unset( _flags )
+  unset( _flag_ok )
+
+endmacro()
+
+macro( cmake_add_fortran_flags m_fortran_flags )
+  message( DEPRECATION " cmake_add_fortran_flags is deprecated, use ecbuild_add_fortran_flags instead." )
+  ecbuild_add_fortran_flags( ${m_fortran_flags} )
+endmacro()
diff --git a/cmake/ecbuild_add_library.cmake b/cmake/ecbuild_add_library.cmake
index f17d650..2a047e9 100644
--- a/cmake/ecbuild_add_library.cmake
+++ b/cmake/ecbuild_add_library.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,14 +7,149 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# auxiliary macro for adding a library
+#.rst:
+#
+# ecbuild_add_library
+# ===================
+#
+# Add a library with a given list of source files. ::
+#
+#   ecbuild_add_library( TARGET <name>
+#                        SOURCES <source1> [<source2> ...]
+#                        [ SOURCES_GLOB <glob1> [<glob2> ...] ]
+#                        [ SOURCES_EXCLUDE_REGEX <regex1> [<regex2> ...] ]
+#                        [ TYPE SHARED|STATIC|MODULE|OBJECT ]
+#                        [ OBJECTS <obj1> [<obj2> ...] ]
+#                        [ TEMPLATES <template1> [<template2> ...] ]
+#                        [ LIBS <library1> [<library2> ...] ]
+#                        [ INCLUDES <path1> [<path2> ...] ]
+#                        [ PRIVATE_INCLUDES <path1> [<path2> ...] ]
+#                        [ PUBLIC_INCLUDES <path1> [<path2> ...] ]
+#                        [ DEFINITIONS <definition1> [<definition2> ...] ]
+#                        [ PERSISTENT <file1> [<file2> ...] ]
+#                        [ GENERATED <file1> [<file2> ...] ]
+#                        [ DEPENDS <target1> [<target2> ...] ]
+#                        [ CONDITION <condition1> [<condition2> ...] ]
+#                        [ NOINSTALL ]
+#                        [ HEADER_DESTINATION <path> ]
+#                        [ INSTALL_HEADERS LISTED|ALL ]
+#                        [ INSTALL_HEADERS_LIST <header1> [<header2> ...] ]
+#                        [ INSTALL_HEADERS_REGEX <pattern> ]
+#                        [ VERSION <version> | AUTO_VERSION ]
+#                        [ CFLAGS <flag1> [<flag2> ...] ]
+#                        [ CXXFLAGS <flag1> [<flag2> ...] ]
+#                        [ FFLAGS <flag1> [<flag2> ...] ]
+#                        [ LINKER_LANGUAGE <lang> ]
+#                        [ OUTPUT_NAME <name> ] )
+#
+# Options
+# -------
+#
+# TARGET : required
+#   target name
+#
+# SOURCES : required
+#   list of source files
+#
+# TYPE : optional
+#   library type, one of:
+#
+#   :SHARED: libraries are linked dynamically and loaded at runtime
+#   :STATIC: archives of object files for use when linking other targets.
+#   :MODULE: plugins that are not linked into other targets but may be loaded
+#            dynamically at runtime using dlopen-like functionality
+#   :OBJECT: files are just compiled into objects
+#
+# SOURCES_GLOB : optional
+#   search pattern to find source files to compile (note: not recommend according to CMake guidelines)
+#   it is usually better to explicitly list the source files in the CMakeList.txt
+#
+# SOURCES_EXCLUDE_REGEX : optional
+#   search pattern to exclude source files from compilation, applies o the results of SOURCES_GLOB
+#
+# OBJECTS : optional
+#   list of object libraries to add to this target
+#
+# TEMPLATES : optional
+#   list of files specified as SOURCES which are not to be compiled separately
+#   (these are commonly template implementation files included in a header)
+#
+# LIBS : optional
+#   list of libraries to link against (CMake targets or external libraries)
+#
+# INCLUDES : (DEPRECATED) optional
+#   list of paths to add to include directories, behaves as PUBLIC_INCLUDES if CMake >= 2.8.11
+#   and reverts to include_directories() for CMake < 2.8.11
+#
+# PUBLIC_INCLUDES : optional
+#   list of paths to add to include directories which will be publicly exported to other projects
+#
+# PRIVATE_INCLUDES : optional
+#   list of paths to add to include directories which won't be exported to other projects,
+#   equivalent to using a include_directories() before calling this macro
+#
+# DEFINITIONS : optional
+#   list of definitions to add to preprocessor defines
+#
+# PERSISTENT : optional
+#   list of persistent layer object files
+#
+# GENERATED : optional
+#   list of files to mark as generated (sets GENERATED source file property)
+#
+# DEPENDS : optional
+#   list of targets to be built before this target
+#
+# CONDITION : optional
+#   conditional expression which must evaluate to true for this target to be
+#   built (must be valid in a CMake ``if`` statement)
+#
+# NOINSTALL : optional
+#   do not install the library
+#
+# HEADER_DESTINATION
+#   directory to install headers (if not specified, INSTALL_INCLUDE_DIR is used)
+#
+# INSTALL_HEADERS : optional
+#   specify which header files to install:
+#
+#   :LISTED: install header files listed as SOURCES
+#   :ALL:    install all header files ending in .h, .hh, .hpp, .H
+#
+# INSTALL_HEADERS_LIST : optional
+#   list of extra headers to install
+#
+# INSTALL_HEADERS_REGEX : optional
+#   regular expression to match extra headers to install
+#
+# VERSION : optional, AUTO_VERSION or LIBS_VERSION is used if not specified
+#   version to use as library version
+#
+# AUTO_VERSION : optional, ignored if VERSION is specified
+#   automatically version the library with the package version
+#
+# CFLAGS : optional
+#   list of C compiler flags to use for all C source files
+#
+# CXXFLAGS : optional
+#   list of C++ compiler flags to use for all C++ source files
+#
+# FFLAGS : optional
+#   list of Fortran compiler flags to use for all Fortran source files
+#
+# LINKER_LANGUAGE : optional
+#   sets the LINKER_LANGUAGE property on the target
+#
+# OUTPUT_NAME : optional
+#   sets the OUTPUT_NAME property on the target
+#
 ##############################################################################
 
 function( ecbuild_add_library_impl )
 
   set( options NOINSTALL AUTO_VERSION )
   set( single_value_args TARGET TYPE COMPONENT INSTALL_HEADERS INSTALL_HEADERS_REGEX LINKER_LANGUAGE HEADER_DESTINATION VERSION OUTPUT_NAME )
-  set( multi_value_args  SOURCES TEMPLATES LIBS INCLUDES DEPENDS PERSISTENT DEFINITIONS INSTALL_HEADERS_LIST CFLAGS CXXFLAGS FFLAGS GENERATED CONDITION )
+  set( multi_value_args  SOURCES SOURCES_GLOB SOURCES_EXCLUDE_REGEX OBJECTS TEMPLATES LIBS INCLUDES PRIVATE_INCLUDES PUBLIC_INCLUDES DEPENDS PERSISTENT DEFINITIONS INSTALL_HEADERS_LIST CFLAGS CXXFLAGS FFLAGS GENERATED CONDITION )
 
   cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
@@ -26,8 +161,8 @@ function( ecbuild_add_library_impl )
     message(FATAL_ERROR "The call to ecbuild_add_library() doesn't specify the TARGET.")
   endif()
 
-  if( NOT _PAR_SOURCES )
-    message(FATAL_ERROR "The call to ecbuild_add_library() doesn't specify the SOURCES.")
+  if( NOT _PAR_SOURCES AND NOT _PAR_OBJECTS AND NOT _PAR_SOURCES_GLOB )
+    message(FATAL_ERROR "The call to ecbuild_add_library() specifies neither SOURCES nor OBJECTS nor SOURCES_GLOB")
   endif()
 
   ### conditional build
@@ -51,8 +186,9 @@ function( ecbuild_add_library_impl )
       # checks that is either SHARED or STATIC or MODULE
       if( NOT _PAR_TYPE MATCHES "STATIC" AND
           NOT _PAR_TYPE MATCHES "SHARED" AND
+          NOT _PAR_TYPE MATCHES "OBJECT" AND
           NOT _PAR_TYPE MATCHES "MODULE" )
-        message( FATAL_ERROR "library type must be one of [ STATIC | SHARED | MODULE ]" )
+        message( FATAL_ERROR "library type must be one of [ STATIC | SHARED | MODULE | OBJECT ]" )
       endif()
       ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): library type is ${_PAR_TYPE}")
     endif()
@@ -74,7 +210,25 @@ function( ecbuild_add_library_impl )
       add_custom_target( ${_PAR_TARGET}_templates SOURCES ${_PAR_TEMPLATES} )
     endif()
 
-    add_library( ${_PAR_TARGET} ${_PAR_TYPE} ${_PAR_SOURCES} )
+    # glob sources
+    unset( _glob_srcs )
+    foreach( pattern ${_PAR_SOURCES_GLOB} )
+        ecbuild_list_add_pattern( LIST _glob_srcs GLOB "${pattern}" )
+    endforeach()
+
+    foreach( pattern ${_PAR_SOURCES_EXCLUDE_REGEX} )
+        ecbuild_list_exclude_pattern( LIST _glob_srcs REGEX "${pattern}" )
+    endforeach()
+
+    # insert already compiled objects (from OBJECT libraries)
+    unset( _all_objects )
+    foreach( _obj ${_PAR_OBJECTS} )
+      list( APPEND _all_objects $<TARGET_OBJECTS:${_obj}> )
+    endforeach()
+
+    add_library( ${_PAR_TARGET} ${_PAR_TYPE} ${_PAR_SOURCES} ${_glob_srcs} ${_all_objects} )
+
+    # ecbuild_echo_target( ${_PAR_TARGET} )
 
     # set OUTPUT_NAME
 
@@ -121,6 +275,38 @@ function( ecbuild_add_library_impl )
       endforeach()
     endif()
 
+    # add private include dirs if defined
+    if( DEFINED _PAR_PRIVATE_INCLUDES )
+      if( "${CMAKE_VERSION}" VERSION_LESS "2.8.11" )
+        ecbuild_critical("ecbuild_add_library(${_PAR_TARGET}): cannot use PRIVATE_INCLUDES with CMake < 2.8.11" )
+      endif()
+      list( REMOVE_DUPLICATES _PAR_PRIVATE_INCLUDES )
+      foreach( path ${_PAR_PRIVATE_INCLUDES} ) # skip NOTFOUND
+        if( path )
+          ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): add ${path} to include_directories")
+          target_include_directories( ${_PAR_TARGET} PRIVATE ${path} )
+        else()
+          ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): ${path} not found - not adding to include_directories")
+        endif()
+      endforeach()
+    endif()
+
+    # add public include dirs if defined
+    if( DEFINED _PAR_PUBLIC_INCLUDES )
+      if( "${CMAKE_VERSION}" VERSION_LESS "2.8.11" )
+        ecbuild_critical("ecbuild_add_library(${_PAR_TARGET}): cannot use PUBLIC_INCLUDES with CMake < 2.8.11" )
+      endif()
+      list( REMOVE_DUPLICATES _PAR_PUBLIC_INCLUDES )
+      foreach( path ${_PAR_PUBLIC_INCLUDES} ) # skip NOTFOUND
+        if( path )
+          ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): add ${path} to include_directories")
+          target_include_directories( ${_PAR_TARGET} PUBLIC ${path} )
+        else()
+          ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): ${path} not found - not adding to include_directories")
+        endif()
+      endforeach()
+    endif()
+
     # FIX: Cray compiler PIC option is not detected by CMake
 
     get_property( _target_pic TARGET ${_PAR_TARGET} PROPERTY POSITION_INDEPENDENT_CODE )
@@ -153,27 +339,74 @@ function( ecbuild_add_library_impl )
 
     # filter sources
 
-    ecbuild_separate_sources( TARGET ${_PAR_TARGET} SOURCES ${_PAR_SOURCES} )
+    if( _PAR_SOURCES )
+      ecbuild_separate_sources( TARGET ${_PAR_TARGET} SOURCES ${_PAR_SOURCES} )
+    endif()
 
-    #   debug_var( ${_PAR_TARGET}_h_srcs )
-    #   debug_var( ${_PAR_TARGET}_c_srcs )
-    #   debug_var( ${_PAR_TARGET}_cxx_srcs )
-    #   debug_var( ${_PAR_TARGET}_f_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_h_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_c_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_cxx_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_f_srcs )
 
     # add local flags
 
-    if( DEFINED _PAR_CFLAGS )
-      ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
-      set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
+    if( ${_PAR_TARGET}_c_srcs )
+
+      if( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${_PAR_TARGET}_C_SOURCE_FLAGS
+                              ${_PAR_TARGET}_c
+                              "${_PAR_CFLAGS}"
+                              "${${_PAR_TARGET}_c_srcs}" )
+
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): setting source file C flags from ${${_PAR_TARGET}_C_SOURCE_FLAGS}")
+        include( ${${_PAR_TARGET}_C_SOURCE_FLAGS} )
+
+      elseif( DEFINED _PAR_CFLAGS )
+
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
+        set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
+
+      endif()
     endif()
-    if( DEFINED _PAR_CXXFLAGS )
-      ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
-      set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
+
+    if( ${_PAR_TARGET}_cxx_srcs )
+
+      if( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${_PAR_TARGET}_CXX_SOURCE_FLAGS
+                              ${_PAR_TARGET}_cxx
+                              "${_PAR_CXXFLAGS}"
+                              "${${_PAR_TARGET}_cxx_srcs}" )
+
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): setting source file CXX flags from ${${_PAR_TARGET}_CXX_SOURCE_FLAGS}")
+        include( ${${_PAR_TARGET}_CXX_SOURCE_FLAGS} )
+
+      elseif( DEFINED _PAR_CXXFLAGS )
+
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
+        set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
+
+      endif()
     endif()
-    if( DEFINED _PAR_FFLAGS )
-      ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
-      set_source_files_properties( ${${_PAR_TARGET}_f_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
+
+    if( ${_PAR_TARGET}_f_srcs )
+
+      if( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${_PAR_TARGET}_Fortran_SOURCE_FLAGS
+                              ${_PAR_TARGET}_f
+                              "${_PAR_FFLAGS}"
+                              "${${_PAR_TARGET}_f_srcs}" )
+
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): setting source file Fortran flags from ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS}")
+        include( ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS} )
+
+      elseif( DEFINED _PAR_FFLAGS )
+
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
+        set_source_files_properties( ${${_PAR_TARGET}_f_srcs}  PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
+
+      endif()
     endif()
+
     if( DEFINED _PAR_GENERATED )
       ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): mark as generated ${_PAR_GENERATED}")
       set_source_files_properties( ${_PAR_GENERATED} PROPERTIES GENERATED 1 )
@@ -185,9 +418,9 @@ function( ecbuild_add_library_impl )
       set_property( TARGET ${_PAR_TARGET} PROPERTY LINKER_LANGUAGE ${_PAR_LINKER_LANGUAGE} )
     endif()
 
-    # installation
+    # installation (except for OBJECT libraries)
 
-    if( NOT _PAR_NOINSTALL )
+    if( NOT _PAR_NOINSTALL AND NOT _PAR_TYPE MATCHES "OBJECT" )
       ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): installing to ${INSTALL_LIB_DIR}")
 
       # and associate with defined component
@@ -268,7 +501,9 @@ function( ecbuild_add_library_impl )
     endif()
 
     # make sure target is removed before - some problems with AIX
-    add_custom_command( TARGET ${_PAR_TARGET} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E remove $<TARGET_FILE:${_PAR_TARGET}> )
+    if( NOT _PAR_TYPE MATCHES "OBJECT" )
+      add_custom_command( TARGET ${_PAR_TARGET} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E remove $<TARGET_FILE:${_PAR_TARGET}> )
+    endif()
 
     # for the links target
     if( NOT _PAR_NOINSTALL )
diff --git a/cmake/ecbuild_add_option.cmake b/cmake/ecbuild_add_option.cmake
index 8a9aaaa..0590bab 100644
--- a/cmake/ecbuild_add_option.cmake
+++ b/cmake/ecbuild_add_option.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,7 +7,66 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for adding a test
+#.rst:
+#
+# ecbuild_add_option
+# ==================
+#
+# Add a CMake configuration option, which may depend on a list of packages. ::
+#
+#   ecbuild_add_option( FEATURE <name>
+#                       [ DEFAULT ON|OFF ]
+#                       [ DESCRIPTION <description> ]
+#                       [ REQUIRED_PACKAGES <package1> [<package2> ...] ]
+#                       [ CONDITION <condition1> [<condition2> ...] ]
+#                       [ ADVANCED ] )
+#
+# Options
+# -------
+#
+# FEATURE : required
+#   name of the feature / option
+#
+# DEFAULT : optional, defaults to ON
+#   if set to ON, the feature is enabled even if not explicitly requested
+#
+# DESCRIPTION : optional
+#   string describing the feature (shown in summary and stored in the cache)
+#
+# REQUIRED_PACKAGES : optional
+#   list of packages required to be found for this feature to be enabled
+#
+#   The package specification can be either ::
+#
+#     <package> [ <version> ... ]
+#
+#   to search for a given package with option minimum required version or ::
+#
+#     PROJECT <name> [ VERSION <version> ... ]
+#
+#   to search for an ecBuild project with optional minimum required version.
+#
+# CONDITION : optional
+#   conditional expression which must evaluate to true for this option to be
+#   enabled (must be valid in a CMake ``if`` statement)
+#
+# ADVANCED : optional
+#   mark the feature as advanced
+#
+# Usage
+# -----
+#
+# Features with ``DEFAULT OFF`` need to be explcitly enabled by the user with
+# ``-DENABLE_<FEATURE>=ON``. If a feature is enabled, all ``REQUIRED_PACKAGES``
+# are found and ``CONDITION`` is met, ecBuild sets the variable
+# ``HAVE_<FEATURE>`` to ``ON``. This is the variable to use to check for the
+# availability of the feature.
+#
+# If a feature is explicitly enabled but the required packages are not found,
+# configuration fails. This only applies when configuring from *clean cache*.
+# With an already populated cache, use ``-DENABLE_<FEATURE>=REQUIRE`` to make
+# the feature a required feature (this cannot be done via the CMake GUI).
+#
 ##############################################################################
 
 macro( ecbuild_add_option )
@@ -37,6 +96,7 @@ macro( ecbuild_add_option )
       message(FATAL_ERROR "In macro ecbuild_add_option(), DEFAULT is either ON or OFF: \"${_p_DEFAULT}\"")
     endif()
   endif()
+  ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): defaults to ${_p_DEFAULT}")
 
   # check CONDITION parameter
   if( DEFINED _p_CONDITION )
@@ -47,6 +107,7 @@ macro( ecbuild_add_option )
     endforeach()
     file( APPEND ${_feature_condition_file} " )\n    set(_${_p_FEATURE}_condition TRUE)\n  else()\n    set(_${_p_FEATURE}_condition FALSE)\n  endif()\n")
     include( ${_feature_condition_file} )
+    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): checking condition ${_p_CONDITION} -> ${_${_p_FEATURE}_condition}")
   else()
     set( _${_p_FEATURE}_condition TRUE )
   endif()
@@ -55,7 +116,12 @@ macro( ecbuild_add_option )
 
   get_property( _in_cache CACHE ENABLE_${_p_FEATURE} PROPERTY VALUE )
 
-  if( NOT "${ENABLE_${_p_FEATURE}}" STREQUAL "" AND _in_cache )
+  # A feature set to REQUIRE is always treated as explicitly enabled
+  if( ENABLE_${_p_FEATURE} MATCHES "REQUIRE" )
+    set( ENABLE_${_p_FEATURE} ON CACHE BOOL "" FORCE )
+    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} was required")
+    set( ${_p_FEATURE}_user_provided_input 1 CACHE BOOL "" FORCE )
+  elseif( NOT "${ENABLE_${_p_FEATURE}}" STREQUAL "" AND _in_cache )
     ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} was found in cache")
     set( ${_p_FEATURE}_user_provided_input 1 CACHE BOOL "" )
   else()
@@ -71,12 +137,14 @@ macro( ecbuild_add_option )
   option( ENABLE_${_p_FEATURE} "${_p_DESCRIPTION}" ${_p_DEFAULT} )
   ecbuild_set_feature( ${_p_FEATURE} ENABLED ${_p_DEFAULT} PURPOSE "${_p_DESCRIPTION}" )
 
+  ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} = ${ENABLE_${_p_FEATURE}}")
   set( _do_search ${ENABLE_${_p_FEATURE}} )
   if( _p_FEATURE STREQUAL "OMP" )
     set( _do_search TRUE )
   endif()
 
   if( _do_search  )
+    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): feature enabled")
 
     set( HAVE_${_p_FEATURE} 1 )
 
@@ -99,22 +167,27 @@ macro( ecbuild_add_option )
           set( pkgproject 0 )
         endif()
 
-        # debug_var( pkg )
-        # debug_var( pkglist )
-        # debug_var( pkgname )
+        # ecbuild_debug_var( pkg )
+        # ecbuild_debug_var( pkglist )
+        # ecbuild_debug_var( pkgname )
 
         string( TOUPPER ${pkgname} pkgUPPER )
         string( TOLOWER ${pkgname} pkgLOWER )
 
         if( ${pkgname}_FOUND OR ${pkgUPPER}_FOUND OR ${pkgLOWER}_FOUND )
+
           ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ${pkgname} has already been found")
           set( ${pkgname}_already_found 1 )
+
         else()
 
           if( pkgproject )
+
             ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for ecbuild project ${pkgname}")
             ecbuild_use_package( ${pkglist} )
+
           else()
+
             if( pkgname STREQUAL "MPI" )
               set( _find_args ${pkglist} )
               list( REMOVE_ITEM _find_args "MPI" )
@@ -137,17 +210,22 @@ macro( ecbuild_add_option )
               ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for package ${pkgname}")
               find_package( ${pkglist} )
             endif()
+
           endif()
 
-          # append to list of third-party libraries (to be forward to other packages )
-          string( TOUPPER ${PROJECT_NAME} PNAME )
-          list( APPEND ${PNAME}_TPLS ${pkgname} )
+        endif()
+
+        # if found append to list of third-party libraries (to be forward to other packages )
+        if( ${pkgname}_FOUND OR ${pkgUPPER}_FOUND OR ${pkgLOWER}_FOUND )
+
+          list( APPEND ${PROJECT_NAME_CAPS}_TPLS ${pkgname} )
+          list( REMOVE_DUPLICATES ${PROJECT_NAME_CAPS}_TPLS )
 
         endif()
 
-        # debug_var( ${pkgname}_FOUND  )
-        # debug_var( ${pkgLOWER}_FOUND )
-        # debug_var( ${pkgUPPER}_FOUND )
+        # ecbuild_debug_var( ${pkgname}_FOUND  )
+        # ecbuild_debug_var( ${pkgLOWER}_FOUND )
+        # ecbuild_debug_var( ${pkgUPPER}_FOUND )
 
         # we have feature if all required packages were FOUND
 
@@ -160,9 +238,9 @@ macro( ecbuild_add_option )
         endif()
 
       endforeach()
-    else()
+    else( _${_p_FEATURE}_condition )
       set( HAVE_${_p_FEATURE} 0 )
-    endif()
+    endif( _${_p_FEATURE}_condition )
 
     ecbuild_set_feature( ${_p_FEATURE} ENABLED ${HAVE_${_p_FEATURE}} )
     # FINAL CHECK
@@ -180,7 +258,11 @@ macro( ecbuild_add_option )
           message( FATAL_ERROR "Feature ${_p_FEATURE} cannot be enabled -- following condition was not met: ${_p_CONDITION}" )
         endif()
       else()
-        message( STATUS "Feature ${_p_FEATURE} was not enabled (also not requested) -- following required packages weren't found: ${_failed_to_find_packages}" )
+        if( _${_p_FEATURE}_condition )
+          message( STATUS "Feature ${_p_FEATURE} was not enabled (also not requested) -- following condition was not met: ${_p_CONDITION}" )
+        else()
+          message( STATUS "Feature ${_p_FEATURE} was not enabled (also not requested) -- following required packages weren't found: ${_failed_to_find_packages}" )
+        endif()
         set( ENABLE_${_p_FEATURE} OFF )
         ecbuild_set_feature( ${_p_FEATURE} ENABLED OFF )
       endif()
@@ -189,7 +271,7 @@ macro( ecbuild_add_option )
 
   else( _do_search )
 
-    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): disabling feature")
+    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): feature disabled")
     set( HAVE_${_p_FEATURE} 0 )
     ecbuild_set_feature( ${_p_FEATURE} ENABLED OFF )
 
@@ -200,7 +282,6 @@ macro( ecbuild_add_option )
     mark_as_advanced( ENABLE_${_p_FEATURE} )
   endif()
 
-  string( TOUPPER PNAME ${PROJECT_NAME} )
-  set( ${PNAME}_HAVE_${_p_FEATURE} ${HAVE_${_p_FEATURE}} )
+  set( ${PROJECT_NAME_CAPS}_HAVE_${_p_FEATURE} ${HAVE_${_p_FEATURE}} )
 
 endmacro( ecbuild_add_option  )
diff --git a/cmake/ecbuild_add_persistent.cmake b/cmake/ecbuild_add_persistent.cmake
index 80ba582..0e1fdbf 100644
--- a/cmake/ecbuild_add_persistent.cmake
+++ b/cmake/ecbuild_add_persistent.cmake
@@ -1,15 +1,40 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
+# (C) Copyright 1996-2015 ECMWF.
+#
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for adding persistent layer object classes
+#.rst:
+#
+# ecbuild_add_persistent
+# ======================
+#
+# Add persistent layer object classes. ::
+#
+#   ecbuild_add_persistent( SRC_LIST <variable>
+#                           FILES <file1> [<file2> ...] ]
+#                           [ NAMESPACE <namespace> ] )
+#
+# Options
+# -------
+#
+# SRC_LIST : required
+#   CMake variable to append the generated persistent layer objects to
+#
+# FILES : required
+#   list of base names of files to build persistent class information for
+#
+#   The source file is expected to have a .h extension, the generated file
+#   gets a .b extension.
+#
+# NAMESPACE : optional
+#   C++ namespace to place the persistent class information in
+#
 ##############################################################################
-  
+
 # define the script to build the persistent class information
 set( sg_perl "${CMAKE_CURRENT_LIST_DIR}/sg.pl" CACHE INTERNAL "perl script to generate persistent objects" )
 
@@ -19,7 +44,7 @@ macro( ecbuild_add_persistent )
 
   set( options )
   set( single_value_args SRC_LIST NAMESPACE )
-  set( multi_value_args  FILES ) 
+  set( multi_value_args  FILES )
 
   cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
@@ -46,7 +71,7 @@ macro( ecbuild_add_persistent )
       set( file ${_file_dir}/${_file_we} )
     endif()
 
-    # debug_var(file)
+    # ecbuild_debug_var(file)
 
     add_custom_command( OUTPUT  ${file}.b
                         COMMAND ${PERL_EXECUTABLE} ${sg_perl} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.h
diff --git a/cmake/ecbuild_add_resources.cmake b/cmake/ecbuild_add_resources.cmake
index 3a4176a..da6e55a 100644
--- a/cmake/ecbuild_add_resources.cmake
+++ b/cmake/ecbuild_add_resources.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -7,7 +7,50 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for adding a resources
+#.rst:
+#
+# ecbuild_add_resources
+# =====================
+#
+# Add resources as project files but optionally exclude them from packaging. ::
+#
+#   ecbuild_add_resources( TARGET <name>
+#                          [ SOURCES <source1> [<source2> ...] ]
+#                          [ SOURCES_PACK <source1> [<source2> ...] ]
+#                          [ SOURCES_DONT_PACK <source1> [<source2> ...] ]
+#                          [ PACK <file1> [<file2> ...] ]
+#                          [ DONT_PACK <file1> [<file2> ...] ]
+#                          [ DONT_PACK_DIRS <directory1> [<directory2> ...] ]
+#                          [ DONT_PACK_REGEX <regex1> [<regex2> ...] ] )
+#
+# Options
+# -------
+#
+# TARGET : required
+#   target name (target will only be created if there are any sources)
+#
+# SOURCES : optional, alias for SOURCES_PACK
+#   list of source files included when packaging
+#
+# SOURCES_PACK : optional, alias for SOURCES
+#   list of source files included when packaging
+#
+# SOURCES_DONT_PACK : optional
+#   list of source files excluded when packaging
+#
+# PACK : optional, priority over DONT_PACK, DONT_PACK_DIRS, DONT_PACK_REGEX
+#   list of files to include when packaging
+#
+# DONT_PACK : optional
+#   list of files to exclude when packaging
+#
+# DONT_PACK_DIRS : optional
+#   list of directories to exclude when packaging
+#
+# DONT_PACK_REGEX : optional
+#   list of regular expressions to match files and directories to exclude when
+#   packaging
+#
 ##############################################################################
 
 macro( ecbuild_add_resources )
diff --git a/cmake/ecbuild_add_test.cmake b/cmake/ecbuild_add_test.cmake
index df0fd0b..b9b93ec 100644
--- a/cmake/ecbuild_add_test.cmake
+++ b/cmake/ecbuild_add_test.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,28 +7,131 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for adding a test
+#.rst:
+#
+# ecbuild_add_test
+# ================
+#
+# Add a test as a script or an executable with a given list of source files. ::
+#
+#   ecbuild_add_test( [ TARGET <name> ]
+#                     [ SOURCES <source1> [<source2> ...] ]
+#                     [ OBJECTS <obj1> [<obj2> ...] ]
+#                     [ COMMAND <executable> ]
+#                     [ TYPE EXE|SCRIPT|PYTHON ]
+#                     [ ARGS <argument1> [<argument2> ...] ]
+#                     [ RESOURCES <file1> [<file2> ...] ]
+#                     [ TEST_DATA <file1> [<file2> ...] ]
+#                     [ BOOST ]
+#                     [ MPI <number-of-ranks> ]
+#                     [ ENABLED ON|OFF ]
+#                     [ LIBS <library1> [<library2> ...] ]
+#                     [ INCLUDES <path1> [<path2> ...] ]
+#                     [ DEFINITIONS <definition1> [<definition2> ...] ]
+#                     [ PERSISTENT <file1> [<file2> ...] ]
+#                     [ GENERATED <file1> [<file2> ...] ]
+#                     [ DEPENDS <target1> [<target2> ...] ]
+#                     [ TEST_DEPENDS <target1> [<target2> ...] ]
+#                     [ CONDITION <condition1> [<condition2> ...] ]
+#                     [ ENVIRONMENT <variable1> [<variable2> ...] ]
+#                     [ WORKING_DIRECTORY <path> ]
+#                     [ CFLAGS <flag1> [<flag2> ...] ]
+#                     [ CXXFLAGS <flag1> [<flag2> ...] ]
+#                     [ FFLAGS <flag1> [<flag2> ...] ]
+#                     [ LINKER_LANGUAGE <lang> ] )
+#
+# Options
+# -------
+#
+# TARGET : either TARGET or COMMAND must be provided, unless TYPE is PYTHON
+#   target name to be built
+#
+# SOURCES : required if TARGET is provided
+#   list of source files to be compiled
+#
+# OBJECTS : optional
+#   list of object libraries to add to this target
+#
+# COMMAND : either TARGET or COMMAND must be provided, unless TYPE is PYTHON
+#   command or script to execute (no executable is built)
+#
+# TYPE : optional
+#   test type, one of:
+#
+#   :EXE:    run built executable, default if TARGET is provided
+#   :SCRIPT: run command or script, default if COMMAND is provided
+#   :PYTHON: run a Python script (requires the Python interpreter to be found)
+#
+# ARGS : optional
+#   list of arguments to pass to TARGET or COMMAND when running the test
+#
+# RESOURCES : optional
+#   list of files to copy from the test source directory to the test directory
+#
+# TEST_DATA : optional
+#   list of test data files to download
+#
+# BOOST : optional
+#   use the Boost Unit Test Framework
+#
+# MPI : optional
+#   number of MPI tasks to use.
+#
+#   If greater than 1, and MPI is not available, the test is disabled.
+#
+# ENABLED : optional
+#   if set to OFF, the test is built but not enabled as a test case
+#
+# LIBS : optional
+#   list of libraries to link against (CMake targets or external libraries)
+#
+# INCLUDES : optional
+#   list of paths to add to include directories
+#
+# DEFINITIONS : optional
+#   list of definitions to add to preprocessor defines
+#
+# PERSISTENT : optional
+#   list of persistent layer object files
+#
+# GENERATED : optional
+#   list of files to mark as generated (sets GENERATED source file property)
+#
+# DEPENDS : optional
+#   list of targets to be built before this target
+#
+# TEST_DEPENDS : optional
+#   list of tests to be run before this one
+#
+# CONDITION : optional
+#   conditional expression which must evaluate to true for this target to be
+#   built (must be valid in a CMake ``if`` statement)
+#
+# ENVIRONMENT : optional
+#   list of environment variables to set in the test environment
+#
+# WORKING_DIRECTORY : optional
+#   directory to switch to before running the test
+#
+# CFLAGS : optional
+#   list of C compiler flags to use for all C source files
+#
+# CXXFLAGS : optional
+#   list of C++ compiler flags to use for all C++ source files
+#
+# FFLAGS : optional
+#   list of Fortran compiler flags to use for all Fortran source files
+#
+# LINKER_LANGUAGE : optional
+#   sets the LINKER_LANGUAGE property on the target
+#
 ##############################################################################
 
-# Arguments:
-#  TARGET : name of test
-#  ENABLED [optional]: (default ON)
-#  COMMAND [optional]: Run command instead of executable
-#  TYPE [optional]: EXE / SCRIPT / PYTHON  (default EXE)
-#  MPI [optional]: number of mpi-tasks to use. If greater than 1,
-#                  and MPI is not available, the test is disabled
-#  SOURCES: sources to be compiled
-#  LIBS: Libraries needed for linking
-#  INCLUDES: Extra include directories
-#  DEPENDS: Add explicit dependency to other targets (for building)
-#  TEST_DEPENDS: add explicity dependency on another test running before
-#  ARGS: Command-line arguments to COMMAND OR TARGET
-
 macro( ecbuild_add_test )
 
   set( options           BOOST )
   set( single_value_args TARGET ENABLED COMMAND TYPE LINKER_LANGUAGE MPI WORKING_DIRECTORY )
-  set( multi_value_args  SOURCES LIBS INCLUDES TEST_DEPENDS DEPENDS ARGS
+  set( multi_value_args  SOURCES OBJECTS LIBS INCLUDES TEST_DEPENDS DEPENDS ARGS
                          PERSISTENT DEFINITIONS RESOURCES TEST_DATA CFLAGS
                          CXXFLAGS FFLAGS GENERATED CONDITION ENVIRONMENT )
 
@@ -167,9 +270,13 @@ macro( ecbuild_add_test )
         endif()
       endif()
 
-      # add the test target
+      # insert already compiled objects (from OBJECT libraries)
+      unset( _all_objects )
+      foreach( _obj ${_PAR_OBJECTS} )
+        list( APPEND _all_objects $<TARGET_OBJECTS:${_obj}> )
+      endforeach()
 
-      add_executable( ${_PAR_TARGET} ${_PAR_SOURCES} )
+      add_executable( ${_PAR_TARGET} ${_PAR_SOURCES} ${_all_objects} )
 
       # add extra dependencies
       if( DEFINED _PAR_DEPENDS)
diff --git a/cmake/ecbuild_append_to_rpath.cmake b/cmake/ecbuild_append_to_rpath.cmake
index 0260356..5a7bd66 100644
--- a/cmake/ecbuild_append_to_rpath.cmake
+++ b/cmake/ecbuild_append_to_rpath.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,13 +6,24 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to append paths to rpath
-
-# if dir is absolute, it simply appends
-# if dir is relative,
-#    then it will try to make it relative to the executables
-#    else it will fallback to making it absolute by prepending the install path
+##############################################################################
+#.rst:
+#
+# ecbuild_append_to_rpath
+# =======================
+#
+# Append paths to the rpath. ::
+#
+#   ecbuild_append_to_rpath( RPATH_DIRS )
+#
+# ``RPATH_DIRS`` is a list of directories to append to ``CMAKE_INSTALL_RPATH``.
+#
+# * If a directory is absolute, simply append it.
+# * If a directory is relative, build a platform-dependent relative path
+#   (using ``@loader_path`` on Mac OSX, ``$ORIGIN`` on Linux and Solaris)
+#   or fall back to making it absolute by prepending the install prefix.
+#
+##############################################################################
 
 function( _path_append var path )
 	if( "${${var}}" STREQUAL "" )
diff --git a/cmake/ecbuild_bundle.cmake b/cmake/ecbuild_bundle.cmake
index 98a5f05..3e1af0d 100644
--- a/cmake/ecbuild_bundle.cmake
+++ b/cmake/ecbuild_bundle.cmake
@@ -1,15 +1,10 @@
-# Manages an external git repository
-# Usage:
-# git(DIR <directory> URL <giturl> [BRANCH <gitbranch>] [TAG <gittag>] [UPDATE] )
+# (C) Copyright 1996-2015 ECMWF.
 #
-# Arguments:
-#  - DIR: directory name where repo will be cloned to
-#  - URL: location of origin git repository
-#  - BRANCH (optional): Branch to clone
-#  - TAG (optional): Tag or commit-id to checkout
-#  - UPDATE (optional) : Option to try to update every cmake run
-#  - NOREMOTE (optional) : Option to avoid remote operations that require network
-#                          changes to tags that havent been fetched might fail
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
 
 # Set policies
 include( ecbuild_policies NO_POLICY_SCOPE )
@@ -20,222 +15,18 @@ endmacro()
 
 include(CMakeParseArguments)
 
-set( ECBUILD_GIT  ON  CACHE BOOL "Turn on/off ecbuild_git() function" )
+include(ecbuild_git)
 
-if( ECBUILD_GIT )
-
-  find_package(Git)
-
-  set( ECMWF_USER $ENV{USER} CACHE STRING "ECMWF git user" )
-  set( ECMWF_GIT  SSH        CACHE STRING "ECMWF git protocol" )
-
-  set( ECMWF_GIT_SSH   "ssh://git@software.ecmwf.int:7999"                  CACHE INTERNAL "ECMWF ssh address" )
-  set( ECMWF_GIT_HTTPS "https://${ECMWF_USER}@software.ecmwf.int/stash/scm" CACHE INTERNAL "ECMWF https address" )
-
-  if( ECMWF_GIT MATCHES "[Ss][Ss][Hh]" )
-    set( ECMWF_GIT_ADDRESS ${ECMWF_GIT_SSH} CACHE INTERNAL "" )
-  else()
-    set( ECMWF_GIT_ADDRESS ${ECMWF_GIT_HTTPS} CACHE INTERNAL "" )
-  endif()
-
-endif()
-
-macro( ecbuild_git )
-
-  set( options UPDATE NOREMOTE MANUAL )
-  set( single_value_args PROJECT DIR URL TAG BRANCH )
-  set( multi_value_args )
-  cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
-
-  if( DEFINED _PAR_BRANCH AND DEFINED _PAR_TAG )
-    message( FATAL_ERROR "Cannot defined both BRANCH and TAG in macro ecbuild_git" )
-  endif()
-
-  if( _PAR_UPDATE AND _PAR_NOREMOTE )
-    message( FATAL_ERROR "Cannot pass both NOREMOTE and UPDATE in macro ecbuild_git" )
-  endif()
-
-  if(_PAR_UNPARSED_ARGUMENTS)
-    message(FATAL_ERROR "Unknown keywords given to ecbuild_git(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-  endif()
-
-  if( ECBUILD_GIT )
-
-    set( _needs_switch 0 )
-
-    get_filename_component( ABS_PAR_DIR "${_PAR_DIR}" ABSOLUTE )
-    get_filename_component( PARENT_DIR  "${_PAR_DIR}/.." ABSOLUTE )
-
-    ### clone if no directory
-
-    if( NOT EXISTS "${_PAR_DIR}" )
-
-      message( STATUS "Cloning ${_PAR_PROJECT} from ${_PAR_URL} into ${_PAR_DIR}...")
-      execute_process(
-        COMMAND ${GIT_EXECUTABLE} "clone" ${_PAR_URL} ${clone_args} ${_PAR_DIR} "-q"
-        RESULT_VARIABLE nok ERROR_VARIABLE error
-        WORKING_DIRECTORY "${PARENT_DIR}")
-      if(nok)
-        message(FATAL_ERROR "${_PAR_DIR} git clone failed: ${error}\n")
-      endif()
-      message( STATUS "${_PAR_DIR} retrieved.")
-      set( _needs_switch 1 )
-
-    endif()
-
-    ### check current tag and sha1
-
-    if( IS_DIRECTORY "${_PAR_DIR}/.git" )
-
-        execute_process(
-          COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
-          OUTPUT_VARIABLE _sha1 RESULT_VARIABLE nok ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE
-          WORKING_DIRECTORY "${ABS_PAR_DIR}" )
-        if(nok)
-          message(STATUS "git rev-parse HEAD on ${_PAR_DIR} failed:\n ${error}")
-        endif()
-
-        execute_process(
-          COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
-          OUTPUT_VARIABLE _current_branch RESULT_VARIABLE nok ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE
-          WORKING_DIRECTORY "${ABS_PAR_DIR}" )
-        if( nok OR _current_branch STREQUAL "" )
-          message(STATUS "git rev-parse --abbrev-ref HEAD on ${_PAR_DIR} failed:\n ${error}")
-        endif()
-
-        #message(STATUS "git describe --exact-match --abbrev=0 @ ${ABS_PAR_DIR}")
-        execute_process(
-          COMMAND ${GIT_EXECUTABLE} describe --exact-match --abbrev=0
-          OUTPUT_VARIABLE _current_tag RESULT_VARIABLE nok ERROR_VARIABLE error
-          OUTPUT_STRIP_TRAILING_WHITESPACE  ERROR_STRIP_TRAILING_WHITESPACE
-          WORKING_DIRECTORY "${ABS_PAR_DIR}" )
-
-        if( error MATCHES "no tag exactly matches" OR error MATCHES "No names found" )
-          unset( _current_tag )
-        else()
-          if( nok )
-            message(STATUS "git describe --exact-match --abbrev=0 on ${_PAR_DIR} failed:\n ${error}")
-          endif()
-        endif()
-
-        if( NOT _current_tag ) # try nother method
-          #message(STATUS "git name-rev --tags --name-only @ ${ABS_PAR_DIR}")
-          execute_process(
-            COMMAND ${GIT_EXECUTABLE} name-rev --tags --name-only ${_sha1}
-            OUTPUT_VARIABLE _current_tag RESULT_VARIABLE nok ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE
-            WORKING_DIRECTORY "${ABS_PAR_DIR}" )
-          if( nok OR _current_tag STREQUAL "" )
-            message(STATUS "git name-rev --tags --name-only on ${_PAR_DIR} failed:\n ${error}")
-          endif()
-        endif()
-
-    endif()
-
-    if( NOT _PAR_MANUAL AND DEFINED _PAR_BRANCH AND NOT "${_current_branch}" STREQUAL "${_PAR_BRANCH}" )
-      set( _needs_switch 1 )
-    endif()
-
-    if( NOT _PAR_MANUAL AND DEFINED _PAR_TAG AND NOT "${_current_tag}" STREQUAL "${_PAR_TAG}" )
-      set( _needs_switch 1 )
-    endif()
-
-    if( DEFINED _PAR_BRANCH AND _PAR_UPDATE AND NOT _PAR_NOREMOTE )
-
-      add_custom_target( git_update_${_PAR_PROJECT}
-                         COMMAND "${GIT_EXECUTABLE}" pull -q
-                         WORKING_DIRECTORY "${ABS_PAR_DIR}"
-                         COMMENT "git pull of branch ${_PAR_BRANCH} on ${_PAR_DIR}" )
-
-      set( git_update_targets "git_update_${_PAR_PROJECT};${git_update_targets}" )
-
-    endif()
-
-    ### updates
-
-    if( _needs_switch AND IS_DIRECTORY "${_PAR_DIR}/.git" )
-
-      # debug_here( ABS_PAR_DIR )
-      # debug_here( _sha1 )
-      # debug_here( _current_branch )
-      # debug_here( _current_tag )
-      # debug_here( _PAR_TAG )
-      # debug_here( _PAR_BRANCH )
-      # debug_here( _needs_switch )
-      # debug_here( _PAR_UPDATE )
-
-      if( DEFINED _PAR_BRANCH )
-        set ( _gitref ${_PAR_BRANCH} )
-        message(STATUS "Updating ${_PAR_PROJECT} to head of BRANCH ${_PAR_BRANCH}...")
-      else()
-        message(STATUS "Updating ${_PAR_PROJECT} to TAG ${_PAR_TAG}...")
-        set ( _gitref ${_PAR_TAG} )
-      endif()
-
-      # fetching latest tags and branches
-
-      if( NOT _PAR_NOREMOTE )
-
-          message(STATUS "git fetch --all @ ${ABS_PAR_DIR}")
-          execute_process(COMMAND "${GIT_EXECUTABLE}" fetch --all -q
-            RESULT_VARIABLE nok ERROR_VARIABLE error
-            WORKING_DIRECTORY "${ABS_PAR_DIR}")
-          if(nok)
-            message(STATUS "git fetch --all in ${_PAR_DIR} failed:\n ${error}")
-          endif()
-
-          message(STATUS "git fetch --all --tags @ ${ABS_PAR_DIR}")
-          execute_process(COMMAND "${GIT_EXECUTABLE}" fetch --all --tags -q
-            RESULT_VARIABLE nok ERROR_VARIABLE error
-            WORKING_DIRECTORY "${ABS_PAR_DIR}")
-          if(nok)
-            message(STATUS "git fetch --all --tags in ${_PAR_DIR} failed:\n ${error}")
-          endif()
-
-      else()
-          message(STATUS "${_PAR_DIR} marked NOREMOTE : Skipping git fetch")
-      endif()
-
-      # checking out gitref
-
-      message(STATUS "git checkout ${_gitref} @ ${ABS_PAR_DIR}")
-      execute_process(COMMAND "${GIT_EXECUTABLE}" checkout -q "${_gitref}"
-        RESULT_VARIABLE nok ERROR_VARIABLE error
-        WORKING_DIRECTORY "${ABS_PAR_DIR}")
-      if(nok)
-        message(FATAL_ERROR "git checkout ${_gitref} on ${_PAR_DIR} failed:\n ${error}")
-      endif()
-
-      if( DEFINED _PAR_BRANCH AND _PAR_UPDATE ) #############################################################################
-
-            execute_process(COMMAND "${GIT_EXECUTABLE}" pull -q
-              RESULT_VARIABLE nok ERROR_VARIABLE error
-              WORKING_DIRECTORY "${ABS_PAR_DIR}")
-            if(nok)
-              message(STATUS "git pull of branch ${_PAR_BRANCH} on ${_PAR_DIR} failed:\n ${error}")
-            endif()
-
-      endif() ####################################################################################
-
-    endif( _needs_switch AND IS_DIRECTORY "${_PAR_DIR}/.git" )
-
-  endif( ECBUILD_GIT )
-
-endmacro()
-
-########################################################################################################################
-
-macro( ecmwf_stash )
-
-  set( options )
-  set( single_value_args STASH )
-  set( multi_value_args )
-  cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
-
-  ecbuild_git( URL "${ECMWF_GIT_ADDRESS}/${_PAR_STASH}.git" ${_PAR_UNPARSED_ARGUMENTS} )
-
-endmacro()
-
-########################################################################################################################
+##############################################################################
+#.rst:
+#
+# ecbuild_bundle_initialize
+# =========================
+#
+# Initialise the ecBuild environment for a bundle. *Must* be called *before*
+# any call to ecbuild_bundle.
+#
+##############################################################################
 
 macro( ecbuild_bundle_initialize )
 
@@ -261,32 +52,117 @@ macro( ecbuild_bundle_initialize )
 
 endmacro()
 
-########################################################################################################################
+##############################################################################
+#.rst:
+#
+# ecbuild_bundle
+# ==============
+#
+# Declare a subproject to be built as part of this bundle. ::
+#
+#   ecbuild_bundle( PROJECT <name>
+#                   STASH <repository> | GIT <giturl> | SOURCE <path>
+#                   [ BRANCH <gitbranch> | TAG <gittag> ]
+#                   [ UPDATE | NOREMOTE ] )
+#                   [ MANUAL ] )
+#
+# Options
+# -------
+#
+# PROJECT : required
+#   project name for the Git repository to be managed
+#
+# STASH : cannot be combined with GIT or SOURCE
+#   Stash repository in the form <project>/<repository>
+#
+# GIT : cannot be combined with STASH or SOURCE
+#   Git URL of the remote repository to clone (see ``git help clone``)
+#
+# SOURCE : cannot be combined with STASH or GIT
+#   Path to an existing local repository, which will be symlinked
+#
+# BRANCH : optional, cannot be combined with TAG
+#   Git branch to check out
+#
+# TAG : optional, cannot be combined with BRANCH
+#   Git tag or commit id to check out
+#
+# UPDATE : optional, requires BRANCH, cannot be combined with NOREMOTE
+#   Create a CMake target update to fetch changes from the remote repository
+#
+# NOREMOTE : optional, cannot be combined with UPDATE
+#   Do not fetch changes from the remote repository
+#
+# MANUAL : optional
+#   Do not automatically switch branches or tags
+#
+# Usage
+# -----
+#
+# A bundle is used to build a number of projects together. Each subproject
+# needs to be declared with a call to ecbuild_bundle, where the order of
+# projects is important and needs to respect dependencies: if project B
+# depends on project A, A should be listed before B in the bundle.
+#
+# The first time a bundle is built, the sources of all subprojects are cloned
+# into directories named according to project in the *source* tree of the
+# bundle (which means these directories should be added to ``.gitignore``).
+# If the ``SOURCE`` option is used it must point to an existing local
+# repository on disk and no new repository is cloned. Be aware that using the
+# ``BRANCH`` or ``TAG`` option leads to the corresponding version being checked
+# out in that repository!
+#
+# Subprojects are configured and built in order. Due to being added as a
+# subproject, the usual project discovery mechanism (i.e. locating and
+# importing a ``<project>-config.cmake`` file) is not used. Also there are no
+# ``<project>-config.cmake`` files being generated for individual subprojects.
+# However there *are* package-config files being generated for each library.
+#
+# To switch off a subproject when building a bundle, set the CMake variable
+# ``BUNDLE_SKIP_<PNAME>`` where ``PNAME`` is the capitalised project name.
+#
+##############################################################################
 
 macro( ecbuild_bundle )
 
   set( options )
-  set( single_value_args PROJECT STASH GIT )
+  set( single_value_args PROJECT STASH GIT SOURCE )
   set( multi_value_args )
   cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
 
   string(TOUPPER "${_PAR_PROJECT}" PNAME)
 
   if( BUNDLE_SKIP_${PNAME} )
-      message( STATUS "Skipping bundle project ${PNAME}" )
+    message( STATUS "Skipping bundle project ${PNAME}" )
   else()
 
-      if( _PAR_STASH )
-          ecmwf_stash( PROJECT ${_PAR_PROJECT} DIR ${PROJECT_SOURCE_DIR}/${_PAR_PROJECT} STASH ${_PAR_STASH} ${_PAR_UNPARSED_ARGUMENTS} )
-      elseif( _PAR_GIT )
-          ecbuild_git( PROJECT ${_PAR_PROJECT} DIR ${PROJECT_SOURCE_DIR}/${_PAR_PROJECT} URL ${_PAR_GIT} ${_PAR_UNPARSED_ARGUMENTS} )
+    if( _PAR_STASH )
+      ecmwf_stash( PROJECT ${_PAR_PROJECT} DIR ${PROJECT_SOURCE_DIR}/${_PAR_PROJECT} STASH ${_PAR_STASH} ${_PAR_UNPARSED_ARGUMENTS} )
+    elseif( _PAR_GIT )
+      ecbuild_git( PROJECT ${_PAR_PROJECT} DIR ${PROJECT_SOURCE_DIR}/${_PAR_PROJECT} URL ${_PAR_GIT} ${_PAR_UNPARSED_ARGUMENTS} )
+    elseif( _PAR_SOURCE )
+      if( DEFINED ${PNAME}_SOURCE )
+        ecbuild_critical( "ecbuild_bundle called with SOURCE for project ${_PAR_PROJECT} but ${PNAME}_SOURCE is defined" )
       endif()
+      execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${_PAR_SOURCE} ${PROJECT_SOURCE_DIR}/${_PAR_PROJECT} )
+    endif()
 
-      ecbuild_use_package( PROJECT ${_PAR_PROJECT} )
+    ecbuild_use_package( PROJECT ${_PAR_PROJECT} )
   endif()
 
 endmacro()
 
+##############################################################################
+#.rst:
+#
+# ecbuild_bundle_finalize
+# =======================
+#
+# Finalise the ecBuild environment for a bundle. *Must* be called *after* the
+# last call to ecbuild_bundle.
+#
+##############################################################################
+
 macro( ecbuild_bundle_finalize )
 
   add_custom_target( update DEPENDS ${git_update_targets} )
diff --git a/cmake/ecbuild_cache.cmake b/cmake/ecbuild_cache.cmake
index af12cf1..9663bca 100644
--- a/cmake/ecbuild_cache.cmake
+++ b/cmake/ecbuild_cache.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -6,6 +6,30 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
+##############################################################################
+#.rst:
+#
+# ecBuild Cache
+# =============
+#
+# During initialisation, ecBuild introspects the compiler and operating system
+# and performs a number of checks. The result of these is written to a
+# dedicated ``ecbuild-cache.cmake`` file in the build tree. This cache may be
+# used to speed up subsequent *clean* builds i.e. those where no CMakeCache.txt
+# exists yet.
+#
+# To use the ecBuild cache, configure with ``-DECBUILD_CACHE=<cache-file>``,
+# where ``<cache-file>`` is the path to an existing ``ecbuild-cache.cmake``.
+#
+# .. note ::
+#
+#   The ecBuild cache is specific to compiler *and* operating system. Do *not*
+#   attempt to use a cache file created on a different machine or with a
+#   different compiler!
+#
+##############################################################################
+
+# Prepare the cache and clobber any existing ecbuild-cache.cmake
 macro( ecbuild_prepare_cache )
     include( CheckSymbolExists )
     include( CheckIncludeFiles )
@@ -16,7 +40,7 @@ macro( ecbuild_prepare_cache )
     file(WRITE ${ecbuild_cache_file} "# ecbuild cache file\n\n")    
 endmacro()
 
-
+# Buffer the CMake variable var to be written to the ecBuild cache
 function( ecbuild_cache_var var )
   if( NOT ${var} )
     set( ${var} 0 )
@@ -24,6 +48,7 @@ function( ecbuild_cache_var var )
   set( ECBUILD_CACHE_BUFFER "${ECBUILD_CACHE_BUFFER}set( ${var} ${${var}} )\n" CACHE INTERNAL "Cache buffer" )
 endfunction()
 
+# Call check_symbol_exists only if the output is not defined yet
 function( ecbuild_cache_check_symbol_exists symbol includes output )
   if( NOT DEFINED ${output} )
     check_symbol_exists( ${symbol} ${includes} ${output} )
@@ -31,6 +56,7 @@ function( ecbuild_cache_check_symbol_exists symbol includes output )
   ecbuild_cache_var( ${output} )
 endfunction()
 
+# Call check_include_files only if the output is not defined yet
 function( ecbuild_cache_check_include_files includes output )
   if( NOT DEFINED ${output} )
     check_include_files( ${includes} ${output} )
@@ -38,6 +64,7 @@ function( ecbuild_cache_check_include_files includes output )
   ecbuild_cache_var( ${output} )
 endfunction()
 
+# Call check_c_source_compiles only if the output is not defined yet
 function( ecbuild_cache_check_c_source_compiles source output )
   if( NOT DEFINED ${output} )
     check_c_source_compiles( "${source}" ${output} )
@@ -45,6 +72,7 @@ function( ecbuild_cache_check_c_source_compiles source output )
   ecbuild_cache_var( ${output} )
 endfunction()
 
+# Call check_cxx_source_compiles only if the output is not defined yet
 function( ecbuild_cache_check_cxx_source_compiles source output )
   if( NOT DEFINED ${output} )
     check_cxx_source_compiles( "${source}" ${output} )
@@ -52,6 +80,7 @@ function( ecbuild_cache_check_cxx_source_compiles source output )
   ecbuild_cache_var( ${output} )
 endfunction()
 
+# Call check_type_size only if the output is not defined yet
 function( ecbuild_cache_check_type_size type output )
   if( NOT DEFINED ${output} )
     check_type_size( "${type}" ${output} )
@@ -59,7 +88,8 @@ function( ecbuild_cache_check_type_size type output )
   ecbuild_cache_var( ${output} )
 endfunction()
 
+# Flush the ecBuild cache to disk and reset the buffer
 function( ecbuild_flush_cache )
   file( APPEND ${ecbuild_cache_file} "${ECBUILD_CACHE_BUFFER}" )
   set( ECBUILD_CACHE_BUFFER "" CACHE INTERNAL "Cache buffer" )
-endfunction()
\ No newline at end of file
+endfunction()
diff --git a/cmake/ecbuild_check_c_source.cmake b/cmake/ecbuild_check_c_source.cmake
deleted file mode 100644
index 12a26c1..0000000
--- a/cmake/ecbuild_check_c_source.cmake
+++ /dev/null
@@ -1,161 +0,0 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
-# This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
-# granted to it by virtue of its status as an intergovernmental organisation nor
-# does it submit to any jurisdiction.
-
-##############################################################################
-# macro that runs the given C code and returns its output
-
-macro( ecbuild_check_c_source_return SOURCE )
-
-    set( options )
-    set( single_value_args VAR  OUTPUT )
-    set( multi_value_args  INCLUDES LIBS DEFINITIONS )
-
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if(_PAR_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_check_c_source_return(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-    endif()
-
-    if( NOT _PAR_VAR OR NOT _PAR_OUTPUT )
-      message(FATAL_ERROR "The call to ecbuild_check_c_source_return() doesn't specify either SOURCE, VAR or OUTPUT")
-    endif()
-
-
-    if( NOT DEFINED ${_PAR_VAR} )
-
-        set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${_PAR_VAR} ${CMAKE_REQUIRED_FLAGS}")
-
-        set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
-        if( CMAKE_REQUIRED_LIBRARIES )
-            list( APPEND __add_libs ${CMAKE_REQUIRED_LIBRARIES} )
-        endif()
-        if( _PAR_LIBS )
-            list( APPEND __add_libs ${_PAR_LIBS} )
-        endif()
-        if( __add_libs )
-            set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${__add_libs}")
-        endif()
-
-        set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
-        if( CMAKE_REQUIRED_INCLUDES )
-            list( APPEND __add_incs ${CMAKE_REQUIRED_INCLUDES} )
-        endif()
-        if( _PAR_INCLUDES )
-            list( APPEND __add_incs ${_PAR_INCLUDES} )
-        endif()
-		if( __add_incs )
-            set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
-        endif()
-    
-        # write the source file
-    
-        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.c" "${SOURCE}\n" )
-
-        message( STATUS "Performing Test ${_PAR_VAR}" )
-        try_run( ${_PAR_VAR}_EXITCODE ${_PAR_VAR}_COMPILED
-          ${CMAKE_BINARY_DIR}
-          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.c
-          COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-          CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-          -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
-          "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
-          "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
-          COMPILE_OUTPUT_VARIABLE compile_OUTPUT 
-          RUN_OUTPUT_VARIABLE     run_OUTPUT )
-    
-        # if it did not compile make the return value fail code of 1
-        if( NOT ${_PAR_VAR}_COMPILED )
-          set( ${_PAR_VAR}_EXITCODE 1 )
-        endif()
-    
-        # if the return value was 0 then it worked
-        if("${${_PAR_VAR}_EXITCODE}" EQUAL 0)
-    
-          message(STATUS "Performing Test ${_PAR_VAR} - Success")
-          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
-            "Performing C SOURCE FILE Test ${_PAR_VAR} succeded with the following compile output:\n"
-            "${compile_OUTPUT}\n" 
-            "Performing C SOURCE FILE Run ${_PAR_VAR} succeded with the following run output:\n"
-            "${run_OUTPUT}\n" 
-            "Return value: ${${_PAR_VAR}}\n"
-            "Source file was:\n${SOURCE}\n")
-
-          set( ${_PAR_VAR}     1              CACHE INTERNAL "Test ${_PAR_VAR}")
-          set( ${_PAR_OUTPUT} "${run_OUTPUT}" CACHE INTERNAL "Test ${_PAR_VAR} output")
-    
-        else()
-    
-          if(CMAKE_CROSSCOMPILING AND "${${_PAR_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
-            set(${_PAR_VAR} "${${_PAR_VAR}_EXITCODE}")
-            set(${OUTPUT} "")
-          else()
-            set(${_PAR_VAR} "" CACHE INTERNAL "Test ${_PAR_VAR}")
-            set(${_PAR_OUTPUT} "" CACHE INTERNAL "Test ${_PAR_VAR} output")
-          endif()
-    
-          message(STATUS "Performing Test ${_PAR_VAR} - Failed")
-          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
-            "Performing C SOURCE FILE Test ${_PAR_VAR} failed with the following compile output:\n"
-            "${compile_OUTPUT}\n" 
-            "Performing C SOURCE FILE Run ${_PAR_VAR} failed with the following run output:\n"
-            "${run_OUTPUT}\n" 
-            "Return value: ${${_PAR_VAR}_EXITCODE}\n"
-            "Source file was:\n${SOURCE}\n")
-        endif()
-    
-    endif()
-
-endmacro()
-
-##############################################################################
-# macro that only adds a c flag if compiler supports it
-
-macro( cmake_add_c_flags m_c_flags )
-
-  set( _flags ${m_c_flags} )
-
-  if( _flags AND CMAKE_C_COMPILER_LOADED )
-    set( options )
-    set( single_value_args BUILD NAME )
-    set( multi_value_args )
-
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if( NOT DEFINED N_CFLAG )
-      set( N_CFLAG 0 )
-    endif()
-
-    math( EXPR N_CFLAG '${N_CFLAG}+1' )
-
-    if( NOT ECBUILD_TRUST_FLAGS )
-      if( DEFINED _PAR_NAME )
-        check_c_compiler_flag( ${_flags} ${_PAR_NAME} )
-        set( _flag_ok ${${_PAR_NAME}} )
-      else()
-        check_c_compiler_flag( ${_flags} C_FLAG_TEST_${N_CFLAG} )
-        set( _flag_ok ${C_FLAG_TEST_${N_CFLAG}} )
-      endif()
-    else()
-      set( _flag_ok 1 )
-    endif()
-    
-    if( _flag_ok )
-      if( _PAR_BUILD )
-        set( CMAKE_C_FLAGS_${_PAR_BUILD} "${CMAKE_C_FLAGS_${_PAR_BUILD}} ${_flags}" )
-      else()
-        set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flags}" )
-        # message( STATUS "C FLAG [${_flags}] added" )
-      endif()
-    else()
-      message( WARNING "Unrecognised C flag [${_flags}] -- skipping" )
-    endif()
-  endif()
-  unset( _flags )
-  unset( _flag_ok )
-endmacro()
-
diff --git a/cmake/ecbuild_check_c_source_return.cmake b/cmake/ecbuild_check_c_source_return.cmake
new file mode 100644
index 0000000..1dadca6
--- /dev/null
+++ b/cmake/ecbuild_check_c_source_return.cmake
@@ -0,0 +1,154 @@
+# (C) Copyright 1996-2015 ECMWF.
+# 
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# In applying this licence, ECMWF does not waive the privileges and immunities 
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_check_c_source_return
+# =============================
+#
+# Compile and run a given C source code and return its output. ::
+#
+#   ecbuild_check_c_source_return( <source>
+#                                  VAR <name>
+#                                  OUTPUT <name>
+#                                  [ INCLUDES <path1> [ <path2> ... ] ]
+#                                  [ LIBS <library1> [ <library2> ... ] ]
+#                                  [ DEFINITIONS <definition1> [ <definition2> ... ] ] )
+#
+# Options
+# -------
+#
+# VAR : required
+#   name of the check and name of the CMake variable to write result to
+#
+# OUTPUT : required
+#   name of CMake variable to write the output to
+#
+# INCLUDES : optional
+#   list of paths to add to include directories
+#
+# LIBS : optional
+#   list of libraries to link against (CMake targets or external libraries)
+#
+# DEFINITIONS : optional
+#   list of definitions to add to preprocessor defines
+#
+# Usage
+# -----
+#
+# This will write the given source to a .c file and compile and run it with
+# try_run. If successful, ``${VAR}`` is set to 1 and ``${OUTPUT}`` is set to
+# the output of the successful run in the CMake cache.
+#
+# The check will not run if ``${VAR}`` is defined (e.g. from ecBuild cache).
+#
+##############################################################################
+
+macro( ecbuild_check_c_source_return SOURCE )
+
+    set( options )
+    set( single_value_args VAR  OUTPUT )
+    set( multi_value_args  INCLUDES LIBS DEFINITIONS )
+
+    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if(_PAR_UNPARSED_ARGUMENTS)
+      message(FATAL_ERROR "Unknown keywords given to ecbuild_check_c_source_return(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+    endif()
+
+    if( NOT _PAR_VAR OR NOT _PAR_OUTPUT )
+      message(FATAL_ERROR "The call to ecbuild_check_c_source_return() doesn't specify either SOURCE, VAR or OUTPUT")
+    endif()
+
+
+    if( NOT DEFINED ${_PAR_VAR} )
+
+        set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${_PAR_VAR} ${CMAKE_REQUIRED_FLAGS}")
+
+        set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
+        if( CMAKE_REQUIRED_LIBRARIES )
+            list( APPEND __add_libs ${CMAKE_REQUIRED_LIBRARIES} )
+        endif()
+        if( _PAR_LIBS )
+            list( APPEND __add_libs ${_PAR_LIBS} )
+        endif()
+        if( __add_libs )
+            set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${__add_libs}")
+        endif()
+
+        set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
+        if( CMAKE_REQUIRED_INCLUDES )
+            list( APPEND __add_incs ${CMAKE_REQUIRED_INCLUDES} )
+        endif()
+        if( _PAR_INCLUDES )
+            list( APPEND __add_incs ${_PAR_INCLUDES} )
+        endif()
+        if( __add_incs )
+            set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
+        endif()
+    
+        # write the source file
+    
+        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.c" "${SOURCE}\n" )
+
+        message( STATUS "Performing Test ${_PAR_VAR}" )
+        try_run( ${_PAR_VAR}_EXITCODE ${_PAR_VAR}_COMPILED
+          ${CMAKE_BINARY_DIR}
+          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.c
+          COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+          CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+          -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
+          "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
+          "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
+          COMPILE_OUTPUT_VARIABLE compile_OUTPUT 
+          RUN_OUTPUT_VARIABLE     run_OUTPUT )
+    
+        # if it did not compile make the return value fail code of 1
+        if( NOT ${_PAR_VAR}_COMPILED )
+          set( ${_PAR_VAR}_EXITCODE 1 )
+        endif()
+    
+        # if the return value was 0 then it worked
+        if("${${_PAR_VAR}_EXITCODE}" EQUAL 0)
+    
+          message(STATUS "Performing Test ${_PAR_VAR} - Success")
+          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+            "Performing C SOURCE FILE Test ${_PAR_VAR} succeded with the following compile output:\n"
+            "${compile_OUTPUT}\n" 
+            "Performing C SOURCE FILE Run ${_PAR_VAR} succeded with the following run output:\n"
+            "${run_OUTPUT}\n" 
+            "Return value: ${${_PAR_VAR}}\n"
+            "Source file was:\n${SOURCE}\n")
+
+          set( ${_PAR_VAR}     1              CACHE INTERNAL "Test ${_PAR_VAR}")
+          set( ${_PAR_OUTPUT} "${run_OUTPUT}" CACHE INTERNAL "Test ${_PAR_VAR} output")
+    
+        else()
+    
+          if(CMAKE_CROSSCOMPILING AND "${${_PAR_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
+            set(${_PAR_VAR} "${${_PAR_VAR}_EXITCODE}")
+            set(${OUTPUT} "")
+          else()
+            set(${_PAR_VAR} "" CACHE INTERNAL "Test ${_PAR_VAR}")
+            set(${_PAR_OUTPUT} "" CACHE INTERNAL "Test ${_PAR_VAR} output")
+          endif()
+    
+          message(STATUS "Performing Test ${_PAR_VAR} - Failed")
+          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+            "Performing C SOURCE FILE Test ${_PAR_VAR} failed with the following compile output:\n"
+            "${compile_OUTPUT}\n" 
+            "Performing C SOURCE FILE Run ${_PAR_VAR} failed with the following run output:\n"
+            "${run_OUTPUT}\n" 
+            "Return value: ${${_PAR_VAR}_EXITCODE}\n"
+            "Source file was:\n${SOURCE}\n")
+        endif()
+    
+    endif()
+
+endmacro()
diff --git a/cmake/ecbuild_check_compiler.cmake b/cmake/ecbuild_check_compiler.cmake
index 30f740c..32ff6cc 100644
--- a/cmake/ecbuild_check_compiler.cmake
+++ b/cmake/ecbuild_check_compiler.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -101,23 +101,23 @@ endif()
 
 if( CMAKE_COMPILER_IS_GNUCC )
 
-    cmake_add_c_flags("-pipe") # use pipe for faster compilation
+    ecbuild_add_c_flags("-pipe") # use pipe for faster compilation
 
     if( ENABLE_WARNINGS )
-        cmake_add_c_flags("-Wall")
-        # cmake_add_c_flags("-pedantic")
-        # cmake_add_c_flags("-Wextra")
+        ecbuild_add_c_flags("-Wall")
+        # ecbuild_add_c_flags("-pedantic")
+        # ecbuild_add_c_flags("-Wextra")
     endif()
 
 endif()
 
 if( CMAKE_COMPILER_IS_GNUCXX )
 
-   cmake_add_cxx_flags("-pipe") # use pipe for faster compilation
+   ecbuild_add_cxx_flags("-pipe") # use pipe for faster compilation
 
     if( ENABLE_WARNINGS )
-        cmake_add_cxx_flags("-Wall")
-        #    cmake_add_cxx_flags("-Wextra")
+        ecbuild_add_cxx_flags("-Wall")
+        #    ecbuild_add_cxx_flags("-Wextra")
     endif()
 
 endif()
@@ -143,9 +143,9 @@ endif()
 # Fortran compiler specific flags
 # if( NOT HAVE_SINGLE_PRECISION )
 #  if(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
-#      cmake_add_fortran_flags("-r8")
+#      ecbuild_add_fortran_flags("-r8")
 #  elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
 #      # NOTE that if we add -fdefault-real-8 then we NEED -fdefault-double-8 to avoid quadmath
-#      cmake_add_fortran_flags("-fdefault-real-8 -fdefault-double-8")
+#      ecbuild_add_fortran_flags("-fdefault-real-8 -fdefault-double-8")
 #  endif()
-# endif()
\ No newline at end of file
+# endif()
diff --git a/cmake/ecbuild_check_cxx11.cmake b/cmake/ecbuild_check_cxx11.cmake
index 4bb3fb5..6453786 100644
--- a/cmake/ecbuild_check_cxx11.cmake
+++ b/cmake/ecbuild_check_cxx11.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,9 +6,33 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to check for cxx11 features
-# uses macros from the project github.com/UCL/GreatCMakeCookOff
+##############################################################################
+#.rst:
+#
+# ecbuild_check_cxx11
+# ===================
+#
+# Check for C++11 features. ::
+#
+#   ecbuild_check_cxx11( [ FEATURES <feature1> [ <feature2> ... ] ]
+#                        [ REQUIRED <feature1> [ <feature2> ... ] ]
+#                        [ PRINT ] )
+#
+# This function uses macros from http://github.com/UCL/GreatCMakeCookOff
+#
+# Options
+# -------
+#
+# FEATURES : optional, checks for all features if omitted
+#   list of features to check for
+#
+# REQUIRED : optional
+#   list of required features to check for
+#
+# PRINT : optional
+#   print a summary of features check for, found and not found
+#
+##############################################################################
 
 function( ecbuild_check_cxx11 )
 
diff --git a/cmake/ecbuild_check_cxx_source.cmake b/cmake/ecbuild_check_cxx_source.cmake
deleted file mode 100644
index a48ae5a..0000000
--- a/cmake/ecbuild_check_cxx_source.cmake
+++ /dev/null
@@ -1,160 +0,0 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
-# This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
-# granted to it by virtue of its status as an intergovernmental organisation nor
-# does it submit to any jurisdiction.
-
-##############################################################################
-# macro that runs the given C++ code and returns its output
-
-macro( ecbuild_check_cxx_source_return SOURCE )
-
-    set( options )
-    set( single_value_args VAR  OUTPUT )
-    set( multi_value_args  INCLUDES LIBS DEFINITIONS )
-
-    cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if(_p_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_check_cxx_source_return(): \"${_p_UNPARSED_ARGUMENTS}\"")
-    endif()
-
-    if( NOT _p_VAR OR NOT _p_OUTPUT )
-      message(FATAL_ERROR "The call to ecbuild_check_cxx_source_return() doesn't specify either SOURCE, VAR or OUTPUT")
-    endif()
-
-    set( _msg "Testing ${_p_VAR}:" )
-
-    if( NOT DEFINED ${_p_VAR} )
-
-        set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${_p_VAR} ${CMAKE_REQUIRED_FLAGS}")
-
-        set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
-        if(CMAKE_REQUIRED_LIBRARIES)
-            list( APPEND __add_libs ${CMAKE_REQUIRED_LIBRARIES} )
-        endif()
-        if( _p_LIBS )
-            list( APPEND __add_libs ${_p_LIBS} )
-        endif()
-        if( __add_libs )
-            set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${__add_libs}")
-        endif()
-
-        set(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES)
-        if(CMAKE_REQUIRED_INCLUDES)
-            list( APPEND __add_incs ${CMAKE_REQUIRED_INCLUDES} )
-        endif()
-        if( _p_INCLUDES )
-            list( APPEND __add_incs ${_p_INCLUDES} )
-        endif()
-		if( __add_incs )
-            set(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
-        endif()
-    
-        # write the source file
-    
-        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_p_VAR}.cxx" "${SOURCE}\n" )
-
-        message( STATUS "${_msg}" )
-        try_run( ${_p_VAR}_EXITCODE ${_p_VAR}_COMPILED
-          ${CMAKE_BINARY_DIR}
-          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_p_VAR}.cxx
-          COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-          CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-          -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
-          "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}"
-          "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
-          COMPILE_OUTPUT_VARIABLE compile_OUTPUT 
-          RUN_OUTPUT_VARIABLE     run_OUTPUT )
-   
-	  # debug_var( ${_p_VAR}_COMPILED )
-	  # debug_var( ${_p_VAR}_EXITCODE )
-
-        # if it did not compile make the return value fail code of 1
-
-        if( NOT ${_p_VAR}_COMPILED )
-          message( STATUS "${_msg} failed to compile" )
-        endif()
-
-        if( "${${_p_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN" )
-          message( STATUS "${_msg} failed to run" )
-        endif()
-
-        # if the return value was 0 then it worked
-        if( ${_p_VAR}_COMPILED AND "${${_p_VAR}_EXITCODE}" EQUAL 0 )
-    
-          message(STATUS "${_msg} Success")
-          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
-            "Performing C++ SOURCE FILE Test ${_p_VAR} succeded with the following compile output:\n"
-            "${compile_OUTPUT}\n" 
-            "Performing C++ SOURCE FILE Run ${_p_VAR} succeded with the following run output:\n"
-            "${run_OUTPUT}\n" 
-            "Return value: ${${_p_VAR}}\n"
-            "Source file was:\n${SOURCE}\n")
-
-          set( ${_p_VAR}     1              CACHE INTERNAL "Test ${_p_VAR}")
-          set( ${_p_OUTPUT} "${run_OUTPUT}" CACHE INTERNAL "Test ${_p_VAR} output")
-    
-        else()
-    
-          if(CMAKE_CROSSCOMPILING AND "${${_p_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
-            set(${_p_VAR} "${${_p_VAR}_EXITCODE}")
-            set(${OUTPUT} "")
-          else()
-            set(${_p_VAR} "" CACHE INTERNAL "Test ${_p_VAR}")
-            set(${_p_OUTPUT} "" CACHE INTERNAL "Test ${_p_VAR} output")
-          endif()
-    
-          message(STATUS "Test ${_p_VAR} - Failed")
-          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
-            "Performing C++ SOURCE FILE Test ${_p_VAR} failed with the following compile output:\n"
-            "${compile_OUTPUT}\n" 
-            "Performing C++ SOURCE FILE Run ${_p_VAR} failed with the following run output:\n"
-            "${run_OUTPUT}\n" 
-            "Return value: ${${_p_VAR}_EXITCODE}\n"
-            "Source file was:\n${SOURCE}\n")
-        endif()
-    
-    endif()
-
-endmacro()
-
-##############################################################################
-# macro that only adds a cxx flag if compiler supports it
-
-macro( cmake_add_cxx_flags m_cxx_flags )
-
-  set( _flags ${m_cxx_flags} )
-  if( _flags AND CMAKE_CXX_COMPILER_LOADED )
-    set( options )
-    set( single_value_args BUILD )
-    set( multi_value_args )
-
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if( NOT DEFINED N_CXXFLAG )
-      set( N_CXXFLAG 0 )
-    endif()
-
-    math( EXPR N_CXXFLAG '${N_CXXFLAG}+1' )
-
-    if( NOT ECBUILD_TRUST_FLAGS )
-      check_cxx_compiler_flag( ${_flags} CXX_FLAG_TEST_${N_CXXFLAG} )
-    endif()
-
-    if( CXX_FLAG_TEST_${N_CXXFLAG} OR ECBUILD_TRUST_FLAGS )
-      if( _PAR_BUILD )
-        set( CMAKE_CXX_FLAGS_${_PAR_BUILD} "${CMAKE_CXX_FLAGS_${_PAR_BUILD}} ${_flags}" )
-      else()
-        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flags}" )
-        # message( STATUS "C++ FLAG [${_flags}] added" )
-      endif()
-    else()
-      message( STATUS "Unrecognised CXX flag [${_flags}] -- skipping" )
-    endif()
-  endif()
-  unset( _flags )
-
-endmacro()
diff --git a/cmake/ecbuild_check_cxx_source_return.cmake b/cmake/ecbuild_check_cxx_source_return.cmake
new file mode 100644
index 0000000..8f96f61
--- /dev/null
+++ b/cmake/ecbuild_check_cxx_source_return.cmake
@@ -0,0 +1,163 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_check_cxx_source_return
+# ===============================
+#
+# Compile and run a given C++ code and return its output. ::
+#
+#   ecbuild_check_cxx_source_return( <source>
+#                                    VAR <name>
+#                                    OUTPUT <name>
+#                                    [ INCLUDES <path1> [ <path2> ... ] ]
+#                                    [ LIBS <library1> [ <library2> ... ] ]
+#                                    [ DEFINITIONS <definition1> [ <definition2> ... ] ] )
+#
+# Options
+# -------
+#
+# VAR : required
+#   name of the check and name of the CMake variable to write result to
+#
+# OUTPUT : required
+#   name of CMake variable to write the output to
+#
+# INCLUDES : optional
+#   list of paths to add to include directories
+#
+# LIBS : optional
+#   list of libraries to link against (CMake targets or external libraries)
+#
+# DEFINITIONS : optional
+#   list of definitions to add to preprocessor defines
+#
+# Usage
+# -----
+#
+# This will write the given source to a .cxx file and compile and run it with
+# try_run. If successful, ``${VAR}`` is set to 1 and ``${OUTPUT}`` is set to
+# the output of the successful run in the CMake cache.
+#
+# The check will not run if ``${VAR}`` is defined (e.g. from ecBuild cache).
+#
+##############################################################################
+
+macro( ecbuild_check_cxx_source_return SOURCE )
+
+    set( options )
+    set( single_value_args VAR  OUTPUT )
+    set( multi_value_args  INCLUDES LIBS DEFINITIONS )
+
+    cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if(_p_UNPARSED_ARGUMENTS)
+      message(FATAL_ERROR "Unknown keywords given to ecbuild_check_cxx_source_return(): \"${_p_UNPARSED_ARGUMENTS}\"")
+    endif()
+
+    if( NOT _p_VAR OR NOT _p_OUTPUT )
+      message(FATAL_ERROR "The call to ecbuild_check_cxx_source_return() doesn't specify either SOURCE, VAR or OUTPUT")
+    endif()
+
+    set( _msg "Testing ${_p_VAR}:" )
+
+    if( NOT DEFINED ${_p_VAR} )
+
+        set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${_p_VAR} ${CMAKE_REQUIRED_FLAGS}")
+
+        set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
+        if(CMAKE_REQUIRED_LIBRARIES)
+            list( APPEND __add_libs ${CMAKE_REQUIRED_LIBRARIES} )
+        endif()
+        if( _p_LIBS )
+            list( APPEND __add_libs ${_p_LIBS} )
+        endif()
+        if( __add_libs )
+            set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${__add_libs}")
+        endif()
+
+        set(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES)
+        if(CMAKE_REQUIRED_INCLUDES)
+            list( APPEND __add_incs ${CMAKE_REQUIRED_INCLUDES} )
+        endif()
+        if( _p_INCLUDES )
+            list( APPEND __add_incs ${_p_INCLUDES} )
+        endif()
+        if( __add_incs )
+            set(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
+        endif()
+
+        # write the source file
+
+        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_p_VAR}.cxx" "${SOURCE}\n" )
+
+        message( STATUS "${_msg}" )
+        try_run( ${_p_VAR}_EXITCODE ${_p_VAR}_COMPILED
+          ${CMAKE_BINARY_DIR}
+          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_p_VAR}.cxx
+          COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+          CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+          -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
+          "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}"
+          "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
+          COMPILE_OUTPUT_VARIABLE compile_OUTPUT
+          RUN_OUTPUT_VARIABLE     run_OUTPUT )
+
+        # ecbuild_debug_var( ${_p_VAR}_COMPILED )
+        # ecbuild_debug_var( ${_p_VAR}_EXITCODE )
+
+        # if it did not compile make the return value fail code of 1
+
+        if( NOT ${_p_VAR}_COMPILED )
+          message( STATUS "${_msg} failed to compile" )
+        endif()
+
+        if( "${${_p_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN" )
+          message( STATUS "${_msg} failed to run" )
+        endif()
+
+        # if the return value was 0 then it worked
+        if( ${_p_VAR}_COMPILED AND "${${_p_VAR}_EXITCODE}" EQUAL 0 )
+
+          message(STATUS "${_msg} Success")
+          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+            "Performing C++ SOURCE FILE Test ${_p_VAR} succeded with the following compile output:\n"
+            "${compile_OUTPUT}\n"
+            "Performing C++ SOURCE FILE Run ${_p_VAR} succeded with the following run output:\n"
+            "${run_OUTPUT}\n"
+            "Return value: ${${_p_VAR}}\n"
+            "Source file was:\n${SOURCE}\n")
+
+          set( ${_p_VAR}     1              CACHE INTERNAL "Test ${_p_VAR}")
+          set( ${_p_OUTPUT} "${run_OUTPUT}" CACHE INTERNAL "Test ${_p_VAR} output")
+
+        else()
+
+          if(CMAKE_CROSSCOMPILING AND "${${_p_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
+            set(${_p_VAR} "${${_p_VAR}_EXITCODE}")
+            set(${OUTPUT} "")
+          else()
+            set(${_p_VAR} "" CACHE INTERNAL "Test ${_p_VAR}")
+            set(${_p_OUTPUT} "" CACHE INTERNAL "Test ${_p_VAR} output")
+          endif()
+
+          message(STATUS "Test ${_p_VAR} - Failed")
+          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+            "Performing C++ SOURCE FILE Test ${_p_VAR} failed with the following compile output:\n"
+            "${compile_OUTPUT}\n"
+            "Performing C++ SOURCE FILE Run ${_p_VAR} failed with the following run output:\n"
+            "${run_OUTPUT}\n"
+            "Return value: ${${_p_VAR}_EXITCODE}\n"
+            "Source file was:\n${SOURCE}\n")
+        endif()
+
+    endif()
+
+endmacro()
diff --git a/cmake/ecbuild_check_fortran_source.cmake b/cmake/ecbuild_check_fortran_source.cmake
deleted file mode 100644
index da04a70..0000000
--- a/cmake/ecbuild_check_fortran_source.cmake
+++ /dev/null
@@ -1,157 +0,0 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
-# This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
-# granted to it by virtue of its status as an intergovernmental organisation nor
-# does it submit to any jurisdiction.
-
-##############################################################################
-# macro that runs the given Fortran code and returns its output
-
-macro( ecbuild_check_fortran_source_return SOURCE )
-
-    message( WARNING "This macro ecbuild_check_fortran_source has never been tested" )
-    set( options )
-    set( single_value_args VAR  OUTPUT )
-    set( multi_value_args  INCLUDES LIBS DEFINITIONS )
-
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if(_PAR_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_check_fortran_source_return(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-    endif()
-
-    if( NOT _PAR_VAR OR NOT _PAR_OUTPUT )
-      message(FATAL_ERROR "The call to ecbuild_check_fortran_source_return() doesn't specify either SOURCE, VAR or OUTPUT")
-    endif()
-
-
-    if( NOT DEFINED ${_PAR_VAR} )
-
-        set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${_PAR_VAR} ${CMAKE_REQUIRED_FLAGS}")
-
-        set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES)
-        if( CMAKE_REQUIRED_LIBRARIES )
-            list( APPEND __add_libs ${CMAKE_REQUIRED_LIBRARIES} )
-        endif()
-        if( _PAR_LIBS )
-            list( APPEND __add_libs ${_PAR_LIBS} )
-        endif()
-        if( __add_libs )
-            set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${__add_libs}")
-        endif()
-
-        set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES)
-        if( CMAKE_REQUIRED_INCLUDES )
-            list( APPEND __add_incs ${CMAKE_REQUIRED_INCLUDES} )
-        endif()
-        if( _PAR_INCLUDES )
-            list( APPEND __add_incs ${_PAR_INCLUDES} )
-        endif()
-        if( __add_libs )
-            set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
-        endif()
-    
-        # write the source file
-    
-        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.f" "${SOURCE}\n" )
-
-        message( STATUS "Performing Test ${_PAR_VAR}" )
-        try_run( ${_PAR_VAR}_EXITCODE ${_PAR_VAR}_COMPILED
-          ${CMAKE_BINARY_DIR}
-          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.f
-          COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-          CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-          -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
-          "${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}"
-          "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
-          COMPILE_OUTPUT_VARIABLE compile_OUTPUT 
-          RUN_OUTPUT_VARIABLE     run_OUTPUT )
-    
-        # if it did not compile make the return value fail code of 1
-        if( NOT ${_PAR_VAR}_COMPILED )
-          set( ${_PAR_VAR}_EXITCODE 1 )
-        endif()
-    
-        # if the return value was 0 then it worked
-        if("${${_PAR_VAR}_EXITCODE}" EQUAL 0)
-    
-          message(STATUS "Performing Test ${_PAR_VAR} - Success")
-          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
-            "Performing Fortran SOURCE FILE Test ${_PAR_VAR} succeded with the following compile output:\n"
-            "${compile_OUTPUT}\n" 
-            "Performing Fortran SOURCE FILE Run ${_PAR_VAR} succeded with the following run output:\n"
-            "${run_OUTPUT}\n" 
-            "Return value: ${${_PAR_VAR}}\n"
-            "Source file was:\n${SOURCE}\n")
-
-          set( ${_PAR_VAR}     1              CACHE INTERNAL "Test ${_PAR_VAR}")
-          set( ${_PAR_OUTPUT} "${run_OUTPUT}" CACHE INTERNAL "Test ${_PAR_VAR} output")
-    
-        else()
-    
-          if(CMAKE_CROSSCOMPILING AND "${${_PAR_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
-            set(${_PAR_VAR} "${${_PAR_VAR}_EXITCODE}")
-            set(${OUTPUT} "")
-          else()
-            set(${_PAR_VAR} "" CACHE INTERNAL "Test ${_PAR_VAR}")
-            set(${_PAR_OUTPUT} "" CACHE INTERNAL "Test ${_PAR_VAR} output")
-          endif()
-    
-          message(STATUS "Performing Test ${_PAR_VAR} - Failed")
-          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
-            "Performing C SOURCE FILE Test ${_PAR_VAR} failed with the following compile output:\n"
-            "${compile_OUTPUT}\n" 
-            "Performing C SOURCE FILE Run ${_PAR_VAR} failed with the following run output:\n"
-            "${run_OUTPUT}\n" 
-            "Return value: ${${_PAR_VAR}_EXITCODE}\n"
-            "Source file was:\n${SOURCE}\n")
-        endif()
-    
-    endif()
-
-endmacro()
-
-##############################################################################
-# macro that only adds a Fortran flag if compiler supports it
-
-include( CheckFortranCompilerFlag )
-macro( cmake_add_fortran_flags m_fortran_flags )
-
-  set( _flags ${m_fortran_flags} )
-
-  if( _flags AND CMAKE_Fortran_COMPILER_LOADED )
-
-    set( options )
-    set( single_value_args BUILD )
-    set( multi_value_args )
-
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if( NOT DEFINED N_FortranFLAG )
-      set( N_FortranFLAG 0 )
-    endif()
-
-    math( EXPR N_FortranFLAG '${N_FortranFLAG}+1' )
-
-    if( NOT ECBUILD_TRUST_FLAGS )
-      check_fortran_compiler_flag( ${_flags} Fortran_FLAG_TEST_${N_FortranFLAG} )
-    endif()
-
-    if( Fortran_FLAG_TEST_${N_FortranFLAG} OR ECBUILD_TRUST_FLAGS )
-      if( _PAR_BUILD )
-        set( CMAKE_Fortran_FLAGS_${_PAR_BUILD} "${CMAKE_Fortran_FLAGS_${_PAR_BUILD}} ${_flags}" )
-      else()
-        set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${_flags}" )
-        # message( STATUS "Fortran FLAG [${_flags}] added" )
-      endif()
-    else()
-      message( STATUS "Unrecognised Fortran flag [${_flags}] -- skipping" )
-    endif()
-  endif()
-
-  unset( _flags )
-
-endmacro()
-
diff --git a/cmake/ecbuild_check_fortran_source_return.cmake b/cmake/ecbuild_check_fortran_source_return.cmake
new file mode 100644
index 0000000..1c50896
--- /dev/null
+++ b/cmake/ecbuild_check_fortran_source_return.cmake
@@ -0,0 +1,155 @@
+# (C) Copyright 1996-2015 ECMWF.
+# 
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# In applying this licence, ECMWF does not waive the privileges and immunities 
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_check_fortran_source_return
+# ===================================
+#
+# Compile and run a given Fortran code and return its output. ::
+#
+#   ecbuild_check_fortran_source_return( <source>
+#                                        VAR <name>
+#                                        OUTPUT <name>
+#                                        [ INCLUDES <path1> [ <path2> ... ] ]
+#                                        [ LIBS <library1> [ <library2> ... ] ]
+#                                        [ DEFINITIONS <def1> [ <def2> ... ] ] )
+#
+# Options
+# -------
+#
+# VAR : required
+#   name of the check and name of the CMake variable to write result to
+#
+# OUTPUT : required
+#   name of CMake variable to write the output to
+#
+# INCLUDES : optional
+#   list of paths to add to include directories
+#
+# LIBS : optional
+#   list of libraries to link against (CMake targets or external libraries)
+#
+# DEFINITIONS : optional
+#   list of definitions to add to preprocessor defines
+#
+# Usage
+# -----
+#
+# This will write the given source to a .f file and compile and run it with
+# try_run. If successful, ``${VAR}`` is set to 1 and ``${OUTPUT}`` is set to
+# the output of the successful run in the CMake cache.
+#
+# The check will not run if ``${VAR}`` is defined (e.g. from ecBuild cache).
+#
+##############################################################################
+
+macro( ecbuild_check_fortran_source_return SOURCE )
+
+    message( WARNING "This macro ecbuild_check_fortran_source has never been tested" )
+    set( options )
+    set( single_value_args VAR  OUTPUT )
+    set( multi_value_args  INCLUDES LIBS DEFINITIONS )
+
+    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if(_PAR_UNPARSED_ARGUMENTS)
+      message(FATAL_ERROR "Unknown keywords given to ecbuild_check_fortran_source_return(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+    endif()
+
+    if( NOT _PAR_VAR OR NOT _PAR_OUTPUT )
+      message(FATAL_ERROR "The call to ecbuild_check_fortran_source_return() doesn't specify either SOURCE, VAR or OUTPUT")
+    endif()
+
+
+    if( NOT DEFINED ${_PAR_VAR} )
+
+        set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${_PAR_VAR} ${CMAKE_REQUIRED_FLAGS}")
+
+        set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES)
+        if( CMAKE_REQUIRED_LIBRARIES )
+            list( APPEND __add_libs ${CMAKE_REQUIRED_LIBRARIES} )
+        endif()
+        if( _PAR_LIBS )
+            list( APPEND __add_libs ${_PAR_LIBS} )
+        endif()
+        if( __add_libs )
+            set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${__add_libs}")
+        endif()
+
+        set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES)
+        if( CMAKE_REQUIRED_INCLUDES )
+            list( APPEND __add_incs ${CMAKE_REQUIRED_INCLUDES} )
+        endif()
+        if( _PAR_INCLUDES )
+            list( APPEND __add_incs ${_PAR_INCLUDES} )
+        endif()
+        if( __add_libs )
+            set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
+        endif()
+    
+        # write the source file
+    
+        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.f" "${SOURCE}\n" )
+
+        message( STATUS "Performing Test ${_PAR_VAR}" )
+        try_run( ${_PAR_VAR}_EXITCODE ${_PAR_VAR}_COMPILED
+          ${CMAKE_BINARY_DIR}
+          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.f
+          COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+          CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+          -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
+          "${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}"
+          "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
+          COMPILE_OUTPUT_VARIABLE compile_OUTPUT 
+          RUN_OUTPUT_VARIABLE     run_OUTPUT )
+    
+        # if it did not compile make the return value fail code of 1
+        if( NOT ${_PAR_VAR}_COMPILED )
+          set( ${_PAR_VAR}_EXITCODE 1 )
+        endif()
+    
+        # if the return value was 0 then it worked
+        if("${${_PAR_VAR}_EXITCODE}" EQUAL 0)
+    
+          message(STATUS "Performing Test ${_PAR_VAR} - Success")
+          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+            "Performing Fortran SOURCE FILE Test ${_PAR_VAR} succeded with the following compile output:\n"
+            "${compile_OUTPUT}\n" 
+            "Performing Fortran SOURCE FILE Run ${_PAR_VAR} succeded with the following run output:\n"
+            "${run_OUTPUT}\n" 
+            "Return value: ${${_PAR_VAR}}\n"
+            "Source file was:\n${SOURCE}\n")
+
+          set( ${_PAR_VAR}     1              CACHE INTERNAL "Test ${_PAR_VAR}")
+          set( ${_PAR_OUTPUT} "${run_OUTPUT}" CACHE INTERNAL "Test ${_PAR_VAR} output")
+    
+        else()
+    
+          if(CMAKE_CROSSCOMPILING AND "${${_PAR_VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
+            set(${_PAR_VAR} "${${_PAR_VAR}_EXITCODE}")
+            set(${OUTPUT} "")
+          else()
+            set(${_PAR_VAR} "" CACHE INTERNAL "Test ${_PAR_VAR}")
+            set(${_PAR_OUTPUT} "" CACHE INTERNAL "Test ${_PAR_VAR} output")
+          endif()
+    
+          message(STATUS "Performing Test ${_PAR_VAR} - Failed")
+          file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+            "Performing C SOURCE FILE Test ${_PAR_VAR} failed with the following compile output:\n"
+            "${compile_OUTPUT}\n" 
+            "Performing C SOURCE FILE Run ${_PAR_VAR} failed with the following run output:\n"
+            "${run_OUTPUT}\n" 
+            "Return value: ${${_PAR_VAR}_EXITCODE}\n"
+            "Source file was:\n${SOURCE}\n")
+        endif()
+    
+    endif()
+
+endmacro()
diff --git a/cmake/ecbuild_check_functions.cmake b/cmake/ecbuild_check_functions.cmake
index 0369797..25f9d62 100644
--- a/cmake/ecbuild_check_functions.cmake
+++ b/cmake/ecbuild_check_functions.cmake
@@ -1,8 +1,8 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
@@ -73,10 +73,10 @@ if( ENABLE_OS_FUNCTIONS_TEST )
     ecbuild_cache_check_c_source_compiles( "#define _LARGEFILE64_SOURCE\n#include <sys/stat.h>\nint main(){ struct stat64 s; fstat64(1,&s); return 0; }" EC_HAVE_FSTAT64 )
     # test fseeko64
     ecbuild_cache_check_c_source_compiles( "#define _LARGEFILE64_SOURCE\n#include <stdio.h>\n#include <sys/types.h>\nint main(){FILE* file;off64_t l=0;fseeko64(file,l,SEEK_CUR);return 0;}\n" EC_HAVE_FSEEKO64 )
-   
+
     # test for ftello64
     ecbuild_cache_check_c_source_compiles( "#define _LARGEFILE64_SOURCE\n#include <stdio.h>\n#include <sys/types.h>\nint main(){FILE* file;off64_t l = ftello64(file);return 0;}\n"  EC_HAVE_FTELLO64 )
-    
+
     # test for lseek64
     ecbuild_cache_check_c_source_compiles( "#define _LARGEFILE64_SOURCE\n#include <sys/types.h>\n#include <unistd.h>\nint main(){off64_t h = lseek64(0,0,SEEK_SET);return 0;}\n"  EC_HAVE_LSEEK64 )
     # test for open64
@@ -114,7 +114,7 @@ if( ENABLE_OS_FUNCTIONS_TEST )
     # test for getpwuid_r
     ecbuild_cache_check_c_source_compiles( "#include <unistd.h>\n#include <sys/types.h>\n#include <pwd.h>\nint main(){ char buf[4096]; struct passwd pwbuf; struct passwd *pwbufp = 0; getpwuid_r(getuid(), &pwbuf, buf, sizeof(buf), &pwbufp); }\n" EC_HAVE_GETPWUID_R )
     # test for getpwnam_r
-    ecbuild_cache_check_c_source_compiles( "#include <sys/types.h>\n#include <pwd.h>\nint main(){ struct passwd p; char line[1024]; int n = getpwnam_r(\"user\",&p,line,sizeof(line),0); }\n" EC_HAVE_GETPWNAM_R )    
+    ecbuild_cache_check_c_source_compiles( "#include <sys/types.h>\n#include <pwd.h>\nint main(){ struct passwd p; char line[1024]; int n = getpwnam_r(\"user\",&p,line,sizeof(line),0); }\n" EC_HAVE_GETPWNAM_R )
     # test for readdir_r
     ecbuild_cache_check_c_source_compiles( "#include <dirent.h>\nint main(){ DIR *dirp; struct dirent *entry; struct dirent **result; int i = readdir_r(dirp, entry, result); }\n" EC_HAVE_READDIR_R )
     # test for gethostbyname_r
@@ -164,8 +164,8 @@ if( ENABLE_OS_FUNCTIONS_TEST )
     endif()
     ecbuild_cache_var( EC_HAVE_PROCFS )
 
-#    debug_var(EC_HAVE_PROCFS)
-#    debug_var(EC_HAVE_PROCFS_OUTPUT)
+#    ecbuild_debug_var(EC_HAVE_PROCFS)
+#    ecbuild_debug_var(EC_HAVE_PROCFS_OUTPUT)
 
 endif()
 
diff --git a/cmake/ecbuild_check_os.cmake b/cmake/ecbuild_check_os.cmake
index 8373c4a..942fb6b 100644
--- a/cmake/ecbuild_check_os.cmake
+++ b/cmake/ecbuild_check_os.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -181,6 +181,35 @@ if( ENABLE_OS_ENDINESS_TEST )
 endif()
 
 ############################################################################################
+# enable profiling
+
+if( ENABLE_PROFILING )
+
+  if( CMAKE_C_COMPILER_ID MATCHES "GNU" )
+
+    set( _flags "-pg --coverage" )
+
+    set( CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} ${_flags}" )
+    set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${_flags}" )
+    set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${_flags}" )
+
+    set( _trust_flags ${ECBUILD_TRUST_FLAGS} )
+    set( ECBUILD_TRUST_FLAGS ON )
+    ecbuild_add_c_flags( "${_flags}" )
+    ecbuild_add_cxx_flags( "${_flags}" )
+    ecbuild_add_fortran_flags( "${_flags}" )
+    set( ECBUILD_TRUST_FLAGS ${_trust_flags} )
+    unset( _trust_flags )
+
+    unset( _flags )
+  
+  else()
+    message( WARNING "Profiling enabled but ecbuild doesn't know how to enable for this particular compiler ${CMAKE_C_COMPILER_ID}")
+  endif()
+
+endif()
+
+############################################################################################
 # check operating system
 
 set( EC_OS_NAME "UNKNOWN" )
@@ -237,78 +266,78 @@ if( UNIX )
 
 		if( CMAKE_COMPILER_IS_GNUCC )
 			if( EC_OS_BITS EQUAL "64" )
-				cmake_add_c_flags("-maix64")
+				ecbuild_add_c_flags("-maix64")
 			endif()
 			if( EC_OS_BITS EQUAL "32" )
-				cmake_add_c_flags("-maix32")
+				ecbuild_add_c_flags("-maix32")
 			endif()
 		endif()
 
 		if( CMAKE_COMPILER_IS_GNUCXX )
 			if( EC_OS_BITS EQUAL "64" )
-				cmake_add_cxx_flags("-maix64")
+				ecbuild_add_cxx_flags("-maix64")
 			endif()
 			if( EC_OS_BITS EQUAL "32" )
-				cmake_add_cxx_flags("-maix32")
+				ecbuild_add_cxx_flags("-maix32")
 			endif()
 		endif()
 
 		if( CMAKE_C_COMPILER_ID MATCHES "XL" )
 
-			cmake_add_c_flags("-qpic=large")
-#            cmake_add_c_flags("-qweaksymbol")
+			ecbuild_add_c_flags("-qpic=large")
+#            ecbuild_add_c_flags("-qweaksymbol")
 
 			if(EC_OS_BITS EQUAL "32" )
-				cmake_add_c_flags("-q32")
+				ecbuild_add_c_flags("-q32")
 			endif()
 
 			if(${CMAKE_BUILD_TYPE} MATCHES "Release" OR ${CMAKE_BUILD_TYPE} MATCHES "Production" )
-					cmake_add_c_flags("-qstrict")
-					cmake_add_c_flags("-qinline")
+					ecbuild_add_c_flags("-qstrict")
+					ecbuild_add_c_flags("-qinline")
 			endif()
 
 			if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
-					cmake_add_c_flags("-qfullpath")
-					cmake_add_c_flags("-qkeepparm")
+					ecbuild_add_c_flags("-qfullpath")
+					ecbuild_add_c_flags("-qkeepparm")
 			endif()
 
 		endif()
 
 		if( CMAKE_CXX_COMPILER_ID MATCHES "XL" )
 
-			cmake_add_cxx_flags("-qpic=large")
-			cmake_add_cxx_flags("-bmaxdata:0x40000000")
-			cmake_add_cxx_flags("-qrtti")
-			cmake_add_cxx_flags("-qfuncsect")
+			ecbuild_add_cxx_flags("-qpic=large")
+			ecbuild_add_cxx_flags("-bmaxdata:0x40000000")
+			ecbuild_add_cxx_flags("-qrtti")
+			ecbuild_add_cxx_flags("-qfuncsect")
 
-#           cmake_add_cxx_flags("-qweaksymbol")
+#           ecbuild_add_cxx_flags("-qweaksymbol")
 
 			if(EC_OS_BITS EQUAL "32" )
-				cmake_add_cxx_flags("-q32")
+				ecbuild_add_cxx_flags("-q32")
 			endif()
 
 			if(${CMAKE_BUILD_TYPE} MATCHES "Release" OR ${CMAKE_BUILD_TYPE} MATCHES "Production" )
-					cmake_add_cxx_flags("-qstrict")
-					cmake_add_cxx_flags("-qinline")
+					ecbuild_add_cxx_flags("-qstrict")
+					ecbuild_add_cxx_flags("-qinline")
 			endif()
 
 			if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
-					cmake_add_cxx_flags("-qfullpath")
-					cmake_add_cxx_flags("-qkeepparm")
+					ecbuild_add_cxx_flags("-qfullpath")
+					ecbuild_add_cxx_flags("-qkeepparm")
 			endif()
 
 		endif()
 
 		if( CMAKE_Fortran_COMPILER_ID MATCHES "XL" )
 
-			cmake_add_fortran_flags("-qxflag=dealloc_cfptr")
-			cmake_add_fortran_flags("-qextname")
-			cmake_add_fortran_flags("-qdpc=e")
-			cmake_add_fortran_flags("-bmaxdata:0x40000000")
-			cmake_add_fortran_flags("-bloadmap:loadmap -bmap:loadmap")
+			ecbuild_add_fortran_flags("-qxflag=dealloc_cfptr")
+			ecbuild_add_fortran_flags("-qextname")
+			ecbuild_add_fortran_flags("-qdpc=e")
+			ecbuild_add_fortran_flags("-bmaxdata:0x40000000")
+			ecbuild_add_fortran_flags("-bloadmap:loadmap -bmap:loadmap")
 
 			if(EC_OS_BITS EQUAL "32" )
-				cmake_add_fortran_flags("-q32")
+				ecbuild_add_fortran_flags("-q32")
 			endif()
 		endif()
 
@@ -338,5 +367,3 @@ if( ${EC_OS_NAME} MATCHES "UNKNOWN" )
 	endif()
 
 endif()
-
-
diff --git a/cmake/ecbuild_config.h.in b/cmake/ecbuild_config.h.in
index 68d31f8..2a01618 100644
--- a/cmake/ecbuild_config.h.in
+++ b/cmake/ecbuild_config.h.in
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 1996-2014 ECMWF.
+ * (C) Copyright 1996-2015 ECMWF.
  *
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/ecbuild_debug_var.cmake b/cmake/ecbuild_debug_var.cmake
deleted file mode 100644
index 7084c7c..0000000
--- a/cmake/ecbuild_debug_var.cmake
+++ /dev/null
@@ -1,47 +0,0 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
-# This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
-# granted to it by virtue of its status as an intergovernmental organisation nor
-# does it submit to any jurisdiction.
-
-##############################################################################
-# macro for exporting a variable to parent scope
-
-macro( set_parent_scope VAR )
-
-	set( ${VAR} ${${VAR}} PARENT_SCOPE )
-
-endmacro( set_parent_scope )
-
-##############################################################################
-# macro for debugging a cmake variable
-
-macro( debug_var VAR )
-
-    message( STATUS "${VAR} [${${VAR}}]" )
-
-endmacro( debug_var )
-
-##############################################################################
-# macro for debugging a cmake list
-
-macro( debug_list VAR )
-
-    message( STATUS "${VAR}:" )
-    foreach( _elem ${${VAR}} )
-      message( STATUS "  ${_elem}" )
-    endforeach()
-
-endmacro( debug_list )
-
-##############################################################################
-# macro for debugging a environment variable within cmake
-
-macro( debug_env_var VAR )
-
-    message( STATUS "ENV ${VAR} [$ENV{${VAR}}]" )
-
-endmacro( debug_env_var )
-
diff --git a/cmake/ecbuild_declare_project.cmake b/cmake/ecbuild_declare_project.cmake
index fa6286c..23e835d 100644
--- a/cmake/ecbuild_declare_project.cmake
+++ b/cmake/ecbuild_declare_project.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,140 +6,188 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-# macro to initialize a project
+##############################################################################
+#.rst:
+#
+# ecbuild_declare_project
+# =======================
+#
+# Initialise an ecBuild project. A CMake project must have previously been
+# declared with ``project( <name> ... )``. ::
+#
+#   ecbuild_declare_project()
+#
+# Sets the following CMake variables
+# (where ``PNAME`` is the capitalised project name):
+#
+# :<PNAME>_GIT_SHA1:       Git revision (if project is a Git repo)
+# :<PNAME>_GIT_SHA1_SHORT: short Git revision (if project is a Git repo)
+# :<PNAME>_VERSION:        version in format ``MAJOR.MINOR.PATCH``
+# :<PNAME>_VERSION_STR:    version as given in ``VERSION.cmake`` or 0.0.0
+# :<PNAME>_MAJOR_VERSION:  major version number
+# :<PNAME>_MINOR_VERSION:  minor version number
+# :<PNAME>_PATCH_VERSION:  patch version number
+# :INSTALL_BIN_DIR:        relative install directory for executables
+#                          (default: ``bin``)
+# :INSTALL_LIB_DIR:        relative install directory for libraries
+#                          (default: ``lib``)
+# :INSTALL_INCLUDE_DIR:    relative install directory for include files
+#                          (default: ``include``)
+# :INSTALL_DATA_DIR:       relative install directory for data
+#                          (default: ``share/<project_name>``)
+# :INSTALL_CMAKE_DIR:      relative install directory for CMake files
+#                          (default: ``share/<project_name>/cmake``)
+#
+# The relative installation directories of components can be customised by
+# setting the following CMake variables on the command line or in cache:
+#
+# :<PNAME>_INSTALL_BIN_DIR:     directory for installing executables
+# :<PNAME>_INSTALL_LIB_DIR:     directory for installing libraries
+# :<PNAME>_INSTALL_INCLUDE_DIR: directory for installing include files
+# :<PNAME>_INSTALL_DATA_DIR:    directory for installing data
+# :<PNAME>_INSTALL_CMAKE_DIR:   directory for installing CMake files
+#
+# Using *relative* paths is recommended, which are interpreted relative to the
+# ``CMAKE_INSTALL_PREFIX``. Using absolute paths makes the build
+# non-relocatable and may break the generation of relocatable binary packages.
+#
+##############################################################################
 
 macro( ecbuild_declare_project )
 
-	string( TOUPPER ${PROJECT_NAME} PNAME )
+  string( TOUPPER ${PROJECT_NAME} PNAME )
 
-	# reset the lists of targets (executables, libs, tests & resources)
+  # reset the lists of targets (executables, libs, tests & resources)
 
-	set( ${PROJECT_NAME}_ALL_EXES "" CACHE INTERNAL "" )
-	set( ${PROJECT_NAME}_ALL_LIBS "" CACHE INTERNAL "" )
+  set( ${PROJECT_NAME}_ALL_EXES "" CACHE INTERNAL "" )
+  set( ${PROJECT_NAME}_ALL_LIBS "" CACHE INTERNAL "" )
 
-	# if git project get its HEAD SHA1
-	# leave it here so we may use ${PNAME}_GIT_SHA1 on the version file
+  # if git project get its HEAD SHA1
+  # leave it here so we may use ${PNAME}_GIT_SHA1 on the version file
 
-	if( EXISTS ${PROJECT_SOURCE_DIR}/.git )
-		get_git_head_revision( GIT_REFSPEC ${PNAME}_GIT_SHA1 )
-		if( ${PNAME}_GIT_SHA1 )
-		  string( SUBSTRING "${${PNAME}_GIT_SHA1}" 0 7 ${PNAME}_GIT_SHA1_SHORT )
-#		  debug_var( ${PNAME}_GIT_SHA1 )
-#		  debug_var( ${PNAME}_GIT_SHA1_SHORT )
-        else()
-          message( STATUS "Could not get git-sha1 for project ${PNAME}")
-        endif()
-	endif()
+  if( EXISTS ${PROJECT_SOURCE_DIR}/.git )
+    get_git_head_revision( GIT_REFSPEC ${PNAME}_GIT_SHA1 )
+    if( ${PNAME}_GIT_SHA1 )
+      string( SUBSTRING "${${PNAME}_GIT_SHA1}" 0 7 ${PNAME}_GIT_SHA1_SHORT )
+      #     ecbuild_debug_var( ${PNAME}_GIT_SHA1 )
+      #     ecbuild_debug_var( ${PNAME}_GIT_SHA1_SHORT )
+    else()
+      message( STATUS "Could not get git-sha1 for project ${PNAME}")
+    endif()
+  endif()
 
-	# read and parse project version file
-	if( EXISTS ${PROJECT_SOURCE_DIR}/VERSION.cmake )
-		include( ${PROJECT_SOURCE_DIR}/VERSION.cmake )
-	else()
-		set( ${PROJECT_NAME}_VERSION_STR "0.0.0" )
-	endif()
+  # read and parse project version file
+  if( EXISTS ${PROJECT_SOURCE_DIR}/VERSION.cmake )
+    include( ${PROJECT_SOURCE_DIR}/VERSION.cmake )
+  else()
+    set( ${PROJECT_NAME}_VERSION_STR "0.0.0" )
+  endif()
 
-	string( REPLACE "." " " _version_list ${${PROJECT_NAME}_VERSION_STR} ) # dots to spaces
+  string( REPLACE "." " " _version_list ${${PROJECT_NAME}_VERSION_STR} ) # dots to spaces
 
-	separate_arguments( _version_list )
+  separate_arguments( _version_list )
 
-	list( GET _version_list 0 ${PNAME}_MAJOR_VERSION )
-	list( GET _version_list 1 ${PNAME}_MINOR_VERSION )
-	list( GET _version_list 2 ${PNAME}_PATCH_VERSION )
+  list( GET _version_list 0 ${PNAME}_MAJOR_VERSION )
+  list( GET _version_list 1 ${PNAME}_MINOR_VERSION )
+  list( GET _version_list 2 ${PNAME}_PATCH_VERSION )
 
-	# cleanup patch version of any extra qualifiers ( -dev -rc1 ... )
+  # cleanup patch version of any extra qualifiers ( -dev -rc1 ... )
 
-	string( REGEX REPLACE "^([0-9]+).*" "\\1" ${PNAME}_PATCH_VERSION "${${PNAME}_PATCH_VERSION}" )
+  string( REGEX REPLACE "^([0-9]+).*" "\\1" ${PNAME}_PATCH_VERSION "${${PNAME}_PATCH_VERSION}" )
 
-	set( ${PNAME}_VERSION "${${PNAME}_MAJOR_VERSION}.${${PNAME}_MINOR_VERSION}.${${PNAME}_PATCH_VERSION}" CACHE INTERNAL "package ${PNAME} version" )
+  set( ${PNAME}_VERSION "${${PNAME}_MAJOR_VERSION}.${${PNAME}_MINOR_VERSION}.${${PNAME}_PATCH_VERSION}"
+       CACHE INTERNAL "package ${PNAME} version" )
 
-	set( ${PNAME}_VERSION_STR "${${PROJECT_NAME}_VERSION_STR}" CACHE INTERNAL "package ${PNAME} version string" ) # ignore caps
+  set( ${PNAME}_VERSION_STR "${${PROJECT_NAME}_VERSION_STR}"
+       CACHE INTERNAL "package ${PNAME} version string" ) # ignore caps
 
-#    debug_var( ${PNAME}_VERSION )
-#    debug_var( ${PNAME}_VERSION_STR )
-#    debug_var( ${PNAME}_MAJOR_VERSION )
-#    debug_var( ${PNAME}_MINOR_VERSION )
-#    debug_var( ${PNAME}_PATCH_VERSION )
+  #    ecbuild_debug_var( ${PNAME}_VERSION )
+  #    ecbuild_debug_var( ${PNAME}_VERSION_STR )
+  #    ecbuild_debug_var( ${PNAME}_MAJOR_VERSION )
+  #    ecbuild_debug_var( ${PNAME}_MINOR_VERSION )
+  #    ecbuild_debug_var( ${PNAME}_PATCH_VERSION )
 
-	# install dirs for this project
+  # install dirs for this project
 
-	set( INSTALL_BIN_DIR bin )
-	set( INSTALL_LIB_DIR lib )
-    set( INSTALL_INCLUDE_DIR include )
-	set( INSTALL_DATA_DIR share/${PROJECT_NAME} )
-	set( INSTALL_CMAKE_DIR share/${PROJECT_NAME}/cmake )
+  set( INSTALL_BIN_DIR bin )
+  set( INSTALL_LIB_DIR lib )
+  set( INSTALL_INCLUDE_DIR include )
+  set( INSTALL_DATA_DIR share/${PROJECT_NAME} )
+  set( INSTALL_CMAKE_DIR share/${PROJECT_NAME}/cmake )
 
-	mark_as_advanced( INSTALL_BIN_DIR )
-	mark_as_advanced( INSTALL_LIB_DIR )
-	mark_as_advanced( INSTALL_INCLUDE_DIR )
-	mark_as_advanced( INSTALL_DATA_DIR )
-	mark_as_advanced( INSTALL_CMAKE_DIR )
+  mark_as_advanced( INSTALL_BIN_DIR )
+  mark_as_advanced( INSTALL_LIB_DIR )
+  mark_as_advanced( INSTALL_INCLUDE_DIR )
+  mark_as_advanced( INSTALL_DATA_DIR )
+  mark_as_advanced( INSTALL_CMAKE_DIR )
 
-	# overrides of install dirs
+  # overrides of install dirs
 
-	foreach( p LIB BIN INCLUDE DATA CMAKE )
-		if( ${PNAME}_INSTALL_${p}_DIR )
-			set( INSTALL_${p}_DIR ${${PNAME}_INSTALL_${p}_DIR} )
-		endif()
-	endforeach()
+  foreach( p LIB BIN INCLUDE DATA CMAKE )
+    if( ${PNAME}_INSTALL_${p}_DIR )
+      set( INSTALL_${p}_DIR ${${PNAME}_INSTALL_${p}_DIR} )
+    endif()
+  endforeach()
 
-	# warnings for non-relocatable projects
+  # warnings for non-relocatable projects
 
-	foreach( p LIB BIN INCLUDE DATA CMAKE )
-		if( IS_ABSOLUTE ${INSTALL_${p}_DIR} )
-			message( WARNING "Defining INSTALL_${p}_DIR as absolute path '${INSTALL_${p}_DIR}' makes this build non-relocatable, possibly breaking the installation of RPMS and DEB packages" )
-		endif()
-	endforeach()
+  foreach( p LIB BIN INCLUDE DATA CMAKE )
+    if( IS_ABSOLUTE ${INSTALL_${p}_DIR} )
+      message( WARNING "Defining INSTALL_${p}_DIR as absolute path '${INSTALL_${p}_DIR}' makes this build non-relocatable, possibly breaking the installation of RPMS and DEB packages" )
+    endif()
+  endforeach()
 
-	# make relative paths absolute ( needed later on ) and cache them ...
-	foreach( p LIB BIN INCLUDE DATA CMAKE )
+  # make relative paths absolute ( needed later on ) and cache them ...
+  foreach( p LIB BIN INCLUDE DATA CMAKE )
 
-		set( var INSTALL_${p}_DIR )
+    set( var INSTALL_${p}_DIR )
 
-		if( NOT IS_ABSOLUTE "${${var}}" )
-			set( ${PNAME}_FULL_INSTALL_${p}_DIR "${CMAKE_INSTALL_PREFIX}/${${var}}" CACHE INTERNAL "${PNAME} ${p} full install path" )
-		else()
-			message( WARNING "Setting an absolute path for ${VAR} in project ${PNAME}, breakes generation of relocatable binary packages (rpm,deb,...)" )
-			set( ${PNAME}_FULL_INSTALL_${p}_DIR "${${var}}" CACHE INTERNAL "${PNAME} ${p} full install path" )
-		endif()
+    if( NOT IS_ABSOLUTE "${${var}}" )
+      set( ${PNAME}_FULL_INSTALL_${p}_DIR "${CMAKE_INSTALL_PREFIX}/${${var}}"
+           CACHE INTERNAL "${PNAME} ${p} full install path" )
+    else()
+      message( WARNING "Setting an absolute path for ${VAR} in project ${PNAME}, breakes generation of relocatable binary packages (rpm,deb,...)" )
+      set( ${PNAME}_FULL_INSTALL_${p}_DIR "${${var}}"
+           CACHE INTERNAL "${PNAME} ${p} full install path" )
+    endif()
 
-#        debug_var( ${PNAME}_FULL_INSTALL_${p}_DIR )
+    #        ecbuild_debug_var( ${PNAME}_FULL_INSTALL_${p}_DIR )
 
-	endforeach()
+  endforeach()
 
-	# correctly set CMAKE_INSTALL_RPATH
+  # correctly set CMAKE_INSTALL_RPATH
 
-	if( ENABLE_RPATHS )
+  if( ENABLE_RPATHS )
 
-		if( ENABLE_RELATIVE_RPATHS )
+    if( ENABLE_RELATIVE_RPATHS )
 
-			file( RELATIVE_PATH relative_rpath ${${PNAME}_FULL_INSTALL_BIN_DIR} ${${PNAME}_FULL_INSTALL_LIB_DIR} )
-			# debug_var( relative_rpath )
+      file( RELATIVE_PATH relative_rpath ${${PNAME}_FULL_INSTALL_BIN_DIR} ${${PNAME}_FULL_INSTALL_LIB_DIR} )
+      # ecbuild_debug_var( relative_rpath )
 
-			ecbuild_append_to_rpath( ${relative_rpath} )
+      ecbuild_append_to_rpath( ${relative_rpath} )
 
-		else() # make rpaths absolute
+    else() # make rpaths absolute
 
-		    if( IS_ABSOLUTE ${INSTALL_LIB_DIR} )
-		        ecbuild_append_to_rpath( "${INSTALL_LIB_DIR}" )
-		    else()
-		        ecbuild_append_to_rpath( "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" ) 
-		    endif()
+      if( IS_ABSOLUTE ${INSTALL_LIB_DIR} )
+        ecbuild_append_to_rpath( "${INSTALL_LIB_DIR}" )
+      else()
+        ecbuild_append_to_rpath( "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" )
+      endif()
 
-		endif()
-    
-	endif()
+    endif()
 
-	# debug_var( CMAKE_INSTALL_RPATH )
+  endif()
 
-	# print project header
+  # ecbuild_debug_var( CMAKE_INSTALL_RPATH )
 
-	message( STATUS "---------------------------------------------------------" )
+  # print project header
 
-	if( ${PNAME}_GIT_SHA1_SHORT )
-		message( STATUS "[${PROJECT_NAME}] (${${PNAME}_VERSION_STR}) [${${PNAME}_GIT_SHA1_SHORT}]" )
-	else()
-		message( STATUS "[${PROJECT_NAME}] (${${PNAME}_VERSION_STR})" )
-	endif()
+  message( STATUS "---------------------------------------------------------" )
 
-endmacro( ecbuild_declare_project )
+  if( ${PNAME}_GIT_SHA1_SHORT )
+    message( STATUS "[${PROJECT_NAME}] (${${PNAME}_VERSION_STR}) [${${PNAME}_GIT_SHA1_SHORT}]" )
+  else()
+    message( STATUS "[${PROJECT_NAME}] (${${PNAME}_VERSION_STR})" )
+  endif()
 
+endmacro( ecbuild_declare_project )
diff --git a/cmake/ecbuild_define_build_types.cmake b/cmake/ecbuild_define_build_types.cmake
index f239f01..53e4de0 100644
--- a/cmake/ecbuild_define_build_types.cmake
+++ b/cmake/ecbuild_define_build_types.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/ecbuild_define_options.cmake b/cmake/ecbuild_define_options.cmake
index 3999db8..f7a2321 100644
--- a/cmake/ecbuild_define_options.cmake
+++ b/cmake/ecbuild_define_options.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -16,6 +16,8 @@ option( ENABLE_WARNINGS         "enable compiler warnings"
 
 option( ENABLE_LARGE_FILE_SUPPORT "build with large file support"   ON  )
 
+option( ENABLE_PROFILING        "build with profiling support" OFF )
+
 mark_as_advanced( ENABLE_LARGE_FILE_SUPPORT )
 
 option( ENABLE_OS_TESTS          "Run all OS tests" ON )
@@ -43,4 +45,4 @@ option( ECBUILD_USE_INCLUDE_DIRECTORIES "Forces to use global include_directorie
 
 mark_as_advanced( ECBUILD_USE_INCLUDE_DIRECTORIES )
 
-set( CMAKE_NO_SYSTEM_FROM_IMPORTED ON )
\ No newline at end of file
+set( CMAKE_NO_SYSTEM_FROM_IMPORTED ON )
diff --git a/cmake/ecbuild_define_paths.cmake b/cmake/ecbuild_define_paths.cmake
index 57a3f1a..822bf71 100644
--- a/cmake/ecbuild_define_paths.cmake
+++ b/cmake/ecbuild_define_paths.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2012 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/ecbuild_dont_pack.cmake b/cmake/ecbuild_dont_pack.cmake
index 4704343..099ee1d 100644
--- a/cmake/ecbuild_dont_pack.cmake
+++ b/cmake/ecbuild_dont_pack.cmake
@@ -7,7 +7,29 @@
 # nor does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for specifying files to exclude from packaging
+#.rst:
+#
+# ecbuild_dont_pack
+# =================
+#
+# Specify files and directories to exclude from packaging. ::
+#
+#   ecbuild_dont_pack( [ FILES <file1> [ <file2> ... ] ]
+#                      [ DIRS <dir1> [ <dir2> ... ] ]
+#                      [ REGEX <regex> ] )
+#
+# Options
+# -------
+#
+# FILES : optional, one of FILES, DIRS, REGEX required
+#   list of files to exclude from packaging
+#
+# DIRS : optional, one of FILES, DIRS, REGEX required
+#   list of directories to exclude from packaging
+#
+# REGEX : optional, one of FILES, DIRS, REGEX required
+#   regular expression to match files / directories to exclude from packaging
+#
 ##############################################################################
 
 macro( ecbuild_dont_pack )
diff --git a/cmake/ecbuild_download_resource.cmake b/cmake/ecbuild_download_resource.cmake
index 8212e7f..d313704 100644
--- a/cmake/ecbuild_download_resource.cmake
+++ b/cmake/ecbuild_download_resource.cmake
@@ -7,8 +7,18 @@
 # nor does it submit to any jurisdiction.
 
 ##############################################################################
-
-# function to download a file from a given URL at configure time
+#.rst:
+#
+# ecbuild_download_resource
+# =========================
+#
+# Download a file from a given URL and save to FILE at configure time. ::
+#
+#   ecbuild_download_resource( FILE URL )
+#
+# curl or wget is required (curl is preferred if available).
+#
+##############################################################################
 
 function( ecbuild_download_resource _p_OUT _p_URL )
 
diff --git a/cmake/ecbuild_echo_targets.cmake b/cmake/ecbuild_echo_targets.cmake
index 015192b..217a196 100644
--- a/cmake/ecbuild_echo_targets.cmake
+++ b/cmake/ecbuild_echo_targets.cmake
@@ -1,14 +1,25 @@
+# (C) Copyright 1996-2015 ECMWF.
 #
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_echo_target_property
+# ============================
+#
+# Output a given property of a given target. ::
 #
-# FUNCTION ecbuild_echo_targets ( <list-of-targets> )
+#   ecbuild_echo_target_property( <target> <property> )
 #
-#   Writes all possible target properties of the specified list-of-targets.
-#   This is very useful for debugging
-# 
+##############################################################################
 
+function(ecbuild_echo_target_property tgt prop)
 
-function(echo_target_property tgt prop)
- 
   cmake_policy(PUSH)
 
   if( POLICY CMP0026 )
@@ -19,26 +30,38 @@ function(echo_target_property tgt prop)
   get_property(v TARGET ${tgt} PROPERTY ${prop})
   get_property(d TARGET ${tgt} PROPERTY ${prop} DEFINED)
   get_property(s TARGET ${tgt} PROPERTY ${prop} SET)
- 
+
   # only produce output for values that are set
-  #if(s)
+  if(s)
     message("tgt='${tgt}' prop='${prop}'")
     message("  value='${v}'")
     message("  defined='${d}'")
     message("  set='${s}'")
     message("")
-  #endif()
+  endif()
 
   cmake_policy(POP)
 
 endfunction()
- 
-function(echo_target tgt)
+
+##############################################################################
+#.rst:
+#
+# ecbuild_echo_target
+# ===================
+#
+# Output all possible target properties of a given target. ::
+#
+#   ecbuild_echo_target( <target> )
+#
+##############################################################################
+
+function(ecbuild_echo_target tgt)
   if(NOT TARGET ${tgt})
     message("There is no target named '${tgt}'")
     return()
   endif()
- 
+
   set(props
 DEBUG_OUTPUT_NAME
 DEBUG_POSTFIX
@@ -181,18 +204,30 @@ VS_WINRT_REFERENCES
 WIN32_EXECUTABLE
 XCODE_ATTRIBUTE_WHATEVER
 )
- 
+
   message("======================== ${tgt} ========================")
   foreach(p ${props})
-    echo_target_property("${t}" "${p}")
+    ecbuild_echo_target_property("${tgt}" "${p}")
   endforeach()
   message("")
 endfunction()
- 
- 
+
+##############################################################################
+#.rst:
+#
+# ecbuild_echo_targets
+# ====================
+#
+# Output all possible target properties of the specified list-of-targets.
+# This is very useful for debugging. ::
+#
+#   ecbuild_echo_targets( <list-of-targets> )
+#
+##############################################################################
+
 function(ecbuild_echo_targets)
   set(tgts ${ARGV})
   foreach(t ${tgts})
-    echo_target("${t}")
+    ecbuild_echo_target("${t}")
   endforeach()
-endfunction()
\ No newline at end of file
+endfunction()
diff --git a/cmake/ecbuild_enable_fortran.cmake b/cmake/ecbuild_enable_fortran.cmake
index dfb28d4..16512e8 100644
--- a/cmake/ecbuild_enable_fortran.cmake
+++ b/cmake/ecbuild_enable_fortran.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,50 +7,68 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-
-# macro for enabling the fortan language
+#.rst:
+#
+# ecbuild_enable_fortran
+# ======================
+#
+# Enable the Fortran language. ::
+#
+#   ecbuild_enable_fortran( [ MODULE_DIRECTORY <directory> ] [ REQUIRED ] )
+#
+# Options
+# -------
+#
+# MODULE_DIRECTORY : optional, defaults to ``${CMAKE_BINARY_DIR}/module``
+#   set the CMAKE_Fortran_MODULE_DIRECTORY
+#
+# REQUIRED : optional
+#   fail if no working Fortran compiler was detected
+#
+##############################################################################
 
 macro( ecbuild_enable_fortran )
 
-    set( options REQUIRED  )
-    set( single_value_args MODULE_DIRECTORY )
-    set( multi_value_args  )
+  set( options REQUIRED  )
+  set( single_value_args MODULE_DIRECTORY )
+  set( multi_value_args  )
 
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+  cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
-    if(_PAR_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_enable_fortran(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-    endif()
+  if(_PAR_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unknown keywords given to ecbuild_enable_fortran(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+  endif()
 
-    enable_language( Fortran )
+  enable_language( Fortran )
 
-    if( DEFINED _PAR_REQUIRED )
-      if( CMAKE_Fortran_COMPILER_FORCED )
-        set( CMAKE_Fortran_COMPILER_WORKS 1 )
-      endif()
-      if( NOT CMAKE_Fortran_COMPILER OR NOT CMAKE_Fortran_COMPILER_WORKS )
-          message( FATAL_ERROR "Fortran compiler required by project ${PROJECT_NAME} but does not seem to work" )
-      endif()
+  if( DEFINED _PAR_REQUIRED )
+    if( CMAKE_Fortran_COMPILER_FORCED )
+      set( CMAKE_Fortran_COMPILER_WORKS 1 )
     endif()
-
-    if( CMAKE_Fortran_COMPILER_LOADED )
-        include(CheckFortranFunctionExists)
-		if( CMAKE_C_COMPILER_LOADED AND ENABLE_FORTRAN_C_INTERFACE )
-			include(FortranCInterface)
-		endif()
-		set( EC_HAVE_FORTRAN 1 )
+    if( NOT CMAKE_Fortran_COMPILER OR NOT CMAKE_Fortran_COMPILER_WORKS )
+      message( FATAL_ERROR "Fortran compiler required by project ${PROJECT_NAME} but does not seem to work" )
     endif()
+  endif()
 
-    if( DEFINED _PAR_MODULE_DIRECTORY )
-        set( CMAKE_Fortran_MODULE_DIRECTORY  ${_PAR_MODULE_DIRECTORY} )
-    else()
-        set( CMAKE_Fortran_MODULE_DIRECTORY  ${CMAKE_BINARY_DIR}/module CACHE PATH "directory for all fortran modules." )
+  if( CMAKE_Fortran_COMPILER_LOADED )
+    include(CheckFortranFunctionExists)
+    if( CMAKE_C_COMPILER_LOADED AND ENABLE_FORTRAN_C_INTERFACE )
+      include(FortranCInterface)
     endif()
+    set( EC_HAVE_FORTRAN 1 )
+  endif()
+
+  if( DEFINED _PAR_MODULE_DIRECTORY )
+    set( CMAKE_Fortran_MODULE_DIRECTORY  ${_PAR_MODULE_DIRECTORY} )
+  else()
+    set( CMAKE_Fortran_MODULE_DIRECTORY  ${CMAKE_BINARY_DIR}/module
+         CACHE PATH "directory for all fortran modules." )
+  endif()
 
-	file( MAKE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} )
+  file( MAKE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} )
 
-    include_directories( ${CMAKE_Fortran_MODULE_DIRECTORY} )
+  include_directories( ${CMAKE_Fortran_MODULE_DIRECTORY} )
 
-    install( CODE "EXECUTE_PROCESS (COMMAND \"${CMAKE_COMMAND}\" -E copy_directory \"${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE}\" \"${INSTALL_INCLUDE_DIR}\")" )
+  install( CODE "EXECUTE_PROCESS (COMMAND \"${CMAKE_COMMAND}\" -E copy_directory \"${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE}\" \"${INSTALL_INCLUDE_DIR}\")" )
 
 endmacro( ecbuild_enable_fortran )
diff --git a/cmake/ecbuild_features.cmake b/cmake/ecbuild_features.cmake
index 65f75a9..7c7bafa 100644
--- a/cmake/ecbuild_features.cmake
+++ b/cmake/ecbuild_features.cmake
@@ -1,55 +1,67 @@
-include( FeatureSummary )
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
 
-function( debug_var _var )
-  message( "${_var} = ${${_var}}" )
-endfunction()
+# Internal macros to handle CMake features
 
+include( FeatureSummary )
+
+# Write list of enabled features to CMake variable ${OUT}
 macro( ecbuild_enabled_features OUT )
     get_property( ${OUT}  GLOBAL PROPERTY ENABLED_FEATURES )
 endmacro()
 
+# Write list of disabled features to CMake variable ${OUT}
 macro( ecbuild_disabled_features OUT )
     get_property( ${OUT}  GLOBAL PROPERTY DISABLED_FEATURES )
 endmacro()
 
+# Enable the feature ${_name} (add to enabled features, remove from disabled)
 function( ecbuild_enable_feature _name )
-  
+
   get_property( _enabled_features  GLOBAL PROPERTY ENABLED_FEATURES )
   get_property( _disabled_features GLOBAL PROPERTY DISABLED_FEATURES )
-  
+
   if( _disabled_features )
     list( REMOVE_ITEM _disabled_features ${_name} )
   endif()
 
   list( APPEND _enabled_features ${_name} )
   list( REMOVE_DUPLICATES _enabled_features )
-    
+
   set_property(GLOBAL PROPERTY ENABLED_FEATURES  "${_enabled_features}" )
   set_property(GLOBAL PROPERTY DISABLED_FEATURES "${_disabled_features}" )
 
 endfunction()
 
+# Disable the feature ${_name} (add to disabled features, remove from enabled)
 function( ecbuild_disable_feature _name )
 
   get_property( _enabled_features  GLOBAL PROPERTY ENABLED_FEATURES )
   get_property( _disabled_features GLOBAL PROPERTY DISABLED_FEATURES )
-  
+
   if( _enabled_features )
     list( REMOVE_ITEM _enabled_features ${_name} )
   endif()
 
   list( APPEND _disabled_features ${_name} )
   list( REMOVE_DUPLICATES _disabled_features )
-    
+
   set_property(GLOBAL PROPERTY ENABLED_FEATURES  "${_enabled_features}" )
   set_property(GLOBAL PROPERTY DISABLED_FEATURES "${_disabled_features}" )
-  
+
 endfunction()
 
-function( ecbuild_set_feature_description _name _desc)      
+# Set description of feature ${_name} to ${_desc}
+function( ecbuild_set_feature_description _name _desc)
   set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
 endfunction()
 
+# Set purpose of feature ${_name} to ${_desc}
 function( ecbuild_set_feature_purpose _name _purpose )
   get_property( _purpose_list  GLOBAL PROPERTY _CMAKE_${_name}_PURPOSE )
   list( APPEND _purpose_list ${_purpose} )
@@ -57,6 +69,7 @@ function( ecbuild_set_feature_purpose _name _purpose )
   set_property(GLOBAL PROPERTY _CMAKE_${_name}_PURPOSE "${_purpose_list}" )
 endfunction()
 
+# en/disable feature ${_name} and set its description and purpose
 function( ecbuild_set_feature _name )
 
   set(options ) # none
@@ -64,11 +77,11 @@ function( ecbuild_set_feature _name )
   set(multiValueArgs ) # none
 
   CMAKE_PARSE_ARGUMENTS( _PAR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
-  
-  get_property( _feature_desc      GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION )  
+
+  get_property( _feature_desc      GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION )
   get_property( _enabled_features  GLOBAL PROPERTY ENABLED_FEATURES )
   get_property( _disabled_features GLOBAL PROPERTY DISABLED_FEATURES )
-  
+
   if( DEFINED _PAR_ENABLED )
     if( _PAR_ENABLED )
       ecbuild_enable_feature( ${_name} )
@@ -76,7 +89,7 @@ function( ecbuild_set_feature _name )
       ecbuild_disable_feature( ${_name} )
     endif()
   endif()
-  
+
   ecbuild_enabled_features( _enabled_features )
   list (FIND _enabled_features "${_name}" _index)
   if (${_index} GREATER -1)
@@ -88,17 +101,17 @@ function( ecbuild_set_feature _name )
   if (${_index} GREATER -1)
     set( _feature_found 1 )
   endif()
-  
+
   if( NOT _feature_found )
     message( WARNING "Feature ${_name} has not yet been enabled or disabled" )
   endif()
-  
+
   if( _PAR_DESCRIPTION )
     ecbuild_set_feature_description( ${_name} ${_PAR_DESCRIPTION} )
   endif()
-  
+
   if( _PAR_PURPOSE )
     ecbuild_set_feature_purpose( ${_name} ${_PAR_PURPOSE} )
   endif()
 
-endfunction()
\ No newline at end of file
+endfunction()
diff --git a/cmake/ecbuild_find_fortranlibs.cmake b/cmake/ecbuild_find_fortranlibs.cmake
index de4b167..850c4a3 100644
--- a/cmake/ecbuild_find_fortranlibs.cmake
+++ b/cmake/ecbuild_find_fortranlibs.cmake
@@ -6,8 +6,27 @@
 # granted to it by virtue of its status as an intergovernmental organisation
 # nor does it submit to any jurisdiction.
 
-###############################################################################
-# macro to find fortran (static) link libraries
+##############################################################################
+#.rst:
+#
+# ecbuild_find_fortranlibs
+# ========================
+#
+# Find the Fortran (static) link libraries. ::
+#
+#   ecbuild_find_fortranlibs( [ COMPILER gfortran|pgi|xlf|intel ]
+#                             [ REQUIRED ] )
+#
+# Options
+# -------
+#
+# COMPILER : optional, defaults to gfortran
+#   request a given Fortran compiler (``gfortran``, ``pgi``, ``xlf``, ``intel``)
+#
+# REQUIRED : optional
+#   fail if Fortran libraries were not found
+#
+##############################################################################
 
 macro( ecbuild_find_fortranlibs )
 
diff --git a/cmake/ecbuild_find_lexyacc.cmake b/cmake/ecbuild_find_lexyacc.cmake
index 373b81c..9876097 100644
--- a/cmake/ecbuild_find_lexyacc.cmake
+++ b/cmake/ecbuild_find_lexyacc.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,55 +6,79 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to find python
-
-# OUTPUT:
+##############################################################################
+#.rst:
+#
+# ecbuild_find_lexyacc
+# ====================
+#
+# Find flex and bison (preferred) or lex and yacc.
+#
+# Input variables
+# ---------------
+#
+# The following CMake variables can set to skip search for bison or yacc:
+#
+# :SKIP_BISON: do not search for flex and bison
+# :SKIP_YACC:  do not search for lex and yacc
+#
+# Output variables
+# ----------------
+#
+# The following CMake variables are set if flex and bison were found:
+#
+# :FLEX_FOUND:       flex was found
+# :BISON_FOUND:      bison was found
+# :FLEX_EXECUTABLE:  path to the flex executable
+# :BISON_EXECUTABLE: path to the bison executable
+#
+# The following CMake variables are set if lex and yacc were found:
 #
-# BISON_FOUND or YACC_FOUND
-# FLEX_FOUND or LEX_FOUND
+# :LEX_FOUND:       lex was found
+# :YACC_FOUND:      yacc was found
+# :LEX_EXECUTABLE:  path to the lex executable
+# :YACC_EXECUTABLE: path to the yacc executable
 #
-# BISON_EXECUTABLE or YACC_EXECUTABLE
-# FLEX_EXECUTABLE or LEX_EXECUTABLE
+##############################################################################
 
 macro( ecbuild_find_lexyacc )
 
-	# find preferably bison or else yacc
+  # find preferably bison or else yacc
 
-	if( NOT SKIP_BISON )
+  if( NOT SKIP_BISON )
 
-		find_package( BISON 2.3 )
-		find_package( FLEX )
+    find_package( BISON 2.3 )
+    find_package( FLEX )
 
-	endif()
+  endif()
 
-	if( NOT BISON_FOUND AND NOT SKIP_YACC )
+  if( NOT BISON_FOUND AND NOT SKIP_YACC )
 
-		find_package( YACC )
-		find_package( LEX  )
+    find_package( YACC )
+    find_package( LEX  )
 
-	endif()
+  endif()
 
-	if( NOT YACC_FOUND AND NOT BISON_FOUND ) # neither bison nor yacc were found
-		message( FATAL_ERROR "neither bison or yacc were found - at least one is required (together with its lexical analyser" )
-	endif()
+  if( NOT YACC_FOUND AND NOT BISON_FOUND ) # neither bison nor yacc were found
+    message( FATAL_ERROR "neither bison or yacc were found - at least one is required (together with its lexical analyser" )
+  endif()
 
-	if( NOT YACC_FOUND ) # check for both bison & flex together
-		if( BISON_FOUND AND NOT FLEX_FOUND )
-			message( FATAL_ERROR "both bison and flex are required - flex not found" )
-		endif()
-		if( FLEX_FOUND AND NOT BISON_FOUND )
-			message( FATAL_ERROR "both bison and flex are required - bison not found" )
-		endif()
-	endif()
+  if( NOT YACC_FOUND ) # check for both bison & flex together
+    if( BISON_FOUND AND NOT FLEX_FOUND )
+      message( FATAL_ERROR "both bison and flex are required - flex not found" )
+    endif()
+    if( FLEX_FOUND AND NOT BISON_FOUND )
+      message( FATAL_ERROR "both bison and flex are required - bison not found" )
+    endif()
+  endif()
 
-	if( NOT BISON_FOUND ) # check for both yacc & lex together
-		if( YACC_FOUND AND NOT LEX_FOUND )
-			message( FATAL_ERROR "both yacc and lex are required - lex not found" )
-		endif()
-		if( LEX_FOUND AND NOT YACC_FOUND )
-			message( FATAL_ERROR "both yacc and lex are required - yacc not found" )
-		endif()
-	endif()
+  if( NOT BISON_FOUND ) # check for both yacc & lex together
+    if( YACC_FOUND AND NOT LEX_FOUND )
+      message( FATAL_ERROR "both yacc and lex are required - lex not found" )
+    endif()
+    if( LEX_FOUND AND NOT YACC_FOUND )
+      message( FATAL_ERROR "both yacc and lex are required - yacc not found" )
+    endif()
+  endif()
 
 endmacro( ecbuild_find_lexyacc )
diff --git a/cmake/ecbuild_find_mpi.cmake b/cmake/ecbuild_find_mpi.cmake
index 9ed4b3c..82fc4b5 100644
--- a/cmake/ecbuild_find_mpi.cmake
+++ b/cmake/ecbuild_find_mpi.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,10 +6,69 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to find MPI
-# uses the canonical find_package( MPI )
-# but does more checks
+##############################################################################
+#.rst:
+#
+# ecbuild_find_mpi
+# ================
+#
+# Find MPI and check if MPI compilers successfully compile C/C++/Fortran. ::
+#
+#   ecbuild_find_mpi( [ COMPONENTS <component1> [ <component2> ... ] ]
+#                     [ REQUIRED ] )
+#
+# Options
+# -------
+#
+# COMPONENTS : optional, defaults to C
+#   list of required languages bindings
+#
+# REQUIRED : optional
+#   fail if MPI was not found
+#
+# Input variables
+# ---------------
+#
+# ECBUILD_FIND_MPI : optional, defaults to TRUE
+#   test C/C++/Fortran MPI compiler wrappers (assume working if FALSE)
+#
+# Output variables
+# ----------------
+#
+# The following CMake variables are set if MPI was found: ::
+#
+#   MPI_FOUND
+#   MPI_LIBRARY
+#   MPI_EXTRA_LIBRARY 
+#
+# The following CMake variables are set if C bindings were found: ::
+#
+#   MPI_C_FOUND
+#   MPI_C_COMPILER
+#   MPI_C_COMPILE_FLAGS
+#   MPI_C_INCLUDE_PATH
+#   MPI_C_LIBRARIES
+#   MPI_C_LINK_FLAGS
+#
+# The following CMake variables are set if C++ bindings were found: ::
+#
+#   MPI_CXX_FOUND
+#   MPI_CXX_COMPILER
+#   MPI_CXX_COMPILE_FLAGS
+#   MPI_CXX_INCLUDE_PATH
+#   MPI_CXX_LIBRARIES
+#   MPI_CXX_LINK_FLAGS
+#
+# The following CMake variables are set if Fortran bindings were found: ::
+#
+#   MPI_Fortran_FOUND
+#   MPI_Fortran_COMPILER
+#   MPI_Fortran_COMPILE_FLAGS
+#   MPI_Fortran_INCLUDE_PATH
+#   MPI_Fortran_LIBRARIES
+#   MPI_Fortran_LINK_FLAGS
+#
+##############################################################################
 
 macro( ecbuild_find_mpi )
 
@@ -156,6 +215,32 @@ macro( ecbuild_find_mpi )
 
 endmacro( ecbuild_find_mpi )
 
+##############################################################################
+#.rst:
+#
+# ecbuild_enable_mpi
+# ==================
+#
+# Find MPI, add include directories and set compiler flags. ::
+#
+#   ecbuild_enable_mpi( [ COMPONENTS <component1> [ <component2> ... ] ]
+#                       [ REQUIRED ] )
+#
+# For each MPI language binding found, set the corresponding compiler flags
+# and add the include directories.
+#
+# See ``ecbuild_find_mpi`` for input and output variables.
+#
+# Options
+# -------
+#
+# COMPONENTS : optional, defaults to C
+#   list of required languages bindings
+#
+# REQUIRED : optional
+#   fail if MPI was not found
+#
+##############################################################################
 
 macro( ecbuild_enable_mpi )
 
@@ -180,23 +265,36 @@ macro( ecbuild_enable_mpi )
     endif()
 
     if( MPI_C_FOUND AND NOT C_COMPILER_SUPPORTS_MPI )
-        cmake_add_c_flags("${MPI_C_COMPILE_FLAGS}")
+        ecbuild_add_c_flags("${MPI_C_COMPILE_FLAGS}")
         include_directories(${MPI_C_INCLUDE_PATH})
     endif()
 
     if( MPI_CXX_FOUND AND NOT CXX_COMPILER_SUPPORTS_MPI )
-        cmake_add_cxx_flags("${MPI_CXX_COMPILE_FLAGS}")
+        ecbuild_add_cxx_flags("${MPI_CXX_COMPILE_FLAGS}")
         include_directories(${MPI_CXX_INCLUDE_PATH})
     endif()
 
     if( MPI_Fortran_FOUND AND NOT Fortran_COMPILER_SUPPORTS_MPI )
-        include(ecbuild_check_fortran_source)
-        cmake_add_fortran_flags("${MPI_Fortran_COMPILE_FLAGS}")
+        include( ecbuild_check_fortran_source_return )
+        ecbuild_add_fortran_flags("${MPI_Fortran_COMPILE_FLAGS}")
         include_directories(${MPI_Fortran_INCLUDE_PATH})
     endif()
 
 endmacro( ecbuild_enable_mpi )
 
+##############################################################################
+#.rst:
+#
+# ecbuild_include_mpi
+# ===================
+#
+# Add MPI include directories and set compiler flags, assuming MPI was found.
+#
+# For each MPI language binding found, set corresponding compiler flags and
+# add include directories. ``ecbuild_find_mpi`` must have been called before.
+#
+##############################################################################
+
 macro( ecbuild_include_mpi )
 
     set( options )
@@ -210,20 +308,20 @@ macro( ecbuild_include_mpi )
     endif()
 
     if( MPI_C_FOUND AND NOT C_COMPILER_SUPPORTS_MPI )
-        include( ecbuild_check_c_source )
-        cmake_add_c_flags("${MPI_C_COMPILE_FLAGS}")
+        include( ecbuild_check_c_source_return )
+        ecbuild_add_c_flags("${MPI_C_COMPILE_FLAGS}")
         include_directories(${MPI_C_INCLUDE_PATH})
     endif()
 
     if( MPI_CXX_FOUND AND NOT CXX_COMPILER_SUPPORTS_MPI )
-        include( ecbuild_check_cxx_source )
-        cmake_add_cxx_flags("${MPI_CXX_COMPILE_FLAGS}")
+        include( ecbuild_check_cxx_source_return )
+        ecbuild_add_cxx_flags("${MPI_CXX_COMPILE_FLAGS}")
         include_directories(${MPI_CXX_INCLUDE_PATH})
     endif()
 
     if( MPI_Fortran_FOUND AND NOT Fortran_COMPILER_SUPPORTS_MPI )
-        include( ecbuild_check_fortran_source )
-        cmake_add_fortran_flags("${MPI_Fortran_COMPILE_FLAGS}")
+        include( ecbuild_check_fortran_source_return )
+        ecbuild_add_fortran_flags("${MPI_Fortran_COMPILE_FLAGS}")
         include_directories(${MPI_Fortran_INCLUDE_PATH})
     endif()
 
diff --git a/cmake/ecbuild_find_omp.cmake b/cmake/ecbuild_find_omp.cmake
index c8f4123..882adfe 100644
--- a/cmake/ecbuild_find_omp.cmake
+++ b/cmake/ecbuild_find_omp.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -73,19 +73,47 @@ macro( lookup_omp_flags )
 
 endmacro()
 
-
-# MACRO ecbuild_find_omp
+##############################################################################
+#.rst:
+#
+# ecbuild_find_omp
+# ================
+#
+# Find OpenMP. ::
+#
+#   ecbuild_find_omp( [ COMPONENTS <component1> [ <component2> ... ] ]
+#                     [ REQUIRED ]
+#                     [ STUBS ] )
+#
+# Options
+# -------
+#
+# COMPONENTS : optional, defaults to C
+#   list of required languages bindings
+#
+# REQUIRED : optional
+#   fail if OpenMP was not found
+#
+# STUBS : optional
+#   search for OpenMP stubs
+#
+# Output variables
+# ----------------
+#
+# The following CMake variables are set if OpenMP was found:
+#
+# :OMP_FOUND: OpenMP was found
 #
-# ecbuild_find_omp( COMPONENTS C CXX Fortran
-#                   STUBS )
-# Sets following variables
-#   - OMP_FOUND
-#   - OMP_<lang>_FOUND
-#   - OMP_<lang>_FLAGS
+# For each language listed in COMPONENTS, the following variables are set:
 #
-# If STUBS are available, above flags will still hold TRUE,
-# as OMP code will just work.
+# :OMP_<LANG>_FOUND: OpenMP bindings for LANG were found
+# :OMP_<LANG>_FLAGS: OpenMP compiler flags for LANG
 #
+# If the STUBS option was given, all variables are also set with the OMPSTUBS
+# instead of the OMP prefix.
+#
+##############################################################################
+
 macro( ecbuild_find_omp )
 
   set( options REQUIRED STUBS )
@@ -166,7 +194,15 @@ macro( ecbuild_find_omp )
 endmacro( ecbuild_find_omp )
 
 ##############################################################################
-# macro for enabling openmp
+#.rst:
+#
+# ecbuild_enable_omp
+# ==================
+#
+# Find OpenMP for C, C++ and Fortran and set the compiler flags for each
+# language for which OpenMP support was detected.
+#
+##############################################################################
 
 macro( ecbuild_enable_omp )
 
@@ -187,7 +223,15 @@ macro( ecbuild_enable_omp )
 endmacro( ecbuild_enable_omp )
 
 ##############################################################################
-# macro for enabling openmp stubs
+#.rst:
+#
+# ecbuild_enable_ompstubs
+# =======================
+#
+# Find OpenMP stubs for C, C++ and Fortran and set the compiler flags for each
+# language for which OpenMP stubs were detected.
+#
+##############################################################################
 
 macro( ecbuild_enable_ompstubs )
 
diff --git a/cmake/ecbuild_find_package.cmake b/cmake/ecbuild_find_package.cmake
index a8787b4..9616720 100644
--- a/cmake/ecbuild_find_package.cmake
+++ b/cmake/ecbuild_find_package.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,7 +7,80 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for adding a subproject directory
+#.rst:
+#
+# ecbuild_find_package
+# ====================
+#
+# Find a package and import its configuration. ::
+#
+#   ecbuild_find_package( NAME <name>
+#                         [ VERSION <version> [ EXACT ] ]
+#                         [ COMPONENTS <component1> [ <component2> ... ] ]
+#                         [ REQUIRED ]
+#                         [ QUIET ] )
+#
+# Options
+# -------
+#
+# NAME : required
+#   package name (used as ``Find<name>.cmake`` and ``<name>-config.cmake``)
+#
+# VERSION : optional
+#   minimum required package version
+#
+# COMPONENTS : optional
+#   list of package components to find (behaviour depends on the package)
+#
+# EXACT : optional, requires VERSION
+#   require the exact version rather than a minimum version
+#
+# REQUIRED : optional
+#   fail if package cannot be found
+#
+# QUIET : optional
+#   do not output package information if found
+#
+# Input variables
+# ---------------
+#
+# The following CMake variables influence the behaviour if set (``<name>`` is
+# the package name as given, ``<NAME>`` is the capitalised version):
+#
+# :DEVELOPER_MODE: if enabled, discover projects parallel in the build tree
+# :<name>_PATH:    install prefix path of the package
+# :<NAME>_PATH:    install prefix path of the package
+# :<name>_DIR:     directory containing the ``<name>-config.cmake`` file
+#                  (usually ``<install-prefix>/share/<name>/cmake``)
+#
+# The environment variables ``<name>_PATH``, ``<NAME>_PATH``, ``<name>_DIR``
+# are taken into account only if the corresponding CMake variables are unset.
+#
+# Usage
+# -----
+#
+# The search proceeds as follows:
+#
+# 1.  If any paths have been specified by the user via CMake or environment
+#     variables as given above or a parallel build tree has been discovered in
+#     DEVELOPER_MODE:
+#
+#     * search for ``<name>-config.cmake`` in those paths only
+#     * search using ``Find<name>.cmake`` (which should respect those paths)
+#     * fail if the package was not found in any of those paths
+#
+# 2.  Search for ``<name>-config.cmake`` in the ``CMAKE_PREFIX_PATH`` and if
+#     DEVELOPER_MODE is enabled also in the user package registry.
+#
+# 3.  Search system paths for ``<name>-config.cmake``.
+#
+# 4.  Search system paths using ``Find<name>.cmake``.
+#
+# 5.  If the package was found, and a minimum version was requested, check if
+#     the version is acceptable and if not, unset ``<NAME>_FOUND``.
+#
+# 6.  Fail if the package was not found and is REQUIRED.
+#
 ##############################################################################
 
 macro( ecbuild_find_package )
@@ -30,15 +103,16 @@ macro( ecbuild_find_package )
     message(FATAL_ERROR "Call to ecbuild_find_package() requests EXACT but doesn't specify VERSION.")
   endif()
 
-  # debug_var( _PAR_NAME )
+  # ecbuild_debug_var( _PAR_NAME )
 
-  string( TOUPPER ${_PAR_NAME} PNAME )
+  string( TOUPPER ${_PAR_NAME} pkgUPPER )
+  string( TOLOWER ${_PAR_NAME} pkgLOWER )
 
-  set( _${PNAME}_version "" )
+  set( _${pkgUPPER}_version "" )
   if( _PAR_VERSION )
-    set( _${PNAME}_version ${_PAR_VERSION} )
+    set( _${pkgUPPER}_version ${_PAR_VERSION} )
     if( _PAR_EXACT )
-      set( _${PNAME}_version ${_PAR_VERSION} EXACT )
+      set( _${pkgUPPER}_version ${_PAR_VERSION} EXACT )
     endif()
   endif()
 
@@ -53,42 +127,55 @@ macro( ecbuild_find_package )
   # so lets prepend a parallel build tree to the search path if we find it
 
   if( DEVELOPER_MODE )
-    get_filename_component( _proj_bdir "${CMAKE_BINARY_DIR}/../${_PAR_NAME}" ABSOLUTE )
-    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - searching for ${_PAR_NAME}-config.cmake in ${_proj_bdir}")
-    if( EXISTS ${_proj_bdir}/${_PAR_NAME}-config.cmake )
+    get_filename_component( _proj_bdir "${CMAKE_BINARY_DIR}/../${pkgLOWER}" ABSOLUTE )
+    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - searching for ${pkgLOWER}-config.cmake in ${_proj_bdir}")
+    if( EXISTS ${_proj_bdir}/${pkgLOWER}-config.cmake )
       ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - found parallel build tree in ${_proj_bdir}")
-      if( ${PNAME}_PATH )
-        ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - ${PNAME}_PATH already set to ${${PNAME}_PATH}, not modifying")
+      if( ${pkgUPPER}_PATH )
+        ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - ${pkgUPPER}_PATH already set to ${${pkgUPPER}_PATH}, not modifying")
       else()
-        ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - setting ${PNAME}_PATH to ${_proj_bdir}")
-        set( ${PNAME}_PATH "${_proj_bdir}" )
+        ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): in DEVELOPER_MODE - setting ${pkgUPPER}_PATH to ${_proj_bdir}")
+        set( ${pkgUPPER}_PATH "${_proj_bdir}" )
       endif()
     endif()
   endif()
 
-  # search user defined paths first
+  # Read environment variables but ONLY if the corresponding CMake variables are unset
 
-  if( NOT DEFINED ${PNAME}_PATH AND NOT "$ENV{${PNAME}_PATH}" STREQUAL "" )
-    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): setting ${PNAME}_PATH=${${PNAME}_PATH} from environment")
-    set( ${PNAME}_PATH "$ENV{${PNAME}_PATH}" )
+  if( NOT DEFINED ${pkgUPPER}_PATH AND NOT "$ENV{${pkgUPPER}_PATH}" STREQUAL "" )
+    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): setting ${pkgUPPER}_PATH=${${pkgUPPER}_PATH} from environment")
+    set( ${pkgUPPER}_PATH "$ENV{${pkgUPPER}_PATH}" )
   endif()
 
-  if( NOT DEFINED ${_PAR_NAME}_DIR AND NOT "$ENV{${_PAR_NAME}_DIR}" STREQUAL "" )
+  if( NOT DEFINED ${_PAR_NAME}_PATH AND NOT "$ENV{${_PAR_NAME}_PATH}" STREQUAL "" )
     ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): setting ${_PAR_NAME}_PATH=${${_PAR_NAME}_PATH} from environment")
+    set( ${_PAR_NAME}_PATH "$ENV{${_PAR_NAME}_PATH}" )
+  endif()
+
+  if( NOT DEFINED ${_PAR_NAME}_DIR AND NOT "$ENV{${_PAR_NAME}_DIR}" STREQUAL "" )
+    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): setting ${_PAR_NAME}_DIR=${${_PAR_NAME}_DIR} from environment")
     set( ${_PAR_NAME}_DIR "$ENV{${_PAR_NAME}_DIR}" )
   endif()
 
-  if( ${_PAR_NAME}_PATH OR ${PNAME}_PATH OR ${_PAR_NAME}_DIR OR ${PNAME}_DIR )
-    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): ${_PAR_NAME}_PATH=${${_PAR_NAME}}, ${PNAME}_PATH=${${PNAME}_PATH}, ${PNAME}_PATH=${${_PAR_NAME}_DIR}, ${PNAME}_DIR=${${PNAME}_DIR}")
+  # Find packages quietly unless in DEVELOPER_MODE, LOG_LEVEL is DEBUG or the package is REQUIRED
+
+  if( NOT ( DEVELOPER_MODE OR _PAR_REQUIRED ) AND ( ECBUILD_LOG_LEVEL GREATER ${ECBUILD_DEBUG} ) )
+    set( _find_quiet QUIET )
+  endif()
+
+  # search user defined paths first
+
+  if( ${_PAR_NAME}_PATH OR ${pkgUPPER}_PATH OR ${_PAR_NAME}_DIR )
+    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): ${_PAR_NAME}_PATH=${${_PAR_NAME}_PATH}, ${pkgUPPER}_PATH=${${pkgUPPER}_PATH}, ${_PAR_NAME}_DIR=${${_PAR_NAME}_DIR}")
 
     # 1) search using CONFIG mode -- try to locate a configuration file provided by the package (package-config.cmake)
 
     if( NOT ${_PAR_NAME}_FOUND )
       ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 1) search using CONFIG mode -- try to locate ${_PAR_NAME}-config.cmake")
-      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}):    using hints ${PNAME}_PATH=${${PNAME}_PATH}, ${_PAR_NAME}_PATH=${${_PAR_NAME}_PATH}, ${PNAME}_DIR=${${PNAME}_DIR}, ${_PAR_NAME}_DIR=${${_PAR_NAME}_DIR}")
-      find_package( ${_PAR_NAME} ${_${PNAME}_version} NO_MODULE QUIET
+      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}):    using hints ${pkgUPPER}_PATH=${${pkgUPPER}_PATH}, ${_PAR_NAME}_PATH=${${_PAR_NAME}_PATH}, ${_PAR_NAME}_DIR=${${_PAR_NAME}_DIR}")
+      find_package( ${_PAR_NAME} ${_${pkgUPPER}_version} NO_MODULE ${_find_quiet}
         COMPONENTS ${_PAR_COMPONENTS}
-        HINTS ${${PNAME}_PATH} ${${_PAR_NAME}_PATH} ${${PNAME}_DIR} ${${_PAR_NAME}_DIR}
+        HINTS ${${pkgUPPER}_PATH} ${${_PAR_NAME}_PATH} ${${_PAR_NAME}_DIR}
         NO_DEFAULT_PATH )
     endif()
 
@@ -96,7 +183,8 @@ macro( ecbuild_find_package )
 
     if( NOT ${_PAR_NAME}_FOUND )
       ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 2) search using a file Find${_PAR_NAME}.cmake if it exists")
-      find_package( ${_PAR_NAME} ${_${PNAME}_version} MODULE QUIET COMPONENTS ${_PAR_COMPONENTS} )
+      find_package( ${_PAR_NAME} ${_${pkgUPPER}_version} MODULE ${_find_quiet}
+                    COMPONENTS ${_PAR_COMPONENTS} )
     endif()
 
     # is <package>_PATH was given and we don't find anything then we FAIL
@@ -105,8 +193,8 @@ macro( ecbuild_find_package )
       if( ${_PAR_NAME}_PATH )
         message( FATAL_ERROR "${_PAR_NAME}_PATH was provided by user but package ${_PAR_NAME} wasn't found" )
       endif()
-      if( ${PNAME}_PATH )
-        message( FATAL_ERROR "${PNAME}_PATH was provided by user but package ${_PAR_NAME} wasn't found" )
+      if( ${pkgUPPER}_PATH )
+        message( FATAL_ERROR "${pkgUPPER}_PATH was provided by user but package ${_PAR_NAME} wasn't found" )
       endif()
     endif()
 
@@ -117,14 +205,14 @@ macro( ecbuild_find_package )
 
   if( NOT ${_PAR_NAME}_FOUND )
     if (NO_DEV_BUILD_DIRS)
-      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 3) search CMAKE_PREFIX_PATH and \$${PNAME}_PATH")
+      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 3) search CMAKE_PREFIX_PATH and \$${pkgUPPER}_PATH")
     else()
-      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 3) search CMAKE_PREFIX_PATH and \$${PNAME}_PATH and package registry")
+      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 3) search CMAKE_PREFIX_PATH and \$${pkgUPPER}_PATH and package registry")
     endif()
 
-    find_package( ${_PAR_NAME} ${_${PNAME}_version} QUIET NO_MODULE
+    find_package( ${_PAR_NAME} ${_${pkgUPPER}_version} ${_find_quiet} NO_MODULE
       COMPONENTS ${_PAR_COMPONENTS}
-      HINTS ENV ${PNAME}_PATH
+      HINTS ENV ${pkgUPPER}_PATH
       ${NO_DEV_BUILD_DIRS}
       NO_CMAKE_ENVIRONMENT_PATH
       NO_SYSTEM_ENVIRONMENT_PATH
@@ -133,42 +221,24 @@ macro( ecbuild_find_package )
 
   endif()
 
-  # 4) search special ECMWF paths
-
-  if( NOT ${_PAR_NAME}_FOUND )
-    ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 4) search special ECMWF paths")
-
-    set( _ecmwf_paths ) # clear variable
-    ecbuild_list_extra_search_paths( ${_PAR_NAME} _ecmwf_paths )
-
-    if( _ecmwf_paths )
-      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}):    ECMWF paths ${_ecmwf_paths}")
-      find_package( ${_PAR_NAME} ${_${PNAME}_version} QUIET NO_MODULE
-        COMPONENTS ${_PAR_COMPONENTS}
-        PATHS ${_ecmwf_paths} NO_DEFAULT_PATH )
-    else()
-      ecbuild_debug("ecbuild_find_package(${_PAR_NAME}):    no special ECMWF paths found")
-    endif()
-
-  endif()
-
-  # 5) search system paths, for <package>-config.cmake
+  # 4) search system paths, for <package>-config.cmake
 
   if( NOT ${_PAR_NAME}_FOUND )
     ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 5) search system paths, for ${_PAR_NAME}-config.cmake")
 
-    find_package( ${_PAR_NAME} ${_${PNAME}_version} QUIET NO_MODULE
+    find_package( ${_PAR_NAME} ${_${pkgUPPER}_version} ${_find_quiet} NO_MODULE
       COMPONENTS ${_PAR_COMPONENTS}
       ${NO_DEV_BUILD_DIRS} )
 
   endif()
 
-  # 6) search system paths, using Find<package>.cmake if it exists
+  # 5) search system paths, using Find<package>.cmake if it exists
 
   if( NOT ${_PAR_NAME}_FOUND )
     ecbuild_debug("ecbuild_find_package(${_PAR_NAME}): 6) search system paths, using Find${_PAR_NAME}.cmake if it exists")
 
-    find_package( ${_PAR_NAME} ${_${PNAME}_version} QUIET MODULE COMPONENTS ${_PAR_COMPONENTS} )
+    find_package( ${_PAR_NAME} ${_${pkgUPPER}_version} ${_find_quiet} MODULE
+                  COMPONENTS ${_PAR_COMPONENTS} )
 
   endif()
 
@@ -205,12 +275,12 @@ macro( ecbuild_find_package )
   if( ${_PAR_NAME}_FOUND )
 
     if( _version_acceptable )
-      set( ${PNAME}_FOUND ${${_PAR_NAME}_FOUND} )
+      set( ${pkgUPPER}_FOUND ${${_PAR_NAME}_FOUND} )
     else()
       if( NOT _PAR_QUIET )
         message( WARNING "${PROJECT_NAME} found ${_PAR_NAME} but with unsuitable version" )
       endif()
-      set( ${PNAME}_FOUND 0 )
+      set( ${pkgUPPER}_FOUND 0 )
       set( ${_PAR_NAME}_FOUND 0 )
     endif()
 
@@ -222,21 +292,21 @@ macro( ecbuild_find_package )
     "\n"
     "  ${PROJECT_NAME} FAILED to find package ${_PAR_NAME}\n"
     "\n"
-    "    Provide location with \"-D ${PNAME}_PATH=/...\" or \"-D ${_PAR_NAME}_DIR=/...\" \n"
-    "    You may also export environment variables ${PNAME}_PATH or ${_PAR_NAME}_DIR\n"
+    "    Provide location with \"-D${pkgUPPER}_PATH=/...\" or \"-D${_PAR_NAME}_DIR=/...\" \n"
+    "    You may also export environment variables ${pkgUPPER}_PATH or ${_PAR_NAME}_DIR\n"
     "\n"
     "  Values (note CAPITALISATION):\n"
-    "    ${PNAME}_PATH should contain the path to the installation (as in <install>/bin <install>/lib <install>/include)\n"
+    "    ${pkgUPPER}_PATH should contain the path to the install prefix (as in <install>/bin <install>/lib <install>/include)\n"
     "    ${_PAR_NAME}_DIR should be a directory containing a <package>-config.cmake file (usually <install>/share/<package>/cmake)\n"
     "\n"
     )
 
-  if( ${_PAR_NAME}_FOUND OR ${PNAME}_FOUND )
+  if( ${_PAR_NAME}_FOUND OR ${pkgUPPER}_FOUND )
     if( NOT _PAR_QUIET )
       message( STATUS "[${_PAR_NAME}] (${${_PAR_NAME}_VERSION})" )
       foreach( var in ITEMS INCLUDE_DIR INCLUDE_DIRS DEFINITIONS LIBRARY LIBRARIES )
-        if( ${PNAME}_${var} )
-          message( STATUS "   ${PNAME}_${var} : [${${PNAME}_${var}}]" )
+        if( ${pkgUPPER}_${var} )
+          message( STATUS "   ${pkgUPPER}_${var} : [${${pkgUPPER}_${var}}]" )
         elseif( ${_PAR_NAME}_${var} )
           message( STATUS "   ${_PAR_NAME}_${var} : [${${_PAR_NAME}_${var}}]" )
         endif()
diff --git a/cmake/ecbuild_find_perl.cmake b/cmake/ecbuild_find_perl.cmake
index 054b414..c615203 100644
--- a/cmake/ecbuild_find_perl.cmake
+++ b/cmake/ecbuild_find_perl.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -6,7 +6,33 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-# OUTPUT:
+##############################################################################
+#.rst:
+#
+# ecbuild_find_perl
+# =================
+#
+# Find perl executable and its version. ::
+#
+#   ecbuild_find_perl( [ REQUIRED ] )
+#
+# Options
+# -------
+#
+# REQUIRED : optional
+#   fail if perl was not found
+#
+# Output variables
+# ----------------
+#
+# The following CMake variables are set if perl was found:
+#
+# :PERL_FOUND:          perl was found
+# :PERL_EXECUTABLE:     path to the perl executable
+# :PERL_VERSION:        perl version
+# :PERL_VERSION_STRING: perl version (same as ``PERL_VERSION``)
+#
+##############################################################################
 
 macro( ecbuild_find_perl )
 
diff --git a/cmake/ecbuild_find_python.cmake b/cmake/ecbuild_find_python.cmake
index e6a3db6..dde6c06 100644
--- a/cmake/ecbuild_find_python.cmake
+++ b/cmake/ecbuild_find_python.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,20 +6,43 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to find python
-
-# OUTPUT:
-#   PYTHONINTERP_FOUND
-#   PYTHONLIBS_FOUND
-#   PYTHON_FOUND
-#   PYTHON_VERSION_MAJOR
-#   PYTHON_VERSION_MINOR
-#   PYTHON_VERSION_PATCH
-#   PYTHON_VERSION_STRING
-#   PYTHON_INCLUDE_DIRS
-#   PYTHON_LIBRARIES
-#   PYTHON_SITE_PACKAGES
+##############################################################################
+#.rst:
+#
+# ecbuild_find_python
+# ===================
+#
+# Find Python interpreter, its version and the Python libraries. ::
+#
+#   ecbuild_find_python( [ VERSION <version> ] [ REQUIRED ] )
+#
+# Options
+# -------
+#
+# VERSION : optional
+#   minimum required version
+#
+# REQUIRED : optional
+#   fail if Python was not found
+#
+# Output variables
+# ----------------
+#
+# The following CMake variables are set if python was found:
+#
+# :PYTHONINTERP_FOUND:    Python interpreter was found
+# :PYTHONLIBS_FOUND:      Python libraries were found
+# :PYTHON_FOUND:          Python was found (both interpreter and libraries)
+# :PYTHON_EXECUTABLE:     Python executable
+# :PYTHON_VERSION_MAJOR:  major version number
+# :PYTHON_VERSION_MINOR:  minor version number
+# :PYTHON_VERSION_PATCH:  patch version number
+# :PYTHON_VERSION_STRING: Python version
+# :PYTHON_INCLUDE_DIRS:   Python include directories
+# :PYTHON_LIBRARIES:      Python libraries
+# :PYTHON_SITE_PACKAGES:  Python site packages directory
+#
+##############################################################################
 
 set( __test_python ${CMAKE_CURRENT_LIST_DIR}/pymain.c )
 
@@ -42,7 +65,7 @@ macro( ecbuild_find_python )
     find_package( PythonInterp )
 
     if( NOT PYTHONINTERP_FOUND AND _p_REQUIRED )
-        message( FATAL_ERROR "Failed to find any Python interpreter (REQUIRED)" )
+        ecbuild_error( "Failed to find any Python interpreter (REQUIRED)" )
     endif()
 
     # find python version
@@ -52,10 +75,10 @@ macro( ecbuild_find_python )
     # endif()
     # endif()
 
-    # message( STATUS "Python version ${PYTHON_VERSION_STRING}" )
-    # debug_var(PYTHON_VERSION_MAJOR)
-    # debug_var(PYTHON_VERSION_MINOR)
-    # debug_var(PYTHON_VERSION_PATCH)
+    # ecbuild_debug( "Python version ${PYTHON_VERSION_STRING}" )
+    # ecbuild_debug_var(PYTHON_VERSION_MAJOR)
+    # ecbuild_debug_var(PYTHON_VERSION_MINOR)
+    # ecbuild_debug_var(PYTHON_VERSION_PATCH)
 
     if( PYTHONINTERP_FOUND AND DEFINED _p_VERSION )
         if( _p_VERSION VERSION_GREATER "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}" )
@@ -80,14 +103,16 @@ macro( ecbuild_find_python )
             find_program( PYTHON_CONFIG NAMES python-config python-config${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} )
         endif()
 
+        ecbuild_debug_var( PYTHON_CONFIG )
+
         # find python libs
 
-        # The OpenBSD python packages have python-config's 
+        # The OpenBSD python packages have python-config's
         # that don't reliably report linking flags that will work.
-        
+
         if( PYTHON_CONFIG AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
             ecbuild_debug( "ecbuild_find_python: Searching for Python include directories and libraries using ${PYTHON_CONFIG}" )
-            
+
             execute_process(COMMAND "${PYTHON_CONFIG}" --ldflags
                             OUTPUT_VARIABLE PYTHON_LIBRARIES
                             OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -100,12 +125,12 @@ macro( ecbuild_find_python )
 
             string(REGEX REPLACE "^[-I]" "" PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
             string(REGEX REPLACE "[ ]-I" " " PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
-            
+
             separate_arguments(PYTHON_INCLUDE_DIR)
 
         else() # revert to finding pythonlibs the standard way (cmake macro)
             ecbuild_debug( "ecbuild_find_python: Searching for Python include directories and libraries using find_package(PythonLibs)" )
-            
+
             find_package(PythonLibs)
             if( PYTHON_INCLUDE_PATH AND NOT PYTHON_INCLUDE_DIR )
                 set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}")
@@ -113,24 +138,29 @@ macro( ecbuild_find_python )
 
         endif()
 
-        # Test if we can link against the Python libraries and include Python.h
-        try_compile( PYTHON_LIBS_WORKING ${CMAKE_CURRENT_BINARY_DIR}
-                     ${__test_python}
-                     COMPILE_DEFINITIONS -I${PYTHON_INCLUDE_DIR}
-                     LINK_LIBRARIES ${PYTHON_LIBRARIES} )
+        # Remove duplicate include directories
+        list(REMOVE_DUPLICATES PYTHON_INCLUDE_DIR)
+
 
-        # set output variables
+        if( PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIR )
+            # Test if we can link against the Python libraries and include Python.h
+            try_compile( PYTHON_LIBS_WORKING ${CMAKE_CURRENT_BINARY_DIR}
+                         ${__test_python}
+                         CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${PYTHON_INCLUDE_DIR}"
+                         LINK_LIBRARIES ${PYTHON_LIBRARIES} )
 
-        find_package_handle_standard_args( PythonLibs DEFAULT_MSG
-                                           PYTHON_INCLUDE_DIR PYTHON_LIBRARIES PYTHON_LIBS_WORKING )
-        ecbuild_debug( "ecbuild_find_python: PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}" )
-        ecbuild_debug( "ecbuild_find_python: PYTHON_LIBRARIES=${PYTHON_LIBRARIES}" )
+            # set output variables
+
+            find_package_handle_standard_args( PythonLibs DEFAULT_MSG
+                                               PYTHON_INCLUDE_DIR PYTHON_LIBRARIES PYTHON_LIBS_WORKING )
+            ecbuild_debug( "ecbuild_find_python: PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}" )
+            ecbuild_debug( "ecbuild_find_python: PYTHON_LIBRARIES=${PYTHON_LIBRARIES}" )
+
+        endif()
 
         set( PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR} )
         set( PYTHON_INCLUDE_PATH ${PYTHON_INCLUDE_DIR} )
 
-        list( REMOVE_DUPLICATES PYTHON_INCLUDE_DIRS )
-
         # Also set PYTHON_FOUND and Python_FOUND for compatibility with ecbuild_add_option
         if( PYTHONLIBS_FOUND )
           set( PYTHON_FOUND 1 )
@@ -139,16 +169,22 @@ macro( ecbuild_find_python )
 
         # find where python site-packages are ...
 
-        execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
+        if( PYTHON_EXECUTABLE )
+            execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
+        endif()
         ecbuild_debug( "ecbuild_find_python: PYTHON_SITE_PACKAGES=${PYTHON_SITE_PACKAGES}" )
 
     endif()
 
-#    debug_var( PYTHONINTERP_FOUND )
-#    debug_var( PYTHON_EXECUTABLE )
-#    debug_var( PYTHONLIBS_FOUND )
-#    debug_var( PYTHON_INCLUDE_DIRS )
-#    debug_var( PYTHON_LIBRARIES )
-#    debug_var( PYTHON_SITE_PACKAGES )
+    ecbuild_debug_var( PYTHONINTERP_FOUND )
+    ecbuild_debug_var( PYTHON_FOUND )
+    ecbuild_debug_var( PYTHON_EXECUTABLE )
+    ecbuild_debug_var( PYTHON_VERSION_MAJOR )
+    ecbuild_debug_var( PYTHON_VERSION_MINOR )
+    ecbuild_debug_var( PYTHON_VERSION_PATCH )
+    ecbuild_debug_var( PYTHON_VERSION_STRING )
+    ecbuild_debug_var( PYTHON_INCLUDE_DIRS )
+    ecbuild_debug_var( PYTHON_LIBRARIES )
+    ecbuild_debug_var( PYTHON_SITE_PACKAGES )
 
 endmacro( ecbuild_find_python )
diff --git a/cmake/ecbuild_generate_config_headers.cmake b/cmake/ecbuild_generate_config_headers.cmake
index abf9aac..93cbb1f 100644
--- a/cmake/ecbuild_generate_config_headers.cmake
+++ b/cmake/ecbuild_generate_config_headers.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,42 +6,58 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# generates the config header fot the project with the system introspection done by CMake
+##############################################################################
+#.rst:
+#
+# ecbuild_generate_config_headers
+# ===============================
+#
+# Generates the ecBuild configuration header for the project with the system
+# introspection done by CMake. ::
+#
+#   ecbuild_generate_config_headers( [ DESTINATION <directory> ] )
+#
+# Options
+# -------
+#
+# DESTINATION : optional
+#   installation destination directory
+#
+##############################################################################
 
 function( ecbuild_generate_config_headers )
 
-    # parse parameters
+  # parse parameters
 
-    set( options )
-	set( single_value_args DESTINATION )
-    set( multi_value_args  )
+  set( options )
+  set( single_value_args DESTINATION )
+  set( multi_value_args  )
 
-	cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+  cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
-    if(_PAR_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_generate_config_headers(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-    endif()
+  if(_PAR_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unknown keywords given to ecbuild_generate_config_headers(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+  endif()
 
-	# generate list of compiler flags
+  # generate list of compiler flags
 
-	string( TOUPPER ${PROJECT_NAME} PNAME )
+  string( TOUPPER ${PROJECT_NAME} PNAME )
 
-	get_property( langs GLOBAL PROPERTY ENABLED_LANGUAGES )
+  get_property( langs GLOBAL PROPERTY ENABLED_LANGUAGES )
 
-	foreach( lang ${langs} )
-		set( EC_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
-	endforeach()
+  foreach( lang ${langs} )
+    set( EC_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
+  endforeach()
 
-	configure_file( ${ECBUILD_MACROS_DIR}/ecbuild_config.h.in  ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ecbuild_config.h   )
+  configure_file( ${ECBUILD_MACROS_DIR}/ecbuild_config.h.in  ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ecbuild_config.h   )
 
-	# install ecbuild configuration
+  # install ecbuild configuration
 
-	set( _destination ${INSTALL_INCLUDE_DIR} )
-	if( _p_DESTINATION )
-		set( _destination ${_p_DESTINATION} )
-	endif()
+  set( _destination ${INSTALL_INCLUDE_DIR} )
+  if( _p_DESTINATION )
+    set( _destination ${_p_DESTINATION} )
+  endif()
 
-	install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ecbuild_config.h DESTINATION ${_destination} )
+  install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ecbuild_config.h DESTINATION ${_destination} )
 
 endfunction( ecbuild_generate_config_headers )
diff --git a/cmake/ecbuild_generate_fortran_interfaces.cmake b/cmake/ecbuild_generate_fortran_interfaces.cmake
new file mode 100644
index 0000000..d57d89a
--- /dev/null
+++ b/cmake/ecbuild_generate_fortran_interfaces.cmake
@@ -0,0 +1,115 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_generate_fortran_interfaces
+# ===================================
+#
+# Generates interfaces form the Fortran source files. ::
+#
+#   ecbuild_generate_fortran_interfaces()
+#
+# Options
+# -------
+#
+# TARGET : required
+#   target name
+#
+##############################################################################
+
+function( ecbuild_generate_fortran_interfaces )
+
+  find_program( FCM_EXECUTABLE fcm REQUIRED DOC "Fortran interface generator" )
+
+  if( NOT FCM_EXECUTABLE )
+    message( FATAL_ERROR "ecbuild_generate_fortran_interfaces: fcm executable not found." )
+  endif()
+
+  set( FCM_CONFIG_FILE "${PROJECT_SOURCE_DIR}/cmake/fcm-make-interfaces.cfg")
+
+  if( NOT EXISTS ${FCM_CONFIG_FILE} )
+    message( FATAL_ERROR "ecbuild_generate_fortran_interfaces: needs fcm configuration in ${FCM_CONFIG_FILE}" )
+  endif()
+
+  set( options )
+  set( single_value_args TARGET DESTINATION PARALLEL INCLUDE_DIRS GENERATED SOURCE_DIR )
+  set( multi_value_args DIRECTORIES )
+
+  cmake_parse_arguments( P "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+  if( NOT DEFINED P_TARGET )
+    message( FATAL_ERROR "ecbuild_generate_fortran_interfaces: TARGET argument missing" )
+  endif()
+
+  if( NOT DEFINED P_DESTINATION )
+    message( FATAL_ERROR "ecbuild_generate_fortran_interfaces: DESTINATION argument missing" )
+  endif()
+
+  if( NOT DEFINED P_DIRECTORIES )
+    message( FATAL_ERROR "ecbuild_generate_fortran_interfaces: DIRECTORIES argument missing" )
+  endif()
+
+  if( NOT DEFINED P_PARALLEL OR (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") )
+    set( P_PARALLEL 1 )
+  endif()
+
+  if( NOT DEFINED P_SOURCE_DIR )
+    message( FATAL_ERROR "ecbuild_generate_fortran_interfaces: SOURCE_DIR argument missing")
+  endif()
+
+  foreach( _srcdir ${P_DIRECTORIES} )
+    if( _srcdir MATCHES "/$" )
+      ecbuild_critical("ecbuild_generate_fortran_interfaces: directory ${_srcdir} must not end with /")
+    endif()
+    ecbuild_list_add_pattern( LIST fortran_files SOURCE_DIR ${P_SOURCE_DIR} GLOB ${_srcdir}/*.F* )
+  endforeach()
+
+  string( REPLACE ";" " " _srcdirs "${P_DIRECTORIES}" )
+
+  set( _cnt 0 )
+  foreach( file ${_fortran_files} )
+    if( ${${SRC}/file} IS_NEWER_THAN ${${SRC}/file} )
+      set( run_fcm 1 )
+    endif()
+  endforeach()
+
+  foreach( fortran_file ${fortran_files} )
+    #list( APPEND fullpath_fortran_files ${CMAKE_CURRENT_SOURCE_DIR}/${fortran_file} )
+      get_filename_component(base ${fortran_file} NAME_WE)
+      set( interface_file "${CMAKE_CURRENT_BINARY_DIR}/interfaces/include/${base}.intfb.h" )
+      list( APPEND interface_files ${interface_file} )
+      set_source_files_properties( ${interface_file} PROPERTIES GENERATED TRUE )
+      math(EXPR _cnt "${_cnt}+1")
+  endforeach()
+
+  ecbuild_info("Target ${P_TARGET} will generate ${_cnt} interface files using FCM")
+
+  if( DEFINED P_GENERATED )
+    set( ${P_GENERATED} ${interface_files} PARENT_SCOPE )
+  endif()
+
+  set( include_dir ${CMAKE_CURRENT_BINARY_DIR}/${P_DESTINATION}/interfaces/include )
+  set( ${P_INCLUDE_DIRS} ${include_dir} PARENT_SCOPE )
+
+  execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${include_dir}
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
+
+    add_custom_command(
+      OUTPUT  "${P_DESTINATION}/${P_TARGET}.timestamp"
+      COMMAND ${FCM_EXECUTABLE} make -j ${P_PARALLEL} --config-file=${FCM_CONFIG_FILE} interfaces.ns-incl=${_srcdirs} interfaces.source=${P_SOURCE_DIR}
+      COMMAND touch "${P_TARGET}.timestamp"
+      DEPENDS ${fortran_files}
+      COMMENT "Generating ${_cnt} interface files for target ${P_TARGET}"
+      WORKING_DIRECTORY ${P_DESTINATION} VERBATIM )
+
+    add_custom_target( ${P_TARGET} DEPENDS ${P_DESTINATION}/${P_TARGET}.timestamp )
+
+
+endfunction( ecbuild_generate_fortran_interfaces )
diff --git a/cmake/ecbuild_generate_rpc.cmake b/cmake/ecbuild_generate_rpc.cmake
index 5bd4f76..45a00ba 100644
--- a/cmake/ecbuild_generate_rpc.cmake
+++ b/cmake/ecbuild_generate_rpc.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,8 +6,35 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to process rpcgen files
+##############################################################################
+#.rst:
+#
+# ecbuild_generate_rpc
+# ====================
+#
+# Process RPC (Remote Procedure Call) Language files using rpcgen. ::
+#
+#   ecbuild_generate_rpc( SOURCE <file>
+#                         [ TARGET_H <file> ]
+#                         [ TARGET_C <file> ]
+#                         [ DEPENDANT <file1> [ <file2> ... ] ] )
+#
+# Options
+# -------
+#
+# SOURCE : required
+#   RPC source file
+#
+# TARGET_H : optional (required if TARGET_C not given)
+#   name of header file to be generated
+#
+# TARGET_C : optional (required if TARGET_H not given)
+#   name of source file to be generated
+#
+# DEPENDANT : optional
+#  list of files which depend on the generated source and header files
+#
+##############################################################################
 
 macro( ecbuild_generate_rpc )
 
diff --git a/cmake/ecbuild_generate_yy.cmake b/cmake/ecbuild_generate_yy.cmake
index 75bef3a..5ef2dad 100644
--- a/cmake/ecbuild_generate_yy.cmake
+++ b/cmake/ecbuild_generate_yy.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,116 +6,188 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# macro to process lex/yacc files
+##############################################################################
+#.rst:
+#
+# ecbuild_generate_yy
+# ===================
+#
+# Process lex/yacc files. ::
+#
+#   ecbuild_generate_yy( YYPREFIX <prefix>
+#                        YACC <file>
+#                        LEX <file>
+#                        DEPENDANT <file1> [ <file2> ... ]
+#                        [ SOURCE_DIR <dir> ]
+#                        [ YACC_TARGET <file> ]
+#                        [ LEX_TARGET <file> ]
+#                        [ YACC_FLAGS <flags> ]
+#                        [ LEX_FLAGS <flags> ]
+#                        [ BISON_FLAGS <flags> ]
+#                        [ FLEX_FLAGS <flags> ] )
+#
+# Options
+# -------
+#
+# YYPREFIX : required
+#   prefix to use for file and function names
+#
+# YACC : required
+#   base name of the yacc source file (without .y extension)
+#
+# LEX : required
+#   base name of the lex source file (without .l extension)
+#
+# DEPENDANT : required
+#  list of files which depend on the generated lex and yacc target files
+#  At least one should be an existing source file (not generated itself).
+#
+# SOURCE_DIR : optional, defaults to CMAKE_CURRENT_SOURCE_DIR
+#   directory where yacc and lex source files are located
+#
+# YACC_TARGET : optional, defaults to YACC
+#   base name of the generated yacc target file (without .c extension)
+#
+# LEX_TARGET : optional, defaults to LEX
+#   base name of the generated lex target file (without .c extension)
+#
+# YACC_FLAGS : optional, defaults to -t
+#   flags to pass to yacc executable
+#
+# LEX_FLAGS : optional
+#   flags to pass to lex executable
+#
+# BISON_FLAGS : optional, defaults to -t
+#   flags to pass to bison executable
+#
+# FLEX_FLAGS : optional, defaults to -l
+#   flags to pass to flex executable
+#
+##############################################################################
 
 macro( ecbuild_generate_yy )
 
-	ecbuild_find_lexyacc() # find [ yacc|byson ] and [ lex|flex ]
+  ecbuild_find_lexyacc() # find [ yacc|byson ] and [ lex|flex ]
 
-	ecbuild_find_perl( REQUIRED )
+  ecbuild_find_perl( REQUIRED )
 
-    set( options )
-	set( single_value_args YYPREFIX YACC LEX YACC_TARGET LEX_TARGET LEX_FLAGS YACC_FLAGS FLEX_FLAGS BISON_FLAGS )
-    set( multi_value_args  DEPENDANT )
+  set( options )
+  set( single_value_args YYPREFIX YACC LEX SOURCE_DIR YACC_TARGET LEX_TARGET LEX_FLAGS YACC_FLAGS FLEX_FLAGS BISON_FLAGS )
+  set( multi_value_args  DEPENDANT )
 
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+  cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
-    if(_PAR_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_generate_yy(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-    endif()
+  if(_PAR_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unknown keywords given to ecbuild_generate_yy(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+  endif()
 
-    if( NOT _PAR_YYPREFIX  )
-      message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the YYPREFIX.")
-    endif()
+  if( NOT _PAR_YYPREFIX  )
+    message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the YYPREFIX.")
+  endif()
 
-    if( NOT _PAR_YACC  )
-      message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the YACC file.")
-    endif()
+  if( NOT _PAR_YACC  )
+    message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the YACC file.")
+  endif()
 
-    if( NOT _PAR_LEX  )
-      message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the LEX file.")
-    endif()
+  if( NOT _PAR_LEX  )
+    message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the LEX file.")
+  endif()
 
-    if( NOT _PAR_DEPENDANT )
-      message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the DEPENDANT files.")
-    endif()
+  if( NOT _PAR_DEPENDANT )
+    message(FATAL_ERROR "The call to ecbuild_generate_yy() doesn't specify the DEPENDANT files.")
+  endif()
 
-    set( BASE ${_PAR_YYPREFIX}_${_PAR_YACC} )
+  set( BASE ${_PAR_YYPREFIX}_${_PAR_YACC} )
 
-	## default flags
+  ## default flags
 
-	if( NOT _PAR_LEX_FLAGS )
-		set( _PAR_LEX_FLAGS "" )
-	endif()
+  if( NOT _PAR_LEX_FLAGS )
+    set( _PAR_LEX_FLAGS "" )
+  endif()
 
-	if( NOT _PAR_FLEX_FLAGS )
-		set( _PAR_FLEX_FLAGS "-l" )
-	endif()
+  if( NOT _PAR_FLEX_FLAGS )
+    set( _PAR_FLEX_FLAGS "-l" )
+  endif()
 
-	if( NOT _PAR_YACC_FLAGS )
-		set( _PAR_YACC_FLAGS "-t" )
-	endif()
+  if( NOT _PAR_YACC_FLAGS )
+    set( _PAR_YACC_FLAGS "-t" )
+  endif()
 
-	if( NOT _PAR_BISON_FLAGS )
-		set( _PAR_BISON_FLAGS "-t" )
-	endif()
+  if( NOT _PAR_BISON_FLAGS )
+    set( _PAR_BISON_FLAGS "-t" )
+  endif()
 
-    #debug_var( BASE )
+  if( NOT _PAR_YACC_TARGET )
+    set ( _PAR_YACC_TARGET ${_PAR_YACC} )
+  endif()
 
-    if( NOT _PAR_YACC_TARGET )
-        set ( _PAR_YACC_TARGET ${_PAR_YACC} )
-    endif()
+  if ( NOT _PAR_LEX_TARGET )
+    set ( _PAR_LEX_TARGET ${_PAR_LEX} )
+  endif()
 
-    if ( NOT _PAR_LEX_TARGET )
-        set ( _PAR_LEX_TARGET ${_PAR_LEX} )
-    endif()
+  set( ${BASE}yy_tmp_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_YACC_TARGET}.tmp.c )
+  set( ${BASE}yh_tmp_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_YACC_TARGET}.tmp.h )
+  set( ${BASE}yl_tmp_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_LEX_TARGET}.tmp.c )
 
-    set( ${BASE}yy_tmp_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_YACC_TARGET}.tmp.c )
-    set( ${BASE}yl_tmp_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_LEX_TARGET}.tmp.c )
+  set( ${BASE}yy_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_YACC_TARGET}.c )
+  set( ${BASE}yh_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_YACC_TARGET}.h )
+  set( ${BASE}yl_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_LEX_TARGET}.c )
 
-    set( ${BASE}yy_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_YACC_TARGET}.c )
-    set( ${BASE}yl_target ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_LEX_TARGET}.c )
+  if( NOT _PAR_SOURCE_DIR )
+    set( _PAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
+  endif()
 
-    add_custom_target( ${_PAR_YYPREFIX}_${DEPENDANT} SOURCES ${_PAR_YACC}.y ${_PAR_LEX}.l )
+  add_custom_target( ${_PAR_YYPREFIX}_${DEPENDANT} SOURCES ${_PAR_SOURCE_DIR}/${_PAR_YACC}.y ${_PAR_SOURCE_DIR}/${_PAR_LEX}.l )
 
-    if( BISON_FOUND )
-		bison_target( ${BASE}_parser  ${_PAR_YACC}.y  ${${BASE}yy_tmp_target} COMPILE_FLAGS "${_PAR_BISON_FLAGS}" )
-	else()
-		yacc_target( ${BASE}_parser  ${_PAR_YACC}.y   ${${BASE}yy_tmp_target} COMPILE_FLAGS "${_PAR_YACC_FLAGS}" )
-    endif()
+  if( BISON_FOUND )
+    bison_target( ${BASE}_parser ${_PAR_SOURCE_DIR}/${_PAR_YACC}.y ${${BASE}yy_tmp_target} COMPILE_FLAGS "${_PAR_BISON_FLAGS}" )
+  else()
+    yacc_target( ${BASE}_parser ${_PAR_SOURCE_DIR}/${_PAR_YACC}.y ${${BASE}yy_tmp_target} COMPILE_FLAGS "${_PAR_YACC_FLAGS}" )
+  endif()
 
-    if( FLEX_FOUND )
-		flex_target(  ${BASE}_scanner ${_PAR_LEX}.l   ${${BASE}yl_tmp_target} COMPILE_FLAGS "${_PAR_FLEX_FLAGS}" )
-        add_flex_bison_dependency(${BASE}_scanner ${BASE}_parser)
-    else()
-		lex_target(  ${BASE}_scanner ${_PAR_LEX}.l   ${${BASE}yl_tmp_target} COMPILE_FLAGS "${_PAR_LEX_FLAGS}" )
-        add_lex_yacc_dependency(${BASE}_scanner ${BASE}_parser)
-    endif()
+  if( FLEX_FOUND )
+    flex_target( ${BASE}_scanner ${_PAR_SOURCE_DIR}/${_PAR_LEX}.l ${${BASE}yl_tmp_target} COMPILE_FLAGS "${_PAR_FLEX_FLAGS}" )
+    add_flex_bison_dependency(${BASE}_scanner ${BASE}_parser)
+  else()
+    lex_target( ${BASE}_scanner ${_PAR_SOURCE_DIR}/${_PAR_LEX}.l ${${BASE}yl_tmp_target} COMPILE_FLAGS "${_PAR_LEX_FLAGS}" )
+    add_lex_yacc_dependency(${BASE}_scanner ${BASE}_parser)
+  endif()
 
-    set_source_files_properties(${${BASE}yy_tmp_target} GENERATED)
-    set_source_files_properties(${${BASE}yl_tmp_target} GENERATED)
+  set_source_files_properties(${${BASE}yy_tmp_target} GENERATED)
+  set_source_files_properties(${${BASE}yh_tmp_target} GENERATED)
+  set_source_files_properties(${${BASE}yl_tmp_target} GENERATED)
 
-    add_custom_command(OUTPUT  ${${BASE}yy_target}
-                       COMMAND ${CMAKE_COMMAND} -E copy ${${BASE}yy_tmp_target} ${${BASE}yy_target}
-                       COMMAND ${PERL_EXECUTABLE} -pi -e 's/yy/${_PAR_YYPREFIX}/g' ${${BASE}yy_target}
-                       COMMAND ${PERL_EXECUTABLE} -pi -e 's/\\.tmp\\.c/\\.c/g' ${${BASE}yy_target}
-                       DEPENDS ${${BASE}yy_tmp_target}
+  add_custom_command(OUTPUT  ${${BASE}yy_target}
+    COMMAND ${CMAKE_COMMAND} -E copy ${${BASE}yy_tmp_target} ${${BASE}yy_target}
+    COMMAND ${PERL_EXECUTABLE} -pi -e 's/yy/${_PAR_YYPREFIX}/g' ${${BASE}yy_target}
+    COMMAND ${PERL_EXECUTABLE} -pi -e 's/\\.tmp\\.c/\\.c/g' ${${BASE}yy_target}
+    DEPENDS ${${BASE}yy_tmp_target}
     )
 
-    add_custom_command(OUTPUT  ${${BASE}yl_target}
-                       COMMAND ${CMAKE_COMMAND} -E copy ${${BASE}yl_tmp_target} ${${BASE}yl_target}
-                       COMMAND ${PERL_EXECUTABLE} -pi -e 's/yy/${_PAR_YYPREFIX}/g' ${${BASE}yl_target}
-                       COMMAND ${PERL_EXECUTABLE} -pi -e 's/\\.tmp\\.c/\\.c/g' ${${BASE}yl_target}
-                       DEPENDS ${${BASE}yl_tmp_target}
+  add_custom_command(OUTPUT  ${${BASE}yh_target}
+    COMMAND ${CMAKE_COMMAND} -E copy ${${BASE}yh_tmp_target} ${${BASE}yh_target}
+    COMMAND ${PERL_EXECUTABLE} -pi -e 's/yy/${_PAR_YYPREFIX}/g' ${${BASE}yh_target}
+    COMMAND ${PERL_EXECUTABLE} -pi -e 's/\\.tmp\\.h/\\.h/g' ${${BASE}yh_target}
+    DEPENDS ${${BASE}yh_tmp_target}
     )
 
-    set_source_files_properties(${${BASE}yy_target} GENERATED)
-    set_source_files_properties(${${BASE}yl_target} GENERATED)
+  add_custom_command(OUTPUT  ${${BASE}yl_target}
+    COMMAND ${CMAKE_COMMAND} -E copy ${${BASE}yl_tmp_target} ${${BASE}yl_target}
+    COMMAND ${PERL_EXECUTABLE} -pi -e 's/yy/${_PAR_YYPREFIX}/g' ${${BASE}yl_target}
+    COMMAND ${PERL_EXECUTABLE} -pi -e 's/\\.tmp\\.c/\\.c/g' ${${BASE}yl_target}
+    DEPENDS ${${BASE}yl_tmp_target}
+    )
+
+  set_source_files_properties(${${BASE}yy_target} GENERATED)
+  set_source_files_properties(${${BASE}yh_target} GENERATED)
+  set_source_files_properties(${${BASE}yl_target} GENERATED)
 
-    foreach( file ${_PAR_DEPENDANT} )
-        set_source_files_properties( ${file} PROPERTIES
-                                    OBJECT_DEPENDS "${${BASE}yy_target};${${BASE}yl_target}" )
-    endforeach()
+  foreach( file ${_PAR_DEPENDANT} )
+    if( NOT IS_ABSOLUTE ${file})
+      set( file ${_PAR_SOURCE_DIR}/${file} )
+    endif()
+    set_source_files_properties( ${file} PROPERTIES
+        OBJECT_DEPENDS "${${BASE}yy_target};${${BASE}yh_target};${${BASE}yl_target}" )
+  endforeach()
 
 endmacro( ecbuild_generate_yy )
diff --git a/cmake/ecbuild_get_cxx11_flags.cmake b/cmake/ecbuild_get_cxx11_flags.cmake
index dc6b700..5bfed07 100644
--- a/cmake/ecbuild_get_cxx11_flags.cmake
+++ b/cmake/ecbuild_get_cxx11_flags.cmake
@@ -7,8 +7,17 @@
 # nor does it submit to any jurisdiction.
 
 ##############################################################################
-# Function setting ${CXX11_FLAGS} to the cxx11 flags for the current compiler
-# based on macros from the project github.com/UCL/GreatCMakeCookOff
+#.rst:
+#
+# ecbuild_get_cxx11_flags
+# =======================
+#
+# Set the CMake variable ``${CXX11_FLAGS}`` to the C++11 flags for the current
+# compiler (based on macros from https://github.com/UCL/GreatCMakeCookOff). ::
+#
+#   ecbuild_get_cxx11_flags( CXX11_FLAGS )
+#
+##############################################################################
 
 function( ecbuild_get_cxx11_flags CXX11_FLAGS )
 
diff --git a/cmake/ecbuild_get_date.cmake b/cmake/ecbuild_get_date.cmake
index afe3d09..ec308a3 100644
--- a/cmake/ecbuild_get_date.cmake
+++ b/cmake/ecbuild_get_date.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -6,8 +6,18 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# get date macro
+##############################################################################
+#.rst:
+#
+# ecbuild_get_date
+# ================
+#
+# Set the CMake variable ``${DATE}`` to the current date in the form
+# YYYY.mm.DD. ::
+#
+#   ecbuild_get_date( DATE )
+#
+##############################################################################
 
 macro(ecbuild_get_date RESULT)
     if(UNIX)
@@ -18,8 +28,18 @@ macro(ecbuild_get_date RESULT)
     endif()
 endmacro(ecbuild_get_date)
 
-############################################################################################
-# get timestamp
+##############################################################################
+#.rst:
+#
+# ecbuild_get_timestamp
+# =====================
+#
+# Set the CMake variable ``${TIMESTAMP}`` to the current date and time in the
+# form YYYYmmDDHHMMSS. ::
+#
+#   ecbuild_get_timestamp( TIMESTAMP )
+#
+##############################################################################
 
 macro(ecbuild_get_timestamp RESULT)
     if(UNIX)
diff --git a/cmake/ecbuild_get_resources.cmake b/cmake/ecbuild_get_resources.cmake
index bf48ecf..d79ee59 100644
--- a/cmake/ecbuild_get_resources.cmake
+++ b/cmake/ecbuild_get_resources.cmake
@@ -1,8 +1,8 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
+# (C) Copyright 1996-2015 ECMWF.
+#
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
@@ -29,7 +29,7 @@ macro( ecbuild_get_resources )
     if( NOT _PAR_TO_DIR )
 		set( _PAR_TO_DIR ${CMAKE_CURRENT_BINARY_DIR} )
 	endif()
-	
+
     list( LENGTH _PAR_LIST _rsize )
     math( EXPR _max "${_rsize}-1" )
     foreach( i RANGE 0 ${_max} 2 )
@@ -39,14 +39,14 @@ macro( ecbuild_get_resources )
         list( GET _PAR_LIST ${i}  r  )
         list( GET _PAR_LIST ${in} rh )
 
-#        debug_var( r  )
-#        debug_var( rh )
+#        ecbuild_debug_var( r  )
+#        ecbuild_debug_var( rh )
 
         get_filename_component( rf ${r} NAME )
 
         file( DOWNLOAD ${r} ${_PAR_TO_DIR}/${rf} EXPECTED_HASH SHA1=${rh} )
 
     endforeach()
-		
+
 
 endmacro()
diff --git a/cmake/ecbuild_get_test_data.cmake b/cmake/ecbuild_get_test_data.cmake
index 6c6ea5e..0920133 100644
--- a/cmake/ecbuild_get_test_data.cmake
+++ b/cmake/ecbuild_get_test_data.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -12,66 +12,118 @@
 
 function( _download_test_data _p_NAME _p_DIRNAME )
 
-    # TODO: make that 'at ecmwf'
-    #if(1)
-    #unset(ENV{no_proxy})
-    #unset(ENV{NO_PROXY})
-    #set(ENV{http_proxy} "http://proxy.ecmwf.int:3333")
-    #endif()
+  # TODO: make that 'at ecmwf'
+  #if(1)
+  #unset(ENV{no_proxy})
+  #unset(ENV{NO_PROXY})
+  #set(ENV{http_proxy} "http://proxy.ecmwf.int:3333")
+  #endif()
 
-    find_program( CURL_PROGRAM curl )
+  find_program( CURL_PROGRAM curl )
 
-    if( CURL_PROGRAM )
+  if( CURL_PROGRAM )
 
-		add_custom_command( OUTPUT ${_p_NAME}
-			COMMENT "(curl) downloading http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME}"
-			COMMAND ${CURL_PROGRAM} --silent --show-error --fail --output ${_p_NAME} http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME} )
+    add_custom_command( OUTPUT ${_p_NAME}
+      COMMENT "(curl) downloading http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME}"
+      COMMAND ${CURL_PROGRAM} --silent --show-error --fail --output ${_p_NAME}
+              http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME} )
 
-    else()
-
-        find_program( WGET_PROGRAM wget )
+  else()
 
-        if( WGET_PROGRAM )
+    find_program( WGET_PROGRAM wget )
 
-				 add_custom_command( OUTPUT ${_p_NAME}
-						COMMENT "(wget) downloading http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME}"
-						COMMAND ${WGET_PROGRAM} -nv -O ${_p_NAME} http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME} )
+    if( WGET_PROGRAM )
 
-				else()
+      add_custom_command( OUTPUT ${_p_NAME}
+        COMMENT "(wget) downloading http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME}"
+        COMMAND ${WGET_PROGRAM} -nv -O ${_p_NAME}
+                http://download.ecmwf.org/test-data/${_p_DIRNAME}/${_p_NAME} )
 
-					if( WARNING_CANNOT_DOWNLOAD_TEST_DATA )
-						message( WARNING "Couldn't find curl neither wget -- cannot download test data from server.\nPlease obtain the test data by other means and pleace it in the build directory." )
-						set( WARNING_CANNOT_DOWNLOAD_TEST_DATA 1 CACHE INTERNAL "Couldn't find curl neither wget -- cannot download test data from server" )
-						mark_as_advanced( WARNING_CANNOT_DOWNLOAD_TEST_DATA )
-					endif()
+    else()
 
-        endif()
+      if( WARNING_CANNOT_DOWNLOAD_TEST_DATA )
+        message( WARNING "Couldn't find curl neither wget -- cannot download test data from server.\nPlease obtain the test data by other means and pleace it in the build directory." )
+        set( WARNING_CANNOT_DOWNLOAD_TEST_DATA 1 CACHE INTERNAL "Couldn't find curl neither wget -- cannot download test data from server" )
+        mark_as_advanced( WARNING_CANNOT_DOWNLOAD_TEST_DATA )
+      endif()
 
     endif()
 
-endfunction()
+  endif()
 
+endfunction()
 
 ##############################################################################
-# function for getting test data
+#.rst:
+#
+# ecbuild_get_test_data
+# =====================
+#
+# Download a test data set at build time. ::
+#
+#   ecbuild_get_test_data( NAME <name>
+#                          [ TARGET <target> ]
+#                          [ DIRNAME <dir> ]
+#                          [ MD5 <hash> ]
+#                          [ EXTRACT ]
+#                          [ NOCHECK ] )
+#
+# curl or wget is required (curl is preferred if available).
+#
+# Options
+# -------
+#
+# NAME : required
+#   name of the test data file
+#
+# TARGET : optional, defaults to test_data_<name>
+#   CMake target name
+#
+# DIRNAME : optional, defaults to <project>/<relative path to current dir>
+#   directory in which the test data resides
 #
-# examples:
+# MD5 : optional, ignored if NOCHECK is given
+#   md5 checksum of the data set to verify. If not given and NOCHECK is *not*
+#   set, download the md5 checksum and verify
 #
-## no check done
-#    ecbuild_get_test_data( NAME msl.grib NOCHECK )
+# EXTRACT : optional
+#   extract the downloaded file (supported archives: tar, zip, tar.gz, tar.bz2)
 #
-## checksum agains remote md5 file
-#    ecbuild_get_test_data( NAME msl.grib )
+# NOCHECK : optional
+#   do not verify the md5 checksum of the data file
 #
-## checksum agains local md5
-#    ecbuild_get_test_data( NAME msl.grib MD5 f69ca0929d1122c7878d19f32401abe9 )
+# Usage
+# -----
 #
-## (DEPRECATED) checksum agains local sha1
-#    ecbuild_get_test_data( NAME msl.grib SHA1 5a8e8c57c510b64e31863ca47cfc3b65971089d9 )
+# Download test data from ``http://download.ecmwf.org/test-data/<DIRNAME>/<NAME>``
+#
+# If the ``DIRNAME`` argument is not given, the project name followed by the
+# relative path from the root directory to the current directory is used.
+#
+# By default, the downloaded file is verified against an md5 checksum, either
+# given as the ``MD5`` argument or downloaded from the server otherwise. Use
+# the argument ``NOCHECK`` to disable this check.
+#
+# Examples
+# --------
+#
+# Do not verify the checksum: ::
+#
+#   ecbuild_get_test_data( NAME msl.grib NOCHECK )
+#
+# Checksum agains remote md5 file: ::
+#
+#   ecbuild_get_test_data( NAME msl.grib )
+#
+# Checksum agains local md5: ::
+#
+#   ecbuild_get_test_data( NAME msl.grib MD5 f69ca0929d1122c7878d19f32401abe9 )
+#
+##############################################################################
 
 function( ecbuild_get_test_data )
 
-    set( options NOCHECK )
+    set( options NOCHECK EXTRACT )
     set( single_value_args TARGET URL NAME DIRNAME MD5 SHA1)
     set( multi_value_args  )
 
@@ -99,10 +151,10 @@ function( ecbuild_get_test_data )
       set( _p_DIRNAME ${PROJECT_NAME}/${currdir} )
     endif()
 
-#    debug_var( _p_TARGET )
-#    debug_var( _p_NAME )
-#    debug_var( _p_URL )
-#    debug_var( _p_DIRNAME )
+#    ecbuild_debug_var( _p_TARGET )
+#    ecbuild_debug_var( _p_NAME )
+#    ecbuild_debug_var( _p_URL )
+#    ecbuild_debug_var( _p_DIRNAME )
 
     # download the data
 
@@ -114,38 +166,38 @@ function( ecbuild_get_test_data )
 
     if( NOT _p_NOCHECK )
 
-        find_program( MD5SUM md5sum )
-
-        if( MD5SUM AND NOT _p_MD5 AND NOT _p_SHA1) # use remote md5
+        if( NOT _p_MD5 AND NOT _p_SHA1) # use remote md5
 
 #            message( STATUS " ---  getting MD5 sum " )
 
             add_custom_command( OUTPUT ${_p_NAME}.localmd5
-                                COMMAND ${MD5SUM} -t ${_p_NAME} > ${_p_NAME}.localmd5
+                                COMMAND ${CMAKE_COMMAND} -E md5sum ${_p_NAME} > ${_p_NAME}.localmd5
                                 DEPENDS ${_p_NAME} )
 
             _download_test_data( ${_p_NAME}.md5 ${_p_DIRNAME} )
 
-            add_custom_command(	OUTPUT ${_p_NAME}.ok
-                                COMMAND diff ${_p_NAME}.md5 ${_p_NAME}.localmd5 && touch ${_p_NAME}.ok
+            add_custom_command( OUTPUT ${_p_NAME}.ok
+                                COMMAND ${CMAKE_COMMAND} -E compare_files ${_p_NAME}.md5 ${_p_NAME}.localmd5 &&
+                                        ${CMAKE_COMMAND} -E touch ${_p_NAME}.ok
                                 DEPENDS ${_p_NAME}.localmd5 ${_p_NAME}.md5 )
 
             list( APPEND _deps  ${_p_NAME}.localmd5 ${_p_NAME}.ok )
 
         endif()
 
-        if( MD5SUM AND _p_MD5 )
+        if( _p_MD5 )
 
 #            message( STATUS " ---  computing MD5 sum [${_p_MD5}]" )
 
             add_custom_command( OUTPUT ${_p_NAME}.localmd5
-                                COMMAND ${MD5SUM} -t ${_p_NAME} > ${_p_NAME}.localmd5
+                                COMMAND ${CMAKE_COMMAND} -E md5sum ${_p_NAME} > ${_p_NAME}.localmd5
                                 DEPENDS ${_p_NAME} )
 
             configure_file( "${ECBUILD_MACROS_DIR}/md5.in" ${_p_NAME}.md5 @ONLY )
 
             add_custom_command( OUTPUT ${_p_NAME}.ok
-                                COMMAND diff ${_p_NAME}.md5 ${_p_NAME}.localmd5 && touch ${_p_NAME}.ok
+                                COMMAND ${CMAKE_COMMAND} -E compare_files ${_p_NAME}.md5 ${_p_NAME}.localmd5 &&
+                                        ${CMAKE_COMMAND} -E touch ${_p_NAME}.ok
                                 DEPENDS ${_p_NAME}.localmd5 )
 
             list( APPEND _deps ${_p_NAME}.localmd5 ${_p_NAME}.ok )
@@ -175,23 +227,86 @@ function( ecbuild_get_test_data )
 
     add_custom_target( ${_p_TARGET} DEPENDS ${_deps} )
 
+    if( _p_EXTRACT )
+      ecbuild_debug("ecbuild_get_test_data: extracting ${_p_NAME} (post-build for target ${_p_TARGET}")
+      add_custom_command( TARGET ${_p_TARGET} POST_BUILD
+                          COMMAND ${CMAKE_COMMAND} -E tar xv ${_p_NAME} )
+    endif()
+
 endfunction(ecbuild_get_test_data)
 
 ##############################################################################
-# function for getting test data
+#.rst:
+#
+# ecbuild_get_test_multidata
+# ==========================
+#
+# Download multiple test data sets at build time. ::
+#
+#   ecbuild_get_test_multidata( NAMES <name1> [ <name2> ... ]
+#                               TARGET <target>
+#                               [ DIRNAME <dir> ]
+#                               [ EXTRACT ]
+#                               [ NOCHECK ] )
+#
+# curl or wget is required (curl is preferred if available).
+#
+# Options
+# -------
+#
+# NAMES : required
+#   list of names of the test data files
+#
+# TARGET : optional
+#   CMake target name
+#
+# DIRNAME : optional, defaults to <project>/<relative path to current dir>
+#   directory in which the test data resides
+#
+# EXTRACT : optional
+#   extract downloaded files (supported archives: tar, zip, tar.gz, tar.bz2)
+#
+# NOCHECK : optional
+#   do not verify the md5 checksum of the data file
+#
+# Usage
+# -----
+#
+# Download test data from ``http://download.ecmwf.org/test-data/<DIRNAME>``
+# for each name given in the list of ``NAMES``. Each name may contain a
+# relative path, which is appended to ``DIRNAME`` and may be followed by an
+# md5 checksum, separated with a ``:`` (the name must not contain spaces).
 #
-# examples:
+# If the ``DIRNAME`` argument is not given, the project name followed by the
+# relative path from the root directory to the current directory is used.
 #
-## no check done
-#    ecbuild_get_test_multidata( TARGET get_foobar_data NAMES foo.grib bar.grib DIRNAME test/data/dir NOCHECK )
+# By default, each downloaded file is verified against an md5 checksum, either
+# given as part of the name as described above or a remote checksum downloaded
+# from the server. Use the argument ``NOCHECK`` to disable this check.
 #
-## check for remote md5
-#    ecbuild_get_test_multidata( TARGET get_foobar_data NAMES foo.grib bar.grib DIRNAME test/data/dir )
+# Examples
+# --------
 #
+# Do not verify checksums: ::
+#
+#   ecbuild_get_test_multidata( TARGET get_grib_data NAMES foo.grib bar.grib
+#                               DIRNAME test/data/dir NOCHECK )
+#
+# Checksums agains remote md5 file: ::
+#
+#   ecbuild_get_test_multidata( TARGET get_grib_data NAMES foo.grib bar.grib
+#                               DIRNAME test/data/dir )
+#
+# Checksum agains local md5: ::
+#
+#   ecbuild_get_test_multidata( TARGET get_grib_data DIRNAME test/data/dir
+#                               NAMES msl.grib:f69ca0929d1122c7878d19f32401abe9 )
+#
+##############################################################################
 
 function( ecbuild_get_test_multidata )
 
-    set( options NOCHECK )
+    set( options EXTRACT NOCHECK )
     set( single_value_args TARGET DIRNAME )
     set( multi_value_args  NAMES )
 
@@ -211,9 +326,13 @@ function( ecbuild_get_test_multidata )
       message(FATAL_ERROR "ecbuild_get_test_data() expects a TARGET")
     endif()
 
-#    debug_var( _p_TARGET )
-#    debug_var( _p_NAME )
-#    debug_var( _p_DIRNAME )
+#    ecbuild_debug_var( _p_TARGET )
+#    ecbuild_debug_var( _p_NAME )
+#    ecbuild_debug_var( _p_DIRNAME )
+
+    if( _p_EXTRACT )
+        set( _extract EXTRACT )
+    endif()
 
     if( _p_NOCHECK )
         set( _nocheck NOCHECK )
@@ -239,12 +358,11 @@ endfunction()\n\n" )
         get_filename_component( _dir  ${_f} PATH )
 
         list( APPEND _path_comps ${_p_DIRNAME} ${_dir} )
-
         join( _path_comps "/" _dirname )
-
         if( _dirname )
             set( _dirname DIRNAME ${_dirname} )
         endif()
+        unset( _path_comps )
 
         string( REPLACE "." "_" _name "${_file}" )
         string( REGEX MATCH ":.*"  _md5  "${_d}" )
@@ -254,22 +372,25 @@ endfunction()\n\n" )
             set( _md5 MD5 ${_md5} )
         endif()
 
-        #debug_var(_f)
-        #debug_var(_file)
-        #debug_var(_dirname)
-        #debug_var(_name)
-        #debug_var(_md5)
+        #ecbuild_debug_var(_f)
+        #ecbuild_debug_var(_file)
+        #ecbuild_debug_var(_dirname)
+        #ecbuild_debug_var(_name)
+        #ecbuild_debug_var(_md5)
 
         ecbuild_get_test_data(
             TARGET __get_data_${_p_TARGET}_${_name}
-            NAME ${_file} ${_dirname} ${_md5} ${_nocheck} )
+            NAME ${_file} ${_dirname} ${_md5} ${_extract} ${_nocheck} )
 
+        # The option /fast disables dependency checking on a target, see
+        # https://cmake.org/Wiki/CMake_FAQ#Is_there_a_way_to_skip_checking_of_dependent_libraries_when_compiling.3F
         file( APPEND ${_script}
-            "exec_check( ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target __get_data_${_p_TARGET}_${_name} )\n" )
+            "exec_check( \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target __get_data_${_p_TARGET}_${_name}/fast )\n" )
 
     endforeach()
 
-    add_test(  NAME ${_p_TARGET} COMMAND ${CMAKE_COMMAND} -P ${_script} )
+    if( ENABLE_TESTS )
+      add_test(  NAME ${_p_TARGET} COMMAND ${CMAKE_COMMAND} -P ${_script} )
+    endif()
 
 endfunction(ecbuild_get_test_multidata)
-
diff --git a/cmake/ecbuild_git.cmake b/cmake/ecbuild_git.cmake
new file mode 100644
index 0000000..42124db
--- /dev/null
+++ b/cmake/ecbuild_git.cmake
@@ -0,0 +1,307 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+set( ECBUILD_GIT  ON  CACHE BOOL "Turn on/off ecbuild_git() function" )
+
+if( ECBUILD_GIT )
+
+  find_package(Git)
+
+  set( ECMWF_USER $ENV{USER} CACHE STRING "ECMWF git user" )
+  set( ECMWF_GIT  SSH        CACHE STRING "ECMWF git protocol" )
+
+  set( ECMWF_GIT_SSH   "ssh://git@software.ecmwf.int:7999"                  CACHE INTERNAL "ECMWF ssh address" )
+  set( ECMWF_GIT_HTTPS "https://${ECMWF_USER}@software.ecmwf.int/stash/scm" CACHE INTERNAL "ECMWF https address" )
+
+  if( ECMWF_GIT MATCHES "[Ss][Ss][Hh]" )
+    set( ECMWF_GIT_ADDRESS ${ECMWF_GIT_SSH} CACHE INTERNAL "" )
+  else()
+    set( ECMWF_GIT_ADDRESS ${ECMWF_GIT_HTTPS} CACHE INTERNAL "" )
+  endif()
+
+endif()
+
+##############################################################################
+#.rst:
+#
+# ecbuild_git
+# ===========
+#
+# Manages an external Git repository. ::
+#
+#   ecbuild_git( PROJECT <name>
+#                DIR <directory>
+#                URL <giturl>
+#                [ BRANCH <gitbranch> | TAG <gittag> ]
+#                [ UPDATE | NOREMOTE ] )
+#                [ MANUAL ] )
+#
+# Options
+# -------
+#
+# PROJECT : required
+#   project name for the Git repository to be managed
+#
+# DIR : required
+#   directory to clone the repository into (can be relative)
+#
+# URL : required
+#   Git URL of the remote repository to clone (see ``git help clone``)
+#
+# BRANCH : optional, cannot be combined with TAG
+#   Git branch to check out
+#
+# TAG : optional, cannot be combined with BRANCH
+#   Git tag or commit id to check out
+#
+# UPDATE : optional, requires BRANCH, cannot be combined with NOREMOTE
+#   Create a CMake target update to fetch changes from the remote repository
+#
+# NOREMOTE : optional, cannot be combined with UPDATE
+#   Do not fetch changes from the remote repository
+#
+# MANUAL : optional
+#   Do not automatically switch branches or tags
+#
+##############################################################################
+
+macro( ecbuild_git )
+
+  set( options UPDATE NOREMOTE MANUAL )
+  set( single_value_args PROJECT DIR URL TAG BRANCH )
+  set( multi_value_args )
+  cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
+
+  if( DEFINED _PAR_BRANCH AND DEFINED _PAR_TAG )
+    message( FATAL_ERROR "Cannot defined both BRANCH and TAG in macro ecbuild_git" )
+  endif()
+
+  if( _PAR_UPDATE AND _PAR_NOREMOTE )
+    message( FATAL_ERROR "Cannot pass both NOREMOTE and UPDATE in macro ecbuild_git" )
+  endif()
+
+  if(_PAR_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unknown keywords given to ecbuild_git(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+  endif()
+
+  if( ECBUILD_GIT )
+
+    set( _needs_switch 0 )
+
+    get_filename_component( ABS_PAR_DIR "${_PAR_DIR}" ABSOLUTE )
+    get_filename_component( PARENT_DIR  "${_PAR_DIR}/.." ABSOLUTE )
+
+    ### clone if no directory
+
+    if( NOT EXISTS "${_PAR_DIR}" )
+
+      message( STATUS "Cloning ${_PAR_PROJECT} from ${_PAR_URL} into ${_PAR_DIR}...")
+      execute_process(
+        COMMAND ${GIT_EXECUTABLE} "clone" ${_PAR_URL} ${clone_args} ${_PAR_DIR} "-q"
+        RESULT_VARIABLE nok ERROR_VARIABLE error
+        WORKING_DIRECTORY "${PARENT_DIR}")
+      if(nok)
+        message(FATAL_ERROR "${_PAR_DIR} git clone failed: ${error}\n")
+      endif()
+      message( STATUS "${_PAR_DIR} retrieved.")
+      set( _needs_switch 1 )
+
+    endif()
+
+    ### check current tag and sha1
+
+    if( IS_DIRECTORY "${_PAR_DIR}/.git" )
+
+      execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
+                       OUTPUT_VARIABLE _sha1 RESULT_VARIABLE nok ERROR_VARIABLE error
+                       OUTPUT_STRIP_TRAILING_WHITESPACE
+                       WORKING_DIRECTORY "${ABS_PAR_DIR}" )
+      if(nok)
+        message(STATUS "git rev-parse HEAD on ${_PAR_DIR} failed:\n ${error}")
+      endif()
+
+      execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
+                       OUTPUT_VARIABLE _current_branch RESULT_VARIABLE nok ERROR_VARIABLE error
+                       OUTPUT_STRIP_TRAILING_WHITESPACE
+                       WORKING_DIRECTORY "${ABS_PAR_DIR}" )
+      if( nok OR _current_branch STREQUAL "" )
+        message(STATUS "git rev-parse --abbrev-ref HEAD on ${_PAR_DIR} failed:\n ${error}")
+      endif()
+
+      #message(STATUS "git describe --exact-match --abbrev=0 @ ${ABS_PAR_DIR}")
+      execute_process( COMMAND ${GIT_EXECUTABLE} describe --exact-match --abbrev=0
+                       OUTPUT_VARIABLE _current_tag RESULT_VARIABLE nok ERROR_VARIABLE error
+                       OUTPUT_STRIP_TRAILING_WHITESPACE  ERROR_STRIP_TRAILING_WHITESPACE
+                       WORKING_DIRECTORY "${ABS_PAR_DIR}" )
+
+      if( error MATCHES "no tag exactly matches" OR error MATCHES "No names found" )
+        unset( _current_tag )
+      else()
+        if( nok )
+          message(STATUS "git describe --exact-match --abbrev=0 on ${_PAR_DIR} failed:\n ${error}")
+        endif()
+      endif()
+
+      if( NOT _current_tag ) # try nother method
+        #message(STATUS "git name-rev --tags --name-only @ ${ABS_PAR_DIR}")
+        execute_process( COMMAND ${GIT_EXECUTABLE} name-rev --tags --name-only ${_sha1}
+                         OUTPUT_VARIABLE _current_tag RESULT_VARIABLE nok ERROR_VARIABLE error
+                         OUTPUT_STRIP_TRAILING_WHITESPACE
+                         WORKING_DIRECTORY "${ABS_PAR_DIR}" )
+        if( nok OR _current_tag STREQUAL "" )
+          message(STATUS "git name-rev --tags --name-only on ${_PAR_DIR} failed:\n ${error}")
+        endif()
+      endif()
+
+    endif()
+
+    if( NOT _PAR_MANUAL AND DEFINED _PAR_BRANCH AND NOT "${_current_branch}" STREQUAL "${_PAR_BRANCH}" )
+      set( _needs_switch 1 )
+    endif()
+
+    if( NOT _PAR_MANUAL AND DEFINED _PAR_TAG AND NOT "${_current_tag}" STREQUAL "${_PAR_TAG}" )
+      set( _needs_switch 1 )
+    endif()
+
+    if( DEFINED _PAR_BRANCH AND _PAR_UPDATE AND NOT _PAR_NOREMOTE )
+
+      add_custom_target( git_update_${_PAR_PROJECT}
+                         COMMAND "${GIT_EXECUTABLE}" pull -q
+                         WORKING_DIRECTORY "${ABS_PAR_DIR}"
+                         COMMENT "git pull of branch ${_PAR_BRANCH} on ${_PAR_DIR}" )
+
+      set( git_update_targets "git_update_${_PAR_PROJECT};${git_update_targets}" )
+
+    endif()
+
+    ### updates
+
+    if( _needs_switch AND IS_DIRECTORY "${_PAR_DIR}/.git" )
+
+      # debug_here( ABS_PAR_DIR )
+      # debug_here( _sha1 )
+      # debug_here( _current_branch )
+      # debug_here( _current_tag )
+      # debug_here( _PAR_TAG )
+      # debug_here( _PAR_BRANCH )
+      # debug_here( _needs_switch )
+      # debug_here( _PAR_UPDATE )
+
+      if( DEFINED _PAR_BRANCH )
+        set ( _gitref ${_PAR_BRANCH} )
+        message(STATUS "Updating ${_PAR_PROJECT} to head of BRANCH ${_PAR_BRANCH}...")
+      else()
+        message(STATUS "Updating ${_PAR_PROJECT} to TAG ${_PAR_TAG}...")
+        set ( _gitref ${_PAR_TAG} )
+      endif()
+
+      # fetching latest tags and branches
+
+      if( NOT _PAR_NOREMOTE )
+
+        message(STATUS "git fetch --all @ ${ABS_PAR_DIR}")
+        execute_process( COMMAND "${GIT_EXECUTABLE}" fetch --all -q
+                         RESULT_VARIABLE nok ERROR_VARIABLE error
+                         WORKING_DIRECTORY "${ABS_PAR_DIR}")
+        if(nok)
+          message(STATUS "git fetch --all in ${_PAR_DIR} failed:\n ${error}")
+        endif()
+
+        message(STATUS "git fetch --all --tags @ ${ABS_PAR_DIR}")
+        execute_process( COMMAND "${GIT_EXECUTABLE}" fetch --all --tags -q
+                         RESULT_VARIABLE nok ERROR_VARIABLE error
+                         WORKING_DIRECTORY "${ABS_PAR_DIR}")
+        if(nok)
+          message(STATUS "git fetch --all --tags in ${_PAR_DIR} failed:\n ${error}")
+        endif()
+
+      else()
+        message(STATUS "${_PAR_DIR} marked NOREMOTE : Skipping git fetch")
+      endif()
+
+      # checking out gitref
+
+      message(STATUS "git checkout ${_gitref} @ ${ABS_PAR_DIR}")
+      execute_process( COMMAND "${GIT_EXECUTABLE}" checkout -q "${_gitref}"
+                       RESULT_VARIABLE nok ERROR_VARIABLE error
+                       WORKING_DIRECTORY "${ABS_PAR_DIR}")
+      if(nok)
+        message(FATAL_ERROR "git checkout ${_gitref} on ${_PAR_DIR} failed:\n ${error}")
+      endif()
+
+      if( DEFINED _PAR_BRANCH AND _PAR_UPDATE ) #############################################################################
+
+        execute_process( COMMAND "${GIT_EXECUTABLE}" pull -q
+                         RESULT_VARIABLE nok ERROR_VARIABLE error
+                         WORKING_DIRECTORY "${ABS_PAR_DIR}")
+        if(nok)
+          message(STATUS "git pull of branch ${_PAR_BRANCH} on ${_PAR_DIR} failed:\n ${error}")
+        endif()
+
+      endif() ####################################################################################
+
+    endif( _needs_switch AND IS_DIRECTORY "${_PAR_DIR}/.git" )
+
+  endif( ECBUILD_GIT )
+
+endmacro()
+
+##############################################################################
+#.rst:
+#
+# ecbuild_stash
+# =============
+#
+# Manages an external Git repository on ECMWF Stash. ::
+#
+#   ecbuild_stash( PROJECT <name>
+#                  DIR <directory>
+#                  STASH <repository>
+#                  [ BRANCH <gitbranch> | TAG <gittag> ]
+#                  [ UPDATE | NOREMOTE ] )
+#                  [ MANUAL ] )
+#
+# Options
+# -------
+#
+# PROJECT : required
+#   project name for the Git repository to be managed
+#
+# DIR : required
+#   directory to clone the repository into (can be relative)
+#
+# STASH : required
+#   Stash repository in the form <project>/<repository>
+#
+# BRANCH : optional, cannot be combined with TAG
+#   Git branch to check out
+#
+# TAG : optional, cannot be combined with BRANCH
+#   Git tag or commit id to check out
+#
+# UPDATE : optional, requires BRANCH, cannot be combined with NOREMOTE
+#   Create a CMake target update to fetch changes from the remote repository
+#
+# NOREMOTE : optional, cannot be combined with UPDATE
+#   Do not fetch changes from the remote repository
+#
+# MANUAL : optional
+#   Do not automatically switch branches or tags
+#
+##############################################################################
+
+macro( ecmwf_stash )
+
+  set( options )
+  set( single_value_args STASH )
+  set( multi_value_args )
+  cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
+
+  ecbuild_git( URL "${ECMWF_GIT_ADDRESS}/${_PAR_STASH}.git" ${_PAR_UNPARSED_ARGUMENTS} )
+
+endmacro()
diff --git a/cmake/ecbuild_install_package.cmake b/cmake/ecbuild_install_package.cmake
deleted file mode 100644
index 7837bc3..0000000
--- a/cmake/ecbuild_install_package.cmake
+++ /dev/null
@@ -1,305 +0,0 @@
-# (C) Copyright 1996-2014 ECMWF.
-#
-# This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-# In applying this licence, ECMWF does not waive the privileges and immunities
-# granted to it by virtue of its status as an intergovernmental organisation nor
-# does it submit to any jurisdiction.
-
-###############################################################################
-
-macro( ecbuild_install_project )
-
-
-    set( options )
-    set( single_value_args NAME DESCRIPTION )
-    set( multi_value_args  COMPONENTS )
-
-    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
-
-    if(_PAR_UNPARSED_ARGUMENTS)
-      message(FATAL_ERROR "Unknown keywords given to ecbuild_install_project(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-    endif()
-
-    if( NOT _PAR_NAME  )
-      message(FATAL_ERROR "The call to ecbuild_install_project() doesn't specify the NAME.")
-    endif()
-
-    ### PACKAGING ########################################################
-
-    string( TOUPPER ${PROJECT_NAME} PNAME )
-    string( TOLOWER ${PROJECT_NAME} LNAME )
-
-    # components
-
-    #    if( DEFINED _PAR_COMPONENTS )
-    #        set(CPACK_COMPONENTS_ALL   "${_PAR_COMPONENTS}")
-    #    else()
-    #        set(CPACK_COMPONENTS_ALL   "${PROJECT_NAME}")
-    #    endif()
-
-    # name, version, etc ...
-
-    set(CPACK_PACKAGE_NAME      "${_PAR_NAME}")
-    set(CPACK_PACKAGE_VERSION   "${${PNAME}_VERSION_STR}")
-
-    set(CPACK_PACKAGE_FILE_NAME   "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
-
-    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ECMWF") # required for DEB
-
-    #    set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON")
-    #    set(CPACK_RPM_COMPONENT_INSTALL "ON")
-
-    #    set(CPACK_GENERATOR        "TGZ;RPM;DEB")
-    set(CPACK_GENERATOR        "TGZ")
-    set(CPACK_SOURCE_GENERATOR "TGZ")
-    set(CPACK_PACKAGE_VENDOR   "ECMWF")
-
-    # short description
-
-    if( _PAR_DESCRIPTION )
-        set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${_PAR_DESCRIPTION}" )
-    else()
-        set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${_PAR_NAME} misses a description" )
-    endif()
-
-    # long description
-
-    if( EXISTS ${PROJECT_SOURCE_DIR}/INSTALL )
-        set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/INSTALL")
-    endif()
-	if( EXISTS ${PROJECT_SOURCE_DIR}/LICENSE )
-        set(CPACK_RESOURCE_FILE_LICENSE    "${PROJECT_SOURCE_DIR}/LICENSE")
-    endif()
-
-    # set(CPACK_PACKAGE_EXECUTABLES ${ECBUILD_ALL_EXES})
-
-	list( APPEND CPACK_SOURCE_INSTALLED_DIRECTORIES
-	   "${PROJECT_SOURCE_DIR}" "."
-	   "${ECBUILD_MACROS_DIR}" "cmake/" )
-
-	# what to pack and not
-
-    set(CPACK_SOURCE_IGNORE_FILES
-        /build/
-        /\\\\.git/
-        /\\\\.svn/
-        CMakeLists.txt.user
-        \\\\.swp$
-        p4config
-    )
-
-    # skip the files that were declared as DONT_PACK
-
-    list( APPEND CPACK_SOURCE_IGNORE_FILES ${ECBUILD_DONT_PACK_FILES} )
-
-    # cpack config file
-
-    # set(CPACK_INSTALL_CMAKE_PROJECTS "${${PROJECT_NAME}_BINARY_DIR}" "${PROJECT_NAME}" "${CPACK_COMPONENTS_ALL}" "*" )
-
-    include( CPack )
-
-    ### EXPORTS ########################################################
-
-    ecbuild_enabled_features( ${PNAME}_FEATURES )
-    foreach( _f ${${PNAME}_FEATURES} )
-        set( ${PNAME}_HAVE_${_f} 1 )
-    endforeach()
-
-
-    foreach( _tpl ${${PNAME}_TPLS} )
-        string( TOUPPER ${_tpl} _TPL )
-
-        if( ${_tpl}_INCLUDE_DIRS )
-            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
-        elseif( ${_tpl}_INCLUDE_DIR )
-            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
-        elseif( ${_TPL}_INCLUDE_DIRS )
-            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_TPL}_INCLUDE_DIRS} )
-        elseif( ${_TPL}_INCLUDE_DIR )
-            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_TPL}_INCLUDE_DIR} )
-        endif()
-
-        if( ${_tpl}_LIBRARIES )
-            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_tpl}_LIBRARIES} )
-        elseif( ${_tpl}_LIBRARY )
-            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_tpl}_LIBRARY} )
-        elseif( ${_TPL}_LIBRARIES )
-            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_TPL}_LIBRARIES} )
-        elseif( ${_TPL}_LIBRARY )
-            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_TPL}_LIBRARY} )
-        endif()
-
-        if( ${_tpl}_DEFINITIONS )
-            list( APPEND ${PNAME}_TPL_DEFINITIONS ${${_tpl}_DEFINITIONS} )
-        elseif( ${_TPL}_DEFINITIONS )
-            list( APPEND ${PNAME}_TPL_DEFINITIONS ${${_TPL}_DEFINITIONS} )
-        endif()
-    endforeach()
-
-    # TOP-LEVEL PROJECT EXPORT
-
-    if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
-
-        # exports the package for use from the build-tree but only in DEVELOPER_MODE
-        # inserts <package> into the CMake user package registry
-
-        if( DEVELOPER_MODE )
-            export( PACKAGE ${PROJECT_NAME} )
-        endif()
-
-        set( _template_config "${ECBUILD_MACROS_DIR}/project-config.cmake.in" )
-        if( EXISTS ${LNAME}-config.cmake.in )
-            set( _template_config "${LNAME}-config.cmake.in" )
-        endif()
-
-        set( _template_config_version "${ECBUILD_MACROS_DIR}/project-config-version.cmake.in" )
-        if( EXISTS ${LNAME}-config-version.cmake.in )
-            set( _template_config_version "${LNAME}-config-version.cmake.in" )
-        endif()
-
-        # project-config-version.cmake -- format ([0-9]+).([0-9]+).([0-9]+)
-
-        set( PACKAGE_VERSION "${${PNAME}_VERSION}" )
-
-        configure_file( "${_template_config_version}" "${PROJECT_BINARY_DIR}/${LNAME}-config-version.cmake" @ONLY )
-
-        install( FILES "${PROJECT_BINARY_DIR}/${LNAME}-config-version.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" )
-
-        # prepare imutable variables (don't depend on install path)
-
-        if( ${PNAME}_FEATURES )
-          set( CONF_FEATURES ${${PNAME}_FEATURES} )
-        endif()
-
-        set( CONF_LIBRARIES ${${PROJECT_NAME}_ALL_LIBS} )
-        if( ${PNAME}_LIBRARIES )
-            set( CONF_LIBRARIES ${${PNAME}_LIBRARIES} )
-        endif()
-
-        set( CONF_DEFINITIONS "" )
-        if( ${PNAME}_DEFINITIONS )
-           set( CONF_DEFINITIONS ${${PNAME}_DEFINITIONS} )
-        endif()
-
-        set( CONF_TPL_LIBRARIES   "" )
-        if( ${PNAME}_TPL_LIBRARIES )
-           set( CONF_TPL_LIBRARIES ${${PNAME}_TPL_LIBRARIES} )
-        endif()
-
-        # project-config.cmake @ build tree
-
-        set( CONF_TPLS ${${PNAME}_TPLS} )
-
-        set( CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" )
-        if( ${PNAME}_INCLUDE_DIRS )
-            set( CONF_INCLUDE_DIRS ${${PNAME}_INCLUDE_DIRS} )
-        endif()
-
-        set( CONF_TPL_INCLUDE_DIRS "" )
-        foreach( _tpl ${${PNAME}_TPLS} )
-            string( TOUPPER ${_tpl} TPL )
-            if( ${_tpl}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
-            elseif( ${_tpl}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
-            elseif( ${TPL}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
-            elseif( ${TPL}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIR} )
-            endif()
-        endforeach()
-
-        set( CONF_IMPORT_FILE "${LNAME}-import.cmake" )
-
-        # If <project>-import.cmake.in exist in source tree, configure it to
-        # the build tree and install the configured version
-        if( EXISTS "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}.in" )
-          configure_file( "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}.in"
-                          "${PROJECT_BINARY_DIR}/${CONF_IMPORT_FILE}" @ONLY )
-          install( FILES "${PROJECT_BINARY_DIR}/${CONF_IMPORT_FILE}"
-                   DESTINATION "${INSTALL_CMAKE_DIR}" )
-        # Otherwise, if <project>-import.cmake exist in source tree, copy it to
-        # the build tree and install it
-        elseif( EXISTS "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}" )
-          configure_file( "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}"
-                          "${PROJECT_BINARY_DIR}/${CONF_IMPORT_FILE}" COPYONLY )
-          install( FILES "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}"
-                   DESTINATION "${INSTALL_CMAKE_DIR}" )
-        endif()
-
-        set( _lname_config "${PROJECT_BINARY_DIR}/${LNAME}-config.cmake")
-
-        set( _is_build_dir_export ON )
-        configure_file( "${_template_config}" "${_lname_config}" @ONLY )
-
-        file( REMOVE ${_lname_config}.tpls.in )
-
-        foreach( _tpl ${${PNAME}_TPLS} )
-            string( TOUPPER ${_tpl} TPL )
-            if( ${TPL}_IMPORT_FILE )
-                set( __import_file "${${TPL}_IMPORT_FILE}" )
-                file( APPEND "${_lname_config}.tpls.in" "if( NOT ${TPL}_IMPORT_FILE )\n" )
-                file( APPEND "${_lname_config}.tpls.in" "    include( \"${__import_file}\" OPTIONAL )\n" )
-                file( APPEND "${_lname_config}.tpls.in" "endif()\n" )
-            endif()
-        endforeach()
-
-        if( EXISTS "${_lname_config}.tpls.in" )
-            configure_file( "${_lname_config}.tpls.in" "${_lname_config}.tpls" @ONLY )
-            install( FILES "${_lname_config}.tpls" DESTINATION "${INSTALL_CMAKE_DIR}" )
-        endif()
-
-        # project-config.cmake @ install tree
-
-        file( RELATIVE_PATH REL_INCLUDE_DIR "${${PNAME}_FULL_INSTALL_CMAKE_DIR}" "${${PNAME}_FULL_INSTALL_INCLUDE_DIR}" )
-        set( CONF_INCLUDE_DIRS "\${${PNAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
-
-        set( CONF_TPL_INCLUDE_DIRS "" )
-        foreach( _tpl ${${PNAME}_TPLS} )
-            string( TOUPPER ${_tpl} TPL )
-            if( ${TPL}_FULL_INSTALL_INCLUDE_DIR )
-                 list( APPEND CONF_TPL_INCLUDE_DIRS "\${${PNAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
-            endif()
-            if( ${_tpl}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
-            elseif( ${_tpl}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
-            elseif( ${TPL}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
-            elseif( ${TPL}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIR} )
-            endif()
-        endforeach()
-
-        set( _is_build_dir_export OFF )
-        configure_file( "${_template_config}" "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LNAME}-config.cmake" @ONLY )
-        install( FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LNAME}-config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" )
-
-        # install the export
-
-        if( ${PROJECT_NAME}_ALL_EXES OR ${PROJECT_NAME}_ALL_LIBS )
-            install( EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION "${INSTALL_CMAKE_DIR}" )
-        endif()
-
-    else()
-
-        set( ${PNAME}_FOUND             TRUE                          PARENT_SCOPE )
-        set( ${PROJECT_NAME}_FOUND      TRUE                          PARENT_SCOPE )
-        set( ${PNAME}_VERSION           ${${PNAME}_VERSION}           PARENT_SCOPE )
-        set( ${PROJECT_NAME}_VERSION    ${${PNAME}_VERSION}           PARENT_SCOPE )
-        set( ${PNAME}_INCLUDE_DIRS      ${${PNAME}_INCLUDE_DIRS}      PARENT_SCOPE )
-        set( ${PNAME}_LIBRARIES         ${${PNAME}_LIBRARIES}         PARENT_SCOPE )
-        set( ${PNAME}_DEFINITIONS       ${${PNAME}_DEFINITIONS}       PARENT_SCOPE )
-        set( ${PNAME}_PACKAGES          ${${PNAME}_PACKAGES}          PARENT_SCOPE )
-        set( ${PNAME}_TPLS              ${${PNAME}_TPLS}              PARENT_SCOPE )
-        set( ${PNAME}_TPL_LIBRARIES     ${${PNAME}_TPL_LIBRARIES}     PARENT_SCOPE )
-        set( ${PNAME}_TPL_DEFINITIONS   ${${PNAME}_TPL_DEFINITIONS}   PARENT_SCOPE )
-        set( ${PNAME}_TPL_INCLUDE_DIRS  ${${PNAME}_TPL_INCLUDE_DIRS}  PARENT_SCOPE )
-        set( ${PNAME}_FEATURES          ${${PNAME}_FEATURES}          PARENT_SCOPE )
-        foreach( _f ${${PNAME}_FEATURES} )
-            set( ${PNAME}_HAVE_${_f} ${${PNAME}_HAVE_${_f}} PARENT_SCOPE )
-        endforeach()
-     endif()
-
-endmacro( ecbuild_install_project )
diff --git a/cmake/ecbuild_install_project.cmake b/cmake/ecbuild_install_project.cmake
new file mode 100644
index 0000000..d53f110
--- /dev/null
+++ b/cmake/ecbuild_install_project.cmake
@@ -0,0 +1,387 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_install_project
+# =======================
+#
+# Set up packaging and export configuration. ::
+#
+#   ecbuild_install_project( NAME <name> [ DESCRIPTION <description> ] )
+#
+# Options
+# -------
+#
+# NAME : required
+#   project name used for packaging
+#
+# DESCRIPTION : optional
+#   project description used for packaging
+#
+# Usage
+# -----
+#
+# ``ecbuild_install_project`` should be called at the very end of any ecBuild
+# project (only followed by ``ecbuild_print_summary``), sets up packaging of
+# the project with cpack and exports the configuration and targets for other
+# projects to use.
+#
+# In a top-level project, the following files are generated:
+#
+# :<project>-config.cmake:         default project configuration
+# :<project>-config-version.cmake: project version number
+# :<project>-import.cmake:         extra project configuration (optional)
+# :<project>-config.cmake.tpls:    3rd party project configurations
+# :<project>-targets.cmake:        exported targets
+#
+# For ``<project>-import.cmake`` to be exported to build and install tree,
+# ``<project>-import.cmake`` or ``<project>-import.cmake.in`` must exist in
+# the source tree. ``<project>-config.cmake.in`` and
+# ``<project>-config-version.cmake.in`` can be provided in the source tree to
+# override the default templates used to generate ``<project>-config.cmake``
+# and ``<project>-config-version.cmake``.
+#
+# In DEVELOPER_MODE, the build tree location is also added to the CMake user
+# package registry.
+#
+# If the project is added as a subdirectory, the following CMake variables
+# are set in the parent scope:
+#
+# :<PROJECT>_FOUND:            set to ``TRUE``
+# :<project>_FOUND:            set to ``TRUE``
+# :<PROJECT>_VERSION:          version string
+# :<project>_VERSION:          version string
+# :<PROJECT>_INCLUDE_DIRS:     list of include directories
+# :<PROJECT>_LIBRARIES:        list of libraries
+# :<PROJECT>_DEFINITIONS:      list of compiler definitions
+# :<PROJECT>_TPLS:             list of 3rd party dependencies
+# :<PROJECT>_TPL_LIBRARIES:    libraries of 3rd party dependencies
+# :<PROJECT>_TPL_DEFINITIONS:  compiler definitions of 3rd party dependencies
+# :<PROJECT>_TPL_INCLUDE_DIRS: include directories of 3rd party dependencies
+# :<PROJECT>_FEATURES:         list of enabled features
+# :<PROJECT>_HAVE_<FEATURE>:   set to 1 for each enabled features
+#
+##############################################################################
+
+
+macro( ecbuild_install_project )
+
+    set( options )
+    set( single_value_args NAME DESCRIPTION )
+    set( multi_value_args  COMPONENTS )
+
+    cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+    if(_PAR_UNPARSED_ARGUMENTS)
+      message(FATAL_ERROR "Unknown keywords given to ecbuild_install_project(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+    endif()
+
+    if( NOT _PAR_NAME  )
+      message(FATAL_ERROR "The call to ecbuild_install_project() doesn't specify the NAME.")
+    endif()
+
+    ### PACKAGING ########################################################
+
+    set( PNAME ${PROJECT_NAME_CAPS} )
+    set( LNAME ${PROJECT_NAME_LOWCASE} )
+
+    # components
+
+    #    if( DEFINED _PAR_COMPONENTS )
+    #        set(CPACK_COMPONENTS_ALL   "${_PAR_COMPONENTS}")
+    #    else()
+    #        set(CPACK_COMPONENTS_ALL   "${PROJECT_NAME}")
+    #    endif()
+
+    # name, version, etc ...
+
+    set(CPACK_PACKAGE_NAME      "${_PAR_NAME}")
+    set(CPACK_PACKAGE_VERSION   "${${PNAME}_VERSION_STR}")
+
+    set(CPACK_PACKAGE_FILE_NAME   "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
+
+    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ECMWF") # required for DEB
+
+    #    set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON")
+    #    set(CPACK_RPM_COMPONENT_INSTALL "ON")
+
+    #    set(CPACK_GENERATOR        "TGZ;RPM;DEB")
+    set(CPACK_GENERATOR        "TGZ")
+    set(CPACK_SOURCE_GENERATOR "TGZ")
+    set(CPACK_PACKAGE_VENDOR   "ECMWF")
+
+    # short description
+
+    if( _PAR_DESCRIPTION )
+        set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${_PAR_DESCRIPTION}" )
+    else()
+        set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${_PAR_NAME} misses a description" )
+    endif()
+
+    # long description
+
+    if( EXISTS ${PROJECT_SOURCE_DIR}/INSTALL )
+        set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/INSTALL")
+    endif()
+    if( EXISTS ${PROJECT_SOURCE_DIR}/LICENSE )
+        set(CPACK_RESOURCE_FILE_LICENSE    "${PROJECT_SOURCE_DIR}/LICENSE")
+    endif()
+
+    # set(CPACK_PACKAGE_EXECUTABLES ${ECBUILD_ALL_EXES})
+
+    list( APPEND CPACK_SOURCE_INSTALLED_DIRECTORIES
+          "${PROJECT_SOURCE_DIR}" "."
+          "${ECBUILD_MACROS_DIR}" "cmake/" )
+
+    # what to pack and not
+
+    set(CPACK_SOURCE_IGNORE_FILES
+        /build/
+        /\\\\.git/
+        /\\\\.svn/
+        CMakeLists.txt.user
+        \\\\.swp$
+        p4config
+    )
+
+    # skip the files that were declared as DONT_PACK
+
+    list( APPEND CPACK_SOURCE_IGNORE_FILES ${ECBUILD_DONT_PACK_FILES} )
+
+    # Find the ecbuild toolchain files and include in the source package if found
+    find_path( ECBUILD_TOOLCHAIN_DIR ecmwf-XC30-GNU.cmake
+               PATHS ${ECBUILD_MACROS_DIR}/../toolchains
+                     ${ECBUILD_MACROS_DIR}/../share/ecbuild/toolchains )
+
+    if( ECBUILD_TOOLCHAIN_DIR )
+      list( APPEND CPACK_SOURCE_INSTALLED_DIRECTORIES "${ECBUILD_TOOLCHAIN_DIR}" "share/ecbuild/toolchains/" )
+    endif()
+
+    # Find the ecbuild bin directory and include in the source package if found
+    find_program( ECBUILD_SCRIPT ecbuild
+                  PATHS ${ECBUILD_MACROS_DIR}/../bin
+                        ${ECBUILD_MACROS_DIR}/../../../bin )
+
+    if( ECBUILD_SCRIPT )
+      get_filename_component( ECBUILD_BIN_DIR ${ECBUILD_SCRIPT} PATH )
+      list( APPEND CPACK_SOURCE_INSTALLED_DIRECTORIES "${ECBUILD_BIN_DIR}" "bin/" )
+    endif()
+
+    # cpack config file
+
+    # set(CPACK_INSTALL_CMAKE_PROJECTS "${${PROJECT_NAME}_BINARY_DIR}" "${PROJECT_NAME}" "${CPACK_COMPONENTS_ALL}" "*" )
+
+    include( CPack )
+
+    ### EXPORTS ########################################################
+
+    ecbuild_enabled_features( ${PROJECT_NAME_CAPS}_FEATURES )
+    foreach( _f ${${PNAME}_FEATURES} )
+        set( ${PNAME}_HAVE_${_f} 1 )
+    endforeach()
+
+    message( STATUS "${PROJECT_NAME_CAPS}_TPLS: ${${PROJECT_NAME_CAPS}_TPLS}" )
+
+    foreach( _tpl ${${PNAME}_TPLS} )
+        string( TOUPPER ${_tpl} _TPL )
+
+        if( ${_tpl}_INCLUDE_DIRS )
+            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
+        elseif( ${_tpl}_INCLUDE_DIR )
+            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
+        elseif( ${_TPL}_INCLUDE_DIRS )
+            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_TPL}_INCLUDE_DIRS} )
+        elseif( ${_TPL}_INCLUDE_DIR )
+            list( APPEND ${PNAME}_TPL_INCLUDE_DIRS ${${_TPL}_INCLUDE_DIR} )
+        endif()
+
+        if( ${_tpl}_LIBRARIES )
+            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_tpl}_LIBRARIES} )
+        elseif( ${_tpl}_LIBRARY )
+            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_tpl}_LIBRARY} )
+        elseif( ${_TPL}_LIBRARIES )
+            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_TPL}_LIBRARIES} )
+        elseif( ${_TPL}_LIBRARY )
+            list( APPEND ${PNAME}_TPL_LIBRARIES   ${${_TPL}_LIBRARY} )
+        endif()
+
+        if( ${_tpl}_DEFINITIONS )
+            list( APPEND ${PNAME}_TPL_DEFINITIONS ${${_tpl}_DEFINITIONS} )
+        elseif( ${_TPL}_DEFINITIONS )
+            list( APPEND ${PNAME}_TPL_DEFINITIONS ${${_TPL}_DEFINITIONS} )
+        endif()
+    endforeach()
+
+    # TOP-LEVEL PROJECT EXPORT
+
+    if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
+
+        # exports the package for use from the build-tree but only in DEVELOPER_MODE
+        # inserts <package> into the CMake user package registry
+
+        if( DEVELOPER_MODE )
+            export( PACKAGE ${PROJECT_NAME} )
+        endif()
+
+        set( _template_config "${ECBUILD_MACROS_DIR}/project-config.cmake.in" )
+        if( EXISTS ${LNAME}-config.cmake.in )
+            set( _template_config "${LNAME}-config.cmake.in" )
+        endif()
+
+        set( _template_config_version "${ECBUILD_MACROS_DIR}/project-config-version.cmake.in" )
+        if( EXISTS ${LNAME}-config-version.cmake.in )
+            set( _template_config_version "${LNAME}-config-version.cmake.in" )
+        endif()
+
+        # project-config-version.cmake -- format ([0-9]+).([0-9]+).([0-9]+)
+
+        set( PACKAGE_VERSION "${${PNAME}_VERSION}" )
+
+        configure_file( "${_template_config_version}" "${PROJECT_BINARY_DIR}/${LNAME}-config-version.cmake" @ONLY )
+
+        install( FILES "${PROJECT_BINARY_DIR}/${LNAME}-config-version.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" )
+
+        # prepare imutable variables (don't depend on install path)
+
+        if( ${PNAME}_FEATURES )
+          set( CONF_FEATURES ${${PNAME}_FEATURES} )
+        endif()
+
+        set( CONF_LIBRARIES ${${PROJECT_NAME}_ALL_LIBS} )
+        if( ${PNAME}_LIBRARIES )
+            set( CONF_LIBRARIES ${${PNAME}_LIBRARIES} )
+        endif()
+
+        set( CONF_DEFINITIONS "" )
+        if( ${PNAME}_DEFINITIONS )
+           set( CONF_DEFINITIONS ${${PNAME}_DEFINITIONS} )
+        endif()
+
+        set( CONF_TPL_LIBRARIES   "" )
+        if( ${PNAME}_TPL_LIBRARIES )
+           set( CONF_TPL_LIBRARIES ${${PNAME}_TPL_LIBRARIES} )
+        endif()
+
+        # project-config.cmake @ build tree
+
+        set( CONF_TPLS ${${PNAME}_TPLS} )
+
+        set( CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" )
+        if( ${PNAME}_INCLUDE_DIRS )
+            set( CONF_INCLUDE_DIRS ${${PNAME}_INCLUDE_DIRS} )
+        endif()
+
+        set( CONF_TPL_INCLUDE_DIRS "" )
+        foreach( _tpl ${${PNAME}_TPLS} )
+            string( TOUPPER ${_tpl} TPL )
+            if( ${_tpl}_INCLUDE_DIRS )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
+            elseif( ${_tpl}_INCLUDE_DIR )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
+            elseif( ${TPL}_INCLUDE_DIRS )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
+            elseif( ${TPL}_INCLUDE_DIR )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIR} )
+            endif()
+        endforeach()
+
+        set( CONF_IMPORT_FILE "${LNAME}-import.cmake" )
+
+        # If <project>-import.cmake.in exist in source tree, configure it to
+        # the build tree and install the configured version
+        if( EXISTS "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}.in" )
+          configure_file( "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}.in"
+                          "${PROJECT_BINARY_DIR}/${CONF_IMPORT_FILE}" @ONLY )
+          install( FILES "${PROJECT_BINARY_DIR}/${CONF_IMPORT_FILE}"
+                   DESTINATION "${INSTALL_CMAKE_DIR}" )
+        # Otherwise, if <project>-import.cmake exist in source tree, copy it to
+        # the build tree and install it
+        elseif( EXISTS "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}" )
+          configure_file( "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}"
+                          "${PROJECT_BINARY_DIR}/${CONF_IMPORT_FILE}" COPYONLY )
+          install( FILES "${PROJECT_SOURCE_DIR}/${CONF_IMPORT_FILE}"
+                   DESTINATION "${INSTALL_CMAKE_DIR}" )
+        endif()
+
+        set( _lname_config "${PROJECT_BINARY_DIR}/${LNAME}-config.cmake")
+
+        set( _is_build_dir_export ON )
+        configure_file( "${_template_config}" "${_lname_config}" @ONLY )
+
+        file( REMOVE ${_lname_config}.tpls.in )
+
+        foreach( _tpl ${${PNAME}_TPLS} )
+            string( TOUPPER ${_tpl} TPL )
+            if( ${TPL}_IMPORT_FILE )
+                set( __import_file "${${TPL}_IMPORT_FILE}" )
+                file( APPEND "${_lname_config}.tpls.in" "if( NOT ${TPL}_IMPORT_FILE )\n" )
+                file( APPEND "${_lname_config}.tpls.in" "    include( \"${__import_file}\" OPTIONAL )\n" )
+                file( APPEND "${_lname_config}.tpls.in" "endif()\n" )
+            endif()
+        endforeach()
+
+        if( EXISTS "${_lname_config}.tpls.in" )
+            configure_file( "${_lname_config}.tpls.in" "${_lname_config}.tpls" @ONLY )
+            install( FILES "${_lname_config}.tpls" DESTINATION "${INSTALL_CMAKE_DIR}" )
+        endif()
+
+        # project-config.cmake @ install tree
+
+        file( RELATIVE_PATH REL_INCLUDE_DIR "${${PNAME}_FULL_INSTALL_CMAKE_DIR}" "${${PNAME}_FULL_INSTALL_INCLUDE_DIR}" )
+        set( CONF_INCLUDE_DIRS "\${${PNAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
+
+        set( CONF_TPL_INCLUDE_DIRS "" )
+        foreach( _tpl ${${PNAME}_TPLS} )
+            string( TOUPPER ${_tpl} TPL )
+            if( ${TPL}_FULL_INSTALL_INCLUDE_DIR )
+                 list( APPEND CONF_TPL_INCLUDE_DIRS "\${${PNAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
+            endif()
+            if( ${_tpl}_INCLUDE_DIRS )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
+            elseif( ${_tpl}_INCLUDE_DIR )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
+            elseif( ${TPL}_INCLUDE_DIRS )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
+            elseif( ${TPL}_INCLUDE_DIR )
+                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIR} )
+            endif()
+        endforeach()
+
+        set( _is_build_dir_export OFF )
+        configure_file( "${_template_config}" "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LNAME}-config.cmake" @ONLY )
+        install( FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LNAME}-config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" )
+
+        # install the export
+
+        if( ${PROJECT_NAME}_ALL_EXES OR ${PROJECT_NAME}_ALL_LIBS )
+            install( EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION "${INSTALL_CMAKE_DIR}" )
+        endif()
+
+    else()
+
+        set( ${PNAME}_FOUND             TRUE                          PARENT_SCOPE )
+        set( ${PROJECT_NAME}_FOUND      TRUE                          PARENT_SCOPE )
+        set( ${PNAME}_VERSION           ${${PNAME}_VERSION}           PARENT_SCOPE )
+        set( ${PROJECT_NAME}_VERSION    ${${PNAME}_VERSION}           PARENT_SCOPE )
+        set( ${PNAME}_INCLUDE_DIRS      ${${PNAME}_INCLUDE_DIRS}      PARENT_SCOPE )
+        set( ${PNAME}_LIBRARIES         ${${PNAME}_LIBRARIES}         PARENT_SCOPE )
+        set( ${PNAME}_DEFINITIONS       ${${PNAME}_DEFINITIONS}       PARENT_SCOPE )
+        set( ${PNAME}_PACKAGES          ${${PNAME}_PACKAGES}          PARENT_SCOPE )
+        set( ${PNAME}_TPLS              ${${PNAME}_TPLS}              PARENT_SCOPE )
+        set( ${PNAME}_TPL_LIBRARIES     ${${PNAME}_TPL_LIBRARIES}     PARENT_SCOPE )
+        set( ${PNAME}_TPL_DEFINITIONS   ${${PNAME}_TPL_DEFINITIONS}   PARENT_SCOPE )
+        set( ${PNAME}_TPL_INCLUDE_DIRS  ${${PNAME}_TPL_INCLUDE_DIRS}  PARENT_SCOPE )
+        set( ${PNAME}_FEATURES          ${${PNAME}_FEATURES}          PARENT_SCOPE )
+        foreach( _f ${${PNAME}_FEATURES} )
+            set( ${PNAME}_HAVE_${_f} ${${PNAME}_HAVE_${_f}} PARENT_SCOPE )
+        endforeach()
+     endif()
+
+endmacro( ecbuild_install_project )
diff --git a/cmake/ecbuild_links_target.cmake b/cmake/ecbuild_links_target.cmake
index 5dfacdc..bd9fe6c 100644
--- a/cmake/ecbuild_links_target.cmake
+++ b/cmake/ecbuild_links_target.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -63,11 +63,11 @@ macro( ecbuild_define_links_target )
 
     add_custom_target( links DEPENDS ${ec_link_libs} ${ec_link_exes} )
 
-     #   debug_var( EC_ALL_EXES )
-     #   debug_var( ec_link_exes )
+     #   ecbuild_debug_var( EC_ALL_EXES )
+     #   ecbuild_debug_var( ec_link_exes )
 
-     #  debug_var( EC_ALL_LIBS )
-     #   debug_var( ec_link_libs )
+     #  ecbuild_debug_var( EC_ALL_LIBS )
+     #   ecbuild_debug_var( ec_link_libs )
 
   endif()
 
diff --git a/cmake/ecbuild_list_add_pattern.cmake b/cmake/ecbuild_list_add_pattern.cmake
new file mode 100644
index 0000000..382b0c3
--- /dev/null
+++ b/cmake/ecbuild_list_add_pattern.cmake
@@ -0,0 +1,94 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_list_add_pattern
+# ========================
+#
+# Exclude items from a list that match a list of patterns. ::
+#
+#   ecbuild_list_add_pattern( LIST <input_list>
+#                             GLOB <pattern1> [ <pattern2> ... ]
+#                             [ SOURCE_DIR <source_dir> ]
+#                             [ QUIET ] )
+#
+# Options
+# -------
+#
+# LIST : required
+#   list variable to be appended to
+#
+# GLOB : required
+#   Regex pattern of exclusion
+#
+# SOURCE_DIR : optional
+#   Directory from where to start search
+#
+# QUIET  : optional
+#   Don't warn if patterns don't match
+#
+##############################################################################
+
+function( ecbuild_list_add_pattern )
+
+  set( options QUIET )
+  set( single_value_args LIST SOURCE_DIR )
+  set( multi_value_args  GLOB )
+
+  cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+  if(_p_UNPARSED_ARGUMENTS)
+    ecbuild_critical("Unknown keywords given to ecbuild_list_add_pattern(): \"${_p_UNPARSED_ARGUMENTS}\"")
+  endif()
+
+  if( NOT _p_LIST  )
+    ecbuild_critical("The call to ecbuild_list_add_pattern() doesn't specify the LIST.")
+  endif()
+
+  if( NOT _p_GLOB )
+    ecbuild_critical("The call to ecbuild_list_add_pattern() doesn't specify the GLOB.")
+  endif()
+
+  #####
+
+  set( input_list ${${_p_LIST}} )
+  unset( matched_files )
+
+  foreach( pattern ${_p_GLOB} )
+
+    if( IS_ABSOLUTE ${pattern} )
+      file( GLOB_RECURSE matched_files ${pattern} )
+    else()
+
+      if(_p_SOURCE_DIR)
+        if( IS_ABSOLUTE ${_p_SOURCE_DIR} )
+          file( GLOB_RECURSE matched_files ${_p_SOURCE_DIR}/${pattern} )
+        else()
+          file( GLOB_RECURSE matched_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${_p_SOURCE_DIR}/${pattern} )
+        endif()
+      else()
+          file( GLOB_RECURSE matched_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${pattern} )
+      endif()
+
+    endif()
+
+  endforeach()
+
+  if(matched_files)
+    list( APPEND input_list ${matched_files} )
+    list( REMOVE_DUPLICATES input_list )
+    set( ${_p_LIST} ${input_list} PARENT_SCOPE )
+  else()
+    if(NOT _p_QUIET)
+      ecbuild_warn( "ecbuild_list_add_pattern: no matches found for patterns ${_p_GLOB}" )
+    endif()
+  endif()
+
+endfunction(ecbuild_list_add_pattern)
diff --git a/cmake/ecbuild_list_exclude_pattern.cmake b/cmake/ecbuild_list_exclude_pattern.cmake
new file mode 100644
index 0000000..399f7f1
--- /dev/null
+++ b/cmake/ecbuild_list_exclude_pattern.cmake
@@ -0,0 +1,88 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation nor
+# does it submit to any jurisdiction.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_list_exclude_pattern
+# ============================
+#
+# Exclude items from a list that match a list of patterns. ::
+#
+#   ecbuild_list_remove_pattern( LIST <input_list>
+#                                REGEX <regex1> [ <regex2> ... ]
+#                                [ QUIET ] )
+#
+# Options
+# -------
+#
+# LIST : required
+#   list variable to be cleaned
+#
+# REGEX : required
+#   Regex pattern of exclusions
+#
+# QUIET  : optional
+#   Don't warn if patterns don't match
+#
+##############################################################################
+
+function( ecbuild_list_exclude_pattern )
+
+  set( options QUIET )
+  set( single_value_args LIST )
+  set( multi_value_args  REGEX )
+
+  cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+
+  if(_p_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unknown keywords given to ecbuild_list_exclude_pattern(): \"${_p_UNPARSED_ARGUMENTS}\"")
+  endif()
+
+  if( NOT _p_LIST  )
+    message(FATAL_ERROR "The call to ecbuild_list_exclude_pattern() doesn't specify the LIST.")
+  endif()
+
+  if( NOT _p_REGEX )
+    message(FATAL_ERROR "The call to ecbuild_list_exclude_pattern() doesn't specify the REGEX.")
+  endif()
+
+  #####
+
+  set( result "" )
+  set( matches_found 0 )
+
+  # ecbuild_debug_var(_p_REGEX)
+
+  foreach(item ${${_p_LIST}})
+
+    set(_keep 1)
+
+    foreach( pattern ${_p_REGEX} )
+        if( ${item} MATCHES ${pattern} )
+            set( _keep 0)
+            set( matches_found 1 )
+        endif()
+    endforeach()
+    if( _keep )
+        list( APPEND result ${item} )
+#    else()
+#      ecbuild_warn( "removing ${item}" )
+    endif()
+
+  endforeach()
+
+  if(matches_found)
+      set( ${_p_LIST} ${result} PARENT_SCOPE )
+  else()
+    if(NOT _p_QUIET)
+        ecbuild_warn( "ecbuild_list_exclude_pattern: no matches found for patterns ${_p_REGEX} in ${_p_LIST}" )
+    endif()
+  endif()
+
+endfunction(ecbuild_list_exclude_pattern)
\ No newline at end of file
diff --git a/cmake/ecbuild_list_extra_search_paths.cmake b/cmake/ecbuild_list_extra_search_paths.cmake
index bdfce3e..c120b40 100644
--- a/cmake/ecbuild_list_extra_search_paths.cmake
+++ b/cmake/ecbuild_list_extra_search_paths.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -8,15 +8,17 @@
 
 ############################################################################################
 #
-# macro for adding search paths to CMAKE_PREFIX_PATH
-# for example the ECMWF /usr/local/apps paths
+# macro for adding search paths for a package to a given CMake variable
 #
 # usage: ecbuild_list_extra_search_paths( netcdf4 VARIABLE )
 
 function( ecbuild_list_extra_search_paths pkg var )
 
-	# debug_var( pkg )
-	# debug_var( var )
+  message( DEPRECATION " ecbuild_list_extra_search_paths should no longer be"
+           " used and is going to be removed in a future version of ecBuild." )
+
+	# ecbuild_debug_var( pkg )
+	# ecbuild_debug_var( var )
 
 	string( TOUPPER ${pkg} _PKG )
 
@@ -62,42 +64,6 @@ function( ecbuild_list_extra_search_paths pkg var )
 		list( APPEND ${var} $ENV{${pkg}_DIR} )
 	endif()
 
-	# directories under /usr/local/apps/${pkg}
-
-	if( SEARCH_ECMWF_PATHS )
-
-		foreach( _apps /usr/local/apps/${pkg} /usr/local/lib/metaps/lib/${pkg} )
-
-			if( EXISTS ${_apps} )
-        ecbuild_debug("ecbuild_list_extra_search_paths(${pkg}): Searching ${_apps}")
-
-				 file( GLOB ps ${_apps}/[0-9]* )
-				 list( SORT ps )
-				 list( REVERSE ps ) # reversing will give us the newest versions first
-				 foreach( p ${ps} )
-					 if( IS_DIRECTORY ${p} )
-						  list( APPEND ${var}  ${p} )
-						  if( EXISTS ${p}/LP64 )
-							  list( APPEND ${var} ${p}/LP64 )
-						  endif()
-					 endif()
-				 endforeach()
-
-				 foreach( p ${_apps} ${_apps}/current ${_apps}/stable ${_apps}/new ${_apps}/next ${_apps}/prev )
-				   if( EXISTS ${p} )
-					   list( APPEND ${var} ${p} )
-				   endif()
-				   if( EXISTS ${p}/LP64 )
-					   list( APPEND ${var} ${p}/LP64 )
-				   endif()
-				 endforeach()
-
-			endif()
-
-		endforeach()
-
-	endif( SEARCH_ECMWF_PATHS )
-
 	# sanitize the list
 
 	if( ${var} )
@@ -109,7 +75,7 @@ function( ecbuild_list_extra_search_paths pkg var )
   ecbuild_debug("ecbuild_list_extra_search_paths(${pkg}): setting ${var} to ${${var}}")
 	set( ${var} ${${var}} PARENT_SCOPE )
 
-# debug_var( ${var} )
+# ecbuild_debug_var( ${var} )
 
 endfunction()
 
diff --git a/cmake/ecbuild_list_macros.cmake b/cmake/ecbuild_list_macros.cmake
index fcfc815..95d9512 100644
--- a/cmake/ecbuild_list_macros.cmake
+++ b/cmake/ecbuild_list_macros.cmake
@@ -1,8 +1,8 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
+# (C) Copyright 1996-2015 ECMWF.
+#
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
@@ -56,35 +56,3 @@ function( MAP_GET _map _key _var )
 	set( ${_var} "${_${_map}_${_key}}" PARENT_SCOPE )
 endfunction(MAP_GET)
 
-##############################################################################
-# function to remove items from a list that match a list of patterns
-#
-# examples:
-#
-#   ecbuild_list_remove_pattern( mylist "foo;bar" VAR )
-#
-
-function(ecbuild_list_remove_pattern _list _patterns _var)
-
-#debug_var(  _list )
-#debug_var(  _patterns )
-#debug_var(  _var )
-
-    foreach( _elem ${_list} )
-        set( _keep TRUE)
-        foreach( _pat ${_patterns} )
-            if( ${_elem} MATCHES ${_pat} )
-                set( _keep FALSE)
-            endif()
-        endforeach()
-        if( _keep )
-            list( APPEND _result ${_elem} )
-        endif()
-
-    endforeach()
-
-#debug_var(  _result )
-
-    set( ${_var} "${_result}" PARENT_SCOPE )
-
-endfunction(ecbuild_list_remove_pattern)
diff --git a/cmake/ecbuild_log.cmake b/cmake/ecbuild_log.cmake
index 5858414..b398ade 100644
--- a/cmake/ecbuild_log.cmake
+++ b/cmake/ecbuild_log.cmake
@@ -6,26 +6,41 @@
 # granted to it by virtue of its status as an intergovernmental organisation
 # nor does it submit to any jurisdiction.
 
-###############################################################################
-# Macros for logging based on the log level set
+##############################################################################
+#.rst:
 #
-# CMake variables controlling the behaviour:
+# Logging
+# =======
 #
-# ECBUILD_LOG_LEVEL (string) - controls the log level
-#                              one of DEBUG, INFO, WARN, ERROR, CRITICAL
-#                              OFF to disable logging altogether
+# ecBuild provides macros for logging based on a log level set by the user,
+# similar to the Python logging module:
 #
-# ECBUILD_NO_COLOUR (bool)   - if enabled, does not colour log output
+# :ecbuild_debug:    logs a ``STATUS`` message if log level <= ``DEBUG``
+# :ecbuild_info:     logs a ``STATUS`` message if log level <= ``INFO``
+# :ecbuild_warn:     logs a ``WARNING`` message if log level <= ``WARN``
+# :ecbuild_error:    logs a ``SEND_ERROR`` message if log level <= ``ERROR``
+# :ecbuild_critical: logs a ``FATAL_ERROR`` message if log level <= ``CRITICAL``
 #
-# Macros:
+# Input variables
+# ---------------
 #
-# ecbuild_debug    - logs a STATUS message if log level <= DEBUG
-# ecbuild_info     - logs a STATUS message if log level <= INFO
-# ecbuild_warn     - logs a WARNING message if log level <= WARN
-# ecbuild_error    - logs a SEND_ERROR message if log level <= ERROR
-# ecbuild_critical - logs a FATAL_ERROR message if log level <= CRITICAL
+# CMake variables controlling logging behaviour:
 #
-###############################################################################
+# ECBUILD_LOG_LEVEL : string, one of DEBUG, INFO, WARN, ERROR, CRITICAL, OFF
+#   set the desired log level, OFF to disable logging altogether
+#
+# ECBUILD_NO_COLOUR : bool
+#   if set, does not colour log output (by default log output is coloured)
+#
+# Usage
+# -----
+#
+# The macros ``ecbuild_debug`` and ``ecbuild_info`` can be used to output
+# messages which are not printed by default. Many ecBuild macros use this
+# facility to log debugging hints. When debugging a CMake run, users can use
+# ``-DECBUILD_LOG_LEVEL=DEBUG`` to get detailed diagnostics.
+#
+##############################################################################
 
 # Define colour escape sequences (https://stackoverflow.com/a/19578320/396967)
 if(NOT (WIN32 OR ECBUILD_NO_COLOUR))
@@ -55,7 +70,7 @@ set(ECBUILD_ERROR    40)
 set(ECBUILD_CRITICAL 50)
 
 if( NOT DEFINED ECBUILD_LOG_LEVEL )
-  set(ECBUILD_LOG_LEVEL ${ECBUILD_WARN})
+  set(ECBUILD_LOG_LEVEL ${ECBUILD_INFO})
 elseif( NOT ECBUILD_LOG_LEVEL )
   set(ECBUILD_LOG_LEVEL 60)
 elseif( ECBUILD_LOG_LEVEL STREQUAL "DEBUG" )
@@ -73,32 +88,106 @@ else()
   set(ECBUILD_LOG_LEVEL ${ECBUILD_WARN})
 endif()
 
+##############################################################################
+
 macro( ecbuild_debug MSG )
   if( ECBUILD_LOG_LEVEL LESS 11)
     message(STATUS "${Blue}DEBUG - ${MSG}${ColourReset}")
   endif()
 endmacro( ecbuild_debug )
 
+##############################################################################
+
 macro( ecbuild_info MSG )
   if( ECBUILD_LOG_LEVEL LESS 21)
     message(STATUS "${Green}INFO - ${MSG}${ColourReset}")
   endif()
 endmacro( ecbuild_info )
 
+##############################################################################
+
 macro( ecbuild_warn MSG )
   if( ECBUILD_LOG_LEVEL LESS 31)
     message(WARNING "${Yellow}WARN - ${MSG}${ColourReset}")
   endif()
 endmacro( ecbuild_warn )
 
+##############################################################################
+
 macro( ecbuild_error MSG )
   if( ECBUILD_LOG_LEVEL LESS 41)
     message(SEND_ERROR "${BoldRed}ERROR - ${MSG}${ColourReset}")
   endif()
 endmacro( ecbuild_error )
 
+##############################################################################
+
 macro( ecbuild_critical MSG )
   if( ECBUILD_LOG_LEVEL LESS 51)
     message(FATAL_ERROR "${BoldMagenta}CRITICAL - ${MSG}${ColourReset}")
   endif()
 endmacro( ecbuild_critical )
+
+##############################################################################
+# macro for debugging a cmake variable
+
+macro( ecbuild_debug_var VAR )
+  if( ECBUILD_LOG_LEVEL LESS 11)
+    message(STATUS "${Blue}DEBUG - ${VAR} : ${${VAR}}${ColourReset}")
+  endif()
+endmacro()
+
+##############################################################################
+# macro for debugging a cmake variable
+
+macro( ecbuild_debug_list VAR )
+  if( ECBUILD_LOG_LEVEL LESS 11)
+    message( STATUS "${Blue}DEBUG - ${VAR}" )
+    foreach( _elem ${${VAR}} )
+      message( STATUS "  ${_elem}" )
+    endforeach()
+    message(STATUS "${ColourReset}")
+  endif()
+endmacro()
+
+##############################################################################
+# macro for debugging a environment variable within cmake
+
+macro( ecbuild_debug_env_var VAR )
+  if( ECBUILD_LOG_LEVEL LESS 11)
+    message(STATUS "${Blue}DEBUG - ENV ${VAR} [$ENV{${VAR}}]${ColourReset}")
+  endif()
+endmacro()
+
+##############################################################################
+# macro for debugging a cmake variable
+
+macro( debug_var VAR )
+
+    message( WARNING "DEPRECATED debug_var() -- ${VAR} [${${VAR}}]" )
+
+endmacro()
+
+##############################################################################
+# macro for debugging a cmake list
+
+macro( debug_list VAR )
+
+    message( WARNING "DEPRECATED debug_list() -- ${VAR}:" )
+    foreach( _elem ${${VAR}} )
+      message( WARNING "  ${_elem}" )
+    endforeach()
+
+endmacro()
+
+##############################################################################
+# macro for debugging a environment variable within cmake
+
+macro( debug_env_var VAR )
+
+    message( WARNING "DEPRECATED debug_env_var() -- ENV ${VAR} [$ENV{${VAR}}]" )
+
+endmacro()
+
+
+
diff --git a/cmake/ecbuild_pkgconfig.cmake b/cmake/ecbuild_pkgconfig.cmake
index bd4dfc3..6db3726 100644
--- a/cmake/ecbuild_pkgconfig.cmake
+++ b/cmake/ecbuild_pkgconfig.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,52 +6,10 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-#############################################################################################
-#
-# MACRO ecbuild_pkgconfig
-#
-# This macro creates a pkg-config file for the current project
-#
-# It takes following optional arguments:
-#
-#  - FILENAME <filename>
-#       The file that will be generated. Default value is the lowercase
-#       name of the project with suffix ".pc" is used
-#
-#  - NAME <name>
-#       The name to be given to the package. Default value is the lowercase
-#       name of the project
-#
-#  - TEMPLATE <template>
-#       The template configuration file to use. This is useful to create more
-#       custom pkg-config files. Default is ${ECBUILD_CMAKE_DIR}/pkg-config.pc.in
-#
-#  - URL <url>
-#       The url of the package. Default is ${UPPERCASE_PROJECT_NAME}_URL
-#
-#  - DESCRIPTION <description>
-#       The description of the package. Default is ${UPPERCASE_PROJECT_NAME}_DESCRIPTION
-#
-#  - LIBRARIES <libraries>
-#       The package libraries. Default is ${UPPERCASE_PROJECT_NAME}_LIBRARIES
-#       This is e.g. of the form "eckit;eckit_geometry"
-#
-#  - IGNORE_INCLUDE_DIRS <include_dirs>
-#       Ignore specified include directories
-#
-#  - IGNORE_LIBRARIES <libraries>
-#       Ignore specified libraries
-#
-#  - LANGUAGES <languages>
-#       List of languages used. If none given, all CMake_<lang>_COMPILER_LOAED languages
-#       are added. Accepted languages: C CXX Fortran
-#
-#  - NO_PRIVATE_INCLUDE_DIRS
-#       Don't add include dirs of dependencies to Cflags. This is mainly useful
-#       for Fortran only packages, when only the modules need to be added to Cflags
-#
-#############################################################################################
+##############################################################################
 
+# Write transitive list of library dependencies of each library in ${libraries}
+# to CMake variable ${dependencies}
 function( ecbuild_library_dependencies dependencies libraries )
 
   set( _libraries ${${libraries}} )
@@ -105,8 +63,10 @@ function( ecbuild_library_dependencies dependencies libraries )
 
 endfunction(ecbuild_library_dependencies)
 
-#############################################################################################
+##############################################################################
 
+# Write list of include directories of each library in ${libraries}
+# to CMake variable ${dependencies}
 function( ecbuild_include_dependencies dependencies libraries )
 
   set( _libraries ${${libraries}} )
@@ -129,8 +89,10 @@ function( ecbuild_include_dependencies dependencies libraries )
 
 endfunction(ecbuild_include_dependencies)
 
-#############################################################################################
+##############################################################################
 
+# Transform list of libraries in ${libraries}, ignoring any in ${ignore_libs},
+# and write pkg-config compatible string to CMake variable ${pkgconfig_libs}
 function( ecbuild_pkgconfig_libs pkgconfig_libs libraries ignore_libs )
 
   set( _libraries ${${libraries}} )
@@ -158,6 +120,9 @@ function( ecbuild_pkgconfig_libs pkgconfig_libs libraries ignore_libs )
         get_filename_component( _name ${_lib} NAME_WE )
         get_filename_component( _dir  ${_lib} PATH )
 
+        if( TARGET ${_lib} )
+          get_target_property( _name ${_lib} OUTPUT_NAME )
+        endif()
         if( NOT _name )
           set( _name ${_lib} )
         endif()
@@ -203,10 +168,11 @@ function( ecbuild_pkgconfig_libs pkgconfig_libs libraries ignore_libs )
 
 endfunction(ecbuild_pkgconfig_libs)
 
+##############################################################################
 
-#############################################################################################
-
-
+# Transform list of include directories in ${INCLUDE_DIRS}, ignoring any in
+# ${ignore_includes} and ${${PNAME}_INCLUDE_DIRS}, and write pkg-config
+# compatible string to CMake variable ${INCLUDE}
 function( ecbuild_pkgconfig_include INCLUDE INCLUDE_DIRS ignore_includes )
 
   string( TOUPPER ${PROJECT_NAME} PNAME )
@@ -216,14 +182,17 @@ function( ecbuild_pkgconfig_include INCLUDE INCLUDE_DIRS ignore_includes )
   list( APPEND ignore_include_dirs
     "/usr/include"
      ${${PNAME}_INCLUDE_DIRS} # These are build-directory includes
+     ${CMAKE_SOURCE_DIR}  # Ignore private includes referencing source tree
+     ${CMAKE_BINARY_DIR}  # Ignore private includes referencing build tree
      ${_ignore_includes}
   )
 
   foreach( _incdir ${${INCLUDE_DIRS}} )
 
     foreach( _ignore ${ignore_include_dirs} )
-      if( "${_incdir}" STREQUAL "${_ignore}" )
+      if( "${_incdir}" MATCHES "${_ignore}" )
         unset( _incdir )
+        break()
       endif()
     endforeach()
 
@@ -241,13 +210,100 @@ function( ecbuild_pkgconfig_include INCLUDE INCLUDE_DIRS ignore_includes )
 
 endfunction(ecbuild_pkgconfig_include)
 
-
-#############################################################################################
+##############################################################################
+#.rst:
+#
+# ecbuild_pkgconfig
+# =================
+#
+# Create a pkg-config file for the current project. ::
+#
+#   ecbuild_pkgconfig( [ NAME <name> ]
+#                      [ FILENAME <filename> ]
+#                      [ TEMPLATE <template> ]
+#                      [ URL <url> ]
+#                      [ DESCRIPTION <description> ]
+#                      [ LIBRARIES <lib1> [ <lib2> ... ] ]
+#                      [ IGNORE_INCLUDE_DIRS <dir1> [ <dir2> ... ] ]
+#                      [ IGNORE_LIBRARIES <lib1> [ <lib2> ... ] ]
+#                      [ LANGUAGES <language1> [ <language2> ... ] ]
+#                      [ VARIABLES <variable1> [ <variable2> ... ] ]
+#                      [ NO_PRIVATE_INCLUDE_DIRS ] )
+#
+# Options
+# -------
+#
+# NAME : optional, defaults to lower case name of the project
+#   name to be given to the package
+#
+# FILENAME : optional, defaults to ``<NAME>.pc``
+#   file to be generated, including .pc extension
+#
+# TEMPLATE : optional, defaults to ``${ECBUILD_CMAKE_DIR}/pkg-config.pc.in``
+#   template configuration file to use
+#
+#   This is useful to create customised pkg-config files.
+#
+# URL : optional, defaults to ``${UPPERCASE_PROJECT_NAME}_URL``
+#   url of the package
+#
+# DESCRIPTION : optional, defaults to ``${UPPERCASE_PROJECT_NAME}_DESCRIPTION``
+#   description of the package
+#
+# LIBRARIES : optional, defaults to ``${UPPERCASE_PROJECT_NAME}_LIBRARIES``
+#   list of package libraries
+#
+# IGNORE_INCLUDE_DIRS : optional
+#   list of include directories to ignore
+#
+# IGNORE_LIBRARIES : optional
+#   list of libraries to ignore i.e. those are removed from ``LIBRARIES``
+#
+# VARIABLES : optional
+#   list of additional CMake variables to export to the pkg-config file
+#
+# LANGUAGES : optional, defaults to all loaded languages
+#   list of languages to use. Accepted languages: C CXX Fortran
+#
+# NO_PRIVATE_INCLUDE_DIRS
+#   do not add include directories of dependencies to Cflags
+#
+#   This is mainly useful for Fortran only packages, when only modules need
+#   to be added to Cflags.
+#
+# Input variables
+# ---------------
+#
+# The following CMake variables are used as default values for some of the
+# options listed above, where ``PNAME`` is the project name in upper case: ::
+#
+# :<PNAME>_LIBRARIES:    list of libraries to export
+# :<PNAME>_DESCRIPTION:  package description
+# :<PNAME>_URL:          package URL
+# :<PNAME>_VERSION:      package version
+# :<PNAME>_GIT_SHA1:     Git revision
+#
+# Usage
+# -----
+#
+# It is good practice to provide a separate pkg-config file for each library a
+# package exports. This can be achieved as follows: ::
+#
+#   foreach( _lib ${${PNAME}_LIBRARIES} )
+#     if( TARGET ${_lib} )
+#       ecbuild_pkgconfig( NAME ${_lib}
+#                          DESCRIPTION "..."
+#                          URL "..."
+#                          LIBRARIES ${_lib} )
+#     endif()
+#   endforeach()
+#
+##############################################################################
 
 function( ecbuild_pkgconfig )
 
   set( options REQUIRES NO_PRIVATE_INCLUDE_DIRS )
-  set( single_value_args FILEPATH NAME TEMPLATE URL DESCRIPTION )
+  set( single_value_args FILENAME NAME TEMPLATE URL DESCRIPTION )
   set( multi_value_args LIBRARIES IGNORE_INCLUDE_DIRS IGNORE_LIBRARIES VARIABLES LANGUAGES )
 
   cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
@@ -331,8 +387,8 @@ function( ecbuild_pkgconfig )
     set( PKGCONFIG_NAME ${_PAR_NAME} )
   endif()
 
-  if( NOT _PAR_FILEPATH )
-    set( _PAR_FILEPATH "${PKGCONFIG_NAME}.pc" )
+  if( NOT _PAR_FILENAME )
+    set( _PAR_FILENAME "${PKGCONFIG_NAME}.pc" )
   endif()
 
   set( PKGCONFIG_DESCRIPTION ${${PNAME}_DESCRIPTION} )
@@ -355,10 +411,10 @@ function( ecbuild_pkgconfig )
     endforeach()
   endif()
 
-  configure_file( ${_PAR_TEMPLATE} "${CMAKE_BINARY_DIR}/${_PAR_FILEPATH}" @ONLY )
-  message( STATUS "pkg-config file created: ${_PAR_FILEPATH}" )
+  configure_file( ${_PAR_TEMPLATE} "${CMAKE_BINARY_DIR}/${_PAR_FILENAME}" @ONLY )
+  message( STATUS "pkg-config file created: ${_PAR_FILENAME}" )
 
-  install( FILES ${CMAKE_BINARY_DIR}/${_PAR_FILEPATH}
+  install( FILES ${CMAKE_BINARY_DIR}/${_PAR_FILENAME}
            DESTINATION ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/pkgconfig/
            COMPONENT utilities )
 
diff --git a/cmake/ecbuild_policies.cmake b/cmake/ecbuild_policies.cmake
index 06f856b..e420e81 100644
--- a/cmake/ecbuild_policies.cmake
+++ b/cmake/ecbuild_policies.cmake
@@ -6,13 +6,17 @@
 # granted to it by virtue of its status as an intergovernmental organisation
 # nor does it submit to any jurisdiction.
 
-###############################################################################
-# define cmake policies
+##############################################################################
+#
+# ecBuild Policies
+# ================
 #
 # NOTE: This file needs to be included with NO_POLICY_SCOPE or it will have no
 #       effect!
 # NOTE: Policies 1 through 17 will be set to NEW by requiring CMake 2.8.4 i.e.
 #       calling cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
+#
+##############################################################################
 
 # allow for empty spaces around library names 
 if( POLICY CMP0004 )
diff --git a/cmake/ecbuild_print_summary.cmake b/cmake/ecbuild_print_summary.cmake
index 35a2b36..5394ad8 100644
--- a/cmake/ecbuild_print_summary.cmake
+++ b/cmake/ecbuild_print_summary.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,110 +6,101 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
+##############################################################################
+#.rst:
+#
+# ecbuild_print_summary
+# =====================
+#
+# Print a summary of the project, build environment and enabled features. ::
+#
+#   ecbuild_print_summary()
+#
+# If ``project_summary.cmake`` exist in the source root directory, a project
+# summary is printed by including this file.
+#
+# For a top level project, a summary of the build environment and a feature
+# summary are also printed.
+#
+##############################################################################
+
 macro( ecbuild_print_summary )
 
-    if( EXISTS ${PROJECT_SOURCE_DIR}/project_summary.cmake )
+  if( EXISTS ${PROJECT_SOURCE_DIR}/project_summary.cmake )
+
+    message( STATUS "---------------------------------------------------------" )
+    message( STATUS "Project ${PROJECT_NAME} summary" )
+    message( STATUS "---------------------------------------------------------" )
+
+    include( ${PROJECT_SOURCE_DIR}/project_summary.cmake )
+
+  endif()
+
+  if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
+
+    ecbuild_define_links_target()
 
-		message( STATUS "---------------------------------------------------------" )
-		message( STATUS "Project ${PROJECT_NAME} summary" )
-		message( STATUS "---------------------------------------------------------" )
+    get_property( langs GLOBAL PROPERTY ENABLED_LANGUAGES )
 
-		include( ${PROJECT_SOURCE_DIR}/project_summary.cmake )
+    message( STATUS "---------------------------------------------------------" )
+    if( NOT ${DEVELOPER_MODE} )
+      message( STATUS "Build summary" )
+    else()
+      message( STATUS "Build summary -- ( DEVELOPER_MODE )" )
+    endif()
+    message( STATUS "---------------------------------------------------------" )
 
+    message( STATUS "system : [${BUILD_SITE}] [${CMAKE_SYSTEM}] [${EC_OS_NAME}.${EC_OS_BITS}]" )
+    message( STATUS "processor        : [${CMAKE_SYSTEM_PROCESSOR}]" )
+    if( EC_BIG_ENDIAN )
+      message( STATUS "endiness         : Big Endian -- IEEE [${IEEE_BE}]" )
+    endif()
+    if( EC_LITTLE_ENDIAN )
+      message( STATUS "endiness         : Little Endian -- IEEE [${IEEE_LE}]" )
+    endif()
+    message( STATUS "build type       : [${CMAKE_BUILD_TYPE}]" )
+    message( STATUS "timestamp        : [${EC_BUILD_TIMESTAMP}]" )
+    message( STATUS "install prefix   : [${CMAKE_INSTALL_PREFIX}]" )
+    if( EC_LINK_DIR )
+      message( STATUS "links prefix     : [${EC_LINK_DIR}]" )
     endif()
+    message( STATUS "---------------------------------------------------------" )
 
-    if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
-	
-        ecbuild_define_links_target()
-
-        get_property( langs GLOBAL PROPERTY ENABLED_LANGUAGES )
-
-		message( STATUS "---------------------------------------------------------" )
-		if( NOT ${DEVELOPER_MODE} )
-			message( STATUS "Build summary" )
-		else()
-			message( STATUS "Build summary -- ( DEVELOPER_MODE )" )
-		endif()
-		message( STATUS "---------------------------------------------------------" )
-
-		message( STATUS "system : [${BUILD_SITE}] [${CMAKE_SYSTEM}] [${EC_OS_NAME}.${EC_OS_BITS}]" )
-		message( STATUS "processor        : [${CMAKE_SYSTEM_PROCESSOR}]" )
-		if( EC_BIG_ENDIAN )
-			message( STATUS "endiness         : Big Endian -- IEEE [${IEEE_BE}]" )
-		endif()
-		if( EC_LITTLE_ENDIAN )
-			message( STATUS "endiness         : Little Endian -- IEEE [${IEEE_LE}]" )
-		endif()
-		message( STATUS "build type       : [${CMAKE_BUILD_TYPE}]" )
-		message( STATUS "timestamp        : [${EC_BUILD_TIMESTAMP}]" )
-		message( STATUS "install prefix   : [${CMAKE_INSTALL_PREFIX}]" )
-		if( EC_LINK_DIR )
-			message( STATUS "links prefix     : [${EC_LINK_DIR}]" )
-		endif()
-        message( STATUS "---------------------------------------------------------" )
-
-        foreach( lang ${langs} )
-		  message( STATUS "${lang} -- ${CMAKE_${lang}_COMPILER_ID} ${CMAKE_${lang}_COMPILER_VERSION}"  )
-		  message( STATUS "    compiler   : ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
-		  message( STATUS "    link flags : ${CMAKE_${lang}_LINK_FLAGS}" )
-		endforeach()
-
-	message( STATUS "linker : ${CMAKE_LINKER}")
-	message( STATUS "ar     : ${CMAKE_AR}")
-	message( STATUS "ranlib : ${CMAKE_RANLIB}")
-	message( STATUS "link flags" )
-	message( STATUS "    executable [${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}]" )
-	message( STATUS "    shared lib [${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}]" )
-	message( STATUS "    static lib [${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}]" )
-	message( STATUS "install rpath  : ${CMAKE_INSTALL_RPATH}" )
-
-	get_directory_property( defs COMPILE_DEFINITIONS )
-
-	message( STATUS "common definitions: ${defs}" )
-
-	message( STATUS "---------------------------------------------------------" )
-
-	### FEATURE SUMMARY
-
-	  # debug_var( CMAKE_VERSION )
-	  if( ${CMAKE_VERSION} VERSION_LESS "2.8.6" )
-		feature_summary( WHAT ALL )
-	  else()
-		feature_summary( WHAT ALL INCLUDE_QUIET_PACKAGES )
-	  endif()
-
-	### WARNINGS
+    foreach( lang ${langs} )
+      message( STATUS "${lang} -- ${CMAKE_${lang}_COMPILER_ID} ${CMAKE_${lang}_COMPILER_VERSION}"  )
+      message( STATUS "    compiler   : ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
+      message( STATUS "    link flags : ${CMAKE_${lang}_LINK_FLAGS}" )
+    endforeach()
 
-    # issue warnings / errors in case there are unused project files
-    ecbuild_warn_unused_files()
+    message( STATUS "linker : ${CMAKE_LINKER}")
+    message( STATUS "ar     : ${CMAKE_AR}")
+    message( STATUS "ranlib : ${CMAKE_RANLIB}")
+    message( STATUS "link flags" )
+    message( STATUS "    executable [${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}]" )
+    message( STATUS "    shared lib [${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}]" )
+    message( STATUS "    static lib [${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}]" )
+    message( STATUS "install rpath  : ${CMAKE_INSTALL_RPATH}" )
+
+    get_directory_property( defs COMPILE_DEFINITIONS )
 
-    # issue a warning that 'make install' mighty be broken for old cmakes
-    if( ${CMAKE_VERSION} VERSION_LESS "2.8.3" )
-
-        message( STATUS " +++ WARNING +++ WARNING +++ WARNING +++" )
-        message( STATUS " +++ " )
-		message( STATUS " +++ This CMake version [${CMAKE_VERSION}] is rather OLD !!" )
-        message( STATUS " +++ " )
-        message( STATUS " +++ We work hard to keep CMake backward compatibility (support >= 2.6.4)" )
-        message( STATUS " +++ but there are some limits inherent to older versions." )
-        message( STATUS " +++ " )
-        message( STATUS " +++ You will be able to build the software... " )
-        message( STATUS " +++ " )
-        message( STATUS " +++ But: " )
-        message( STATUS " +++     * the 'make install' target most likely will NOT WORK" )
-        message( STATUS " +++     * if you want to install these binaries you might need to copy them by yourself" )
-        message( STATUS " +++     * the binaries are in '${CMAKE_BINARY_DIR}' /lib and /bin" )
-        message( STATUS " +++     * copying headers will take substantially more work, and you might end up copying files that won't be needed" )
-        message( STATUS " +++ " )
-        message( STATUS " +++ Therefore, we recommend that you:  " )
-        message( STATUS " +++     * upgrade to a newer CMake with version at least >= 2.8.3" )
-        message( STATUS " +++     * remove this build directory '${CMAKE_BINARY_DIR}'" )
-        message( STATUS " +++     * rerun a newer cmake on an new empty build directory" )
-        message( STATUS " +++ " )
-        message( STATUS " +++ WARNING +++ WARNING +++ WARNING +++" )
+    message( STATUS "common definitions: ${defs}" )
 
+    message( STATUS "---------------------------------------------------------" )
+
+    ### FEATURE SUMMARY
+
+    # ecbuild_debug_var( CMAKE_VERSION )
+    if( ${CMAKE_VERSION} VERSION_LESS "2.8.6" )
+      feature_summary( WHAT ALL )
+    else()
+      feature_summary( WHAT ALL INCLUDE_QUIET_PACKAGES )
     endif()
 
-    endif( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
+    ### WARNINGS
+
+    # issue warnings / errors in case there are unused project files
+    ecbuild_warn_unused_files()
+
+  endif( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
 
 endmacro( ecbuild_print_summary )
diff --git a/cmake/ecbuild_project_files.cmake b/cmake/ecbuild_project_files.cmake
index 162a625..537556a 100644
--- a/cmake/ecbuild_project_files.cmake
+++ b/cmake/ecbuild_project_files.cmake
@@ -1,8 +1,8 @@
-# (C) Copyright 1996-2014 ECMWF.
-# 
+# (C) Copyright 1996-2015 ECMWF.
+#
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
-# In applying this licence, ECMWF does not waive the privileges and immunities 
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
@@ -50,7 +50,7 @@ macro( ecbuild_declare_project_files )
   if( CHECK_UNUSED_FILES )
     foreach( _afile ${ARGV} )
 
-      # debug_var( _afile )
+      # ecbuild_debug_var( _afile )
 
       get_property( _src_gen SOURCE ${_afile} PROPERTY GENERATED )
 
diff --git a/cmake/ecbuild_requires_macro_version.cmake b/cmake/ecbuild_requires_macro_version.cmake
index dbdcc05..ef13d64 100644
--- a/cmake/ecbuild_requires_macro_version.cmake
+++ b/cmake/ecbuild_requires_macro_version.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -6,6 +6,18 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
+##############################################################################
+#.rst:
+#
+# ecbuild_requires_macro_version
+# ==============================
+#
+# Check that the ecBuild version satisfied a given minimum version or fail. ::
+#
+#   ecbuild_requires_macro_version( <minimum-version> )
+#
+##############################################################################
+
 macro( ecbuild_requires_macro_version req_vrs )
 
 	if( ECBUILD_MACRO_VERSION VERSION_LESS ${req_vrs} )
diff --git a/cmake/ecbuild_separate_sources.cmake b/cmake/ecbuild_separate_sources.cmake
index 71d56b3..3f930b3 100644
--- a/cmake/ecbuild_separate_sources.cmake
+++ b/cmake/ecbuild_separate_sources.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,7 +7,36 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# macro for separating sources sccording to language
+#.rst:
+#
+# ecbuild_separate_sources
+# ========================
+#
+# Separate a given list of sources according to language. ::
+#
+#   ecbuild_separate_sources( TARGET <name>
+#                             SOURCES <source1> [ <source2> ... ] )
+#
+# Options
+# -------
+#
+# TARGET : required
+#   base name for the CMake output variables to set
+#
+# SOURCES : required
+#   list of source files to separate
+#
+# Output variables
+# ----------------
+#
+# If any file of the following group of extensions is present in the list of
+# sources, the corresponding CMake variable is set:
+#
+# :<target>_h_srcs:   list of sources with extension .h, .hxx, .hh, .hpp, .H
+# :<target>_c_srcs:   list of sources with extension .c
+# :<target>_cxx_srcs: list of sources with extension .cc, .cxx, .cpp, .C
+# :<target>_f_srcs:   list of sources with extension .f, .F, .for, f77, .f90, .f95
+#
 ##############################################################################
 
 macro( ecbuild_separate_sources )
@@ -54,10 +83,9 @@ macro( ecbuild_separate_sources )
 		endif()
 	endforeach()
 
-#    debug_var( ${_PAR_TARGET}_h_srcs )
-#    debug_var( ${_PAR_TARGET}_c_srcs )
-#    debug_var( ${_PAR_TARGET}_cxx_srcs )
-#    debug_var( ${_PAR_TARGET}_f_srcs )
+#    ecbuild_debug_var( ${_PAR_TARGET}_h_srcs )
+#    ecbuild_debug_var( ${_PAR_TARGET}_c_srcs )
+#    ecbuild_debug_var( ${_PAR_TARGET}_cxx_srcs )
+#    ecbuild_debug_var( ${_PAR_TARGET}_f_srcs )
 
 endmacro( ecbuild_separate_sources  )
-
diff --git a/cmake/ecbuild_setup_test_framework.cmake b/cmake/ecbuild_setup_test_framework.cmake
index 538a433..f38bafb 100644
--- a/cmake/ecbuild_setup_test_framework.cmake
+++ b/cmake/ecbuild_setup_test_framework.cmake
@@ -2,7 +2,7 @@ ecbuild_add_option( FEATURE TESTS
                     DEFAULT ON
                     DESCRIPTION "Enable the unit tests" )
 
-if( ENABLE_TESTS )
+if( ENABLE_TESTS AND CMAKE_CXX_COMPILER_LOADED )
 
   # Try to find compiled boost
 
@@ -39,3 +39,7 @@ if( ENABLE_TESTS )
   endif()
 
 endif()
+
+if( NOT ENABLE_TESTS )
+  ecbuild_info("Tests have been disabled")
+endif()
\ No newline at end of file
diff --git a/cmake/ecbuild_source_flags.cmake b/cmake/ecbuild_source_flags.cmake
new file mode 100644
index 0000000..325a941
--- /dev/null
+++ b/cmake/ecbuild_source_flags.cmake
@@ -0,0 +1,30 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+set( __gen_source_flags ${CMAKE_CURRENT_LIST_DIR}/gen_source_flags.py )
+
+# Calls gen_source_flags.py to generate a CMake file with the per
+# source file flags for a given target.
+function( ecbuild_source_flags OUT TARGET DEFAULT_FLAGS SOURCES )
+
+  if( NOT PYTHONINTERP_FOUND OR PYTHON_VERSION VERSION_LESS 2.7 )
+    find_package( PythonInterp 2.7 REQUIRED )
+  endif()
+
+  set( OUTFILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_source_flags.cmake )
+
+  if( ECBUILD_LOG_LEVEL LESS 11)
+    set( __debug "--debug" )
+  endif()
+  execute_process( COMMAND ${PYTHON_EXECUTABLE} ${__gen_source_flags}
+                           ${ECBUILD_SOURCE_FLAGS} ${OUTFILE} "${DEFAULT_FLAGS}"
+                           ${SOURCES} "${__debug}" )
+
+  set( ${OUT} ${OUTFILE} PARENT_SCOPE )
+
+endfunction()
diff --git a/cmake/ecbuild_system.cmake b/cmake/ecbuild_system.cmake
index c226017..02f23ef 100644
--- a/cmake/ecbuild_system.cmake
+++ b/cmake/ecbuild_system.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -28,7 +28,7 @@ endif()
 ########################################################################################################
 # ecbuild versioning support
 
-set( ECBUILD_CMAKE_MINIMUM "2.8.4" )
+set( ECBUILD_CMAKE_MINIMUM "2.8.10" )
 if( ${CMAKE_VERSION} VERSION_LESS ${ECBUILD_CMAKE_MINIMUM} )
     message(FATAL_ERROR "${PROJECT_NAME} requires at least CMake ${ECBUILD_CMAKE_MINIMUM} -- you are using ${CMAKE_COMMAND} [${CMAKE_VERSION}]\n Please, get a newer version of CMake @ www.cmake.org" )
 endif()
@@ -42,6 +42,11 @@ set( ecbuild_VERSION_STR "${ECBUILD_VERSION_STR}" )
 # Set policies
 include( ecbuild_policies NO_POLICY_SCOPE )
 
+# set capitalised project name
+
+string( TOUPPER ${PROJECT_NAME} PROJECT_NAME_CAPS )
+string( TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWCASE )
+
 ########################################################################################################
 # include our cmake macros, but only do so if this is the top project
 if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
@@ -147,20 +152,15 @@ if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
     ############################################################################################
     # add our macros
 
-    include( ecbuild_debug_var )
     include( ecbuild_log )
     include( ecbuild_list_macros )
+    include( ecbuild_list_add_pattern )
+    include( ecbuild_list_exclude_pattern )
 
-    include( ecbuild_check_c_source )
-
-    if( CMAKE_CXX_COMPILER_LOADED )
-    include( ecbuild_check_cxx_source )
+    include( ecbuild_check_c_source_return )
+    include( ecbuild_check_cxx_source_return )
     include( ecbuild_check_cxx11 )
-    endif()
-
-    if( CMAKE_Fortran_COMPILER_LOADED )
-    include( ecbuild_check_fortran_source )
-    endif()
+    include( ecbuild_check_fortran_source_return )
 
     include( ecbuild_requires_macro_version )
     include( ecbuild_get_date )
@@ -168,6 +168,7 @@ if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
     include( ecbuild_generate_config_headers )
     include( ecbuild_generate_rpc )
     include( ecbuild_generate_yy )
+    include( ecbuild_generate_fortran_interfaces )
     include( ecbuild_echo_targets )
     include( ecbuild_features )
     include( ecbuild_add_option )
@@ -176,15 +177,18 @@ if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
     include( ecbuild_append_to_rpath )
     include( ecbuild_download_resource )
     include( ecbuild_get_test_data )
+    include( ecbuild_add_c_flags )
+    include( ecbuild_add_cxx_flags )
     include( ecbuild_add_cxx11_flags )
     include( ecbuild_get_cxx11_flags )
+    include( ecbuild_add_fortran_flags )
     include( ecbuild_add_test )
     include( ecbuild_add_resources )
     include( ecbuild_get_resources )
     include( ecbuild_dont_pack )
     include( ecbuild_project_files )
     include( ecbuild_declare_project )
-    include( ecbuild_install_package )
+    include( ecbuild_install_project )
     include( ecbuild_separate_sources )
     include( ecbuild_find_package )
     include( ecbuild_use_package )
@@ -198,10 +202,9 @@ if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
     include( ecbuild_find_python )
     include( ecbuild_find_lexyacc )
     include( ecbuild_find_fortranlibs )
+    include( ecbuild_git )
     include( ecbuild_enable_fortran )
-    include( ecbuild_check_c_source )
-    include( ecbuild_check_cxx_source )
-    include( ecbuild_check_fortran_source )
+    include( ecbuild_source_flags )
     include( ecbuild_bundle )
     include( ecbuild_pkgconfig )
     include( ecbuild_cache )
diff --git a/cmake/ecbuild_use_package.cmake b/cmake/ecbuild_use_package.cmake
index 0860b2d..c34f07d 100644
--- a/cmake/ecbuild_use_package.cmake
+++ b/cmake/ecbuild_use_package.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
@@ -7,7 +7,75 @@
 # does it submit to any jurisdiction.
 
 ##############################################################################
-# function for adding a subproject directory
+#.rst:
+#
+# ecbuild_use_package
+# ===================
+#
+# Add a project from a source directory, a subdirectory or search for it. ::
+#
+#   ecbuild_use_package( PROJECT <name>
+#                        [ VERSION <version> [ EXACT ] ]
+#                        [ REQUIRED ]
+#                        [ QUIET ] )
+#
+# Options
+# -------
+#
+# NAME : required
+#   package name (used as ``Find<name>.cmake`` and ``<name>-config.cmake``)
+#
+# VERSION : optional
+#   minimum required package version
+#
+# EXACT : optional, requires VERSION
+#   require the exact version rather than a minimum version
+#
+# REQUIRED : optional
+#   fail if package cannot be found
+#
+# QUIET : optional
+#   do not output package information if found
+#
+# Input variables
+# ---------------
+#
+# The following CMake variables influence the behaviour if set (``<name>``
+# is the package name as given, ``<NAME>`` is the capitalised version):
+#
+# :<NAME>_SOURCE:    path to source directory for package
+# :SUBPROJECT_DIRS:  list of additional paths to search for package source
+#
+# See also ``ecbuild_find_package`` for additional CMake variables relevant
+# when search for the package (step 6 below).
+#
+# Usage
+# -----
+#
+# Use another CMake project as a dependency by either building it from source
+# i.e. adding its source directory as a subdirectory or searching for it. This
+# transparently deals with the case where the project has already been included
+# e.g. because multiple projects with shared dependencies are built together.
+#
+# The search proceeds as follows:
+#
+# 1.  If ``SUBPROJECT_DIRS`` is set, each directory in the list is searched
+#     for a subdirectory <name> and ``<NAME>_SOURCE`` is set to the first one
+#     found (if any).
+#
+# 2.  If ``<NAME>_SOURCE`` is set, check if this directory is a CMake project
+#     (contains ``CMakeLists.txt`` and fail if not.
+#
+# 3.  Otherwise, check if the current directory has a ``<name>`` subdirectory.
+#
+# 4.  If the project has not been previously marked as found or added as a
+#     subdirectory and a project source directory has been found in steps 1-3
+#     add this subdirectory.
+#
+# 5.  If the project has been marked as found, check the version.
+#
+# 6.  Otherwise, search for the project using ``ecbuild_find_package``.
+#
 ##############################################################################
 
 macro( ecbuild_use_package )
@@ -32,32 +100,36 @@ macro( ecbuild_use_package )
 
   # try to find the package as a subproject and build it
 
-  string( TOUPPER ${_p_PROJECT} PNAME )
+  string( TOUPPER ${_p_PROJECT} pkgUPPER )
 
   # user defined dir with subprojects
 
-  if( NOT DEFINED ${PNAME}_SOURCE AND DEFINED SUBPROJECT_DIRS )
+  if( NOT DEFINED ${pkgUPPER}_SOURCE AND DEFINED SUBPROJECT_DIRS )
+    ecbuild_warn("ecbuild_use_package(): setting SUBPROJECT_DIRS is deprecated")
+    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): scanning subproject directories ${SUBPROJECT_DIRS}")
     foreach( dir ${SUBPROJECT_DIRS} )
       if( EXISTS ${dir}/${_p_PROJECT} AND EXISTS ${dir}/${_p_PROJECT}/CMakeLists.txt )
-        set( ${PNAME}_SOURCE "${dir}/${_p_PROJECT}" )
+        ecbuild_debug("ecbuild_use_package(${_p_PROJECT}):   setting ${pkgUPPER}_SOURCE to ${dir}/${_p_PROJECT}")
+        set( ${pkgUPPER}_SOURCE "${dir}/${_p_PROJECT}" )
       endif()
     endforeach()
   endif()
 
   # user defined path to subproject
 
-  if( DEFINED ${PNAME}_SOURCE )
+  if( DEFINED ${pkgUPPER}_SOURCE )
 
-    if( NOT EXISTS ${${PNAME}_SOURCE} OR NOT EXISTS ${${PNAME}_SOURCE}/CMakeLists.txt )
-      message( FATAL_ERROR "User defined source directory '${${PNAME}_SOURCE}' for project '${_p_PROJECT}' does not exist or does not contain a CMakeLists.txt file." )
+    if( NOT EXISTS ${${pkgUPPER}_SOURCE} OR NOT EXISTS ${${pkgUPPER}_SOURCE}/CMakeLists.txt )
+      ecbuild_critical("User defined source directory '${${pkgUPPER}_SOURCE}' for project '${_p_PROJECT}' does not exist or does not contain a CMakeLists.txt file.")
     endif()
 
-    set( ${PNAME}_subproj_dir_ "${${PNAME}_SOURCE}" )
+    set( ${pkgUPPER}_subproj_dir_ "${${pkgUPPER}_SOURCE}" )
 
   else() # default is 'dropped in' subdirectory named as project
 
     if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_p_PROJECT} AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_p_PROJECT}/CMakeLists.txt )
-      set( ${PNAME}_subproj_dir_ "${CMAKE_CURRENT_SOURCE_DIR}/${_p_PROJECT}" )
+      ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): found ${_p_PROJECT} in subdirectory ${CMAKE_CURRENT_SOURCE_DIR}/${_p_PROJECT}")
+      set( ${pkgUPPER}_subproj_dir_ "${CMAKE_CURRENT_SOURCE_DIR}/${_p_PROJECT}" )
     endif()
 
   endif()
@@ -68,32 +140,34 @@ macro( ecbuild_use_package )
   set( _do_version_check 0 )
   set( _source_description "" )
 
-  list( FIND ECBUILD_PROJECTS ${_p_PROJECT} _ecbuild_project_${PNAME} )
+  list( FIND ECBUILD_PROJECTS ${_p_PROJECT} _ecbuild_project_${pkgUPPER} )
 
-  if( NOT _ecbuild_project_${PNAME} EQUAL "-1" )
-    set( ${PNAME}_previous_subproj_ 1 )
+  if( NOT _ecbuild_project_${pkgUPPER} EQUAL "-1" )
+    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): ${_p_PROJECT} was previously added as a subproject")
+    set( ${pkgUPPER}_previous_subproj_ 1 )
   else()
-    set( ${PNAME}_previous_subproj_ 0 )
+    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): ${_p_PROJECT} was not previously added as a subproject")
+    set( ${pkgUPPER}_previous_subproj_ 0 )
   endif()
 
   # solve capitalization issues
 
-  if( ${_p_PROJECT}_FOUND AND NOT ${PNAME}_FOUND )
-    set( ${PNAME}_FOUND 1 )
+  if( ${_p_PROJECT}_FOUND AND NOT ${pkgUPPER}_FOUND )
+    set( ${pkgUPPER}_FOUND 1 )
   endif()
-  if( ${PNAME}_FOUND AND NOT ${_p_PROJECT}_FOUND )
+  if( ${pkgUPPER}_FOUND AND NOT ${_p_PROJECT}_FOUND )
     set( ${_p_PROJECT}_FOUND 1 )
   endif()
 
-  # Case 1) project was NOT added as subproject and is NOT FOUND
-
-  if( NOT ${PNAME}_FOUND AND NOT ${PNAME}_previous_subproj_ )
+  # Case 1) project was NOT previously added as subproject and is NOT already FOUND
 
-    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 1) project was NOT added as subproject and is NOT FOUND")
+  if( NOT ${pkgUPPER}_FOUND AND NOT ${pkgUPPER}_previous_subproj_ )
 
     # check if SUBPROJDIR is set
 
-    if( DEFINED ${PNAME}_subproj_dir_ )
+    if( DEFINED ${pkgUPPER}_subproj_dir_ )
+
+      ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 1) project was NOT previously added as subproject and is NOT already FOUND")
 
       # check version is acceptable
       set( _just_added 1 )
@@ -102,16 +176,17 @@ macro( ecbuild_use_package )
 
       # add as a subproject
 
-      set( ${PNAME}_subproj_dir_ ${${PNAME}_subproj_dir_} CACHE PATH "Path to ${_p_PROJECT} source directory" )
+      set( ${pkgUPPER}_subproj_dir_ ${${pkgUPPER}_subproj_dir_} CACHE PATH "Path to ${_p_PROJECT} source directory" )
 
       set( ECBUILD_PROJECTS ${ECBUILD_PROJECTS} ${_p_PROJECT} CACHE INTERNAL "" )
 
-      add_subdirectory( ${${PNAME}_subproj_dir_} ${_p_PROJECT} )
+      ecbuild_debug("ecbuild_use_package(${_p_PROJECT}):    ${_p_PROJECT} found in subdirectory ${${pkgUPPER}_subproj_dir_}")
+      add_subdirectory( ${${pkgUPPER}_subproj_dir_} ${_p_PROJECT} )
 
       set( ${_p_PROJECT}_BASE_DIR ${CMAKE_BINARY_DIR} )
 
-      set( ${PNAME}_FOUND 1 )
-      set( ${_p_PROJECT}_VERSION ${${PNAME}_VERSION} )
+      set( ${pkgUPPER}_FOUND 1 )
+      set( ${_p_PROJECT}_VERSION ${${pkgUPPER}_VERSION} )
 
     endif()
 
@@ -119,12 +194,12 @@ macro( ecbuild_use_package )
 
   # Case 2) project was already added as subproject, so is already FOUND -- BUT must check version acceptable
 
-  if( ${PNAME}_previous_subproj_ )
+  if( ${pkgUPPER}_previous_subproj_ )
 
     ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 2) project was already added as subproject, check version is acceptable")
 
-    if( NOT ${PNAME}_FOUND )
-      message( FATAL_ERROR "${_p_PROJECT} was already included as sub-project but ${PNAME}_FOUND isn't set -- this is likely a BUG in ecbuild" )
+    if( NOT ${pkgUPPER}_FOUND )
+      message( FATAL_ERROR "${_p_PROJECT} was already included as sub-project but ${pkgUPPER}_FOUND isn't set -- this is likely a BUG in ecbuild" )
     endif()
 
     # check version is acceptable
@@ -135,9 +210,9 @@ macro( ecbuild_use_package )
 
   # Case 3) project was NOT added as subproject, but is FOUND -- so it was previously found as a binary ( either build or install tree )
 
-  if( ${PNAME}_FOUND AND NOT ${PNAME}_previous_subproj_ AND NOT _just_added )
+  if( ${pkgUPPER}_FOUND AND NOT ${pkgUPPER}_previous_subproj_ AND NOT _just_added )
 
-    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 3) project was NOT added as subproject, but is FOUND")
+    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 3) project was NOT previously added as subproject, but is FOUND")
 
     # check version is acceptable
     set( _do_version_check 1 )
@@ -147,15 +222,15 @@ macro( ecbuild_use_package )
 
   # test version for Cases 1,2,3
 
-  # debug_var( _p_PROJECT )
-  # debug_var( _p_VERSION )
-  # debug_var( ${PNAME}_VERSION )
-  # debug_var( ${_p_PROJECT}_VERSION )
-  # debug_var( _just_added )
-  # debug_var( _do_version_check )
-  # debug_var( _source_description )
-  # debug_var( ${PNAME}_FOUND )
-  # debug_var( ${PNAME}_previous_subproj_ )
+  # ecbuild_debug_var( _p_PROJECT )
+  # ecbuild_debug_var( _p_VERSION )
+  # ecbuild_debug_var( ${pkgUPPER}_VERSION )
+  # ecbuild_debug_var( ${_p_PROJECT}_VERSION )
+  # ecbuild_debug_var( _just_added )
+  # ecbuild_debug_var( _do_version_check )
+  # ecbuild_debug_var( _source_description )
+  # ecbuild_debug_var( ${pkgUPPER}_FOUND )
+  # ecbuild_debug_var( ${pkgUPPER}_previous_subproj_ )
 
   if( _p_VERSION AND _do_version_check )
     if( _p_EXACT )
@@ -174,9 +249,9 @@ macro( ecbuild_use_package )
   # Case 4) is NOT FOUND so far, NOT as sub-project (now or before), and NOT as binary neither
   #         so try to find precompiled binaries or a build tree
 
-  if( NOT ${PNAME}_FOUND )
+  if( NOT ${pkgUPPER}_FOUND )
 
-    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 4) project was found neither as sub-project nor as binary")
+    ecbuild_debug("ecbuild_use_package(${_p_PROJECT}): 4) project has NOT been added as a subproject and is NOT already FOUND")
 
     set( _opts )
     if( _p_VERSION )
@@ -192,15 +267,20 @@ macro( ecbuild_use_package )
     ecbuild_find_package( NAME ${_p_PROJECT} ${_opts} )
 
     if( ${_p_PROJECT}_FOUND )
-      set( ${PNAME}_FOUND ${${_p_PROJECT}_FOUND} )
+      set( ${pkgUPPER}_FOUND ${${_p_PROJECT}_FOUND} )
     endif()
 
   endif()
 
+  if( ${pkgUPPER}_FOUND )
+    list( APPEND ${PROJECT_NAME_CAPS}_TPLS ${_p_PROJECT} )
+    list( REMOVE_DUPLICATES ${PROJECT_NAME_CAPS}_TPLS )
+  endif()
+
   ### for when we change this macro to a function()
-  # set_parent_scope( ${PNAME}_FOUND )
+  # set_parent_scope( ${pkgUPPER}_FOUND )
   # set_parent_scope( ${_p_PROJECT}_FOUND )
-  # set_parent_scope( ${PNAME}_VERSION )
+  # set_parent_scope( ${pkgUPPER}_VERSION )
   # set_parent_scope( ${_p_PROJECT}_VERSION )
   # set_parent_scope( ${_p_PROJECT}_BINARY_DIR )
 
diff --git a/cmake/ecbuild_version.h.in b/cmake/ecbuild_version.h.in
index d274bf6..3ed96ce 100644
--- a/cmake/ecbuild_version.h.in
+++ b/cmake/ecbuild_version.h.in
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 1996-2014 ECMWF.
+ * (C) Copyright 1996-2015 ECMWF.
  *
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/cmake/ecbuild_warn_unused_files.cmake b/cmake/ecbuild_warn_unused_files.cmake
index e96f082..084adb3 100644
--- a/cmake/ecbuild_warn_unused_files.cmake
+++ b/cmake/ecbuild_warn_unused_files.cmake
@@ -1,4 +1,4 @@
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -6,8 +6,28 @@
 # granted to it by virtue of its status as an intergovernmental organisation nor
 # does it submit to any jurisdiction.
 
-############################################################################################
-# print warnings about unused files
+##############################################################################
+#.rst:
+#
+# ecbuild_warn_unused_files
+# =========================
+#
+# Print warnings about unused source files in the project. ::
+#
+#   ecbuild_warn_unused_files()
+#
+# If the CMake variable ``CHECK_UNUSED_FILES`` is set, ecBuild will keep track
+# of any source files (.c, .cc, .cpp, .cxx) which are not part of a CMake
+# target. If set, this macro reports unused files if any have been found. This
+# is considered a fatal error unless ``UNUSED_FILES_LEVEL`` is set to a value
+# different from ``ERROR``.
+#
+# .. note ::
+#
+#   Enabling ``CHECK_UNUSED_FILES`` can slow down the CMake configure time
+#   considerably!
+#
+##############################################################################
 
 macro( ecbuild_warn_unused_files )
 
diff --git a/cmake/gen_source_flags.py b/cmake/gen_source_flags.py
new file mode 100644
index 0000000..26073c3
--- /dev/null
+++ b/cmake/gen_source_flags.py
@@ -0,0 +1,70 @@
+# (C) Copyright 1996-2015 ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+"""
+Generate .cmake file to set source-file specific compiler flags based on
+rules defined in a JSON file.
+"""
+
+from argparse import ArgumentParser
+from fnmatch import fnmatch
+import logging
+from json import JSONDecoder
+from os import path
+
+log = logging.getLogger('gen_source_flags')
+
+
+def generate(rules, out, default_flags, sources, debug=False):
+    logging.basicConfig(level=logging.DEBUG if debug else logging.INFO,
+                        format='-- %(levelname)s - %(name)s: %(message)s')
+
+    with open(path.expanduser(rules)) as f:
+        rules = JSONDecoder(object_pairs_hook=list).decode(f.read())
+
+    with open(path.expanduser(out), 'w') as f:
+        for source in sources:
+            log.debug(source)
+            flags = default_flags.split()
+            for pattern, op in rules:
+                if fnmatch(source, pattern):
+
+                    log.debug(' -> %10s matches %20s with %s', pattern, source, op[1:])
+
+                    if op[0] == "+":
+                        log.debug('  appending %s', op[1:])
+                        flags += [flag for flag in op[1:] if flag not in flags]
+
+                    if op[0] == "=":
+                        log.debug('  setting %s', op[1:])
+                        flags = []
+                        flags += [flag for flag in op[1:] if flag not in flags]
+
+                    if op[0] == "/":
+                        log.debug('  removing %s', op[1:])
+                        for flag in op[1:]:
+                            flags.remove(flag)
+
+            if flags:
+                log.debug(' ==> setting flags for %s to %s', source, ' '.join(flags))
+                f.write('set_source_files_properties(%s PROPERTIES COMPILE_FLAGS "%s")\n'
+                        % (source, ' '.join(flags)))
+
+
+def main():
+    """Parse arguments"""
+    parser = ArgumentParser(description=__doc__)
+    parser.add_argument('rules', metavar='RULES.json', help='JSON rules file')
+    parser.add_argument('out', metavar='OUT.cmake', help='CMake script to generate')
+    parser.add_argument('default_flags', help='Default compiler flags to use')
+    parser.add_argument('sources', metavar='file', nargs='+', help='Path to file to apply rules to')
+    parser.add_argument('--debug', '-d', action='store_true', help='Log debug messages')
+    generate(**vars(parser.parse_args()))
+
+if __name__ == '__main__':
+    main()
diff --git a/cmake/include/ecbuild/boost_test_framework.h b/cmake/include/ecbuild/boost_test_framework.h
index 09e61dd..8cbd8e9 100644
--- a/cmake/include/ecbuild/boost_test_framework.h
+++ b/cmake/include/ecbuild/boost_test_framework.h
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 1996-2014 ECMWF.
+ * (C) Copyright 1996-2015 ECMWF.
  *
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
diff --git a/cmake/sg.pl b/cmake/sg.pl
index 455161b..8a64bf4 100755
--- a/cmake/sg.pl
+++ b/cmake/sg.pl
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #!/usr/local/share/perl56
 
-# (C) Copyright 1996-2014 ECMWF.
+# (C) Copyright 1996-2015 ECMWF.
 # 
 # This software is licensed under the terms of the Apache Licence Version 2.0
 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 2491764..c578366 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -1,6 +1,8 @@
 list( APPEND common_src_files
+  JPointer.h
   fortint.h
-  fortran.h
+  fortreal.h
+  grprs.h
 )
 
 foreach( src ${common_src_files} )
diff --git a/common/JPointer.h b/common/JPointer.h
new file mode 100644
index 0000000..a2716bc
--- /dev/null
+++ b/common/JPointer.h
@@ -0,0 +1,25 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+
+#ifndef JPOINTER_H
+#define JPOINTER_H
+
+#ifdef INTEGER_IS_INT
+#define JPointer int *
+#else
+#if defined hpR64 || defined hpiaR64
+#define JPointer long long *
+#else
+#define JPointer long *
+#endif
+#endif
+
+#endif /* end of JPOINTER_H */
diff --git a/common/fortint.h b/common/fortint.h
index 07e247c..32b3a08 100644
--- a/common/fortint.h
+++ b/common/fortint.h
@@ -1,22 +1,29 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
+
+#ifndef FORTINT_H
+#define FORTINT_H
+
+#ifdef INTEGER_IS_LONG
+#define fortint long
+#else
 #ifdef INTEGER_IS_INT
 #define fortint int
-#define JPointer int *
 #else
 #if defined hpR64 || defined hpiaR64
 #define fortint long long
-#define JPointer long long *
 #else
 #define fortint long
-#define JPointer long *
 #endif
 #endif
+#endif
+
+#endif /* end of FORTINT_H */
diff --git a/common/fortran.h b/common/fortran.h
deleted file mode 100644
index 9b542ca..0000000
--- a/common/fortran.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef fortran_H
-#define fortran_H
-
-#include "common/fortint.h"
-
-fortint chkout_();
-fortint csect4_(fortfloat*,fortint*,fortint*,fortint*,fortint*,fortint*, fortint*,fortint*,fortint*);
-fortint estima_();
-fortint gasetup_(fortint* isec1, fortint* isec2,fortint* isec3, fortint* isec4, fortfloat* zsec3);
-fortint gettru_();
-fortint global_();
-fortint iainit_(fortint*, fortint*);
-fortint igglat_(fortint*,fortfloat*,fortint*,fortint*);
-fortint intf_(const char*, fortint*, fortfloat*, const char*, fortint*, fortfloat*);
-fortint intin_(const char*, fortint*, fortfloat*, const char*, fortint, fortint);
-fortint intout_(const char*, fortint*, fortfloat*, const char*, fortint, fortint);
-fortint intuvu_(fortfloat*, fortfloat*, fortint*, fortfloat*, fortfloat*, fortint*);
-fortint intuvy_(fortfloat*, fortfloat*, fortint*, fortfloat*, fortfloat* , fortint*);
-fortint intvecy_(fortfloat*, fortfloat*, fortint*, fortfloat*, fortfloat*, fortint*);
-fortint outrep_();
-fortint ref2grb_(fortfloat*,fortint*,fortint*,fortint*);
-fortint setrep_(fortint*);
-
-void clear_c_();
-void gbyte_(void*,void*,fortint*,fortint*);
-void grsmkp_(fortint*);
-void inscal_(fortfloat*,fortint*,fortint*,fortfloat*,fortfloat*,fortint*);
-void inxbit_(fortint*,fortint*,fortint*,fortint*,fortint*,fortint*,fortint*, char*,fortint*,long);
-void jgetgg_(fortint*,unsigned char*,fortfloat*,fortint*,fortint*,long);
-void jmakgg_(fortint*, fortint*, fortint*, fortfloat*, fortfloat*, fortint*);
-void jmakll_(fortint*, fortint*, fortfloat*, fortfloat*, fortfloat*, fortint*);
-
-#endif
diff --git a/common/fortreal.h b/common/fortreal.h
new file mode 100644
index 0000000..e14b414
--- /dev/null
+++ b/common/fortreal.h
@@ -0,0 +1,28 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+#ifndef FORTREAL_H
+#define FORTREAL_H
+
+#ifdef REAL_8
+#define fortreal long double
+#else
+#define fortreal float
+#endif
+
+#define fortdouble double
+
+#ifdef REAL_8
+typedef double fortfloat;
+#else
+typedef float fortfloat; /* fortran single precision float */
+#endif
+
+#endif /* end of FORTREAL_H */
diff --git a/gribex/grprs.h b/common/grprs.h
similarity index 100%
rename from gribex/grprs.h
rename to common/grprs.h
diff --git a/compile_cray.sh b/compile_cray.sh
deleted file mode 100755
index 8586f03..0000000
--- a/compile_cray.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-# CRAY/82
-./compile.sh
-
-# CRAY/83
-module load cray-mpich-compat/v7
-./compile.sh 
-
-# INTEL/140
-module switch PrgEnv-cray PrgEnv-intel
-./compile.sh 
-
-# GNU/48
-module switch PrgEnv-intel PrgEnv-gnu 
-./compile.sh
diff --git a/crextables/B000207 b/crextables/B000207
old mode 100755
new mode 100644
diff --git a/crextables/D000207 b/crextables/D000207
old mode 100755
new mode 100644
diff --git a/data/F640.grib b/data/F640.grib
new file mode 100644
index 0000000..85adcd8
Binary files /dev/null and b/data/F640.grib differ
diff --git a/data/ISMD01_OKPR.bufr b/data/ISMD01_OKPR.bufr
old mode 100755
new mode 100644
diff --git a/data/N640.grib b/data/N640.grib
new file mode 100644
index 0000000..e7e854e
Binary files /dev/null and b/data/N640.grib differ
diff --git a/data/O640.grib b/data/O640.grib
new file mode 100644
index 0000000..b5b4c1c
Binary files /dev/null and b/data/O640.grib differ
diff --git a/data/intf2_F640_to_F48.grib b/data/intf2_F640_to_F48.grib
new file mode 100644
index 0000000..9a9cb8d
Binary files /dev/null and b/data/intf2_F640_to_F48.grib differ
diff --git a/data/intf2_F640_to_F80.grib b/data/intf2_F640_to_F80.grib
new file mode 100644
index 0000000..2eaad65
Binary files /dev/null and b/data/intf2_F640_to_F80.grib differ
diff --git a/data/intf2_F640_to_regular_ll.grib b/data/intf2_F640_to_regular_ll.grib
new file mode 100644
index 0000000..5e3eedb
Binary files /dev/null and b/data/intf2_F640_to_regular_ll.grib differ
diff --git a/data/intf2_F640_to_rotated_regular_ll.grib b/data/intf2_F640_to_rotated_regular_ll.grib
new file mode 100644
index 0000000..9900108
Binary files /dev/null and b/data/intf2_F640_to_rotated_regular_ll.grib differ
diff --git a/data/intf2_N640_to_F48.grib b/data/intf2_N640_to_F48.grib
new file mode 100644
index 0000000..e72529c
Binary files /dev/null and b/data/intf2_N640_to_F48.grib differ
diff --git a/data/intf2_N640_to_F80.grib b/data/intf2_N640_to_F80.grib
new file mode 100644
index 0000000..3ccb2d8
Binary files /dev/null and b/data/intf2_N640_to_F80.grib differ
diff --git a/data/intf2_N640_to_N80.grib b/data/intf2_N640_to_N80.grib
new file mode 100644
index 0000000..5f5a40a
Binary files /dev/null and b/data/intf2_N640_to_N80.grib differ
diff --git a/data/intf2_N640_to_O80.grib b/data/intf2_N640_to_O80.grib
new file mode 100644
index 0000000..3641f35
Binary files /dev/null and b/data/intf2_N640_to_O80.grib differ
diff --git a/data/intf2_N640_to_regular_ll.grib b/data/intf2_N640_to_regular_ll.grib
new file mode 100644
index 0000000..2472afa
Binary files /dev/null and b/data/intf2_N640_to_regular_ll.grib differ
diff --git a/data/intf2_N640_to_rotated_regular_ll.grib b/data/intf2_N640_to_rotated_regular_ll.grib
new file mode 100644
index 0000000..41b2dad
Binary files /dev/null and b/data/intf2_N640_to_rotated_regular_ll.grib differ
diff --git a/data/intf2_O640_to_F48.grib b/data/intf2_O640_to_F48.grib
new file mode 100644
index 0000000..2b07975
Binary files /dev/null and b/data/intf2_O640_to_F48.grib differ
diff --git a/data/intf2_O640_to_F80.grib b/data/intf2_O640_to_F80.grib
new file mode 100644
index 0000000..138c437
Binary files /dev/null and b/data/intf2_O640_to_F80.grib differ
diff --git a/data/intf2_O640_to_N80.grib b/data/intf2_O640_to_N80.grib
new file mode 100644
index 0000000..57074da
Binary files /dev/null and b/data/intf2_O640_to_N80.grib differ
diff --git a/data/intf2_O640_to_O80.grib b/data/intf2_O640_to_O80.grib
new file mode 100644
index 0000000..d812b28
Binary files /dev/null and b/data/intf2_O640_to_O80.grib differ
diff --git a/data/intf2_O640_to_regular_ll.grib b/data/intf2_O640_to_regular_ll.grib
new file mode 100644
index 0000000..8696042
Binary files /dev/null and b/data/intf2_O640_to_regular_ll.grib differ
diff --git a/data/intf2_O640_to_rotated_regular_ll.grib b/data/intf2_O640_to_rotated_regular_ll.grib
new file mode 100644
index 0000000..f4b20c1
Binary files /dev/null and b/data/intf2_O640_to_rotated_regular_ll.grib differ
diff --git a/data/intf2_regular_ll_to_F48.grib b/data/intf2_regular_ll_to_F48.grib
new file mode 100644
index 0000000..72a5982
Binary files /dev/null and b/data/intf2_regular_ll_to_F48.grib differ
diff --git a/data/intf2_regular_ll_to_F80.grib b/data/intf2_regular_ll_to_F80.grib
new file mode 100644
index 0000000..fffbf97
Binary files /dev/null and b/data/intf2_regular_ll_to_F80.grib differ
diff --git a/data/intf2_regular_ll_to_regular_ll.grib b/data/intf2_regular_ll_to_regular_ll.grib
new file mode 100644
index 0000000..99c839b
Binary files /dev/null and b/data/intf2_regular_ll_to_regular_ll.grib differ
diff --git a/data/intf2_sh_vod_to_F48.grib b/data/intf2_sh_vod_to_F48.grib
new file mode 100644
index 0000000..cda875e
Binary files /dev/null and b/data/intf2_sh_vod_to_F48.grib differ
diff --git a/data/intf2_sh_vod_to_F80.grib b/data/intf2_sh_vod_to_F80.grib
new file mode 100644
index 0000000..184ac07
Binary files /dev/null and b/data/intf2_sh_vod_to_F80.grib differ
diff --git a/data/intf2_sh_vod_to_N80.grib b/data/intf2_sh_vod_to_N80.grib
new file mode 100644
index 0000000..b0974a9
Binary files /dev/null and b/data/intf2_sh_vod_to_N80.grib differ
diff --git a/data/intf2_sh_vod_to_O80.grib b/data/intf2_sh_vod_to_O80.grib
new file mode 100644
index 0000000..c39c976
Binary files /dev/null and b/data/intf2_sh_vod_to_O80.grib differ
diff --git a/data/intf2_sh_vod_to_regular_ll.grib b/data/intf2_sh_vod_to_regular_ll.grib
new file mode 100644
index 0000000..7f93193
Binary files /dev/null and b/data/intf2_sh_vod_to_regular_ll.grib differ
diff --git a/data/intf2_sh_vod_to_rotated_regular_ll.grib b/data/intf2_sh_vod_to_rotated_regular_ll.grib
new file mode 100644
index 0000000..155728c
Binary files /dev/null and b/data/intf2_sh_vod_to_rotated_regular_ll.grib differ
diff --git a/data/intf2_sh_z_to_F48.grib b/data/intf2_sh_z_to_F48.grib
new file mode 100644
index 0000000..bc42975
Binary files /dev/null and b/data/intf2_sh_z_to_F48.grib differ
diff --git a/data/intf2_sh_z_to_F80.grib b/data/intf2_sh_z_to_F80.grib
new file mode 100644
index 0000000..bb54193
Binary files /dev/null and b/data/intf2_sh_z_to_F80.grib differ
diff --git a/data/intf2_sh_z_to_N80.grib b/data/intf2_sh_z_to_N80.grib
new file mode 100644
index 0000000..30d2161
Binary files /dev/null and b/data/intf2_sh_z_to_N80.grib differ
diff --git a/data/intf2_sh_z_to_O80.grib b/data/intf2_sh_z_to_O80.grib
new file mode 100644
index 0000000..520067b
Binary files /dev/null and b/data/intf2_sh_z_to_O80.grib differ
diff --git a/data/intf2_sh_z_to_regular_ll.grib b/data/intf2_sh_z_to_regular_ll.grib
new file mode 100644
index 0000000..42a7070
Binary files /dev/null and b/data/intf2_sh_z_to_regular_ll.grib differ
diff --git a/data/intf2_sh_z_to_rotated_regular_ll.grib b/data/intf2_sh_z_to_rotated_regular_ll.grib
new file mode 100644
index 0000000..4361c59
Binary files /dev/null and b/data/intf2_sh_z_to_rotated_regular_ll.grib differ
diff --git a/data/intuvp2_sh_vod_to_F80.grib b/data/intuvp2_sh_vod_to_F80.grib
new file mode 100644
index 0000000..3f27dd4
Binary files /dev/null and b/data/intuvp2_sh_vod_to_F80.grib differ
diff --git a/data/intuvp2_sh_vod_to_N80.grib b/data/intuvp2_sh_vod_to_N80.grib
new file mode 100644
index 0000000..5eb85cc
Binary files /dev/null and b/data/intuvp2_sh_vod_to_N80.grib differ
diff --git a/data/intuvp2_sh_vod_to_O80.grib b/data/intuvp2_sh_vod_to_O80.grib
new file mode 100644
index 0000000..be4b45e
Binary files /dev/null and b/data/intuvp2_sh_vod_to_O80.grib differ
diff --git a/data/intuvp2_sh_vod_to_regular_ll.grib b/data/intuvp2_sh_vod_to_regular_ll.grib
new file mode 100644
index 0000000..5e0d146
Binary files /dev/null and b/data/intuvp2_sh_vod_to_regular_ll.grib differ
diff --git a/data/latlon.grib b/data/latlon.grib
deleted file mode 100755
index c5f6080..0000000
Binary files a/data/latlon.grib and /dev/null differ
diff --git a/data/regular_ll.grib b/data/regular_ll.grib
new file mode 100644
index 0000000..f1c58b4
Binary files /dev/null and b/data/regular_ll.grib differ
diff --git a/data/sh_vod.grib b/data/sh_vod.grib
new file mode 100644
index 0000000..6b0c50d
Binary files /dev/null and b/data/sh_vod.grib differ
diff --git a/data/sh_z.grib b/data/sh_z.grib
new file mode 100644
index 0000000..ca3e2aa
Binary files /dev/null and b/data/sh_z.grib differ
diff --git a/tests/data_in/surface_gaussian_reduced.grib1 b/data/surface_gaussian_reduced.grib1
old mode 100755
new mode 100644
similarity index 100%
rename from tests/data_in/surface_gaussian_reduced.grib1
rename to data/surface_gaussian_reduced.grib1
diff --git a/tests/data_in/surface_latlon.grib1 b/data/surface_latlon.grib1
similarity index 100%
rename from tests/data_in/surface_latlon.grib1
rename to data/surface_latlon.grib1
diff --git a/data/tigge.grib2 b/data/tigge.grib2
old mode 100755
new mode 100644
diff --git a/tests/tc_tracks/tracks_05W_PEIPAH_2014041000.eps.bufr b/data/tracks_05W_PEIPAH_2014041000.eps.bufr
similarity index 100%
rename from tests/tc_tracks/tracks_05W_PEIPAH_2014041000.eps.bufr
rename to data/tracks_05W_PEIPAH_2014041000.eps.bufr
diff --git a/tests/tc_tracks/tracks_05W_PEIPAH_2014041000.eps.bufr4 b/data/tracks_05W_PEIPAH_2014041000.eps.bufr4
similarity index 100%
rename from tests/tc_tracks/tracks_05W_PEIPAH_2014041000.eps.bufr4
rename to data/tracks_05W_PEIPAH_2014041000.eps.bufr4
diff --git a/tests/tc_tracks/tracks_05W_PEIPAH_2014041000.fm b/data/tracks_05W_PEIPAH_2014041000.fm
similarity index 100%
rename from tests/tc_tracks/tracks_05W_PEIPAH_2014041000.fm
rename to data/tracks_05W_PEIPAH_2014041000.fm
diff --git a/tests/tc_tracks/tracks_15U_ITA_2014041000.eps.bufr b/data/tracks_15U_ITA_2014041000.eps.bufr
similarity index 100%
rename from tests/tc_tracks/tracks_15U_ITA_2014041000.eps.bufr
rename to data/tracks_15U_ITA_2014041000.eps.bufr
diff --git a/tests/tc_tracks/tracks_15U_ITA_2014041000.eps.bufr4 b/data/tracks_15U_ITA_2014041000.eps.bufr4
similarity index 100%
rename from tests/tc_tracks/tracks_15U_ITA_2014041000.eps.bufr4
rename to data/tracks_15U_ITA_2014041000.eps.bufr4
diff --git a/tests/tc_tracks/tracks_15U_ITA_2014041000.fm b/data/tracks_15U_ITA_2014041000.fm
similarity index 100%
rename from tests/tc_tracks/tracks_15U_ITA_2014041000.fm
rename to data/tracks_15U_ITA_2014041000.fm
diff --git a/tests/tc_tracks/tracks_15U_ITA_2014041012.det.bufr b/data/tracks_15U_ITA_2014041012.det.bufr
similarity index 100%
rename from tests/tc_tracks/tracks_15U_ITA_2014041012.det.bufr
rename to data/tracks_15U_ITA_2014041012.det.bufr
diff --git a/tests/tc_tracks/tracks_15U_ITA_2014041012.det.bufr4 b/data/tracks_15U_ITA_2014041012.det.bufr4
similarity index 100%
rename from tests/tc_tracks/tracks_15U_ITA_2014041012.det.bufr4
rename to data/tracks_15U_ITA_2014041012.det.bufr4
diff --git a/tests/tc_tracks/tracks_15U_ITA_2014041012.fm b/data/tracks_15U_ITA_2014041012.fm
similarity index 100%
rename from tests/tc_tracks/tracks_15U_ITA_2014041012.fm
rename to data/tracks_15U_ITA_2014041012.fm
diff --git a/grib_api_merging/CMakeLists.txt b/grib_api_merging/CMakeLists.txt
deleted file mode 100644
index 7b8af42..0000000
--- a/grib_api_merging/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-list( APPEND grib_api_merging_src_files
-  copy_spec_from_ksec.c
-  emos.c
-  intuvp2.c
-  intvect2.c
-  describe_input_field.c
-  intf2.c
-  intuvs2.c
-  emos.h
-
-  fortint.h
-)
-
-foreach( src ${grib_api_merging_src_files} )
-  list( APPEND grib_api_merging_srcs grib_api_merging/${src} )
-endforeach()
-
-set( grib_api_merging_srcs ${grib_api_merging_srcs} PARENT_SCOPE )
-
diff --git a/grib_api_merging/copy_spec_from_ksec.c b/grib_api_merging/copy_spec_from_ksec.c
deleted file mode 100755
index ed38f80..0000000
--- a/grib_api_merging/copy_spec_from_ksec.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-
-#include "grib_api.h"
-#include "emos.h"
-#include <assert.h>
-
-#define ISECTION_2  5000
-#define ISECTION_4  512
-
-extern int mars_interpolation;
-
-#define SET_EXTRA_LONG(x,y)     do { assert(packing_spec->extra_settings_count<80); packing_spec->extra_settings[packing_spec->extra_settings_count].name = #x; packing_spec->extra_settings[packing_spec->extra_settings_count].type = GRIB_TYPE_LONG;   packing_spec->extra_settings[packing_spec->extra_settings_count].long_value = y; packing_spec->extra_settings_count++; } while(0)
-#define SET_EXTRA_DOUBLE(x,y)   do { assert(packing_spec->extra_settings_count<80); packing_spec->extra_settings[packing_spec->extra_settings_count].name = #x; packing_spec->extra_settings[packing_spec->extra_settings_count].type = GRIB_TYPE_DOUBLE; packing_spec->extra_settings[packing_spec->extra_settings_count].double_value = y; packing_spec->extra_settings_count++; } while(0)
-
-
-int copy_spec_from_ksec(grib_util_grid_spec* spec,grib_util_packing_spec* packing_spec) {
-	int err=0;
-
-	fortint isec1[ISECTION_1] = {0,};
-	fortint isec2[ISECTION_2] = {0,};
-	fortint isec3[ISECTION_3] = {0,};
-	fortint isec4[ISECTION_4] = {0,};
-
-	fortfloat zsec3[ISECTION_3] = {0,};
-
-	long    rg_def[ISECTION_2] = {0,};
-	char *intf2_debug = getenv("INTF2_DEBUG");
-
-	if((err = int2_gasetup( isec1, isec2, isec3, isec4,zsec3 )) != 0)
-	{
-		return err;
-	}
-
-	memset(spec,         0, sizeof(grib_util_grid_spec));
-	memset(packing_spec, 0, sizeof(grib_util_packing_spec));
-
-	switch (isec4[3]) {
-		case 1:
-			packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX;
-			break;
-		case 2:
-			packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE;
-			packing_spec->packing = GRIB_UTIL_PACKING_USE_PROVIDED;
-			break;
-		case 3:
-			packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_JPEG;
-			break;
-		case 4:
-			packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;
-			break;
-		case 7:
-			packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER;
-			break;
-		default :
-			printf("invalid isec4[3] = %d\n",isec4[3]);
-			abort();
-	}
-	packing_spec->bitsPerValue     = isec4[1];
-
-	/* TODO: get that from emoslib */
-	if(intf2_debug){
-		printf("YYYYYYYYYY  packing: %d    -----  bitsPerValue: %d \n", isec4[3],isec4[1]);
-		printf("missing value XXXXXXXXXX %f\n", zsec3[1]);
-	}
-
-	spec->missingValue = zsec3[1];
-
-
-	if(intf2_debug){
-		printf("missing value XXXXXXXXXX %f \n", spec->missingValue);
-		printf("SIZES double=%d  fortfloat=%d\n", sizeof(double), sizeof(fortfloat));
-		printf("is BITMAP present %d\n", isec1[4]);
-	}
-
-	switch(isec2[0]) {
-
-		case 0:
-			spec->grid_type                         = GRIB_UTIL_GRID_SPEC_REGULAR_LL;
-			spec->Nj = isec2[2];
-			spec->Ni = isec2[1];
-			spec->iDirectionIncrementInDegrees = isec2[8]/1000.0;
-			spec->jDirectionIncrementInDegrees = isec2[9]/1000.0;
-
-			spec->latitudeOfFirstGridPointInDegrees      = isec2[3]/1000.0;
-			spec->longitudeOfFirstGridPointInDegrees     = isec2[4]/1000.0;
-			spec->latitudeOfLastGridPointInDegrees       = isec2[6]/1000.0;
-			spec->longitudeOfLastGridPointInDegrees      = isec2[7]/1000.0;
-
-			if (isec1[4]==192 || isec1[4]==64) 
-				spec->bitmapPresent=1;
-			else 
-				spec->bitmapPresent=0;
-
-			break;
-
-		case 10:
-			spec->grid_type                         = GRIB_UTIL_GRID_SPEC_ROTATED_LL;
-			spec->Nj = isec2[2];
-			spec->Ni = isec2[1];
-			spec->iDirectionIncrementInDegrees = isec2[8]/1000.0;
-			spec->jDirectionIncrementInDegrees = isec2[9]/1000.0;
-
-			spec->latitudeOfFirstGridPointInDegrees      = isec2[3]/1000.0;
-			spec->longitudeOfFirstGridPointInDegrees     = isec2[4]/1000.0;
-			spec->latitudeOfLastGridPointInDegrees       = isec2[6]/1000.0;
-			spec->longitudeOfLastGridPointInDegrees      = isec2[7]/1000.0;
-
-			spec->uvRelativeToGrid= isec2[18]==8 ? 1 : 0;
-			spec->latitudeOfSouthernPoleInDegrees    = isec2[12]/1000.0;
-			spec->longitudeOfSouthernPoleInDegrees   = isec2[13]/1000.0;
-
-			if (isec1[4]==192 || isec1[4]==64) 
-				spec->bitmapPresent=1;
-			else 
-				spec->bitmapPresent=0;
-
-			break;
-
-		case 4:
-			spec->grid_type                                       = GRIB_UTIL_GRID_SPEC_REGULAR_GG;
-			spec->Nj 					 		              	 = isec2[2];
-			spec->Ni								              	 = isec2[1];
-			spec->N												 = isec2[9];
-			spec->iDirectionIncrementInDegrees               	= isec2[8]/1000.0;
-			if(isec2[16]) {
-				spec->grid_type = GRIB_UTIL_GRID_SPEC_REDUCED_GG;
-			}
-
-			spec->latitudeOfFirstGridPointInDegrees      = isec2[3]/1000.0;
-			spec->longitudeOfFirstGridPointInDegrees     = isec2[4]/1000.0;
-			spec->latitudeOfLastGridPointInDegrees       = isec2[6]/1000.0;
-			spec->longitudeOfLastGridPointInDegrees      = isec2[7]/1000.0;
-
-			if (isec1[4]==192 || isec1[4]==64) 
-				spec->bitmapPresent=1;
-			else 
-				spec->bitmapPresent=0;
-
-            
-			/* grib_api to set global area in full precision for gaussian grid */
-			packing_spec->extra_settings_count=1;
-			packing_spec->extra_settings[0].type = GRIB_TYPE_LONG;
-			packing_spec->extra_settings[0].name = "global";
-			packing_spec->extra_settings[0].long_value = int2_global();
-
-			break;
-
-		case 14:
-			spec->grid_type                                  = GRIB_UTIL_GRID_SPEC_ROTATED_GG;
-			spec->Nj							                = isec2[2];
-			spec->Ni							                = isec2[1];
-			spec->N 											= isec2[9];
-			spec->iDirectionIncrementInDegrees               = isec2[8]/1000.0;
-			if(isec2[16]) {
-				/* There is no rotated-reduced, is there ? */
-				abort();
-			}
-
-			spec->latitudeOfFirstGridPointInDegrees      = isec2[3]/1000.0;
-			spec->longitudeOfFirstGridPointInDegrees     = isec2[4]/1000.0;
-			spec->latitudeOfLastGridPointInDegrees       = isec2[6]/1000.0;
-			spec->longitudeOfLastGridPointInDegrees      = isec2[7]/1000.0;
-
-			spec->latitudeOfSouthernPoleInDegrees    = isec2[12]/1000.0;
-			spec->longitudeOfSouthernPoleInDegrees   = isec2[13]/1000.0;
-
-			if (isec1[4]==192 || isec1[4]==64) 
-				spec->bitmapPresent=1;
-			else 
-				spec->bitmapPresent=0;
-
-			break;
-
-
-		case 50:
-			spec->grid_type = GRIB_UTIL_GRID_SPEC_SH;
-			spec->truncation = isec2[1]; /* truncationJ */
-			packing_spec->truncateLaplacian=1;
-
-			break;
-
-		case 26:
-			spec->grid_type = GRIB_UTIL_GRID_SPEC_REDUCED_LL;
-			break;
-
-		default:
-			fprintf(stdout,"INTF2: ERROR - unknown repres: %d\n", isec2[0]);
-			return -2;
-			break;
-	}
-
-	/* ocean special case */
-    if (isec1[36]==4) {
-		/* Bitmap always present for ocean */
-
-        if (isec1[59] == 3 && isec1[60] == 4)
-            SET_EXTRA_LONG(dataRepresentationType , 0);
-        else
-            SET_EXTRA_LONG(dataRepresentationType , 192);
-
-
-        SET_EXTRA_LONG(coordinate4OfFirstGridPoint,isec1[61]);
-        SET_EXTRA_LONG(coordinate3OfFirstGridPoint,isec1[62]);
-        SET_EXTRA_LONG(coordinate4OfLastGridPoint,isec1[63]);
-        SET_EXTRA_LONG(coordinate3OfLastGridPoint,isec1[64]);
-        SET_EXTRA_LONG(iIncrement,isec1[65]);
-        SET_EXTRA_LONG(jIncrement,isec1[66]);
-        SET_EXTRA_LONG(flagForNormalOrStaggeredGrid,isec1[68]);
-        SET_EXTRA_LONG(flagForIrregularGridCoordinateList,0);
-        SET_EXTRA_LONG(numberInTheGridCoordinateList,0);
-        SET_EXTRA_LONG(flagShowingPostAuxiliaryArrayInUse,0);
-        SET_EXTRA_LONG(flagShowingPostAuxiliaryArrayInUse,1);
-        SET_EXTRA_LONG(sizeOfPostAuxiliaryArrayPlusOne,0);
-
-    }
-
-#define D(a) if(intf2_debug) printf("YYYYYYYYYYYY %s -> %g\n", #a, (double)spec->a);
-	
-
-	D(grid_type);
-	D(Ni);
-	D(Nj);
-	D(iDirectionIncrementInDegrees);
-	D(jDirectionIncrementInDegrees);
-	D(longitudeOfFirstGridPointInDegrees);
-	D(longitudeOfLastGridPointInDegrees);
-	D(latitudeOfFirstGridPointInDegrees);
-	D(latitudeOfLastGridPointInDegrees);
-	D(latitudeOfSouthernPoleInDegrees);
-	D(longitudeOfSouthernPoleInDegrees);
-	D(N);
-	D(bitmapPresent);
-	D(missingValue);
-	D(pl_size);
-	D(truncation);
-
-
-	return 0;
-}
diff --git a/grib_api_merging/emos.c b/grib_api_merging/emos.c
deleted file mode 100755
index 8e6bed6..0000000
--- a/grib_api_merging/emos.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "emos.h"
-
-#ifdef FORTRAN_UPPERCASE
-#define outrep_  OUTREP
-#define gettru_  GETTRU
-#define setrep_  SETREP
-#define chkout_  CHKOUT
-#define global_  GLOBAL
-#define intf_    INTF
-#define intout_  INTOUT
-#define intin_   INTIN
-#define gasetup_ GASETUP
-#define intuvs_  INTUVS
-#define intvecy_ INTVECY
-#define estima_  ESTIMA
-#endif
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define outrep_  outrep
-#define gettru_  gettru
-#define setrep_  setrep
-#define chkout_  chkout
-#define global_  global
-#define intf_    intf
-#define intout_  intout
-#define intin_   intin
-#define gasetup_ gasetup
-#define intuvs_  intuvs
-#define intvecy_ intvecy
-#define estima_  estima
-#endif
-
-
-
-fortint int2_estima()
-{
-	return estima_();
-}
-
-fortint int2_global()
-{
-	return global_();
-}
-
-fortint int2_chkout()
-{
-	return chkout_();
-}
-
-fortint int2_setrep(fortint output_flag)
-{
-	return setrep_(&output_flag);
-}
-
-fortint int2_gettru()
-{
-	return gettru_();
-}
-
-fortint int2_outrep()
-{
-	return outrep_();
-}
-
-fortint int2_intf( fortfloat in_array[], fortint in_array_length, fortfloat *out_array, fortint *out_array_length)
-{
-	char  in_grib[1];
-	char  out_grib[500000];
-
-	return intf_(in_grib, &in_array_length, in_array, out_grib, out_array_length, out_array);
-}
-
-fortint int2_intout(const char* param,fortint iv[],fortfloat dv[],const char* cv)
-{
-	char *intf2_debug = getenv("INTF2_DEBUG");
-
-	if(!cv) cv = "";
-	if(intf2_debug)
-	{
-	     printf("int2_intout: %s\n",param);
-    }
-	return intout_(param,iv,dv,cv,strlen(param),strlen(cv));
-}
-
-fortint int2_intin(const char* param,fortint iv[],fortfloat dv[],const char* cv)
-{
-	if(!cv) cv = "";
-	return intin_(param,iv,dv,cv,strlen(param),strlen(cv));
-}
-
-fortint int2_gasetup( fortint isec1[], fortint isec2[], fortint isec3[], fortint isec4[], fortfloat zsec3[])
-{
-	return gasetup_( isec1, isec2, isec3, isec4, zsec3 );
-}
-
-fortint int2_intuvy(fortfloat vort_in[],fortfloat div_in[] , fortint in_array_length, fortfloat *vort_out, fortfloat *div_out, fortint *out_array_length)
-{
-    return intuvy_( vort_in, div_in , &in_array_length, vort_out, div_out, out_array_length);
-}
-
-fortint int2_intuvu(fortfloat vort_in[],fortfloat div_in[] , fortint in_array_length, fortfloat *vort_out, fortfloat *div_out, fortint *out_array_length)
-{
-    return intuvu_( vort_in, div_in , &in_array_length, vort_out, div_out, out_array_length);
-}
-
-fortint int2_intvecy(fortfloat u_in[],fortfloat v_in[] , fortint in_array_length, fortfloat *u_out, fortfloat *v_out, fortint *out_array_length)
-{
-    return intvecy_( u_in, v_in , &in_array_length, u_out, v_out, out_array_length);
-}
-
diff --git a/grib_api_merging/emos.h b/grib_api_merging/emos.h
deleted file mode 100755
index 149a193..0000000
--- a/grib_api_merging/emos.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-#include "fortint.h"
-#define     ISECTION_0  2
-#define     ISECTION_1  1024     /* beware of  for ocean data */
-#define     ISECTION_2  5000
-#define     ISECTION_3  3
-#define     ISECTION_4  512
-
-#define     RSECTION_2  512
-#define     RSECTION_3  2
-#define     RSECTION_4  1
-
-
-fortint int2_global();
-fortint outrep_();
-fortint estima_();
-fortint gettru_();
-fortint setrep_(fortint*);
-fortint chkout_();
-fortint global_();
-fortint intf_(const char*, fortint*, fortfloat[], const char*, fortint*, fortfloat[]);
-fortint intout_(const char*, fortint[], fortfloat[], const char*, fortint, fortint);
-fortint intin_(const char*, fortint[], fortfloat[], const char*, fortint, fortint);
-fortint gasetup_( fortint isec1[], fortint isec2[], fortint isec3[], fortint isec4[], fortfloat zsec3[]);
-fortint intuvs_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
-fortint intuvy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
-fortint intuvu_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
-fortint intvecy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
-/* fortint intvecy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*); */
-fortint int2_intvecy(fortfloat[],fortfloat[] , fortint, fortfloat*, fortfloat*, fortint*);
-
-
diff --git a/grib_api_merging/example.c b/grib_api_merging/example.c
deleted file mode 100755
index 4de06b3..0000000
--- a/grib_api_merging/example.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <assert.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "grib_api.h"
-#include "emos.h"
-
-char outgrib[1000000];
-char buffer[1024*1024*10];
-
-fortint intf2(char* grib_in, fortint* length_in, char* grib_out, fortint* length_out);
-
-#define intout intout_
-
-long edition = 2;
-
-int main(int argc, char** argv) {
-
-	int err = 0;
-
-	size_t length = sizeof(buffer);
-	long outlen = sizeof(outgrib);
-	/* size_t outlen = sizeof(outgrib); */
-
-	size_t mesg_len;
-	const void* mesg;
-
-	FILE* in  = NULL;
-	FILE* out = NULL;
-
-	grib_handle *h = NULL;
-
-	fortint   intv[4] = {0,};
-	double realv[4] = {0,};
-	char*  text = "dissemination";
-	long version;
-	double resol;
-	int count = 1;
-
-    if( argc < 3 )
-	{
-	  printf("\n Usage: ./example inputgrib outputgrib resol \n");
-	  exit(1);
-	}
-
-	in = fopen(argv[1],"r");
-	if(!in)
-	{
-		perror( argv[1] );
-		exit(10);
-	}
-
-	out = fopen(argv[2],"w");
-	if(!out) {
-		perror(argv[2]);
-		exit(10);
-	}
-
-	resol = atof(argv[3]);
-
-	version = grib_get_api_version();
-
-
-	/* printf("--- grib_api version %d \n",version); */
-
-
-	while((err = readany(in,buffer,&length)) == 0)
-	{
-		printf(" ===================  %d  ==============================  \n", count++);
-
-		/* INTOUT settings */
-
-/* Area */
-		/* north */
-		   /* realv[0] =  69.5; */
-		/* west */
-		   /* realv[1] = 345.5; */
-		/* south */
-		   /* realv[2] =  34.5; */
-		/* east */
-		   /* realv[3] =  34.5; */
-/*
-			if(err = int2_intout("area", intv, realv, text))
-			{
-			     fprintf(stderr,"Area setup INTOUT failed %d\n",err);
-			     return err;
-			}
-*/
-
-/* Lat-Lon resolution */
-		   realv[0] = resol;
-		   realv[1] = resol;
-		
-		   if( err = int2_intout("grid",intv,realv,text))
-		   {
-			   fprintf(stderr,"Grid setup INTOUT failed %d\n",err);
-			   exit(err);
-		   }
-/* Accuracy */
-			/*
-           intv[0] = 16;
-           if(err = int2_intout("accuracy",intv,realv,text))
-           {
-               fprintf(stderr,"Reduced Gaussian setup failed %d\n",err);
-			   return err;
-           }
-
-			*/
-/* Reduced gaussian */
-		   /*
-           intv[0] = 200;
-           if(err = int2_intout("reduced",intv,realv,text))
-           {
-               fprintf(stderr,"Reduced Gaussian setup failed %d\n",err);
-			   return err;
-           }
-		   */
-/* Regular gaussian */
-		   /*
-           intv[0] = 200;
-           if(err = int2_intout("regular",intv,realv,text))
-           {
-               fprintf(stderr,"Regular Gaussian setup failed %d\n",err);
-			   return err;
-           }
-		   */
-/* Spectral */
-		   /*
-           intv[0] = 63;
-           if(err = int2_intout("truncation",intv,realv,text))
-           {
-               fprintf(stderr,"Spherical setup failed %d\n",err);
-			   return err;
-           }
-		  */
-/* Rotation */
-		/*
-		   realv[0] =  0.0;
-		   realv[1] = 80.0;
-		   if( err = int2_intout("rotation",intv,realv,text))
-		   {
-			   fprintf(stderr,"Rotation setup INTOUT failed %d\n",err);
-			   exit(err);
-		   }
-		*/
-
-		if(err = intf2(buffer,&length,outgrib,&outlen))
-		{
-			fprintf(stderr,"INTF2 failed %d\n",err);
-			exit(err);
-		}
-
-		if(fwrite(outgrib,1,outlen,out) != outlen)
-		{
-			perror(argv[4]);
-			exit(1);
-		}
-	}
-		if(fclose(in))
-		{
-			perror(argv[3]);
-			exit(1);
-		}
-
-		if(fclose(out))
-		{
-			perror(argv[4]);
-			exit(1);
-		}
-
-	return 0;
-}
-
diff --git a/grib_api_merging/fortint.h b/grib_api_merging/fortint.h
deleted file mode 100644
index 15092e1..0000000
--- a/grib_api_merging/fortint.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-#ifndef FORTINT_H
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#if defined hpR64 || defined hpiaR64
-#define fortint long long
-#else
-#define fortint long
-#endif
-#endif
-
-#ifdef REAL_8
-typedef double fortfloat;
-#else
-typedef float fortfloat; /* fortran single precision float */
-#endif
-
-#endif /* end of  FORTINT_H */
diff --git a/grib_api_merging/intf2.c b/grib_api_merging/intf2.c
deleted file mode 100755
index d82af17..0000000
--- a/grib_api_merging/intf2.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-
-#include "grib_api.h"
-#include "emos.h"
-
-fortint intf2_(char* grib_in, fortint* length_in, char* grib_out, fortint* length_out)
-{
-	fortint isec1[ISECTION_1] = {0,};
-	fortint isec2[ISECTION_2] = {0,};
-	fortint isec3[ISECTION_3] = {0,};
-	fortint isec4[ISECTION_4] = {0,};
-
-	static double *values_in = NULL;
-	static double *values_out = NULL;
-	static size_t values_in_len = 0;
-	static size_t values_out_len = 0;
-	double *values =NULL;
-
-	static float *values_in1 = NULL;
-	static float *values_out1 = NULL;
-	static size_t values_in_len1 = 0;
-	static size_t values_out_len1 = 0;
-
-	size_t ii = 0;
-	size_t inlen;
-	size_t len=0;
-	size_t outlen = *length_out;
-	size_t outlen_grib_message = 0;
-
-	fortint out_length = 0;
-
-	long long_length_in = *length_in;
-	fortint fortint_inlen = *length_in;
-	fortint fortint_outlen = outlen;
-
-	grib_handle *handle = 0;
-	grib_handle *outh   = 0;
-	grib_handle *finalh = 0;
-
-    fortint err1 = 0, mars_interpolation = 0;
-	int err = 0 , what = 0;
-	int  resetOutput = 0;
-	long nins, niwe;
-	long acc = 0;
-	long bitmapPresent = 0;
-
-	size_t size;
-
-	const void* temp;
-	char *intf2_debug = getenv("INTF2_DEBUG");
-	char *intf2_write = getenv("INTF2_WRITE_TO_FILE");
-	int jpeg = 0;
-	int set_spec_flags=0;
-	grib_util_grid_spec     spec={0,}; 
-	grib_util_packing_spec packing_spec={0,}; 
-
-	mars_interpolation = int2_chkout();
-
-	if(!mars_interpolation)
-	{
-		*length_out = 0;	
-		if(intf2_debug){
-			printf("INTF2: There is NOT users settings \n");
-			printf("INTF2: No Interpolation carried out \n");
-		}
-		return err;
-	}
-
-	fortint outputRepresentation = int2_outrep();
-
-	if(intf2_debug)
-	{
-		if(outputRepresentation	)
-			printf("INTF2:  Output Representation is NOT set by user\n");
-	}
-
-	handle = grib_handle_new_from_message(0,grib_in,long_length_in);
-	if(handle == 0) {
-		err = -1;
-		fprintf(stdout,"INTF2: Cannot create Handle %ld\n",err);
-		/* intlog2("INTF2: Cannot create Handle"); */
-		goto cleanup;
-	}
-
-	if( err = grib_get_size(handle,"values",&inlen))
-	{
-		fprintf(stdout,"INTF2: Cannot get size %s\n",grib_get_error_message(err));
-		return err;
-	}
-
-	if(inlen > values_in_len)
-	{
-		if(values_in) free(values_in);
-		values_in = (double*)malloc(sizeof(double)*inlen);
-		values_in_len = inlen;
-
-		if(!values_in)
-		{
-			err = -1;
-			fprintf(stdout,"INTF2: Cannot allocate %ld\n",inlen);
-			goto cleanup;
-		}
-	}
-
-   /* If bitmap Present  */
-    if((err = grib_get_long(handle,"bitmapPresent",&bitmapPresent))!= GRIB_SUCCESS)
-     {
-        fprintf(stderr,"Cannot get bitmapPresent  %s\n",grib_get_error_message(err));
-        return err;
-     }
-
-	/* if bitmap present Set missing value which correspond WAVE in Emos  */
-	if(bitmapPresent)
-	{
-		/* if(err = grib_set_double(handle,"missingValue",12345.0)) */
-		if(err = grib_set_double(handle,"missingValue",-9999999.0))
-		{
-			fprintf(stdout,"INTF2: Cannot set Missing Value %s\n",grib_get_error_message(err));
-			goto cleanup;
-		}
-	}
-
-	/* Get decoded values */
-	if(err = grib_get_double_array(handle,"values",values_in,&inlen))
-	{
-		fprintf(stdout,"INTF2: Cannot get decoded values %s\n",grib_get_error_message(err));
-		goto cleanup;
-	}
-
-
-	/* Descibe input field and initial settings for output field */
-	if(err = describe_input_field(handle,outputRepresentation))
-	{
-		fprintf(stdout,"INTF2 describe_input_field failed : %d\n",err);
-		goto cleanup;
-	}
-
-
-	/*=============  INTF ====================================*/
-
-	if(outputRepresentation){
-		out_length = inlen;
-	}
-	else{
-		out_length = int2_estima();
-		if(!out_length){
-			fprintf(stdout,"INTF2: Estimate for length of output array is 0 \n");
-			err = -1;
-			goto cleanup;
-		}
-	}
-	if(out_length > values_out_len)
-	{
-		if(values_out) free(values_out);
-		values_out = (double*)malloc(sizeof(double)*out_length);
-		values_out_len = out_length;
-
-		if(!values_out)
-		{
-			fprintf(stdout,"INTF2: Cannot allocate values_out %ld\n",out_length);
-			err = -1;
-			goto cleanup;
-		}
-	}
-
-	fortint_inlen = inlen;
-	fortint_outlen = outlen;
-
-
-#ifdef REAL_8
-	if(err = int2_intf(values_in,fortint_inlen,values_out,&fortint_outlen))
-	{
-		fprintf(stdout,"INTF failed %d\n",err);
-		goto cleanup;
-	}
-#else
-	if(inlen > values_in_len1)
-	{
-		if(values_in1) free(values_in1);
-		values_in1 = (float*)malloc(sizeof(float)*inlen);
-		values_in_len1 = inlen;
-
-		if(!values_in1)
-		{
-			err = -1;
-			fprintf(stdout,"INTF2: Cannot allocate values_in1 %ld\n",inlen);
-			goto cleanup;
-		}
-	}
-	if(out_length > values_out_len1)
-	{
-		if(values_out1) free(values_out1);
-		values_out1 = (float*)malloc(sizeof(float)*out_length);
-		values_out_len1 = out_length;
-
-		if(!values_out1)
-		{
-			fprintf(stdout,"INTF2: Cannot allocate values_out1 %ld\n",out_length);
-			err = -1;
-			goto cleanup;
-		}
-	}
-	for( ii = 0 ; ii < fortint_inlen; ii++){
-		values_in1[ii] = values_in[ii];
-	}
-	if(err = int2_intf(values_in1,fortint_inlen,values_out1,&fortint_outlen))
-	{
-		fprintf(stdout,"INTF failed %d\n",err);
-		goto cleanup;
-	}
-	for( ii = 0 ; ii < fortint_outlen; ii++){
-		values_out[ii] = values_out1[ii];
-	}
-#endif
-	outlen = fortint_outlen;
-
-	if(intf2_debug) {
-		printf("INTF2: Outlen: %d  \n",outlen);
-	}
-		
-	err=copy_spec_from_ksec(&spec,&packing_spec);
-	if (err) {
-		fprintf(stdout,"INTF2: ERROR - copy_grid_spec_from_ksec unable to copy spec: %d\n", err);
-		goto cleanup;
-	}
-
-	packing_spec.accuracy=GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
-	packing_spec.packing=GRIB_UTIL_PACKING_USE_PROVIDED;
-
-	if(outlen == 0) { 
-		set_spec_flags |= GRIB_UTIL_SET_SPEC_FLAGS_ONLY_PACKING;
-		/* Sinisa and Enrico 7/3/11 comments this line */
-		/* packing_spec.packing=0; */
-		len=inlen;
-		values=values_in;
-		if(intf2_debug )
-			printf("INTF2: Outlen = 0 No Interpolation carried out \n");
-	} else {
-		len=outlen;
-		values=values_out;
-	}
-
-	finalh = grib_util_set_spec(handle,&spec, &packing_spec, set_spec_flags,values, len, &err);
-	if(!finalh)  {
-		fprintf(stdout,"INTF2: ERROR - grib_util_set_spec: %d\n", err);
-		if(!err) err = 1;
-		goto cleanup;
-	}
-
-    if (outlen == 0){
-		if(err == -1) {
-			/* -1 coming from grib_util when there is not packing */
-			err = 0;
-			*length_out = 0;
-			if(intf2_debug)
-				printf("INTF2: No Interpolation carried out, nothing repacked \n");
-			goto cleanup;
-		}
-	}
-
-	err = grib_get_message(finalh,&temp,&outlen_grib_message);
-
-	if(outlen_grib_message > *length_out) {
-		fprintf(stdout,"INTF2: ERROR - INTF2  OUTLEN is too large: %d %d\n", outlen, *length_out);
-		err = 1;
-		goto cleanup;
-	}
-
-	memcpy(grib_out,temp,outlen_grib_message);
-
-	*length_out = outlen_grib_message;
-
-	/* goto cleanup; */
-	if(intf2_debug && (set_spec_flags & GRIB_UTIL_SET_SPEC_FLAGS_ONLY_PACKING)){
-		printf("INTF2: No Interpolation carried out but data repacked \n");
-	}
-
-
-cleanup:
-	if(resetOutput = int2_setrep(outputRepresentation)) printf("INTF2: Output Representation reset failed:  %d \n",resetOutput);
-	if(handle)     {grib_handle_delete(handle);handle=NULL;}
-	if(outh)       {grib_handle_delete(outh);outh=NULL;}
-	if(outlen!=0 && finalh)     grib_handle_delete(finalh);
-
-	return err;
-}
-
-fortint intf2(char* grib_in, fortint* length_in, char* grib_out, fortint* length_out)
-{
-	return intf2_(grib_in,length_in,grib_out,length_out);
-}
diff --git a/grib_api_merging/intuvp2.c b/grib_api_merging/intuvp2.c
deleted file mode 100755
index 6722bfd..0000000
--- a/grib_api_merging/intuvp2.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-
-#include "grib_api.h"
-#include "emos.h"
-
-
-fortint intuvp2_(char* vort_grib_in, char* div_grib_in, fortint* length_in, char* vort_grib_out, char* div_grib_out, fortint* length_out)
-{
-
-	static double *vort_values_in = NULL;
-	static double *div_values_in  = NULL;
-	static double *vort_values_out = NULL;
-	static double *div_values_out  = NULL;
-	static size_t values_in_len = 0;
-	static size_t values_out_len = 0;
-
-
-	static float *vort_values_in1 = NULL;
-	static float *div_values_in1  = NULL;
-	static float *vort_values_out1 = NULL;
-	static float *div_values_out1  = NULL;
-	static size_t values_in_len1 = 0;
-	static size_t values_out_len1 = 0;
-
-	grib_handle* hu = NULL;
-	grib_handle* hv = NULL;
-
-	size_t inlen;
-	size_t outlen  = *length_out;
-	size_t outlen1  = *length_out;
-
-	long long_inlen  = *length_in;
-	fortint fortint_inlen  = *length_in;
-	fortint fortint_outlen = outlen;
-
-	int jpeg = 0, resetOutput = 0, what = 0;
-	long ii = 0;
-
-	char *text = "";
-	fortint   intv[4];
-	fortfloat realv[4];
-	long truncation;
-	grib_handle *handle1 = NULL, *handle2 = NULL;
-	grib_handle *outh_u = NULL, *outh_v = NULL;
-	int err = 0;
-	int grib_err = 0;
-	long accuracy = 0;
-
-    fortint out_length = 0;
-
-	const void* temp1;
-	const void* temp2;
-	char *intf2_debug ;
-	char *intf2_write ;
-	fortint outputRepresentation;
-	int gribex_compatibility;
-	grib_util_grid_spec spec={0,};
-	grib_util_packing_spec packing_spec={0,};
-
-	gribex_compatibility=grib_get_gribex_mode(0);
-
-	intf2_debug = getenv("INTF2_DEBUG");
-	intf2_write = getenv("INTF2_WRITE_TO_FILE");
-
-	outputRepresentation = int2_outrep();
-
-	if(outputRepresentation)
-		if(intf2_debug) {
-			printf("INTUVP2: Output Representation is Not set by user\n");
-		}
-
-	handle1 = grib_handle_new_from_message_copy(0,vort_grib_in,long_inlen);
-	if(!handle1) {
-		err = -1;
-		goto cleanup;
-	}
-
-	handle2 = grib_handle_new_from_message_copy(0,div_grib_in,long_inlen);
-	if(!handle2) {
-		err = -1;
-		goto cleanup;
-	}
-
-	/*----------------------------------*/
-	if( err = grib_get_size(handle1,"values",&inlen))
-	{
-		fprintf(stderr,"INTUVP2: Cannot get size for vorticity %s\n",grib_get_error_message(err));
-		goto cleanup;
-	}
-
-	if(intf2_debug) { printf("INTUVP2: inlen for vorticity: %d  \n",inlen); }
-
-    if(inlen > values_in_len)
-    {
-        if(vort_values_in) free(vort_values_in);
-        vort_values_in = (double*)malloc(sizeof(double)*inlen);
-        values_in_len = inlen;
-
-        if(!vort_values_in)
-        {
-            err = -1;
-            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_in %ld\n",inlen);
-            goto cleanup;
-        }
-
-        if(div_values_in) free(div_values_in);
-		div_values_in = (double*)malloc(sizeof(double)*inlen);
-		if(!div_values_in)
-		{
-			err = -1;
-			fprintf(stderr,"INTUVP2: Cannot allocate input array for divergency %d\n",inlen);
-			goto cleanup;
-		}
-    }
-
-/*
-	if( err = grib_get_size(handle2,"values",&inlen))
-	{
-		fprintf(stderr,"INTUVP2: Cannot get size for divergency %s\n",grib_get_error_message(err));
-		goto cleanup;
-	}
-*/
-	if(intf2_debug) { printf("INTUVP2: inlen for divergency: %d  \n",inlen); }
-
-
-	/* Default Accuracy */
-	if((err = grib_get_long(handle1,"bitsPerValue",&accuracy))!= GRIB_SUCCESS)
-	{
-		fprintf(stderr,"INTUVP2: Cannot get accuracy %s\n",grib_get_error_message(err));
-		return err;
-	}
-	intv[0] = accuracy;
-	if(err = int2_intin("accuracy",intv,realv,text))
-	{
-		fprintf(stderr,"INTUVP2: Accuracy setup INTIN failed %d\n",err);
-	}
-	if(intf2_debug)
-	{
-		printf("INTUVP2: Input Accuracy  %d  \n",accuracy);
-	}
-
-	/*----------------------------------*/
-
-	/* Get decoded values vorticity */
-	if(err = grib_get_double_array(handle1,"values",vort_values_in,&inlen))
-	{
-		fprintf(stderr,"INTUVP2: Cannot get decoded values %s\n",grib_get_error_message(err));
-		goto cleanup;
-	}
-
-	/* Get decoded values divergency */
-	if(err = grib_get_double_array(handle2,"values",div_values_in,&inlen))
-	{
-		fprintf(stderr,"INTUVP2: Cannot get decoded values %s\n",grib_get_error_message(err));
-		goto cleanup;
-	}
-	/*----------------------------------*/
-
-	/* get Truncation */
-	if(err = grib_get_long(handle1,"J", &truncation))
-	{
-		fprintf(stderr,"INTUVP2: Cannot get Truncation %s\n",grib_get_error_message(err));
-		goto cleanup;
-	}
-	intv[0] = truncation;
-	if(err = int2_intin("truncation",intv,realv,text))
-	{
-		fprintf(stderr,"INTUVP2: Truncation  setup INTIN failed %d\n",err);
-		goto cleanup;
-	}
-	if(outputRepresentation)
-	{
-		if(err = int2_intout("truncation",intv,realv,text))
-		{
-			fprintf(stderr,"INTUVP2: Truncation  setup INTOUT failed %d\n",err);
-			goto cleanup;
-		}
-	}
-
-	/*=============  INTUVY ====================================*/
-   if(outputRepresentation){
-        out_length = inlen;
-    }
-    else{
-        out_length = int2_estima();
-        if(!out_length){
-            fprintf(stdout,"INTUVP2: Estimate for length of output array is 0 \n");
-            err = -1;
-            goto cleanup;
-        }
-    }
-
-	if(out_length > values_out_len)
-    {
-        if(vort_values_out) free(vort_values_out);
-        vort_values_out = (double*)malloc(sizeof(double)*out_length);
-        values_out_len = out_length;
-
-        if(!vort_values_out)
-        {
-            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_out %ld\n",out_length);
-            err = -1;
-            goto cleanup;
-        }
-        if(div_values_out) free(div_values_out);
-        div_values_out = (double*)malloc(sizeof(double)*out_length);
-
-        if(!div_values_out)
-        {
-            fprintf(stdout,"INTUVP2: Cannot allocate div_values_out %ld\n",out_length);
-            err = -1;
-            goto cleanup;
-        }
-    }
-
-
-	fortint_inlen = inlen;
-	fortint_outlen = outlen;
-#ifdef REAL_8
-	if(err = int2_intuvu(vort_values_in, div_values_in, fortint_inlen, vort_values_out, div_values_out, &fortint_outlen))
-	{
-		fprintf(stderr,"INTUVP2 failed %d\n",err);
-		goto cleanup;
-	}
-#else
-    if(inlen > values_in_len1)
-    {
-        if(vort_values_in1) free(vort_values_in1);
-        vort_values_in1 = (float*)malloc(sizeof(float)*inlen);
-        values_in_len1 = inlen;
-
-        if(!vort_values_in1)
-        {
-            err = -1;
-            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_in %ld\n",inlen);
-            goto cleanup;
-        }
-
-        if(div_values_in1) free(div_values_in1);
-		div_values_in1 = (float*)malloc(sizeof(float)*inlen);
-		if(!div_values_in1)
-		{
-			err = -1;
-			fprintf(stderr,"INTUVP2: Cannot allocate input array for divergency %d\n",inlen);
-			goto cleanup;
-		}
-    }
-	if(out_length > values_out_len1)
-    {
-        if(vort_values_out1) free(vort_values_out1);
-        vort_values_out1 = (float*)malloc(sizeof(float)*out_length);
-        values_out_len1 = out_length;
-
-        if(!vort_values_out1)
-        {
-            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_out %ld\n",out_length);
-            err = -1;
-            goto cleanup;
-        }
-        if(div_values_out1) free(div_values_out1);
-        div_values_out1 = (float*)malloc(sizeof(float)*out_length);
-
-        if(!div_values_out1)
-        {
-            fprintf(stdout,"INTUVP2: Cannot allocate div_values_out %ld\n",out_length);
-            err = -1;
-            goto cleanup;
-        }
-    }
-    for( ii = 0 ; ii < fortint_inlen; ii++){
-            vort_values_in1[ii] = vort_values_in[ii];
-   }
-    for( ii = 0 ; ii < fortint_inlen; ii++){
-            div_values_in1[ii] = div_values_in[ii];
-   }
-	if(err = int2_intuvu(vort_values_in1, div_values_in1, fortint_inlen, vort_values_out1, div_values_out1, &fortint_outlen))
-	{
-		fprintf(stderr,"INTUVP2 failed %d\n",err);
-		goto cleanup;
-	}
-    for( ii = 0 ; ii < fortint_outlen; ii++){
-            vort_values_in[ii] = vort_values_in1[ii];
-   }
-    for( ii = 0 ; ii < fortint_outlen; ii++){
-            div_values_in[ii] = div_values_in1[ii];
-   }
-#endif
-
-	*length_out = fortint_outlen;
-	outlen     = fortint_outlen;
-
-	if(intf2_debug)
-	{
-		int i;
-		printf("INTUVP2: outlen: %d  \n",outlen);
-		for(i=0; i<10 ; i++)
-		{
-			printf("INTUVP2: output data values U -  %d -  %f \n",i,vort_values_out[i]);
-			printf("INTUVP2: output data values V -  %d -  %f \n",i,div_values_out[i]);
-		}
-	}
-
-	if(outlen)
-	{
-		err=copy_spec_from_ksec(&spec,&packing_spec);
-
-	    packing_spec.accuracy=GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
-        packing_spec.packing=GRIB_UTIL_PACKING_USE_PROVIDED;
-
-		if (err) {
-		          fprintf(stdout,"INTUVP2: ERROR - copy_grid_spec_from_ksec unable to copy spec: %d\n", err);
-		          goto cleanup;
-		}
-		if (spec.grid_type==GRIB_UTIL_GRID_SPEC_SH) {
-				if (0 && gribex_compatibility) {
-					double laplacianOperator=0;
-					long P=0;
-					grib_get_long(handle2,"P",&P);
-					if(err = grib_get_double(handle2,"laplacianOperator",&laplacianOperator))
-					{
-						fprintf(stderr,"INTUVP2: Cannot Get P %s\n",grib_get_error_message(err));
-						goto cleanup;
-					}
-					/*
-					if(err = grib_set_long(handle2,"computeLaplacianOperator",0))
-					{
-						fprintf(stderr,"INTUVP2: Cannot Set computeLaplacianOperator %s\n",grib_get_error_message(err));
-						goto cleanup;
-					}
-					if(err = grib_set_long(handle1,"computeLaplacianOperator",0))
-					{
-						fprintf(stderr,"INTUVP2: Cannot Set computeLaplacianOperator %s\n",grib_get_error_message(err));
-						goto cleanup;
-					}
-					if(err = grib_set_long(handle1,"P",P))
-					{
-						fprintf(stderr,"INTUVP2: Cannot Set P %s\n",grib_get_error_message(err));
-						goto cleanup;
-					}
-					if(err = grib_set_long(handle2,"P",P))
-					{
-						fprintf(stderr,"INTUVP2: Cannot Set P %s\n",grib_get_error_message(err));
-						goto cleanup;
-					}
-					*/
-					packing_spec.computeLaplacianOperator=0;
-					packing_spec.truncateLaplacian=1;
-					packing_spec.laplacianOperator=laplacianOperator;
-				} else {
-					packing_spec.computeLaplacianOperator=1;
-				}
-		}
-
-		hu = grib_util_set_spec(handle1,&spec, &packing_spec, 0,vort_values_out, outlen, &err);
-		if(!hu)  {
-		           fprintf(stdout,"INTUVP2: ERROR - grib_util_set_spec: %d\n", err);
-		           if(!err) err = 1;
-		           goto cleanup;
-		}
-
-		hv = grib_util_set_spec(handle2,&spec, &packing_spec, 0,div_values_out, outlen, &err);
-		if(!hv)  {
-		           fprintf(stdout,"INTUVP2: ERROR - grib_util_set_spec: %d\n", err);
-		           if(!err) err = 1;
-		           goto cleanup;
-		}
-
-		/* U velocity*/
-		if(err = grib_set_long(hu,"paramId",131))
-		{
-			fprintf(stderr,"INTUVP2: Cannot Set V %s\n",grib_get_error_message(err));
-			goto cleanup;
-		}
-
-		grib_get_message(hu,&temp1,&outlen);
-		if(temp1) {
-			if(intf2_debug) {
-				printf("INTUVP2: outlen u-comp -> %d \n", outlen);
-			}
-			memcpy(vort_grib_out,temp1,outlen);
-		}
-		else
-			fprintf(stderr,"INTUVP2: Error u-comp \n");
-		outlen = *length_out;
-
-		/* V velocity*/
-		if(err = grib_set_long(hv,"paramId",132))
-		{
-			fprintf(stderr,"INTUVP2: Cannot Set V %s\n",grib_get_error_message(err));
-			goto cleanup;
-		}
-		grib_get_message(hv,&temp2,&outlen);
-		if(temp2) {
-			if(intf2_debug) {
-				printf("INTUVP2: outlen v-comp -> %d \n", outlen);
-			}
-			memcpy(div_grib_out,temp2,outlen);
-		}
-		else
-			fprintf(stderr,"INTUVP2: Error v-comp \n");
-		*length_out = outlen;
-
-		goto cleanup;
-
-	}
-	else {
-		fprintf(stderr,"INTUVP2: ERROR - INTUVP2  OUTLEN is: %d\n", outlen);
-		err = 1;
-	}
-
-cleanup:
-
-	if(resetOutput = int2_setrep(outputRepresentation)) printf("INTUVP2: Output Representation reset failed:  %d \n",resetOutput); 
-	if(hu && (hu != handle1))     grib_handle_delete(hu);
-	if(hv && (hv != handle2))     grib_handle_delete(hv);
-	if(handle1)     {grib_handle_delete(handle1);handle1=0;};
-	if(handle2)     {grib_handle_delete(handle2);handle2=0;};
-
-	return err;
-}
-
-fortint intuvp2(char* vort_grib_in, char* div_grib_in, fortint* length_in, char* vort_grib_out, char* div_grib_out, fortint* length_out)
-{
-	return intuvp2_(vort_grib_in,div_grib_in,length_in,vort_grib_out,div_grib_out,length_out);
-}
diff --git a/gribex/0-INDEX-0 b/gribex/0-INDEX-0
new file mode 100644
index 0000000..a5c1738
--- /dev/null
+++ b/gribex/0-INDEX-0
@@ -0,0 +1,2 @@
+0-INDEX-0	mac	This file!
+valpina.c	mac	Find real index of point in feild described by a bitmap.
diff --git a/gribex/CMakeLists.txt b/gribex/CMakeLists.txt
index 798e6e8..eeb8f0a 100644
--- a/gribex/CMakeLists.txt
+++ b/gribex/CMakeLists.txt
@@ -1,58 +1,7 @@
-if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
-  set(CMAKE_Fortran_FLAGS_RELEASE "-O1")           # otherwise breaks second-order packing
-endif()
 
 list( APPEND gribex_src_files
-  comars.h
-  comcomm.h
-  comgrb.h
-  ecdef1.h
-  ecdef2.h
-  ecdef3.h
-  ecdef4.h
-  ecdef5.h
-  ecdef6.h
-  ecdef7.h
-  ecdef8.h
-  ecdef9.h
-  ecdef10.h
-  ecdef11.h
-  ecdef12.h
-  ecdef13.h
-  ecdef14.h
-  ecdef15.h
-  ecdef16.h
-  ecdef17.h
-  ecdef18.h
-  ecdef19.h
-  ecdf190.h
-  ecdf191.h
-  ECMWFdefinitions.h
-  gdecodeStruct.h
-  getsetValues.h
-  grbcom.h
-  gribex.h
-  handleLocalDefinitions.h
-  sfbits.h
-  csgnbt.c
-  dsgnbt.c
   ECMWFdefinitions.c
-  findLocalDefinitionFile.c
-  fortranInterface.c
-  gdecode.c
-  gdecode1.c
-  gdecode2.c
-  getsetValues.c
-  grpr190.c
-  handleLocalDefinitions.c
-  jmalloc.c
-  jfree.c
-  orefdat.c
-  sencode.c
-  sencode1.c
-  sencode2.c
-  swap4.c
-  valpina.c
+  ECMWFdefinitions.h
   abortx.F
   bufrin.F
   c2bitw.F
@@ -69,11 +18,15 @@ list( APPEND gribex_src_files
   chktab2.F
   cmpck.F
   codeps.F
+  comars.h
+  comcomm.h
+  comgrb.h
   confp.F
   confp2.F
   confp3.F
   confpa.F
   csect4.F
+  csgnbt.c
   d2ordr.F
   d2rosd.F
   decext.F
@@ -91,44 +44,72 @@ list( APPEND gribex_src_files
   dmesec2.F
   docsec2.F
   dpssec2.F
+  dsect4a.F
+  dsgnbt.c
   dshsec2.F
   dsvsec2.F
-  dsect4a.F
   ecdef1.F
+  ecdef1.h
   ecdef10.F
+  ecdef10.h
   ecdef11.F
+  ecdef11.h
   ecdef12.F
+  ecdef12.h
   ecdef13.F
+  ecdef13.h
   ecdef14.F
+  ecdef14.h
   ecdef15.F
+  ecdef15.h
   ecdef16.F
+  ecdef16.h
   ecdef17.F
+  ecdef17.h
   ecdef18.F
+  ecdef18.h
   ecdef19.F
-  ecdef50.F
-  ecdf191.F
+  ecdef19.h
   ecdef2.F
+  ecdef2.h
   ecdef3.F
+  ecdef3.h
   ecdef4.F
+  ecdef4.h
   ecdef5.F
+  ecdef5.h
+  ecdef50.F
   ecdef6.F
+  ecdef6.h
   ecdef7.F
+  ecdef7.h
   ecdef8.F
+  ecdef8.h
   ecdef9.F
+  ecdef9.h
+  ecdf190.h
+  ecdf191.F
+  ecdf191.h
   ecloc1.F
   eggsec2.F
   elasec2.F
   ellsec2.F
   emesec2.F
+  emoscyc.F # not used anywhere and creates unref symbol
   eocsec2.F
   epssec2.F
   eshsec2.F
   esvsec2.F
-  emoscyc.F # not used anywhere and creates unref symbol
   exscal.F
   extmap.F
+  findLocalDefinitionFile.c
+  fortranInterface.c
   ftn1cr.F
   gbitmap.F
+  gdecode.c
+  gdecode1.c
+  gdecode2.c
+  gdecodeStruct.h
   genbin.F
   gendir.F
   getchd.F
@@ -139,15 +120,20 @@ list( APPEND gribex_src_files
   getib3.F
   getind.F
   getlgd.F
+  getsetValues.c
+  getsetValues.h
   getsys.F
   getusr.F
+  grbcom.h
   grchk1.F
   grchk2.F
   grchk3.F
   grchk4.F
   gribex.F
+  gribex.h
   gribin.F
   gribnum.F
+  grpr190.c
   grprs0.F
   grprs1.F
   grprs1b.F
@@ -167,11 +153,15 @@ list( APPEND gribex_src_files
   grsvck.F
   grsx2o.F
   gscale.F
+  handleLocalDefinitions.c
+  handleLocalDefinitions.h
   inscal.F
   insmp1.F
   insmp2.F
   inxbit.F
   inxmap.F
+  jfree.c
+  jmalloc.c
   kwchk1.F
   kwloc1.F
   kwprs1.F
@@ -181,6 +171,7 @@ list( APPEND gribex_src_files
   modval.F
   offset.F
   offset2.F
+  orefdat.c
   packcf.F
   prtbin.F
   prtbk1.F
@@ -201,11 +192,17 @@ list( APPEND gribex_src_files
   rowina3.F
   rtb.F
   scm0.F
+  sencode.c
+  sencode1.c
+  sencode2.c
   setpar.F
+  sfbits.h
+  swap4.c
   tab2fil.F
   u2l1cr.F
   uncmpck.F
   unpkcf.F
+  valpina.c
   vod2uv.F
   yyyy2cy.F
 
@@ -222,12 +219,10 @@ list( APPEND gribex_src_files
   ecdef19.h
   ecdef50.h
   eocsec2.h
-  fortint.h
   gdecode.h
   gdecode1.h
   gdecode2.h
   grib_int_t.h
-  grprs.h
   sencode.h
   sencode1.h
   sencode2.h
diff --git a/gribex/ECMWFdefinitions.h b/gribex/ECMWFdefinitions.h
index f4074e3..3dc1237 100644
--- a/gribex/ECMWFdefinitions.h
+++ b/gribex/ECMWFdefinitions.h
@@ -1,17 +1,17 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 #ifndef ECMWFDEFNS_H
 #define ECMWFDEFNS_H
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 void encodeMarsPart(fortint * inputArray, unsigned char * gribSection1);
 
@@ -339,7 +339,7 @@ fortint jmemove_(
 #define FOURBYTEINT(a)  (fortint) (THREEBYTEINT((a))<<8 | (*((a)+3))<<0 )
 
 #define ONEBYTE(n)      ((*(n)>> 0) & 0xFF)
-#define MOVE1BYTE(p,n)  ( *(p)     = ((*(n)>> 0) & 0xFF) ) 
+#define MOVE1BYTE(p,n)  ( *(p)     = ((*(n)>> 0) & 0xFF) )
 #define MOVE2BYTES(p,n) ( *(p)     = ((*(n)>> 8) & 0xFF) ) , \
                         ( *((p)+1) = ((*(n)>> 0) & 0xFF) )
 #define MOVE3BYTES(p,n) ( *(p)     = ((*(n)>>16) & 0xFF) ) , \
diff --git a/gribex/abortx.F b/gribex/abortx.F
index 6401474..813ddcc 100644
--- a/gribex/abortx.F
+++ b/gribex/abortx.F
@@ -82,7 +82,7 @@ C----<
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       CHARACTER*(*) HNAME
 C
diff --git a/gribex/bt_cray.F b/gribex/bt_cray.F
old mode 100755
new mode 100644
diff --git a/gribex/bt_cyber.F b/gribex/bt_cyber.F
old mode 100755
new mode 100644
diff --git a/gribex/bt_ibm.F b/gribex/bt_ibm.F
old mode 100755
new mode 100644
diff --git a/gribex/bt_ibm_bal.bal b/gribex/bt_ibm_bal.bal
old mode 100755
new mode 100644
diff --git a/gribex/bt_sun.F b/gribex/bt_sun.F
old mode 100755
new mode 100644
diff --git a/gribex/bt_sun_c.c b/gribex/bt_sun_c.c
old mode 100755
new mode 100644
diff --git a/gribex/bt_vax.F b/gribex/bt_vax.F
old mode 100755
new mode 100644
diff --git a/gribex/bt_vax_mar.mar b/gribex/bt_vax_mar.mar
old mode 100755
new mode 100644
diff --git a/gribex/c2bitw.F b/gribex/c2bitw.F
old mode 100755
new mode 100644
diff --git a/gribex/c2cwid.F b/gribex/c2cwid.F
old mode 100755
new mode 100644
index a09c29d..395a51a
--- a/gribex/c2cwid.F
+++ b/gribex/c2cwid.F
@@ -161,7 +161,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/c2dosd.F b/gribex/c2dosd.F
old mode 100755
new mode 100644
index 2177a56..69fe061
--- a/gribex/c2dosd.F
+++ b/gribex/c2dosd.F
@@ -133,7 +133,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/c2gene.F b/gribex/c2gene.F
old mode 100755
new mode 100644
index 3a39242..f9b8e82
--- a/gribex/c2gene.F
+++ b/gribex/c2gene.F
@@ -214,7 +214,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/c2ordr.F b/gribex/c2ordr.F
old mode 100755
new mode 100644
index b354b12..e0126d2
--- a/gribex/c2ordr.F
+++ b/gribex/c2ordr.F
@@ -260,7 +260,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/c2pack.F b/gribex/c2pack.F
old mode 100755
new mode 100644
index b008383..16c534a
--- a/gribex/c2pack.F
+++ b/gribex/c2pack.F
@@ -149,7 +149,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/c2pkvw.F b/gribex/c2pkvw.F
index 7042bda..ef7809b 100644
--- a/gribex/c2pkvw.F
+++ b/gribex/c2pkvw.F
@@ -109,7 +109,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/c2rnge.F b/gribex/c2rnge.F
old mode 100755
new mode 100644
diff --git a/gribex/c2rows.F b/gribex/c2rows.F
old mode 100755
new mode 100644
index ae39c4d..ab6b516
--- a/gribex/c2rows.F
+++ b/gribex/c2rows.F
@@ -167,7 +167,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/calcop.F b/gribex/calcop.F
old mode 100755
new mode 100644
index e828c2c..a819efd
--- a/gribex/calcop.F
+++ b/gribex/calcop.F
@@ -103,7 +103,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       INTEGER JPTMAX
diff --git a/gribex/confp3.F b/gribex/confp3.F
index 66396bb..0abb208 100644
--- a/gribex/confp3.F
+++ b/gribex/confp3.F
@@ -95,7 +95,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 #include "grbcom.h"
 C
diff --git a/gribex/csect4.F b/gribex/csect4.F
index f629b96..d316a63 100644
--- a/gribex/csect4.F
+++ b/gribex/csect4.F
@@ -120,7 +120,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/csgnbt.c b/gribex/csgnbt.c
index 0e36815..4fdea64 100644
--- a/gribex/csgnbt.c
+++ b/gribex/csgnbt.c
@@ -1,15 +1,15 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 void csgnbt_(
   fortint * kout,
diff --git a/gribex/d2ordr.F b/gribex/d2ordr.F
old mode 100755
new mode 100644
index dbf2728..6988ae3
--- a/gribex/d2ordr.F
+++ b/gribex/d2ordr.F
@@ -130,7 +130,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/d2rosd.F b/gribex/d2rosd.F
old mode 100755
new mode 100644
index 1bcab01..2a377a6
--- a/gribex/d2rosd.F
+++ b/gribex/d2rosd.F
@@ -95,7 +95,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/decfp2.F b/gribex/decfp2.F
index 6ce07e2..2d91c61 100644
--- a/gribex/decfp2.F
+++ b/gribex/decfp2.F
@@ -90,7 +90,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 #include "grbcom.h"
 C
diff --git a/gribex/decops2.F b/gribex/decops2.F
old mode 100755
new mode 100644
index 1e43aec..9070af7
--- a/gribex/decops2.F
+++ b/gribex/decops2.F
@@ -147,7 +147,7 @@ C*
 C     ---------------------------------------------------------------
 C----<
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C
       PARAMETER (NCHAR=67)
diff --git a/gribex/dggsec2.F b/gribex/dggsec2.F
index 90c6c10..2ef9146 100644
--- a/gribex/dggsec2.F
+++ b/gribex/dggsec2.F
@@ -79,7 +79,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/dlasec2.F b/gribex/dlasec2.F
index 9d8e20b..53b0520 100644
--- a/gribex/dlasec2.F
+++ b/gribex/dlasec2.F
@@ -77,7 +77,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/gribex/dllsec2.F b/gribex/dllsec2.F
index c516b15..b3964a4 100644
--- a/gribex/dllsec2.F
+++ b/gribex/dllsec2.F
@@ -79,7 +79,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/dmesec2.F b/gribex/dmesec2.F
index 8f8682b..2c5c439 100644
--- a/gribex/dmesec2.F
+++ b/gribex/dmesec2.F
@@ -96,7 +96,7 @@ C
 C
 C     Global variables
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Local variables
 C
diff --git a/gribex/docsec2.F b/gribex/docsec2.F
index 5f44ea1..d51faf3 100644
--- a/gribex/docsec2.F
+++ b/gribex/docsec2.F
@@ -78,7 +78,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/dpssec2.F b/gribex/dpssec2.F
index 17f4cce..d9fe395 100644
--- a/gribex/dpssec2.F
+++ b/gribex/dpssec2.F
@@ -77,7 +77,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/gribex/dsect4a.F b/gribex/dsect4a.F
old mode 100755
new mode 100644
index e764d0e..cfcf9be
--- a/gribex/dsect4a.F
+++ b/gribex/dsect4a.F
@@ -127,7 +127,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       INTEGER JP15BIT, JP87SET, JPBYTES
diff --git a/gribex/dsgnbt.c b/gribex/dsgnbt.c
old mode 100755
new mode 100644
index 8a20637..6c36b1e
--- a/gribex/dsgnbt.c
+++ b/gribex/dsgnbt.c
@@ -1,15 +1,15 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 void dsgnbt_(
   fortint * kout,
diff --git a/gribex/dshsec2.F b/gribex/dshsec2.F
index 85b57a2..787e223 100644
--- a/gribex/dshsec2.F
+++ b/gribex/dshsec2.F
@@ -76,7 +76,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/dsvsec2.F b/gribex/dsvsec2.F
index 6c6956c..922c541 100644
--- a/gribex/dsvsec2.F
+++ b/gribex/dsvsec2.F
@@ -77,7 +77,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef1.F b/gribex/ecdef1.F
old mode 100755
new mode 100644
index 9eca069..ef8b3f8
--- a/gribex/ecdef1.F
+++ b/gribex/ecdef1.F
@@ -118,7 +118,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef1.h b/gribex/ecdef1.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef10.F b/gribex/ecdef10.F
old mode 100755
new mode 100644
index 4f7d1a0..e30d10f
--- a/gribex/ecdef10.F
+++ b/gribex/ecdef10.F
@@ -115,7 +115,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef10.h b/gribex/ecdef10.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef11.F b/gribex/ecdef11.F
old mode 100755
new mode 100644
index f4b5c72..b7c5530
--- a/gribex/ecdef11.F
+++ b/gribex/ecdef11.F
@@ -113,7 +113,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef11.h b/gribex/ecdef11.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef12.F b/gribex/ecdef12.F
old mode 100755
new mode 100644
index c7948b2..71ab7de
--- a/gribex/ecdef12.F
+++ b/gribex/ecdef12.F
@@ -113,7 +113,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef12.h b/gribex/ecdef12.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef13.F b/gribex/ecdef13.F
old mode 100755
new mode 100644
index e933b3d..c3b9155
--- a/gribex/ecdef13.F
+++ b/gribex/ecdef13.F
@@ -114,7 +114,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef13.h b/gribex/ecdef13.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef14.F b/gribex/ecdef14.F
old mode 100755
new mode 100644
index c614a3c..2f496dc
--- a/gribex/ecdef14.F
+++ b/gribex/ecdef14.F
@@ -113,7 +113,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef14.h b/gribex/ecdef14.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef15.F b/gribex/ecdef15.F
old mode 100755
new mode 100644
index 4ad9a1c..bbd3711
--- a/gribex/ecdef15.F
+++ b/gribex/ecdef15.F
@@ -112,7 +112,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef15.h b/gribex/ecdef15.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef16.F b/gribex/ecdef16.F
old mode 100755
new mode 100644
index 435b225..c895a13
--- a/gribex/ecdef16.F
+++ b/gribex/ecdef16.F
@@ -112,7 +112,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef16.h b/gribex/ecdef16.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef17.F b/gribex/ecdef17.F
old mode 100755
new mode 100644
index b0fd8d7..b54fd8f
--- a/gribex/ecdef17.F
+++ b/gribex/ecdef17.F
@@ -101,7 +101,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef17.h b/gribex/ecdef17.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef18.F b/gribex/ecdef18.F
index 8eaab60..1d3e18b 100644
--- a/gribex/ecdef18.F
+++ b/gribex/ecdef18.F
@@ -105,7 +105,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef19.F b/gribex/ecdef19.F
index 2822af3..7ccafc5 100644
--- a/gribex/ecdef19.F
+++ b/gribex/ecdef19.F
@@ -89,7 +89,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/ecdef2.F b/gribex/ecdef2.F
old mode 100755
new mode 100644
index ab7ac65..c9d8c37
--- a/gribex/ecdef2.F
+++ b/gribex/ecdef2.F
@@ -114,7 +114,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef2.h b/gribex/ecdef2.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef3.F b/gribex/ecdef3.F
old mode 100755
new mode 100644
index 0390112..768fa88
--- a/gribex/ecdef3.F
+++ b/gribex/ecdef3.F
@@ -113,7 +113,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef3.h b/gribex/ecdef3.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef4.F b/gribex/ecdef4.F
old mode 100755
new mode 100644
index c88e8c4..f4f53e9
--- a/gribex/ecdef4.F
+++ b/gribex/ecdef4.F
@@ -115,7 +115,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ecdef4.h b/gribex/ecdef4.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef5.F b/gribex/ecdef5.F
old mode 100755
new mode 100644
index 99ff908..7b2b658
--- a/gribex/ecdef5.F
+++ b/gribex/ecdef5.F
@@ -115,7 +115,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef5.h b/gribex/ecdef5.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef6.F b/gribex/ecdef6.F
old mode 100755
new mode 100644
index 839f36f..ff878e7
--- a/gribex/ecdef6.F
+++ b/gribex/ecdef6.F
@@ -116,7 +116,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef6.h b/gribex/ecdef6.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef7.F b/gribex/ecdef7.F
old mode 100755
new mode 100644
index 7b8f7df..1e1d2d7
--- a/gribex/ecdef7.F
+++ b/gribex/ecdef7.F
@@ -117,7 +117,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*(*) HFUNC
diff --git a/gribex/ecdef7.h b/gribex/ecdef7.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef8.F b/gribex/ecdef8.F
old mode 100755
new mode 100644
index 598a64d..47f53aa
--- a/gribex/ecdef8.F
+++ b/gribex/ecdef8.F
@@ -114,7 +114,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef8.h b/gribex/ecdef8.h
old mode 100755
new mode 100644
diff --git a/gribex/ecdef9.F b/gribex/ecdef9.F
old mode 100755
new mode 100644
index 90f889d..598f5b0
--- a/gribex/ecdef9.F
+++ b/gribex/ecdef9.F
@@ -113,7 +113,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       CHARACTER*1   HFUNC
diff --git a/gribex/ecdef9.h b/gribex/ecdef9.h
old mode 100755
new mode 100644
diff --git a/gribex/ecloc1.F b/gribex/ecloc1.F
index a838a7a..367a0cb 100644
--- a/gribex/ecloc1.F
+++ b/gribex/ecloc1.F
@@ -129,7 +129,7 @@ C
       IMPLICIT NONE
 C
 #include "grbcom.h"
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/eggsec2.F b/gribex/eggsec2.F
index f225865..42f1644 100644
--- a/gribex/eggsec2.F
+++ b/gribex/eggsec2.F
@@ -79,7 +79,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/elasec2.F b/gribex/elasec2.F
index 7269b3b..f82e66f 100644
--- a/gribex/elasec2.F
+++ b/gribex/elasec2.F
@@ -77,7 +77,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/gribex/ellsec2.F b/gribex/ellsec2.F
index ff28e20..9e189b5 100644
--- a/gribex/ellsec2.F
+++ b/gribex/ellsec2.F
@@ -79,7 +79,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/emesec2.F b/gribex/emesec2.F
index d8df76f..69faf16 100644
--- a/gribex/emesec2.F
+++ b/gribex/emesec2.F
@@ -99,7 +99,7 @@ C
 C
 C     Global variables
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Local variables
 C
diff --git a/gribex/emoscyc.F b/gribex/emoscyc.F
index 5a6c80a..ef4fcc7 100644
--- a/gribex/emoscyc.F
+++ b/gribex/emoscyc.F
@@ -84,7 +84,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/gribex/emoslibVersion.c b/gribex/emoslibVersion.c
old mode 100755
new mode 100644
diff --git a/gribex/eocsec2.F b/gribex/eocsec2.F
index 81234ff..928ce61 100644
--- a/gribex/eocsec2.F
+++ b/gribex/eocsec2.F
@@ -78,7 +78,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/eocsec2.h b/gribex/eocsec2.h
old mode 100755
new mode 100644
diff --git a/gribex/epssec2.F b/gribex/epssec2.F
index 3d07fc0..ec77d32 100644
--- a/gribex/epssec2.F
+++ b/gribex/epssec2.F
@@ -77,7 +77,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/eshsec2.F b/gribex/eshsec2.F
index 59fb62a..044afdc 100644
--- a/gribex/eshsec2.F
+++ b/gribex/eshsec2.F
@@ -77,7 +77,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/esvsec2.F b/gribex/esvsec2.F
index a7e7429..e6e71ae 100644
--- a/gribex/esvsec2.F
+++ b/gribex/esvsec2.F
@@ -78,7 +78,7 @@ C     _______________________________________________________
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/extmap.F b/gribex/extmap.F
index 1043e5e..38326e1 100644
--- a/gribex/extmap.F
+++ b/gribex/extmap.F
@@ -150,7 +150,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/findLocalDefinitionFile.c b/gribex/findLocalDefinitionFile.c
index 24c39a8..a92d6ea 100644
--- a/gribex/findLocalDefinitionFile.c
+++ b/gribex/findLocalDefinitionFile.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -15,8 +15,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdlib.h>
-
-#include "fortint.h"
+#include "common/fortint.h"
 
 #ifdef TABLE_PATH
 #define USER 1
@@ -59,13 +58,14 @@ int defaultDirectoryChosen = 0;
   directoryPath = (char*) getenv("LOCAL_DEFINITION_TEMPLATES");
   if( directoryPath == NULL ) {
     defaultDirectoryChosen = 1;
-	if(USER){
-	  char temp[256] = TABLE_PATH;
-	  strcat(temp,"/gribtemplates"); 
+    if(USER){
+      char temp[256] = TABLE_PATH;
+      strcat(temp,"/gribtemplates");
       directoryPath = temp;
-	}
-	 else
+    }
+    else {
       directoryPath = TABLE_PATH;
+    }
   }
 /*
 // The directoryPath can have a list of directories separated by ':'.
@@ -106,6 +106,6 @@ int defaultDirectoryChosen = 0;
        fullFileName[n] = '/';
        strcpy(&fullFileName[n+1],fileName);
        if( fileExists(fullFileName) ) return fullFileName;
-     return NULL;   
+     return NULL;
   }
 }
diff --git a/gribex/fortint.h b/gribex/fortint.h
deleted file mode 100644
index e517d43..0000000
--- a/gribex/fortint.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-#ifndef FORTINT_H
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#define JPointer int *
-#else
-#if defined hpR64 || defined hpiaR64
-#define fortint long long
-#define JPointer long long *
-#else
-#define fortint long
-#define JPointer long *
-#endif
-#endif
-
-#ifdef REAL_8
-#define fortreal double
-#else
-#define fortreal float
-#endif
-
-#define fortdouble double
-
-#endif /* End of FORTINT_H */
diff --git a/gribex/fortranInterface.c b/gribex/fortranInterface.c
index a4976ae..a6b0dd7 100644
--- a/gribex/fortranInterface.c
+++ b/gribex/fortranInterface.c
@@ -1,20 +1,19 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
+#include "common/fortint.h"
 #include "handleLocalDefinitions.h"
-#include "fortint.h"
 #include "grib_int_t.h"
 
 typedef struct knownActions {
@@ -276,7 +275,7 @@ char printLine[LINELENGTH] = "                                        ";
     setbuf(out,NULL);
   }
   else {
-    if( fileNumber < 10 ) 
+    if( fileNumber < 10 )
       sprintf((fileName+5),"%1d",fileNumber);
     else
       sprintf((fileName+5),"%2d",fileNumber);
@@ -388,11 +387,11 @@ char printLine[LINELENGTH] = "                                        ";
 /*
 //          Special handling for definition 192 (LOCAL within a LIST):
 //
-//   numberOfLocalDefinitions	52	I1	44	-
-//   listOfLocalDefinitions	-	LIST	-	numberOfLocalDefinitions
-//   localDefinitionLength	-	I2	-	-
-//   localDefinition		-	LOCAL	-	-
-//   endListOfLocalDefinitions	-	ENDLIST	-	listOfLocalDefinitions
+//   numberOfLocalDefinitions   52      I1      44      -
+//   listOfLocalDefinitions     -       LIST    -       numberOfLocalDefinitions
+//   localDefinitionLength      -       I2      -       -
+//   localDefinition            -       LOCAL   -       -
+//   endListOfLocalDefinitions  -       ENDLIST -       listOfLocalDefinitions
 */
             action* local, * a;
             action next;
@@ -464,7 +463,7 @@ char printLine[LINELENGTH] = "                                        ";
           numberOfPrintLines = separateItems;
         else
           numberOfPrintLines = listCount * separateItems;
-       
+
         nextItem = 0;
         for( loop = 0; loop < numberOfPrintLines; loop++ ) {
           loadPrintLine(printLine,LINELENGTH,
@@ -472,8 +471,8 @@ char printLine[LINELENGTH] = "                                        ";
                       &unpackedSection1Values[valueToPrint]);
           fprintf(out,"%s\n",printLine);
           valueToPrint++;
-		  if(EQUAL(listCode[nextItem],"A8"))
-		  	valueToPrint++;
+          if(EQUAL(listCode[nextItem],"A8"))
+            valueToPrint++;
           nextItem++;
           if( nextItem == separateItems ) nextItem = 0;
         }
@@ -504,7 +503,7 @@ char printLine[LINELENGTH] = "                                        ";
 
     if( EQUAL("experimentVersionNumber",a->description) ) expverFound = 1;
     if( printableValue ) valueToPrint++;
-	if( printableValue && EQUAL((a->code),"A8") ) valueToPrint++;
+    if( printableValue && EQUAL((a->code),"A8") ) valueToPrint++;
     a = a->next;
   }
 
diff --git a/gribex/fortvalues.h b/gribex/fortvalues.h
index 6d8b6d1..9da9b69 100644
--- a/gribex/fortvalues.h
+++ b/gribex/fortvalues.h
@@ -1,17 +1,17 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 #ifndef FORTVALUES_H
 #define FORTVALUES_H
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 #define BYTE  0xFF & (fortint)
 
diff --git a/gribex/gbitmap.F b/gribex/gbitmap.F
old mode 100755
new mode 100644
index f8643fa..7f98426
--- a/gribex/gbitmap.F
+++ b/gribex/gbitmap.F
@@ -99,7 +99,7 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 #include "grbcom.h"
 C
 C     Function arguments
diff --git a/gribex/gdecode.h b/gribex/gdecode.h
index 7208a12..f11cc49 100644
--- a/gribex/gdecode.h
+++ b/gribex/gdecode.h
@@ -2,12 +2,11 @@
 #define GDECODE_H
 #include <stdio.h>
 #include <stdlib.h>
-#include "fortint.h"
 #include <string.h>
 #include <ctype.h>
-
+#include "common/fortint.h"
+#include "common/fortreal.h"
 #include "gdecodeStruct.h"
-
 #include "sencode1.h"
 
 #ifdef FORTRAN_NO_UNDERSCORE
@@ -146,7 +145,7 @@
 #define RGSUBID rgsubid_
 #endif
 
-#define MOVE1BYTE(p,n)  ( *(p)     = ((*(n)>> 0) & 0xFF) ) 
+#define MOVE1BYTE(p,n)  ( *(p)     = ((*(n)>> 0) & 0xFF) )
 #define MOVE2BYTES(p,n) ( *(p)     = ((*(n)>> 8) & 0xFF) ) , \
                         ( *((p)+1) = ((*(n)>> 0) & 0xFF) )
 #define MOVE3BYTES(p,n) ( *(p)     = ((*(n)>>16) & 0xFF) ) , \
diff --git a/gribex/grchk1.F b/gribex/grchk1.F
index 8501ba4..645b193 100644
--- a/gribex/grchk1.F
+++ b/gribex/grchk1.F
@@ -294,7 +294,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/grchk2.F b/gribex/grchk2.F
index f3d4d3a..018770a 100644
--- a/gribex/grchk2.F
+++ b/gribex/grchk2.F
@@ -98,7 +98,7 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/grchk3.F b/gribex/grchk3.F
index aba1487..be658cc 100644
--- a/gribex/grchk3.F
+++ b/gribex/grchk3.F
@@ -121,7 +121,7 @@ C
 
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KRET
       INTEGER KSEC1
diff --git a/gribex/grchk4.F b/gribex/grchk4.F
index 6463839..e821337 100644
--- a/gribex/grchk4.F
+++ b/gribex/grchk4.F
@@ -100,7 +100,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KRET
       INTEGER KSEC1
diff --git a/gribex/grib_int_t.h b/gribex/grib_int_t.h
index d433fc5..f94b86f 100644
--- a/gribex/grib_int_t.h
+++ b/gribex/grib_int_t.h
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 #ifndef GRIB_INT_T_H
@@ -16,7 +16,6 @@ typedef int grib_int_t;
 #else
 typedef long grib_int_t;
 #endif
-typedef long * JPointer;
 typedef long long grib_int_64_t;
 
 typedef double grib_real_t;
@@ -24,4 +23,4 @@ typedef double grib_real_t;
 typedef unsigned char grib_octet_t;
 typedef const char grib_string_t;
 
-#endif /* End of GRIB_INT_T_H */
+#endif /* end of GRIB_INT_T_H */
diff --git a/gribex/gribex.F b/gribex/gribex.F
index 55b1ae8..3d8b871 100644
--- a/gribex/gribex.F
+++ b/gribex/gribex.F
@@ -18,7 +18,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/gribex.h b/gribex/gribex.h
old mode 100755
new mode 100644
diff --git a/gribex/gribnum.F b/gribex/gribnum.F
index 26305af..a4b8dee 100644
--- a/gribex/gribnum.F
+++ b/gribex/gribnum.F
@@ -75,7 +75,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/gribex/groutpt.F b/gribex/groutpt.F
index 6c33271..f1a38a4 100644
--- a/gribex/groutpt.F
+++ b/gribex/groutpt.F
@@ -65,7 +65,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C
 C     Local variables
diff --git a/gribex/grpr190.c b/gribex/grpr190.c
index b6164cd..06e2429 100644
--- a/gribex/grpr190.c
+++ b/gribex/grpr190.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <memory.h>
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 #ifdef FORTRAN_NO_UNDERSCORE
 #define GRPRS1B grprs1b
diff --git a/gribex/grprs0.F b/gribex/grprs0.F
index b0d2226..4e51945 100644
--- a/gribex/grprs0.F
+++ b/gribex/grprs0.F
@@ -81,7 +81,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KSEC0(*)
 C
diff --git a/gribex/grprs1.F b/gribex/grprs1.F
index ecec22f..d935f8a 100644
--- a/gribex/grprs1.F
+++ b/gribex/grprs1.F
@@ -168,7 +168,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 #include "grbcom.h"
 C
 C     Parameter(s)
diff --git a/gribex/grprs1b.F b/gribex/grprs1b.F
index 6abb71b..eeac83e 100644
--- a/gribex/grprs1b.F
+++ b/gribex/grprs1b.F
@@ -88,7 +88,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 #include "grbcom.h"
 C
 C     Parameter(s)
diff --git a/gribex/grprs2.F b/gribex/grprs2.F
index 38abb8e..996354d 100644
--- a/gribex/grprs2.F
+++ b/gribex/grprs2.F
@@ -108,7 +108,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/grprs3.F b/gribex/grprs3.F
index c105dba..c37bf0d 100644
--- a/gribex/grprs3.F
+++ b/gribex/grprs3.F
@@ -85,7 +85,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KSEC0(*)
       INTEGER KSEC3(*)
diff --git a/gribex/grprs4.F b/gribex/grprs4.F
index 26f5014..11d13ce 100644
--- a/gribex/grprs4.F
+++ b/gribex/grprs4.F
@@ -96,7 +96,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KSEC0(*)
       INTEGER KSEC4(*)
diff --git a/gribex/grprs4w.F b/gribex/grprs4w.F
old mode 100755
new mode 100644
index e650bf0..8a7360e
--- a/gribex/grprs4w.F
+++ b/gribex/grprs4w.F
@@ -78,7 +78,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
       INTEGER KSEC4
diff --git a/gribex/grsdef.F b/gribex/grsdef.F
old mode 100755
new mode 100644
index 5e1079d..56c081b
--- a/gribex/grsdef.F
+++ b/gribex/grsdef.F
@@ -81,7 +81,7 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 #include "grbcom.h"
 C
 C     Local variables
diff --git a/gribex/grsmax.F b/gribex/grsmax.F
old mode 100755
new mode 100644
diff --git a/gribex/grsmkp.F b/gribex/grsmkp.F
old mode 100755
new mode 100644
diff --git a/gribex/grsmok.F b/gribex/grsmok.F
old mode 100755
new mode 100644
diff --git a/gribex/grsn2o.F b/gribex/grsn2o.F
old mode 100755
new mode 100644
diff --git a/gribex/grsubc.F b/gribex/grsubc.F
old mode 100755
new mode 100644
diff --git a/gribex/grsx2o.F b/gribex/grsx2o.F
old mode 100755
new mode 100644
diff --git a/gribex/gscale.F b/gribex/gscale.F
index 4401795..84049f6 100644
--- a/gribex/gscale.F
+++ b/gribex/gscale.F
@@ -126,7 +126,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/inscal.F b/gribex/inscal.F
index ec12651..6ec9622 100644
--- a/gribex/inscal.F
+++ b/gribex/inscal.F
@@ -95,7 +95,7 @@ C
       IMPLICIT NONE
 #endif
 #include "grbcom.h"
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KDATA(KLEN), NBPV, LOOP, MAXNBPV
       INTEGER INTEMAX
diff --git a/gribex/insmp1.F b/gribex/insmp1.F
index e6eb28b..3922f76 100644
--- a/gribex/insmp1.F
+++ b/gribex/insmp1.F
@@ -166,7 +166,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/insmp2.F b/gribex/insmp2.F
index 3648c40..483b587 100644
--- a/gribex/insmp2.F
+++ b/gribex/insmp2.F
@@ -133,7 +133,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/inxbit.F b/gribex/inxbit.F
index 76c7998..430c6d0 100644
--- a/gribex/inxbit.F
+++ b/gribex/inxbit.F
@@ -101,7 +101,7 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       CHARACTER*1 HFUNC
       INTEGER IND, INUM, IOFF, IWORD
diff --git a/gribex/inxmap.F b/gribex/inxmap.F
index e73e776..d58ce06 100644
--- a/gribex/inxmap.F
+++ b/gribex/inxmap.F
@@ -167,7 +167,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       CHARACTER*(*) HFUNC
       CHARACTER*1   YFUNC
diff --git a/gribex/jabort.c b/gribex/jabort.c
old mode 100755
new mode 100644
diff --git a/gribex/jfree.c b/gribex/jfree.c
old mode 100755
new mode 100644
diff --git a/gribex/jmalloc.c b/gribex/jmalloc.c
index 8ceb0cf..f7bca46 100644
--- a/gribex/jmalloc.c
+++ b/gribex/jmalloc.c
@@ -1,18 +1,18 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 #include <stdio.h>
 #include <stdlib.h>
-
-#include "fortint.h"
+#include "common/fortint.h"
+#include "common/JPointer.h"
 
 #if (defined hpR64) || (defined hpiaR64) || (defined CRAY) || (defined rs6000)
 #define XALLOC malloc
diff --git a/gribex/kwchk1.F b/gribex/kwchk1.F
old mode 100755
new mode 100644
index e0a76fd..9b83bd1
--- a/gribex/kwchk1.F
+++ b/gribex/kwchk1.F
@@ -79,7 +79,7 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
       INTEGER KSEC1, KRET
diff --git a/gribex/kwloc1.F b/gribex/kwloc1.F
old mode 100755
new mode 100644
index cc2bf9a..3aa4ce9
--- a/gribex/kwloc1.F
+++ b/gribex/kwloc1.F
@@ -138,7 +138,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       INTEGER KSEC1, KGRIB, KLENG, KNSPT, KBITS, KPLEN, KPR, KRET
diff --git a/gribex/kwprs1.F b/gribex/kwprs1.F
old mode 100755
new mode 100644
index 82d3617..451d443
--- a/gribex/kwprs1.F
+++ b/gribex/kwprs1.F
@@ -178,7 +178,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       INTEGER KSEC0
diff --git a/gribex/maxmni.F b/gribex/maxmni.F
old mode 100755
new mode 100644
diff --git a/gribex/offset2.F b/gribex/offset2.F
index 4d8c94c..df44a03 100644
--- a/gribex/offset2.F
+++ b/gribex/offset2.F
@@ -87,7 +87,7 @@ C----<
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
 C
diff --git a/gribex/orefdat.c b/gribex/orefdat.c
index 8543970..4364d10 100644
--- a/gribex/orefdat.c
+++ b/gribex/orefdat.c
@@ -1,15 +1,15 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 fortint orefdat_(fortint* ksec1) {
 /*
diff --git a/gribex/packcf.F b/gribex/packcf.F
index 7bead8b..108543c 100644
--- a/gribex/packcf.F
+++ b/gribex/packcf.F
@@ -106,7 +106,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       INTEGER JPMAXT
diff --git a/gribex/prtbin.F b/gribex/prtbin.F
index 8d98b14..4392bbb 100644
--- a/gribex/prtbin.F
+++ b/gribex/prtbin.F
@@ -120,7 +120,7 @@ C                  PP, parameter.
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER IDEC
       INTEGER IK
diff --git a/gribex/ptquasi.F b/gribex/ptquasi.F
old mode 100755
new mode 100644
index b864dfa..99b7617
--- a/gribex/ptquasi.F
+++ b/gribex/ptquasi.F
@@ -82,7 +82,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
       INTEGER KSEC2
diff --git a/gribex/qu2reg2.F b/gribex/qu2reg2.F
old mode 100755
new mode 100644
diff --git a/gribex/qu2reg3.F b/gribex/qu2reg3.F
old mode 100755
new mode 100644
index 7fffdde..883800c
--- a/gribex/qu2reg3.F
+++ b/gribex/qu2reg3.F
@@ -134,7 +134,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
 C
diff --git a/gribex/ref2grb.F b/gribex/ref2grb.F
index 5d98c63..5ec0625 100644
--- a/gribex/ref2grb.F
+++ b/gribex/ref2grb.F
@@ -88,7 +88,7 @@ C     -----------------------------------------------------------------|
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 #include "grbcom.h"
 C
diff --git a/gribex/revero.F b/gribex/revero.F
old mode 100755
new mode 100644
index 6989ee9..5afc821
--- a/gribex/revero.F
+++ b/gribex/revero.F
@@ -104,7 +104,7 @@ C     -----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C
 C     Subroutine arguments
diff --git a/gribex/rowina2.F b/gribex/rowina2.F
old mode 100755
new mode 100644
diff --git a/gribex/rowina3.F b/gribex/rowina3.F
old mode 100755
new mode 100644
index 06248a1..562ddf4
--- a/gribex/rowina3.F
+++ b/gribex/rowina3.F
@@ -111,7 +111,7 @@ C*******************************************************************
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Subroutine arguments
       REAL P, PW, PMSVAL
diff --git a/gribex/sencode.h b/gribex/sencode.h
index ead4a07..cf31fa7 100644
--- a/gribex/sencode.h
+++ b/gribex/sencode.h
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 #ifndef SENCODE_H
@@ -13,7 +13,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "fortint.h"
+#include "common/fortint.h"
 /*sinisa #include "getsetValues.h" */
 
 #ifdef FORTRAN_NO_UNDERSCORE
diff --git a/gribex/setpar.F b/gribex/setpar.F
index 2c77196..ae927bc 100644
--- a/gribex/setpar.F
+++ b/gribex/setpar.F
@@ -77,7 +77,7 @@ C     ------------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
       INTEGER KBIT
       INTEGER KNEG
diff --git a/gribex/tab2fil.F b/gribex/tab2fil.F
index 97f2a62..3f4c34b 100644
--- a/gribex/tab2fil.F
+++ b/gribex/tab2fil.F
@@ -94,7 +94,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 #include "grbcom.h"
 C
 C     Function arguments
diff --git a/gribex/unpkcf.F b/gribex/unpkcf.F
index 40f1e9a..2a4b4ee 100644
--- a/gribex/unpkcf.F
+++ b/gribex/unpkcf.F
@@ -107,7 +107,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Parameters
       INTEGER JPMAXT
diff --git a/gribex/valpina.c b/gribex/valpina.c
index 9dccbac..6248046 100644
--- a/gribex/valpina.c
+++ b/gribex/valpina.c
@@ -1,16 +1,16 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 #include <stdio.h>
-#include "fortint.h"
+#include "common/fortint.h"
 
 #define CHARSIZE (long) (sizeof(char)*8)
 #define LEASTSIGBIT 0x01
diff --git a/gribtables/cen080/local_table_2_version_201 b/gribtables/cen080/local_table_2_version_201
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_128 b/gribtables/local_table_2_version_128
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_129 b/gribtables/local_table_2_version_129
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_130 b/gribtables/local_table_2_version_130
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_131 b/gribtables/local_table_2_version_131
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_132 b/gribtables/local_table_2_version_132
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_140 b/gribtables/local_table_2_version_140
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_150 b/gribtables/local_table_2_version_150
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_151 b/gribtables/local_table_2_version_151
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_160 b/gribtables/local_table_2_version_160
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_162 b/gribtables/local_table_2_version_162
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_170 b/gribtables/local_table_2_version_170
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_171 b/gribtables/local_table_2_version_171
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_172 b/gribtables/local_table_2_version_172
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_173 b/gribtables/local_table_2_version_173
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_174 b/gribtables/local_table_2_version_174
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_175 b/gribtables/local_table_2_version_175
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_180 b/gribtables/local_table_2_version_180
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_190 b/gribtables/local_table_2_version_190
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_200 b/gribtables/local_table_2_version_200
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_201 b/gribtables/local_table_2_version_201
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_210 b/gribtables/local_table_2_version_210
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_211 b/gribtables/local_table_2_version_211
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_220 b/gribtables/local_table_2_version_220
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_228 b/gribtables/local_table_2_version_228
old mode 100755
new mode 100644
diff --git a/gribtables/local_table_2_version_230 b/gribtables/local_table_2_version_230
old mode 100755
new mode 100644
diff --git a/gribtemplates/localDefinitionTemplate_098_000_027.old b/gribtemplates/localDefinitionTemplate_098_000_027.old
old mode 100755
new mode 100644
diff --git a/gribtemplates/localDefinitionTemplate_098_000_030 b/gribtemplates/localDefinitionTemplate_098_000_030
old mode 100755
new mode 100644
diff --git a/gribtemplates/localDefinitionTemplate_098_000_031 b/gribtemplates/localDefinitionTemplate_098_000_031
old mode 100755
new mode 100644
diff --git a/gribtemplates/localDefinitionTemplate_098_000_032 b/gribtemplates/localDefinitionTemplate_098_000_032
old mode 100755
new mode 100644
diff --git a/gribtemplates/localDefinitionTemplate_098_000_035 b/gribtemplates/localDefinitionTemplate_098_000_035
old mode 100755
new mode 100644
diff --git a/interpolation/0-INDEX-0 b/interpolation/0-INDEX-0
index a9bd285..13044be 100644
--- a/interpolation/0-INDEX-0
+++ b/interpolation/0-INDEX-0
@@ -1,275 +1,246 @@
-0-INDEX-0	mac	This file!
-Imakefile	mac	To build libspecgp.a
-Makefile	mac	To build libspecgp.a
-areachk.F	mac	Fixup input/output field area definitions.
-auresol.F	mac	Returns the default truncation for given lat/long grid
-bitmap.h	mac	Header for bitmap routines.
-chequal.F	mac	Compare ASCII character strings without regard to case.
-chkprec.F	mac	Check if precipitation threshold has been redefined
-clear_c.F	mac     Clear interpolation common blocks
-createSharedMemoryCoefficients.c mac Creates spectral to grid interpolation coefficients in shared memory.
-csum.F		mac	Implements the BLAS routine of the same name
-current.h	mac	Info about gaussian definition currently in common.
-ddstyle.F	mac	Create regular lat/lon subgrid by selecting points.
-debug.h		mac	Debug header
-defaults_for_table_001	mac  Parameter processing defaults for WMO table 1.
-defaults_for_table_128	mac  Parameter processing defaults for ECMWF table 128.
-dssarea.F	mac	Fixup field area specification (dissemination style).
-dummy.F		mac	Dummy routine to satisfy make. (VECTOR.F)
-dummy2.F	mac	Dummy routine to satisfy make. (NO_OPT.F)
-emosPrecision.c mac	Returns 64 if double-precision (64-bit) REALs in use.
-eulavgg.F       mac     Reverse the effects of ggvalue.F
-fft99.f		mac	Multiple fast real periodic fourier transform.
-fftchk.c        mac     Check truncation and longitude grid interval OK for FFT.
-freecf.F	mac	Set trigger to allow mutual memory flushing of types 6/7
-fixarea.F	mac	Fixup area definition to correspond to grid definitions
-fortdefs.h	mac	Defines for Fortran/C interface data types
-funcs.F		mac	Fortran functions used by ocean interpolation (intocn)
-gb2gb.F		mac	Interpolate lat/lon GRIB to lat/lon: dissemination style
-getconf.F	mac	Decides how to handle legendre coefficients.
-ggintrp.F	mac	Finds value at a point by interpolation in a gaussian field.
-ggrotat.F	mac	Generates a rotated gaussian grid.
-ggvalue.F	mac	Rotates one line of latitude in a gaussian grid.
-gmapbit.c	mac	Get a bit from a given position in a bitmap.
-grdynam.h	mac	Dynamically allocated work space arrays(grid to grid).
-grfixed.h	mac	Fixed work space array definitions
-grspace.h	mac	Work space array definitions
-hgengg.F	mac	Lat/longs (before rot) for rotated gaussian grid.
-hgengrd.F	mac	Lat/longs (before rot) for rotated grid.
-hgengrw.F	mac	Lat/longs (before rot) for rotated grid for winds.
-hgenll.F	mac	Lat/longs (before rot) for rotated lat/long grid.
-hgenllw.F	mac	Calculates lat/longs (before rotation) for wind fields.
-hgetlsm.F	mac	Read old land-sea mask values from file.
-hirlam.F	mac	Rotated lat/lon from reduced gauss using 12-point interpolation.
-hirlamw.F	mac	Rotated lat/lon U/V from reduced gauss using 12-point interpolation.
-hirlsm.F	mac	As hirlam.F but using land-sea masks.
-hll2ll.F	mac	Creates rotated lat/lon from lat/lon using 12-pt interpn
-hll2llw.F	mac	Rotated U and V lat/lon from lat/lon using 12-pt interpn
-hll2xyz.F	mac	Converts array of lat/longs to (x,y,z) coordinates.
-hnei12.F	mac	Finds 12 neighbours for horizontal interpolation.
-hneill.F	mac	Finds 12 neighbours for lat/lon horizontal interpolation
-hntfap.F	mac	Prepare to interpolate packed input field.
-hntfaph.F	mac	Prepare to interpolate packed input field.
-hntfaps.F	mac	Prepare to interpolate packed input field.
-hntfau.F	mac	Prepare to interpolate unpacked input field.
-hntfauh.F	mac	Prepare to interpolate unpacked input field.
-hntfaus.F	mac	Prepare to interpolate unpacked input field.
-hntfbu.F	mac	Interpolate unpacked input field.
-hpshgpw.F	mac	Rotates grid about y-axis and calculates angle between local axes.
-hrg2gg.F	mac	Rotated gauss from reduced gauss using 12-point interpolation.
-hrg2ggw.F	mac	Rotated U and V gauss from reduced gauss using 12-point interpolation.
-hrg2ll.F	mac	Rotated lat/lon from reduced gauss using 12-point interpolation.
-hrg2llw.F	mac	Rotated lat/lon wind from a reduced gauss using 12-point interpolation.
-hsp2gg.F	mac	Finds a gaussian grid for a given spectral truncation.
-hwts12.F	mac	Interpolation weightings for horizontal interpolation.
-hwtsll.F	mac	Interpolation lat/lon weightings for horizontal interpolation.
-hwtslsm.F	mac	As hwts12.F but using land-sea masks.
-iafree.F	mac	Deallocate heap space used by grid-pt to grid-pt interpolation.
-iagcntl.F	mac	Control interpolation regular gaussian or lat/long fields.
-iaidef.F	mac	Generate input field definition from GRIB definition.
-iainit.F	mac	Initialise common decks for grid-pt to grid-pt interpolation.
-iaintgg.F	mac	Control interpolation GRIB -> gaussian
-iaintll.F	mac	Control interpolation GRIB -> regular lat/long
-iaogdef.F	mac	Set the output field definition variables.
-iaoldef.F	mac	Set the output field definition for a regular lat/long
-iarcntl.F	mac	Control interpolation of quasi regular gaussian -> gaussian or lat/long
-iareset.F	mac	Generate the output field definition.
-iarmem.F	mac	Acquires heap space for expanded REAL fields.
-ibasini.F	mac	Ensure basic interpolation setup is done.
-igalloc.F	mac	Allocates heap space.
-igbess.F	mac	Computes initial approximations to gaussian latitudes.
-igdins.F	mac	Calculate distance between points in output latitude array and its N/S neighbours in input latitude array
-igdiwe.F	mac	Calculate distance between points in output latitude array and its W/E neighbours in input latitude array
-igglat.F	mac	Compute gaussian latitudes for a given truncation.
-iggmem.F	mac	Acquires heap space.
-iggrid.F	mac	Generate lat/long points for a gaussian truncation and area.
-igint.F		mac	Calculate unnormalised interpolation wts between regular grids
-igintr.F	mac	Calculate interpolation wts for one line of lat for regular grids
-iglgrid.F	mac	Generate lat/long points for regular lat/long grid
-iglrev.F	mac	Reverses rows or columns of a rectangular matrix
-iglsize.F	mac	Evaluate array sizes for regular lat/long and area
-iglsm01.F	mac	Process one lat row from 10 minute land sea mask
-iglsmb.F	mac	Calculate effects of land-sea masks on unnormalised wts for a quasi regular input and a  regular output
-iglsmd.F	mac	Generate the land sea mask file info
-iglsmr.F	mac	Calculate effects of land-sea masks for one lat on the unnormalised interpolation weights.
-iglsmst.F	mac	Process one line of latitude from standard land sea mask file
-ignorm.F	mac	Normalise the array of interpolation weights.
-igplsm.F	mac	Force an interpolated land sea mask to a real 0-1 field
-igpoleg.F	mac	Calculate values at pole of regular lat/long field when input is gaussian
-igpolew.F	mac	Calculate values at pole of regular lat/long field when input is gaussian (for a wind field).
-igprec.F	mac	Additional interpolation for precipitation
-igscan.F	mac	Transform a regular field between scanning modes
-igsetup.F	mac	Setup GRIB sections 1, 2, 4 for the new interpolation product.
-igsize.F	mac	Evaluate array sizes for a gaussian truncation and area
-igtog.F		mac	Interpolation between regular input and output
-igtogr.F	mac	interpolation for one latitude using two neighbouring lines
-igtran.F	mac	Transposes a rectangular matrix.
-init_cm.F	mac	Initialize default values in interpolation common decks
-insane.F	mac	Check consistency of interpolation options.
-intf.F		mac	Make user interpolation request.
-intf.h		mac	Header for intf, intfa, intfb and intfc.
-intfa.F		mac	Prepare to interpolate input field.
-intfap.F	mac	Prepare to interpolate packed input field.
-intfau.F	mac	Prepare to interpolate unpacked input field.
-intfb.F		mac	Interpolate input field.
-intfbp.F	mac	Interpolate packed input field.
-intfbu.F	mac	Interpolate unpacked input field.
-intfc.F		mac	Move input field to output field.
-intin.F		mac	Handle user request parameters for input data
-intisl.F	mac	Perform ISLSCP processing
-intisl.h	mac	Defines for ISLSCP processing
-intlog.h        mac     Common block for interpolation diagnostics logging.
-intlog.F	mac	Logs error messages from interpolation routines.
-intlogd.F	mac	Toggle display flag for error messages from interpolation
-intlogr.F	mac	Logs error messages containing real number
-intlogs.c	mac	Save MARS server display function pointer.
-intocn.F	mac	Interpolates ocean field.
-intout.F	mac	Handle user request parameters for output data
-intpnum.F	mac	Returns INTP_CYCLE
-intuvdh.F 	mac	Encodes/decodes data into/from GRIB code.
-intuvf.F	mac	Make user interpolation request for U/V fields.
-intuvgh.F	mac	U & V reduced gaussian to rotated GRIB U & V.
-intuvp.F	mac	Interpolate packed U/V fields.
-intuvph.F	mac	Interpolate spectral vort/div or U/V to U and V.
-intuvs.F	mac	Create GRIB U/V from GRIB VO/D without interpolation.
-intuvu.F	mac	Interpolate unpacked U/V fields.
-intuvxh.F	mac	Interpolate wind component spectral field to grid point.
-intvect.F	mac	Interpolate vector fields (winds).
-intwave.F	mac	interpolates quasi-reg lat/long wave field to regular lat/long
-irdiwe.F	mac	Calculate distance between points in long array and its W/E neighbours for a quasi regular input and regular field
-irgmem.F	mac	Acquires heap space for quasi regular to regular
-irgrid.F	mac	Generate lat points and start points for a quasi regular gaussian
-irgtog.F	mac	interpolates quasi regular input to regular output
-irint.F		mac	Calculate unnormalised wts for quasi reg to reg
-irintr.F	mac	Calculate unnormalised wts for quasi reg to reg, 1 lat
-irlrev.F	mac	Reverses rows or columns of a quasi regular matrix
-irlsmb.F	mac	Calculate effects of land-sea mask on unnormalised interpolation weights for regular input and output fields.
-irprec.F	mac	Extra interpolation for precipitation when input is quasi regular 
-irscan.F	mac	Transforms scanning modes for quasi regular field
-irsize.F	mac	Evaluate array sizes for a quasi reg gaussian
-iscrsz.F	mac	Calculate scratch space size for unpacking GRIBs.
-islproc.F	mac	Generates point from four neighbours using lsm types.
-issame.F	mac	Check whether input and output fields are same.
-jacobi.F	mac	Rotates spectral fields by latitude.
-jacobif.F	mac	Rotates spectral fields by latitude (Fujitsu only).
-jagggp.F	mac	Converts spectral input fields to a gaussian grid
-jallgp.F	mac	Converts spectral input fields to lat/long grid
-jallwn.F	mac	Converts spectral input fields to lat/long grid (U & V)
-jchmod.c        mac     Gives Fortran callable chmod (for Fujitsu).
-jdebug.F	mac	Checks whether the debug flag is to be turned on.
-jfindfn.F 	mac	Create full pathname and open file.
-jfindfn3.F 	mac	Version of jfindfn.F which calls PBxxxx3 routines
-jfindir.F	mac	Find directory name defined by an environment variable.
-jgetgg.F	mac	Reads the definition of a gaussian grid.
-jgglat.F	mac	Computes gaussian lines of latitude for given truncation
-jindex.c	mac	Returns length of a character string (+ embedded blanks)
-jintend.F	mac	Deallocates heap memoryallocated by JINTLL/JINTGG.
-jintgg.F	mac	Converts spectral input fields to gaussian.
-jintll.F	mac	Converts spectral input fields to lat/long grid.
-jjset99.F	mac	Update of set99.f which gives a return status.
-jmakgg.F	mac	Makes legendre functions for latitudes(gaussian).
-jmakgg3.F	mac	Version of jmakgg.F which calls PBxxxx3 routines
-jmakll.F	mac	Makes legendre functions for latitudes(regular lat/lon).
-jmakll3.F	mac	Version of jmakll.F which calls PBxxxx3 routines
-jmemhan.F	mac	Handles dynamic memory allocation
-jmkofgg.F	mac	Builds up offsets into storage array for gaussian grid.
-jmovgg.F	mac	Moves gausssian grid point data from array to array.
-jmovll.F	mac	Moves grid point data from array to array.
-jmvugg.F	mac	Moves gaussian grid point data from array to array.
-jmvull.F	mac	Moves grid point data from array to array.
-jnorsgg.F	mac	Determines latitude in gaussian grid N or S of given latitude 
-jnumgg.F	mac	Returns number of points in each latitude of gaussian grid.
-jnumggq.F	mac	Simplified interface to JNUMGG.
-jopngg.F	mac	Finds a file of legendre polynomials for grid/truncation
-jopnggf.F	mac	Open interpolation coefficients file on Fujitsu.
-jopnggsm.c	mac	Handle file of legendre polynomials as memory mapped.
-jopnll.F	mac	Finds a file of legendre polynomials for grid/truncation
-jopnllf.F	mac	Open interpolation coefficients file on Fujitsu.
-jopnllsm.c	mac	Handle file of legendre polynomials as memory mapped.
-jparam2.h	mac	Hold trigger to allow memory flushing of types 6/7
-jparams.h	mac	PARAMETER definitions.
-jsgggp.F        mac     Converts stretched spectral fields to a gaussian grids.
-jsllgp.F        mac     Converts stretched spectral fields to a lat/long grids.
-jstrll.F        mac     Converts stretched spectral fields to a lat/long grids.
-jstrwll.F       mac     Converts stretched spectral winds to a lat/long grids.
-strlat.F        mac     Transform stretched <-> real lats; calculate map factor
-jreadgg.F	mac	Reads legendre functions for one latitude(gaussian).
-jreadll.F	mac	Reads legendre functions for one latitude(lat/long).
-jsh2sh.F	mac	Changes resolution of a field of spectral coefficients.
-jspleg1.F	mac	Calculates the legendre functions for one latitude.
-jsppole.F	mac	Calculates fourier coefficient for U or V at pole.
-jsymgg.F	mac	Converts spectral input fields to gaussian grid.
-jsymll.F	mac	Converts spectral input fields to lat/long grid.
-jtimer.c	mac	Time task processing.
-juvpole.F	mac	Creates polar wind U or V for lat/long from U/V spectral
-jvod2uv.F	mac	Interpolate spectral vort/div to spectral U/V.
-jwindll.F	mac	Converts spectral to lat/long grid for wind U and V.
-jwscal.F	mac	Applies scale factor to all latitudes except the poles
-kintrg.F	mac	Interpolate reduced gaussian to new reduced gaussian
-knfrom4.F	mac	Generates new field point from four nearest neighbours
-krg2rg.F        mac     Interpolate field from reduced gaussian grid to another
-krg2rgu.F       mac     Interpolate unpacked reduced gaussian to reduced gaussian
-lgrpr4.F	mac	Print information from Section 4 of GRIB code
-ll2xyz.F	mac	Convert lat/long coords to (x,y,z)
-lrekam.F	mac	Reverses rotations carried out by makerl.F.
-lsmfld.F	mac	Determines whether field is for 'land-sea mask' treatment.
-lsm_red.F	mac	Lookup filename for N160 reduced gaussian lsm file.
-make.dep	mac	Header file dependencies.
-makemap.c	mac	Build a bitmap from a definition given in a file.
-makerl.F	mac	Rotates an array of spherical harmonic coefficients.
-memreq.h	mac	Memory request definitions
-mkbitmp.F	mac	Select points using a bitmap.
-mkframe.F	mac	Remove points from inside a frame boundary.
-my_ialloc.c	mac	Allocates storage for a file.
-newisl.F	mac	Interpolate field on old lsm mask to one on new lsm
-ngintrp.F	mac	Finds value at a pt by interpolation in a gaussian field
-ngrotat.F	mac	Generates a rotated gaussian grid.
-ngvalue.F	mac	Rotates one line of latitude in a gaussian grid.
-nifld.common	mac	Input field common block.
-nmakgg.F	mac     Make interpolation coeffs one lat at a time for gaussian grids
-nmakll.F	mac     Make interpolation coeffs one lat at a time for lat/long grids
-nofld.common	mac	Output field common block.
-nptwe32.F	mac	32-bit REAL version of numptwe.F
-numptns.F	mac	Calculate number of grid points in range from north to south
-numptwe.F	mac	Calculate number of grid points in range from west to east
-oceanp.F	mac	Interpolate GRIB ocean field.
-options_sgimips	mac	Extra stuff for make(SGI)
-options_sun4	mac	Extra stuff for make(SUN)
-ouspace.h	mac	Work space array definitions(unpacked real data)
-parim.h		mac	PARAMETER definitions
-pddefs.F	mac	Setup interpolation using parameter dependent options.
-ppallow.F	mac	Checks if the rotation coefficients can go into mrfs.
-precip.F	mac	Says if field is to have 'precipitation' treatment.
-qpassm.f	mac	One pass through data for multiple FFT analysis.
-rddefs.c	mac	Read request defaults from file
-rename_unlink.c mac	Provide Fortran interface to rename/unlink.
-reset_c.F	mac	Reset interpolation handling options using GRIB product
-rgauss_*.h	mac	Definitions for reduced gaussian grids.
-rpassm.f	mac	One pass through data for multiple FFT synthesis.
-rphi.F		mac	Rotates spectral coefficients by longitude.
-set99.f		mac	Computes factors of n & trig functions FOR FFT99.
-sharedMemoryCharacteristics.c mac Determines the shared memory characteristics (size/key/number of latitudes) for a set of spectral to grid interpolation coefficients.
-sharedmemory.h	mac	Defines for shared memory interpolation coefficients.
-showmap.c	mac	Display a rectangular bitmap.
-smread.c	mac	Gets interpolation coefficients in a shared memory array
-soffset.c	mac	Find offsets of GRIB sections 0,1,...
-sources.xxx	mac	Sources for library on platform xxx (ALPHA,CRAY,.. ).
-sprotat.F	mac	Rotates a spherical harmonic GRIB field.
-sscal.F		mac	Implements the BLAS routine of the same name
-tatorgg.F       mac     Reverse the effects of ggrotat.F
-valpina.c	mac	Find real index of point in feild described by a bitmap.
-waveidx.F	mac	Find nearest-neighbours for wave field interpolation
-wavexxx.F	mac	Interpolates wave fields (except 2D spectra)
-w251idx.F	mac	Find nearest-neighbour for wave 2dsp (251) field interpolation
-wv2di32.F	mac	32-bit REAL version of wv2didx.F
-wv2didx.F	mac	Find nearest-neighbour for wave 2dsp field interpolation
-wv2dint.F	mac	interpolation of quasi-regular lat/long wave 2D spectra fields
-wv2dppp.F	mac	Interface to WV2DINT used by dissemination program.
-wv2dx32.F	mac	32-bit REAL version of wv2dxxx.F
-wv2dxxx.F	mac	Interpolates 2dsp fields
-wvqlidx.F	mac	Find nearest-neighbours for quasi-regular lat/long waves
-wvqlint.F	mac	Handle interpolation of quasi-regular lat/long wave fields
-xrotate.F	mac	Rotate about x-axis.
-xyz2ll.F	mac	Convert (x,y,z) coords to lat/long.
-yrotate.F	mac	Rotate about y-axis.
-zzz		mac	Directory containing 'useful' programs.
+0-INDEX-0                         mac  This file!
+areachk.F                         mac  Fixup input/output field area definitions
+auresol.F                         mac  Returns the default truncation for given lat/long grid
+bitmap.h                          mac  Header for bitmap routines
+chequal.F                         mac  Compare ASCII character strings without regard to case
+chkout.F
+chkprec.F                         mac  Check if precipitation threshold has been redefined
+clear_c.F                         mac  Clear interpolation common blocks
+current.h                         mac  Info about gaussian definition currently in common
+ddstyle.F                         mac  Create regular lat/lon subgrid by selecting points
+defaults_for_table_001            mac  Parameter processing defaults for WMO table 1
+defaults_for_table_128            mac  Parameter processing defaults for ECMWF table 128
+dpath_tables_interpol.F90
+dssarea.F                         mac  Fixup field area specification (dissemination style)
+emosPrecision.c                   mac  Returns 64 if double-precision (64-bit) REALs in use
+estima.F
+fft99.F
+fftchk.c                          mac  Check truncation and longitude grid interval OK for FFT
+fixarea.F                         mac  Fixup area definition to correspond to grid definitions
+forced_nearest_neighbour.F
+freecf.F                          mac  Set trigger to allow mutual memory flushing of types 6/7
+funcs.F                           mac  Fortran functions used by ocean interpolation (intocn)
+gasetup.F
+getconf.F                         mac  Decides how to handle legendre coefficients
+gettru.F
+gghtype.F                         mac  Return Gaussian grid type, from field representation, grid number and array with the number of points at each latitude
+ggintrp.F                         mac  Finds value at a point by interpolation in a gaussian field
+ggrotat.F                         mac  Generates a rotated gaussian grid
+ggvalue.F                         mac  Rotates one line of latitude in a gaussian grid
+global.F
+gmapbit.c                         mac  Get a bit from a given position in a bitmap
+grdynam.h                         mac  Dynamically allocated work space arrays(grid to grid)
+grfixed.h                         mac  Fixed work space array definitions
+grspace.h                         mac  Work space array definitions
+hgengg.F                          mac  Lat/longs (before rot) for rotated gaussian grid
+hgengrd.F                         mac  Lat/longs (before rot) for rotated grid
+hgengrw.F                         mac  Lat/longs (before rot) for rotated grid for winds
+hgenll.F                          mac  Lat/longs (before rot) for rotated lat/long grid
+hgetlsm.F                         mac  Read old land-sea mask values from file
+hirlam.F                          mac  Rotated lat/lon from reduced gauss using 12-point interpolation
+hirlamw.F                         mac  Rotated lat/lon U/V from reduced gauss using 12-point interpolation
+hirlsm.F                          mac  As hirlam.F but using land-sea masks
+hll2ll.F                          mac  Creates rotated lat/lon from lat/lon using 12-pt interpn
+hll2llw.F                         mac  Rotated U and V lat/lon from lat/lon using 12-pt interpn
+hll2xyz.F                         mac  Converts array of lat/longs to (x,y,z) coordinates
+hnei12.F                          mac  Finds 12 neighbours for horizontal interpolation
+hneill.F                          mac  Finds 12 neighbours for lat/lon horizontal interpolation
+hntfap.F                          mac  Prepare to interpolate packed input field
+hntfaph.F                         mac  Prepare to interpolate packed input field
+hntfaps.F                         mac  Prepare to interpolate packed input field
+hntfau.F                          mac  Prepare to interpolate unpacked input field
+hntfauh.F                         mac  Prepare to interpolate unpacked input field
+hntfaus.F                         mac  Prepare to interpolate unpacked input field
+hpshgpw.F                         mac  Rotates grid about y-axis and calculates angle between local axes
+hrg2gg.F                          mac  Rotated gauss from reduced gauss using 12-point interpolation
+hrg2ggw.F                         mac  Rotated U and V gauss from reduced gauss using 12-point interpolation
+hsh2gg.F                          mac  Finds a suitable Gaussian grid and/or spectral truncation for a given spectral truncation and/or lat/long increments
+hwts12.F                          mac  Interpolation weightings for horizontal interpolation
+hwtsll.F                          mac  Interpolation lat/lon weightings for horizontal interpolation
+hwtslsm.F                         mac  As hwts12.F but using land-sea masks
+iafree.F                          mac  Deallocate heap space used by grid-pt to grid-pt interpolation
+iagcntl.F                         mac  Control interpolation regular gaussian or lat/long fields
+iainit.F                          mac  Initialise common decks for grid-pt to grid-pt interpolation
+iarcntl.F                         mac  Control interpolation of quasi regular gaussian -> gaussian or lat/long
+ibasini.F                         mac  Ensure basic interpolation setup is done
+igalloc.F                         mac  Allocates heap space
+igbess.F                          mac  Computes initial approximations to gaussian latitudes
+igdins.F                          mac  Calculate distance between points in output latitude array and its N/S neighbours in input latitude array
+igdiwe.F                          mac  Calculate distance between points in output latitude array and its W/E neighbours in input latitude array
+igglat.F                          mac  Compute gaussian latitudes for a given truncation
+iggmem.F                          mac  Acquires heap space
+iggrid.F                          mac  Generate lat/long points for a gaussian truncation and area
+igint.F                           mac  Calculate unnormalised interpolation wts between regular grids
+igintr.F                          mac  Calculate interpolation wts for one line of lat for regular grids
+iglgrid.F                         mac  Generate lat/long points for regular lat/long grid
+iglsize.F                         mac  Evaluate array sizes for regular lat/long and area
+iglsm01.F                         mac  Process one lat row from 10 minute land sea mask
+iglsmb.F                          mac  Calculate effects of land-sea masks on unnormalised wts for a quasi regular input and a  regular output
+iglsmd.F                          mac  Generate the land sea mask file info
+iglsmr.F                          mac  Calculate effects of land-sea masks for one lat on the unnormalised interpolation weights
+iglsmst.F                         mac  Process one line of latitude from standard land sea mask file
+ignorm.F                          mac  Normalise the array of interpolation weights
+igplsm.F                          mac  Force an interpolated land sea mask to a real 0-1 field
+igpoleg.F                         mac  Calculate values at pole of regular lat/long field when input is gaussian
+igpolew.F                         mac  Calculate values at pole of regular lat/long field when input is gaussian (for a wind field)
+igprec.F                          mac  Additional interpolation for precipitation
+igsetup.F                         mac  Setup GRIB sections 1, 2, 4 for the new interpolation product
+igsize.F                          mac  Evaluate array sizes for a gaussian truncation and area
+igtog.F                           mac  Interpolation between regular input and output
+insane.F                          mac  Check consistency of interpolation options
+intf.F                            mac  Make user interpolation request
+intf.h                            mac  Header for intf, intfa, intfb and intfc
+intfap.F                          mac  Prepare to interpolate packed input field
+intfau.F                          mac  Prepare to interpolate unpacked input field
+intfb.F                           mac  Interpolate input field
+intfbu.F                          mac  Interpolate unpacked input field
+intin.F                           mac  Handle user request parameters for input data
+intisl.F                          mac  Perform ISLSCP processing
+intisl.h                          mac  Defines for ISLSCP processing
+intlog.F                          mac  Logs error messages from interpolation routines
+intlog.h                          mac  Common block for interpolation diagnostics logging
+intlogd.F                         mac  Toggle display flag for error messages from interpolation
+intlogr.F                         mac  Logs error messages containing real number
+intlogs.c                         mac  Save MARS server display function pointer
+intocn.F                          mac  Interpolates ocean field
+intocnu.F
+intout.F                          mac  Handle user request parameters for output data
+intpnum.F                         mac  Returns INTP_CYCLE
+intuvdh.F                         mac  Encodes/decodes data into/from GRIB code
+intuvgh.F                         mac  U & V reduced gaussian to rotated GRIB U & V
+intuvp.F                          mac  Interpolate packed U/V fields
+intuvs.F                          mac  Create GRIB U/V from GRIB VO/D without interpolation
+intuvu.F                          mac  Interpolate unpacked U/V fields
+intuvxh.F                         mac  Interpolate wind component spectral field to grid point
+intuvy.F
+intvecy.F
+intwave2.F
+isggvalid.F                       mac  Checks if a Gaussian grid definition is valid
+intwavu.F
+irdiwe.F                          mac  Calculate distance between points in long array and its W/E neighbours for a quasi regular input and regular field
+irgmem.F                          mac  Acquires heap space for quasi regular to regular
+irgrid.F                          mac  Generate lat points and start points for a quasi regular gaussian
+irgtog.F                          mac  interpolates quasi regular input to regular output
+irint.F                           mac  Calculate unnormalised wts for quasi reg to reg
+irintr.F                          mac  Calculate unnormalised wts for quasi reg to reg, 1 lat
+irlsmb.F                          mac  Calculate effects of land-sea mask on unnormalised interpolation weights for regular input and output fields
+irprec.F                          mac  Extra interpolation for precipitation when input is quasi regular
+irsize.F                          mac  Evaluate array sizes for a quasi reg gaussian
+iscrsz.F                          mac  Calculate scratch space size for unpacking GRIBs
+islproc.F                         mac  Generates point from four neighbours using lsm types
+issame.F                          mac  Check whether input and output fields are same
+issameiarray.F                    mac  Check if two integer arrays have the same entries
+issamerarray.F                    mac  Check if two real arrays have the same entries
+itimer.c
+jacobi.F                          mac  Rotates spectral fields by latitude
+jagggp.F                          mac  Converts spectral input fields to a gaussian grid
+jallgp.F                          mac  Converts spectral input fields to lat/long grid
+jallwn.F                          mac  Converts spectral input fields to lat/long grid (U & V)
+jbess.F
+jchmod.c                          mac  Gives Fortran callable chmod (for Fujitsu)
+jdebug.F                          mac  Checks whether the debug flag is to be turned on
+jfindfn.F                         mac  Create full pathname and open file
+jfindfn3.F                        mac  Version of jfindfn.F which calls PBxxxx3 routines
+jfindir.F                         mac  Find directory name defined by an environment variable
+jgetgg.F                          mac  Reads the definition of a gaussian grid
+jgglat.F                          mac  Computes gaussian lines of latitude for given truncation
+jindex.c                          mac  Returns length of a character string (+ embedded blanks)
+jjset99.F                         mac  Computes factors of n & trig functions FOR FFT99
+jmakgg.F                          mac  Makes legendre functions for latitudes(gaussian)
+jmakgg3.F                         mac  Version of jmakgg.F which calls PBxxxx3 routines
+jmakll.F                          mac  Makes legendre functions for latitudes(regular lat/lon)
+jmakll3.F                         mac  Version of jmakll.F which calls PBxxxx3 routines
+jmemhan.F                         mac  Handles dynamic memory allocation
+jmemhan2.F
+jmkofgg.F                         mac  Builds up offsets into storage array for gaussian grid
+jmovgg.F                          mac  Moves gaussian grid point data from array to array
+jmovll.F                          mac  Moves grid point data from array to array
+jmvugg.F                          mac  Moves gaussian grid point data from array to array
+jmvull.F                          mac  Moves grid point data from array to array
+jnorsgg.F                         mac  Determines latitude in gaussian grid N or S of given latitude
+jnumgg.F                          mac  Returns number of points in each latitude of gaussian grid
+jopngg.F                          mac  Finds a file of legendre polynomials for grid/truncation
+jopnggf.F                         mac  Open interpolation coefficients file on Fujitsu
+jopnggsm.c                        mac  Handle file of legendre polynomials as memory mapped
+jopnll.F                          mac  Finds a file of legendre polynomials for grid/truncation
+jopnllf.F                         mac  Open interpolation coefficients file on Fujitsu
+jopnllsm.c                        mac  Handle file of legendre polynomials as memory mapped
+jparam2.h                         mac  Hold trigger to allow memory flushing of types 6/7
+jparams.h                         mac  PARAMETER definitions
+jreadgg.F                         mac  Reads legendre functions for one latitude(gaussian)
+jreadll.F                         mac  Reads legendre functions for one latitude(lat/long)
+jsgggp.F                          mac  Converts stretched spectral fields to a gaussian grids
+jsh2sh.F                          mac  Changes resolution of a field of spectral coefficients
+jsllgp.F                          mac  Converts stretched spectral fields to a lat/long grids
+jspleg1.F                         mac  Calculates the legendre functions for one latitude
+jsppole.F                         mac  Calculates fourier coefficient for U or V at pole
+jstrll.F                          mac  Converts stretched spectral fields to a lat/long grids
+jstrwll.F                         mac  Converts stretched spectral winds to a lat/long grids
+jsymgg.F                          mac  Converts spectral input fields to gaussian grid
+jsymll.F                          mac  Converts spectral input fields to lat/long grid
+juvpole.F                         mac  Creates polar wind U or V for lat/long from U/V spectral
+jvod2uv.F                         mac  Interpolate spectral vort/div to spectral U/V
+jwindll.F                         mac  Converts spectral to lat/long grid for wind U and V
+jwscal.F                          mac  Applies scale factor to all latitudes except the poles
+kintrg.F                          mac  Interpolate reduced gaussian to new reduced gaussian
+knfrom4.F                         mac  Generates new field point from four nearest neighbours
+krg2rg.F                          mac  Interpolate field from reduced gaussian grid to another
+krg2rgd.F
+krg2rgu.F                         mac  Interpolate unpacked reduced gaussian to reduced gaussian
+krg2rgy.F
+krg2rgz.F
+ll2xyz.F                          mac  Convert lat/long coords to (x,y,z)
+lsm_red.F                         mac  Lookup filename for N160 reduced gaussian lsm file
+lsmfld.F                          mac  Determines whether field is for 'land-sea mask' treatment
+makemap.c                         mac  Build a bitmap from a definition given in a file
+memreq.h                          mac  Memory request definitions
+mkbitmp.F                         mac  Select points using a bitmap
+mkframe.F                         mac  Remove points from inside a frame boundary
+newisl.F                          mac  Interpolate field on old lsm mask to one on new lsm
+ngintrp.F                         mac  Finds value at a pt by interpolation in a gaussian field
+ngrotat.F                         mac  Generates a rotated gaussian grid
+ngvalue.F                         mac  Rotates one line of latitude in a gaussian grid
+nifld.common                      mac  Input field common block
+nifld.extracommon
+nmakgg.F                          mac  Make interpolation coeffs one lat at a time for gaussian grids
+nmakll.F                          mac  Make interpolation coeffs one lat at a time for lat/long grids
+nofld.common                      mac  Output field common block
+numptns.F                         mac  Calculate number of grid points in range from north to south
+numptwe.F                         mac  Calculate number of grid points in range from west to east
+oceanp.F                          mac  Interpolate GRIB ocean field
+oceanu.F
+outrep.F
+parameter_processing_defaults
+parim.h                           mac  PARAMETER definitions
+pddefs.F                          mac  Setup interpolation using parameter dependent options
+precip.F                          mac  Says if field is to have 'precipitation' treatment
+qgoct.F                           mac  Reduced Gaussian grid, octahedral progression series
+qpassm.F
+rename_unlink.c                   mac  Provide Fortran interface to rename/unlink
+request_defaults
+reset_c.F                         mac  Reset interpolation handling options using GRIB product
+rgauss_*.h                        mac  Definitions for reduced gaussian grids
+rpassm.F
+rphi.F                            mac  Rotates spectral coefficients by longitude
+set99.F
+setrep.F
+shareddt.c
+sharedgg.c
+sharedlib.c
+sharedlib.h
+sharedll.c
+sharedmemory.h                    mac  Defines for shared memory interpolation coefficients
+sscal.F                           mac  Implements the BLAS routine of the same name
+strlat.F                          mac  Transform stretched <-> real lats; calculate map factor
+w251idx.F                         mac  Find nearest-neighbour for wave 2dsp (251) field interpolation
+waveidx.F                         mac  Find nearest-neighbours for wave field interpolation
+wavexx2.F
+wv2didx.F                         mac  Find nearest-neighbour for wave 2dsp field interpolation
+wv2dint.F                         mac  interpolation of quasi-regular lat/long wave 2D spectra fields
+wv2dxx2.F
+wvqlidx.F                         mac  Find nearest-neighbours for quasi-regular lat/long waves
+wvqlin2.F
+wvqlint.F                         mac  Handle interpolation of quasi-regular lat/long wave fields
+xyz2ll.F                          mac  Convert (x,y,z) coords to lat/long
+yrotate.F                         mac  Rotate about y-axis
+zprec.F
diff --git a/interpolation/CMakeLists.txt b/interpolation/CMakeLists.txt
index 4692032..d92f13a 100644
--- a/interpolation/CMakeLists.txt
+++ b/interpolation/CMakeLists.txt
@@ -1,7 +1,6 @@
 list( APPEND interpolation_src_files
 
   current.h
-  debug.h
   grdynam.h
   grfixed.h
   grspace.h
@@ -9,7 +8,6 @@ list( APPEND interpolation_src_files
   intlog.h
   jparams.h
   memreq.h
-  ouspace.h
   parim.h
 
   areachk.F
@@ -18,22 +16,20 @@ list( APPEND interpolation_src_files
   chkout.F
   chkprec.F
   clear_c.F
-  csum.F
   ddstyle.F
-  dpath_tables_interpol.F
+  dpath_tables_interpol.F90
   dssarea.F
-  dummy.F
-  dummy2.F
   estima.F
-  eulavgg.F
   fft99.F
   fixarea.F
+  forced_fftw.F
+  forced_nearest_neighbour.F
   freecf.F
   funcs.F
   gasetup.F
-  gb2gb.F
   getconf.F
   gettru.F
+  gghtype.F
   ggintrp.F
   ggrotat.F
   ggvalue.F
@@ -42,7 +38,6 @@ list( APPEND interpolation_src_files
   hgengrd.F
   hgengrw.F
   hgenll.F
-  hgenllw.F
   hgetlsm.F
   hirlam.F
   hirlamw.F
@@ -58,29 +53,17 @@ list( APPEND interpolation_src_files
   hntfau.F
   hntfauh.F
   hntfaus.F
-  hntfbu.F
   hpshgpw.F
   hrg2gg.F
   hrg2ggw.F
-  hrg2ll.F
-  hrg2llw.F
-  hsp2gg.F
-  hsp2gg2.F
-  hsp2gg3.F
+  hsh2gg.F
   hwts12.F
   hwtsll.F
   hwtslsm.F
   iafree.F
   iagcntl.F
-  iaidef.F
   iainit.F
-  iaintgg.F
-  iaintll.F
-  iaogdef.F
-  iaoldef.F
   iarcntl.F
-  iareset.F
-  iarmem.F
   ibasini.F
   igalloc.F
   igbess.F
@@ -92,7 +75,6 @@ list( APPEND interpolation_src_files
   igint.F
   igintr.F
   iglgrid.F
-  iglrev.F
   iglsize.F
   iglsm01.F
   iglsmb.F
@@ -104,22 +86,15 @@ list( APPEND interpolation_src_files
   igpoleg.F
   igpolew.F
   igprec.F
-  igscan.F
   igsetup.F
   igsize.F
   igtog.F
-  igtogr.F
-  igtran.F
-  init_cm.F
   insane.F
   intf.F
-  intfa.F
   intfap.F
   intfau.F
   intfb.F
-  intfbp.F
   intfbu.F
-  intfc.F
   intin.F
   intisl.F
   intlog.F
@@ -130,17 +105,13 @@ list( APPEND interpolation_src_files
   intout.F
   intpnum.F
   intuvdh.F
-  intuvf.F
   intuvgh.F
   intuvp.F
-  intuvph.F
   intuvs.F
   intuvu.F
   intuvxh.F
   intuvy.F
-  intvect.F
   intvecy.F
-  intwave.F
   intwave2.F
   intwavu.F
   irdiwe.F
@@ -149,14 +120,17 @@ list( APPEND interpolation_src_files
   irgtog.F
   irint.F
   irintr.F
-  irlrev.F
   irlsmb.F
   irprec.F
-  irscan.F
   irsize.F
+  is_wave_direction.F
   iscrsz.F
+  isggvalid.F
   islproc.F
+  isoctahedral.F
   issame.F
+  issameiarray.F
+  issamerarray.F
   jacobi.F
   jagggp.F
   jallgp.F
@@ -168,9 +142,6 @@ list( APPEND interpolation_src_files
   jfindir.F
   jgetgg.F
   jgglat.F
-  jintend.F
-  jintgg.F
-  jintll.F
   jjset99.F
   jmakgg.F
   jmakgg3.F
@@ -185,7 +156,6 @@ list( APPEND interpolation_src_files
   jmvull.F
   jnorsgg.F
   jnumgg.F
-  jnumggq.F
   jopngg.F
   jopnggf.F
   jopnll.F
@@ -212,12 +182,9 @@ list( APPEND interpolation_src_files
   krg2rgu.F
   krg2rgy.F
   krg2rgz.F
-  lgrpr4.F
   ll2xyz.F
-  lrekam.F
   lsm_red.F
   lsmfld.F
-  makerl.F
   mkbitmp.F
   mkframe.F
   newisl.F
@@ -226,7 +193,6 @@ list( APPEND interpolation_src_files
   ngvalue.F
   nmakgg.F
   nmakll.F
-  nptwe32.F  # (unsupported entry point)
   numptns.F
   numptwe.F
   oceanp.F
@@ -234,56 +200,51 @@ list( APPEND interpolation_src_files
   outrep.F
   pddefs.F
   precip.F
+  qgoct.F
   qpassm.F
-  forced_nearest_neighbour.F
   reset_c.F
   rpassm.F
   rphi.F
   set99.F
   setrep.F
-  sprotat.F
   sscal.F
   strlat.F
-  tatorgg.F
   w251idx.F
   waveidx.F
-  wavexxx.F
-  wv2di32.F  # (unsupported entry point)
+  wavexx2.F
   wv2didx.F
   wv2dint.F
-  wv2dx32.F  # (unsupported entry point)
-  wv2dxxx.F
+  wv2dxx2.F
   wvqlidx.F
-  wvqlin2.F  # unused procedure with missing symbol
   wvqlint.F
-  xrotate.F
   xyz2ll.F
   yrotate.F
   zprec.F
 
-  wavexx2.F
-  wv2dxx2.F
-
   emosPrecision.c
   fftchk.c
   gmapbit.c
   intlogs.c
-  itimer.c
   jchmod.c
   jindex.c
   jopnggsm.c
   jopnllsm.c
-  jtimer.c
   makemap.c
-  my_ialloc.c
-  rddefs.c
   rename_unlink.c
   shareddt.c
   sharedgg.c
   sharedlib.c
   sharedll.c
-  showmap.c
-  soffset.c
+
+  # (former grib_api_merging/)
+  copy_spec_from_ksec.c
+  describe_input_field.c
+  emos.c
+  emos.h
+  intf2.c
+  intuvp2.c
+  intuvs2.c
+  intvect2.c
 )
 
 
diff --git a/interpolation/Imakefile b/interpolation/Imakefile
deleted file mode 100644
index 78eb3c2..0000000
--- a/interpolation/Imakefile
+++ /dev/null
@@ -1,17 +0,0 @@
-#define DoNormalLib YES
-
-SRCS.F = areachk.F chequal.F clear_c.F csum.F fft99.F fixarea.F iafree.F iagcntl.F iaidef.F iainit.F iaintgg.F iaintll.F iaogdef.F iaoldef.F iarcntl.F iareset.F iarmem.F ibasini.F igalloc.F igbess.F igdins.F igdiwe.F igglat.F iggmem.F iggrid.F igint.F igintr.F iglgrid.F iglrev.F iglsize.F iglsm01.F iglsmb.F iglsmd.F iglsmr.F iglsmst.F ignorm.F igplsm.F igpoleg.F igpolew.F igprec.F igscan.F igsetup.F igsize.F igtog.F igtogr.F igtran.F init_cm.F insane.F intf.F intfa.F intfap.F intfau.F in [...]
-OBJS.F = $(SRCS.F:.F=.o)
-
-SRCS.c = jmalloc.c my_ialloc.c rddefs.c jopnggsm.c jopnllsm.c intlogs.c fftchk.c
-OBJS.c = $(SRCS.c:.c=.o)
-
-SRCS = $(SRCS.F) $(SRCS.c)
-OBJS = $(OBJS.F) $(OBJS.c)
-
-NormalFortranObjectRule()
-NormalLibraryObjectRule()
-NormalLibraryTarget(specgp,$(OBJS))
-InstallLibrary(specgp,$(WHERE))
-
-DependTarget()
diff --git a/interpolation/areachk.F b/interpolation/areachk.F
index c178df0..39006a3 100644
--- a/interpolation/areachk.F
+++ b/interpolation/areachk.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION AREACHK( EW, NS, NORTH, WEST, SOUTH, EAST )
+      INTEGER FUNCTION AREACHK(EW,NS,NORTH,WEST,SOUTH,EAST)
 C
 C---->
 C**** AREACHK
@@ -23,7 +23,7 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = AREACHK( EW, NS, NORTH, WEST, SOUTH, EAST )
+C     IRET = AREACHK(EW,NS,NORTH,WEST,SOUTH,EAST)
 C
 C     Input
 C     -----
@@ -63,8 +63,8 @@ C     Method
 C     ------
 C
 C     If default (0/0/0/0) selected for input, input area is set
-C       - to global for lat/long grid 
-C       - to global for gaussian grid 
+C       - to global for lat/long grid
+C       - to global for gaussian grid
 C
 C     Output area is adjusted to fit the given grid by expanding
 C     the area if necessary.
@@ -124,6 +124,7 @@ C
       INTEGER*8 NWEST, NEAST
 #endif
       CHARACTER*12 YFLAG
+      CHARACTER*1 HTYPE
       INTEGER NGAUSS, NOLD, IRET, KPTS
       DIMENSION KPTS(JPGTRUNC*2)
       DATA NOLD /0/
@@ -189,7 +190,8 @@ C
 C
         IF( NGAUSS.NE.NOLD ) THEN
           NOLD = NGAUSS
-          CALL JGETGG( NOLD, 'F', RGAUSS, KPTS, IRET)
+          HTYPE = 'F'
+          CALL JGETGG(NOLD,HTYPE,RGAUSS,KPTS,IRET)
           IF( IRET.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'AREACHK: Failed to pick up gaussian ', JPQUIET)
@@ -209,20 +211,14 @@ C
 C
 
 
-C Sinisa added if input area is not global
-C because of stagered grids
-      LSUBAR = ( (NIAREA(1).NE.0).AND.(NIAREA(2).NE.0).AND.
-     X           (NIAREA(3).NE.0).AND.(NIAREA(4).NE.0) ) 
-
-          LSTAGGL  = .FALSE.
-      IF( LSUBAR ) THEN
-        IF(IABS(JP360 - NIAREA(4) - NIAREA(2)).LT.1000) THEN
-          LSTAGGL  = .TRUE.
-        ENDIF
-      ENDIF
-
-      LDEFIN = ( (NORTH.EQ.0).AND.(WEST.EQ.0).AND.
-     X           (SOUTH.EQ.0).AND.(EAST.EQ.0) ) 
+C Sinisa added if input area is not global because of stagered grids
+C WARNING: the staggered grid condition does not seem good...
+      LSUBAR  = ( (NIAREA(1).NE.0).AND.(NIAREA(2).NE.0).AND.
+     X            (NIAREA(3).NE.0).AND.(NIAREA(4).NE.0) )
+      LSTAGGL = ( (LSUBAR).AND.
+     X            (IABS(JP360 - NIAREA(4) - NIAREA(2)).LT.1000) )
+      LDEFIN  = ( (NORTH.EQ.0).AND.(WEST.EQ.0).AND.
+     X            (SOUTH.EQ.0).AND.(EAST.EQ.0) )
 C
       IF( LDEFIN ) THEN
 C
@@ -248,6 +244,8 @@ C
         ELSE
 C
 C         Gaussian grid ..
+C WARN: (issue EMOS-199) EAST calculation is only for [F|N] grids, O
+C (octahedral) has a finer resolution at the equator for the same NGAUSS
 C
           INORTH = JNORSGG( 90.0, RGAUSS, NGAUSS, 0)
           NORTH  = RGAUSS(INORTH)
@@ -281,6 +279,8 @@ C
 C
 C       Gaussian grid ..
 C
+C WARN: (issue EMOS-199) EAST calculation is only for [F|N] grids, O
+C (octahedral) has a finer resolution at the equator for the same NGAUSS
         IEW = DNINT( (DBLE(NP90) / DBLE(NGAUSS)) )
 C
       ENDIF
diff --git a/interpolation/auresol.F b/interpolation/auresol.F
index e62ec1f..54771e2 100644
--- a/interpolation/auresol.F
+++ b/interpolation/auresol.F
@@ -86,83 +86,33 @@ C ------------------------------------------------------------------
 C----<
 C
       IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-C
+
 C     Function arguments
-C
       REAL NS, EW
-C
+
 C     Local variables
-C
-C     Function statement(s)
-C
       REAL STEP
-C
+
       STEP = MIN(ABS(NS),ABS(EW))
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-C     2.5 and greater -> T63
-C
-      IF( STEP.GE.2.5 ) THEN
-        AURESOL = 63
-        GOTO 900
-      ENDIF
-C
-C     1.5 to 2.5      -> T106
-C
-      IF( STEP.GE.1.5 ) THEN
-        AURESOL = 106
-        GOTO 900
-      ENDIF
-C
-C     0.6 to 1.5      -> T213
-C
-      IF( STEP.GE.0.6 ) THEN
-        AURESOL = 213
-        GOTO 900
-      ENDIF
-C
-C     0.4 to 0.6      -> T319
-C
-      IF( STEP.GE.0.4 ) THEN
-        AURESOL = 319
-        GOTO 900
-      ENDIF
-C
-C     0.3 to 0.4      -> T511
-C
-      IF( STEP.GE.0.3 ) THEN
-        AURESOL = 511
-        GOTO 900
-      ENDIF
-C
-C     0.15 to 0.3      -> T799
-C
-      IF( STEP.GE.0.15 ) THEN
-        AURESOL = 799
-        GOTO 900
-      ENDIF
-C
-C     0.09 to 0.15      -> T1279
-C
-      IF( STEP.GE.0.09 ) THEN
+      IF( STEP.GE.2.5 ) THEN       ! 2.5  <= step        -> T63
+        AURESOL =   63
+      ELSEIF( STEP.GE.1.5 ) THEN   ! 1.5  <= step < 2.5  -> T106
+        AURESOL =  106
+C     ELSEIF( STEP.GE.0.4 ) THEN   ! 1.5  <= step < 2.5  -> T191
+C       AURESOL =  191
+      ELSEIF( STEP.GE.0.6 ) THEN   ! 0.6  <= step < 1.5  -> T213
+        AURESOL =  213
+      ELSEIF( STEP.GE.0.4 ) THEN   ! 0.4  <= step < 0.6  -> T319
+        AURESOL =  319
+      ELSEIF( STEP.GE.0.3 ) THEN   ! 0.3  <= step < 0.4  -> T511
+        AURESOL =  511
+      ELSEIF( STEP.GE.0.15 ) THEN  ! 0.15 <= step < 0.3  -> T799
+        AURESOL =  799
+      ELSEIF( STEP.GE.0.09 ) THEN  ! 0.09 <= step < 0.15 -> T1279
         AURESOL = 1279
-        GOTO 900
+      ELSE                         ! highest truncation/resolution
+        AURESOL = 2047
       ENDIF
-C
-C     less than 0.09   -> T2047
-C
-      AURESOL = 2047
-C
-  900 CONTINUE
-C
+
       END
 
diff --git a/interpolation/bitmap.h b/interpolation/bitmap.h
index 63b203e..ea71f22 100644
--- a/interpolation/bitmap.h
+++ b/interpolation/bitmap.h
@@ -1,22 +1,17 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
+
 #ifndef BITMAP_H
 #define BITMAP_H
 
-#ifdef INTEGER_IS_LONG
-#define fortint long
-#else
-#define fortint int
-#endif
-
 #ifdef FORTRAN_NO_UNDERSCORE
 #define MAKEMAP makemap
 #define SHOWMAP showmap
@@ -36,4 +31,4 @@ int findCharacter(char * , int , int , char );
 void setBit(char * , int , int , int , int );
 void copyRow(char * , int , int , int , int );
 
-#endif          /* End of BITMAP_H */
+#endif /* end of BITMAP_H */
diff --git a/interpolation/clear_c.F b/interpolation/clear_c.F
index 4d1f84c..3beaf52 100644
--- a/interpolation/clear_c.F
+++ b/interpolation/clear_c.F
@@ -47,8 +47,6 @@ C
 C----<
 C
 C     IMPLICIT NONE
-C
-C
 #include "parim.h"
 #include "nifld.common"
 #include "nifld.extracommon"
@@ -56,10 +54,6 @@ C
 #include "grfixed.h"
 #include "current.h"
 C
-C     Local variables
-C
-      INTEGER IRET, LOOP
-C
 C     ------------------------------------------------------------------
 C*    Section 1.   Initialise
 C     ------------------------------------------------------------------
@@ -121,7 +115,6 @@ C
       LARESOL   = .FALSE.
       LINTOUT   = .FALSE.
       LIMISSV   = .FALSE.
-cs double interpolation
       LDOUBLE   = .FALSE.
 C
       RMISSGV   = REAL(INT_MISSING)
@@ -129,16 +122,12 @@ C
 C     Clear input and output gaussian grid definitions
 C
       NIGAUSS = 0
+      RIGAUSS(1:JPLAT) = 0.0
+      MILLEN (1:JPLAT) = 0
+
       NOGAUSS = 0
-      DO 110 LOOP = 1, JPLAT
-        RIGAUSS(LOOP) = 0.0
-        MILLEN(LOOP) = 0
-  110 CONTINUE
-C
-      DO 120 LOOP = 1, JPLAT
-        ROGAUSS(LOOP) = 0.0
-        NOLPTS(LOOP) = 0
-  120 CONTINUE
+      ROGAUSS(1:JPLAT) = 0.0
+      NOLPTS (1:JPLAT) = 0
 C
 C     Clear information about gaussian field definitions
 C
diff --git a/interpolation/consint.F90 b/interpolation/consint.F90
deleted file mode 100644
index 2ad20b0..0000000
--- a/interpolation/consint.F90
+++ /dev/null
@@ -1,424 +0,0 @@
-SUBROUTINE CONSINT (KLAT_IN, KLON_IN, PLAT_IN, KIN,&
-                         & KLAT_OUT,KLON_OUT,PLAT_OUT,KOUT,&
-                         & PFLD_IN, PFLD_OUT, &
-                         & LDPAR)
-
-!    Purpose.
-!    --------
-!      Conserving bicubic interpolation of grid field from model 
-!      resolution to grid defined by input parameter. Assumes the 
-!      whole field is in memory.
-
-!    Explicit arguments:
-!    -------------------
-
-!    Input:
-!      KLAT_IN  - number of latitude rows of the input grid
-!      KLON_IN  - number of longitudes for each row of the input grid
-!      PLAT_IN  - latitude (degrees) of each row of the input grid
-!      KIN      - size of input array
-!      KLAT_OUT - number of latitude rows of the output grid
-!      KLON_OUT - number of longitudes for each row of the output grid
-!      PLAT_OUT - latitude (degrees) of each row of the output grid
-!      KOUT     - size of output array
-!      PFLD_IN  - array of grid values at input resolution
-
-!    Output:
-!      PFLD_OUT - array of interpolated values
-
-!    Optional:
-!      LDPAR    - parity for extra-polar calculations
-!                 .TRUE. for scalar fields
-!                 .FASE. for vector fields
-
-!    Author.
-!    -------
-!      E. Holm - modification of GRID_BICUBIC by Y.Tremolet
-
-!    Modifications.
-!    --------------
-!      Original: 27/05/04
-!      20050507 Elias Holm: Introduce order and limiter in call and
-!                           generalize code for up to quintic interpolation
-!        Y.Tremolet    26-Jan-2005 Added optional arguments
-!      20080204 Elias Holm: Surface pressure on input/output and
-!                           simplified
-!      20081015 Elias Holm: Simplify and reorder calculations for speed
-!      20101230 Elias Holm: Simplified version without pressure thickness 
-!                           weighting
-!      20110125 Elias Holm: Latitude inputs in degrees
-!     ------------------------------------------------------------------
-
-IMPLICIT NONE
-
-INTEGER,INTENT(IN)    :: KLAT_IN 
-INTEGER,INTENT(IN)    :: KLON_IN(KLAT_IN) 
-REAL   ,INTENT(IN)    :: PLAT_IN(KLAT_IN) 
-INTEGER,INTENT(IN)    :: KIN 
-INTEGER,INTENT(IN)    :: KLAT_OUT 
-INTEGER,INTENT(IN)    :: KLON_OUT(KLAT_OUT) 
-REAL   ,INTENT(IN)    :: PLAT_OUT(KLAT_OUT) 
-INTEGER,INTENT(IN)    :: KOUT 
-REAL   ,INTENT(IN)    :: PFLD_IN(KIN)
-REAL   ,INTENT(OUT)   :: PFLD_OUT(KOUT) 
-LOGICAL, OPTIONAL, INTENT(IN)    :: LDPAR
-
-INTEGER :: IND_IN  (KLAT_IN)
-INTEGER :: ILON_IN (-2:KLAT_IN+3)
-REAL    :: ZLAT_IN (-2:KLAT_IN+3)
-REAL    :: ZLON_IN (-2:KLAT_IN+3)
-REAL    :: ZDLAT_IN(-2:KLAT_IN+3), ZDLATI_IN(-2:KLAT_IN+3)
-REAL    :: ZDLON_IN(-2:KLAT_IN+3), ZDLONI_IN(-2:KLAT_IN+3)
-REAL    :: ZHLAT_IN(-2:KLAT_IN+3)
-REAL    :: ZHLON_IN(-2:KLAT_IN+3)
-REAL    :: ZDHLAT_IN(-2:KLAT_IN+3), ZDHLATI_IN(-2:KLAT_IN+3)
-REAL    :: ZG_IN   (-2:KLAT_IN+3)
-INTEGER :: ILAT_IO  (0:KLAT_OUT)
-REAL    :: ZLAT_OUT (0:KLAT_OUT), ZLON_OUT (1:KLAT_OUT)
-REAL    :: ZDLAT_OUT(1:KLAT_OUT), ZDLON_OUT(1:KLAT_OUT)
-REAL    :: ZHLAT_OUT(1:KLAT_OUT), ZHLON_OUT(1:KLAT_OUT)
-REAL    :: ZG_OUT   (1:KLAT_OUT)
-
-INTEGER :: J, JLAT, JLON, JNUM, JINX, JINY, JINYD, JOUTY,IRET
-INTEGER :: JXMAX_IN, JXMAX_OUT, JYMAX_OUT, IBL
-INTEGER :: JBL, IBL_OUT, JINYSTA, JINYEND, IBLATSTA_OUT(1:KLAT_OUT)
-INTEGER :: IBLATEND_OUT(1:KLAT_OUT), IBLON_OUT(1:KLAT_OUT)
-REAL    :: ZSUM, ZOUT, ZX, ZY, ZY2, ZDHI
-REAL    :: ZC(0:3), ZDC, ZDL, ZDLL, ZDR, ZDRR, ZCC2, ZCC3
-REAL    :: ZMINMOD, ZFRAC, ZCURVLIM, ZLIML, ZLIMR, ZLIM
-REAL    :: ZPARITY, ZPRIMADD
-REAL, ALLOCATABLE :: ZPRIMX(:,:), ZPRIMY(:,:), ZPRIM(:,:), ZFLD_IN(:)
-REAL, ALLOCATABLE :: ZDIFX(:,:), ZDIFY(:,:), ZOUTPRE(:)
-
-REAL    :: RPI, RD2R
-
-!     ------------------------------------------------------------------
-ZMINMOD(ZDC)=(0.5+SIGN(0.5,ZDC))*MIN(1.,ABS(ZDC))
-ZFRAC(ZDC,ZDR)=ZDC/SIGN(ABS(ZDR)+1.E-30,ZDR)
-ZCURVLIM(ZDL,ZDR)=SIGN(MIN(ABS(ZDL),ABS(ZDR)/3.),ZDL)
-
-
-!     *    0. CONSTANTS AND FUNCTIONS
-
-RPI=ACOS(-1.)
-RD2R=RPI/180.
-ZCC2=1.0/1536.
-ZCC3=1.0/15360.
-
-ZPARITY=1.0
-IF (PRESENT(LDPAR)) THEN
-  IF (.NOT.LDPAR) ZPARITY=-1.0
-ENDIF
-
-ALLOCATE(ZFLD_IN(KIN))
-DO J=1,KIN
-  ZFLD_IN(J)=PFLD_IN(J)
-ENDDO
-
-!     *    1. INPUT GRID AND FIELD
-
-!*         1.1 Geometry of input grid
-!              Assuming lat_(j+.5) = 0.5*(lat_(j) + lat_(j+1))
-
-ZLAT_IN(0)      = SIGN(RPI/2.,RD2R*PLAT_IN(1))
-ZLAT_IN(KLAT_IN)= SIGN(RPI/2.,RD2R*PLAT_IN(KLAT_IN))
-JNUM=1
-JXMAX_IN=0
-DO JLAT=1,KLAT_IN
-  IF (JLAT<KLAT_IN) ZLAT_IN(JLAT)=RD2R*0.5*(PLAT_IN(JLAT)+PLAT_IN(JLAT+1))
-  ZDLAT_IN(JLAT)=ABS(ZLAT_IN(JLAT-1)-ZLAT_IN(JLAT))
-  ILON_IN(JLAT)=KLON_IN(JLAT)
-  ZDLON_IN(JLAT)=2.*RPI/ILON_IN(JLAT)
-  IND_IN(JLAT)=JNUM
-  JNUM=JNUM+ILON_IN(JLAT)
-  JXMAX_IN=MAX(JXMAX_IN,ILON_IN(JLAT))
-!              Starting longitude (must be less or equal to zero)
-  ZLON_IN(JLAT)=-ZDLON_IN(JLAT)/2.
-!              Scale factors
-  ZHLON_IN(JLAT) = (SIN(ZLAT_IN(JLAT-1))-SIN(ZLAT_IN(JLAT)))/ZDLAT_IN(JLAT)
-  ZHLAT_IN(JLAT) = 1.
-  ZG_IN(JLAT)=ZHLON_IN(JLAT)*ZHLAT_IN(JLAT)*ZDLON_IN(JLAT)*ZDLAT_IN(JLAT)
-ENDDO
-
-!          1.1.1 Extension over poles
-! Starting longitude for extension over the poles for even ILON_IN is 0.,
-! and for odd ILON_IN shift by half a gridcell to -RPI/ILON_IN.
-
-DO JINY = 1, 3
-  ILON_IN (1-JINY)       = ILON_IN (JINY)
-  ZDLAT_IN(1-JINY)       = ZDLAT_IN(JINY)
-  ZDLON_IN(1-JINY)       = ZDLON_IN(JINY)
-  ZHLAT_IN(1-JINY)       = ZHLAT_IN(JINY)
-  ZHLON_IN(1-JINY)       = ZHLON_IN(JINY)
-  ZG_IN   (1-JINY)       = ZG_IN   (JINY)
-  ZLAT_IN (1-JINY)       = 2.*ZLAT_IN(0)-ZLAT_IN(JINY-1)
-  ZLON_IN(1-JINY)        = ZLON_IN(JINY)&
-                          &+MOD(ILON_IN(1-JINY),2)*RPI/ILON_IN(1-JINY)
-  ILON_IN (KLAT_IN+JINY) = ILON_IN (KLAT_IN+1-JINY)
-  ZDLAT_IN(KLAT_IN+JINY) = ZDLAT_IN(KLAT_IN+1-JINY)
-  ZDLON_IN(KLAT_IN+JINY) = ZDLON_IN(KLAT_IN+1-JINY)
-  ZHLAT_IN(KLAT_IN+JINY) = ZHLAT_IN(KLAT_IN+1-JINY)
-  ZHLON_IN(KLAT_IN+JINY) = ZHLON_IN(KLAT_IN+1-JINY)
-  ZG_IN   (KLAT_IN+JINY) = ZG_IN   (KLAT_IN+1-JINY)
-  ZLAT_IN (KLAT_IN+JINY) = 2.*ZLAT_IN(KLAT_IN)-ZLAT_IN(KLAT_IN-JINY)
-  ZLON_IN (KLAT_IN+JINY) = ZLON_IN (KLAT_IN+1-JINY)&
-                          &+MOD(ILON_IN(KLAT_IN+JINY),2)*RPI/ILON_IN(KLAT_IN+JINY)
-ENDDO
-
-!              1.1.2 Inverses
-ZDLONI_IN(:)=1./ZDLON_IN(:)
-ZDLATI_IN(:)=1./ZDLAT_IN(:)
-ZDHLAT_IN(:)=ZDLAT_IN(:)*ZHLAT_IN(:)
-ZDHLATI_IN(:)=1./ZDHLAT_IN(:)
-
-!*         1.2 Primitive function of input field with respect to longitude
-!              Valid at grid-cell longitude boundaries.
-!              Make an extension zone of +/-3 grid-cells for interpolation.
-!              The extension over the poles shifts fields by RPI.
-
-!          1.2.1 Primitive function
-ALLOCATE(ZPRIMX(-2:JXMAX_IN+3,-2:KLAT_IN+3))
-ALLOCATE(ZDIFX (-2:JXMAX_IN+2,-2:KLAT_IN+3))
-
-DO JLAT=1,KLAT_IN
-  ZSUM=0.
-  DO JLON=1,ILON_IN(JLAT)
-    ZSUM=ZSUM+ZFLD_IN(IND_IN(JLAT)-1+JLON)*ZG_IN(JLAT)
-    ZPRIMX(JLON,JLAT)=ZSUM
-  ENDDO
-ENDDO
-
-!          1.2.2 The extension over the poles shifts fields by RPI.
-
-DO JINY = 1, 3
-  ZSUM=0.
-  DO JLON=1,ILON_IN(1-JINY)
-    JINX = 1 + MOD( ILON_IN(1-JINY)/2 + JLON - 1, ILON_IN(1-JINY) )
-    ZSUM=ZSUM+ZPARITY*ZFLD_IN(IND_IN(JINY)-1+JINX)*ZG_IN(1-JINY)
-    ZPRIMX(JLON,1-JINY) = ZSUM
-  ENDDO
-  ZSUM=0.
-  DO JLON=1,ILON_IN(KLAT_IN+JINY)
-    JINX = 1+MOD( ILON_IN(KLAT_IN+JINY)/2 + JLON - 1, ILON_IN(KLAT_IN+JINY) )
-    ZSUM=ZSUM+ZPARITY*ZFLD_IN(IND_IN(KLAT_IN+1-JINY)-1+JINX)*ZG_IN(KLAT_IN+JINY)
-    ZPRIMX(JLON,KLAT_IN+JINY) = ZSUM
-  ENDDO
-ENDDO
-
-!          1.2.3 Extension in x-direction
-
-DO JINX = 1, 3
-  DO JLAT=-2,KLAT_IN+3
-    ZPRIMX(1-JINX            ,JLAT) =-ZPRIMX(ILON_IN(JLAT),JLAT)&
-                                    &+ZPRIMX(ILON_IN(JLAT)+1-JINX,JLAT)
-    ZPRIMX(ILON_IN(JLAT)+JINX,JLAT) = ZPRIMX(ILON_IN(JLAT),JLAT)&
-                                    &+ZPRIMX(JINX,JLAT)
-  ENDDO
-ENDDO
-
-!              1.2.5 Difference of primitive function
-
-DO JLAT=-2,KLAT_IN+3
-  DO JLON=-2,ILON_IN(JLAT)+2
-    ZDIFX(JLON,JLAT)=ZPRIMX(JLON+1,JLAT)-ZPRIMX(JLON,JLAT)
-  ENDDO
-ENDDO
-
-
-
-!     *    2. OUTPUT GRID AND FIELD
-
-!*         2.1 Geometry of output grid
-!              Output grid can be finer or coarser than input grid.
-!              Therefore dimensioning [KLAT_IN/KLAT_OUT]+4+1
-!              to allow for 4th order interpolation of primitive
-!              function wrt latitude at top and bottom of grid-cell
-!              boundaries (output latitudes).
-
-!          2.1.1 Grid blocks with constant longitude spacing
-
-IBL_OUT = 1
-IBLATSTA_OUT(1) = 1
-IBLON_OUT(1) = KLON_OUT(1)
-DO JLAT=2,KLAT_OUT
-  IF((KLON_OUT(JLAT)/=KLON_OUT(JLAT-1)) .OR. (JLAT == KLAT_OUT/2))THEN
-    IBL_OUT = IBL_OUT + 1
-    IBLATEND_OUT(IBL_OUT-1) = JLAT-1
-    IBLATSTA_OUT(IBL_OUT) = JLAT
-    IBLON_OUT(IBL_OUT) = KLON_OUT(JLAT)
-  ENDIF
-ENDDO
-IBLATEND_OUT(IBL_OUT)=KLAT_OUT
-
-!          2.1.2 Latitudes and scale factors
-
-ZLAT_OUT(0)       = SIGN(RPI/2.,RD2R*PLAT_OUT(1))
-ZLAT_OUT(KLAT_OUT)= SIGN(RPI/2.,RD2R*PLAT_OUT(KLAT_OUT))
-DO JLAT=1,KLAT_OUT
-  IF (JLAT<KLAT_OUT) ZLAT_OUT(JLAT)=RD2R*0.5*(PLAT_OUT(JLAT)+PLAT_OUT(JLAT+1))
-  ZDLAT_OUT(JLAT)=ABS(ZLAT_OUT(JLAT-1)-ZLAT_OUT(JLAT))
-  ZDLON_OUT(JLAT)=2.*RPI/KLON_OUT(JLAT)
-!              Starting longitude (must be less or equal to zero)
-  ZLON_OUT(JLAT)=-ZDLON_OUT(JLAT)/2.
-!              Scale factors
-  ZHLON_OUT(JLAT) = ABS(SIN(ZLAT_OUT(JLAT-1))-SIN(ZLAT_OUT(JLAT)))/ZDLAT_OUT(JLAT)
-  ZHLAT_OUT(JLAT) = 1.
-  ZG_OUT(JLAT) = ZHLON_OUT(JLAT)*ZHLAT_OUT(JLAT)*ZDLON_OUT(JLAT)*ZDLAT_OUT(JLAT)
-ENDDO
-
-!          2.1.3 Closest input row above each output row
-
-ILAT_IO(0)=0
-DO JLAT=1,KLAT_OUT
-  ILAT_IO(JLAT)=ILAT_IO(JLAT-1)
-  DO WHILE (ZLAT_IN(ILAT_IO(JLAT)) > ZLAT_OUT(JLAT))
-    ILAT_IO(JLAT)=ILAT_IO(JLAT)+1
-  ENDDO
-  ILAT_IO(JLAT)=ILAT_IO(JLAT)-1
-ENDDO
-JXMAX_OUT=0
-JYMAX_OUT=0
-DO JBL=1, IBL_OUT
-  JXMAX_OUT = MAX(JXMAX_OUT,IBLON_OUT(JBL))
-  JYMAX_OUT = MAX(JYMAX_OUT,IBLATEND_OUT(JBL)-IBLATSTA_OUT(JBL)+1)
-ENDDO
-
-  
-!*         2.2 Interpolation of primitive function
-
-JNUM=0
-ALLOCATE(ZPRIM(0:JXMAX_OUT,-3:3+KLAT_IN))
-ALLOCATE(ZDIFY(1:JXMAX_OUT,-3:3+KLAT_IN))
-ALLOCATE(ZPRIMY(0:JXMAX_OUT,0:JYMAX_OUT))
-ALLOCATE(ZOUTPRE(0:JXMAX_OUT))
-DO JBL=1, IBL_OUT
-
-!          2.2.1 Interpolate PF of input field with respect to longitude
-!                to output grid-cell longitude boundaries.
-!                (output longitude / input latitude)
-
-  JINYSTA=ILAT_IO(IBLATSTA_OUT(JBL)-1)
-  JINYEND=ILAT_IO(IBLATEND_OUT(JBL))
-  JINYD=JINYEND-JINYSTA
-  DO JLON=0,IBLON_OUT(JBL)
-    ZPRIM(JLON,-3)=0.
-    ZOUTPRE(JLON)=ZLON_OUT(IBLATSTA_OUT(JBL))+JLON*ZDLON_OUT(IBLATSTA_OUT(JBL))
-  ENDDO
-  DO JINY=JINYSTA-2,JINYEND+3
-    DO JLON=0,IBLON_OUT(JBL)
-      ZOUT =  ZOUTPRE(JLON)-ZLON_IN(JINY)
-      ZPRIMADD=0.
-      IF (ZOUT<0.) THEN
-        ZOUT    = ZOUT+ILON_IN(JINY)*ZDLON_IN(JINY)
-        ZPRIMADD=-ZPRIMX(ILON_IN(JINY),JINY)
-      ENDIF
-      IF (ZOUT>ILON_IN(JINY)*ZDLON_IN(JINY)) THEN
-        ZOUT    = ZOUT-ILON_IN(JINY)*ZDLON_IN(JINY)
-        ZPRIMADD= ZPRIMX(ILON_IN(JINY),JINY)
-      ENDIF
-      JINX=INT(ZOUT*ZDLONI_IN(JINY))
-      ZX=-1.+2.*(ZOUT-JINX*ZDLON_IN(JINY))*ZDLONI_IN(JINY)
-!          2.2.1.1 Basic coefficients
-      ZDLL=ZDIFX(JINX-2,JINY)
-      ZDL =ZDIFX(JINX-1,JINY)
-      ZDC =ZDIFX(JINX  ,JINY)
-      ZDR =ZDIFX(JINX+1,JINY)
-      ZDRR=ZDIFX(JINX+2,JINY)
-      ZC(0) = (ZPRIMX(JINX+1,JINY)+ZPRIMX(JINX  ,JINY))*.5
-      ZC(1) = ZDC*.5
-!          2.2.1.2 Economization of the power series (5th to 3rd order)
-      ZC(2)=(130.*(ZDR-ZDL)-17.*(ZDRR-ZDLL))*ZCC2
-      ZC(3)=(452.*(ZDR-2.*ZDC+ZDL)-33.*(ZDRR-2.*ZDC+ZDLL))*ZCC3
-!          2.2.1.3 Limiting
-      ZC(3) = ZCURVLIM(ZC(3),ZC(2))
-      ZLIMR = ZMINMOD( ZFRAC( (ZDR-ZDC)*.5,       2.*( ZC(2)+ZC(3) ) ) )
-      ZLIML = ZMINMOD( ZFRAC( (ZDL-ZDC)*.5, ZLIMR*2.*(-ZC(2)+ZC(3) ) ) )
-      ZLIM  = ZLIMR*ZLIML
-      ZC(2) = ZLIM*ZC(2)
-      ZC(3) = ZLIM*ZC(3)
-!          2.2.1.5 Evaluation
-      ZPRIM(JLON,JINY-JINYSTA)= ZC(0)+ZC(1)*ZX   &
-                 & +(ZX*ZX-1.)*(ZC(2)+ZC(3)*ZX)   &
-                 & +ZPRIMADD
-    ENDDO
-  ENDDO
-
-!          2.2.2  Differentiate wrt longitude
-
-  DO JINY=-2,3+JINYD
-    ZDHI = 1./(ZDLON_OUT(IBLATSTA_OUT(JBL))*ZHLON_IN(JINYSTA+JINY))
-    DO JLON=IBLON_OUT(JBL),1,-1
-      ZPRIM(JLON,JINY) = (ZPRIM(JLON,JINY)-ZPRIM(JLON-1,JINY))*ZDHI
-    ENDDO
-  ENDDO
-
-!          2.2.3 PF wrt latitude and scalefactor*cellarea (G=h_y, dA=dy ==> G*dA)
-!                (output longitude / input latitude)
-
-  DO JINY=-2,3+JINYD
-    DO JLON=1, IBLON_OUT(JBL)
-      ZPRIM(JLON,JINY)= ZPRIM(JLON,JINY-1)+ZPRIM(JLON,JINY)
-    ENDDO
-  ENDDO
-  DO JINY=-2,2+JINYD
-    DO JLON=1, IBLON_OUT(JBL)
-      ZDIFY(JLON,JINY) = (ZPRIM(JLON,JINY+1)-ZPRIM(JLON,JINY))*ZDHLATI_IN(JINYSTA+JINY+1)
-    ENDDO
-  ENDDO
-
-!          2.2.4 Interpolation PF to output latitude cell boundaries
-
-  DO JOUTY = 0, IBLATEND_OUT(JBL)-IBLATSTA_OUT(JBL)+1
-    JLAT =         JOUTY+IBLATSTA_OUT(JBL)-1
-    JINY = ILAT_IO(JOUTY+IBLATSTA_OUT(JBL)-1)-JINYSTA
-    ZY=-1.+2.*(-ZLAT_OUT(JLAT)+ZLAT_IN(JINYSTA+JINY))*ZDLATI_IN(JINYSTA+JINY+1)
-    ZY2 = (ZY*ZY-1.)
-    DO JLON=1, IBLON_OUT(JBL)
-!          2.2.4.1 Basic coefficients
-      ZDLL=ZDIFY(JLON,JINY-2)
-      ZDL =ZDIFY(JLON,JINY-1)
-      ZDC =ZDIFY(JLON,JINY  )
-      ZDR =ZDIFY(JLON,JINY+1)
-      ZDRR=ZDIFY(JLON,JINY+2)
-      ZC(0) = (ZPRIM(JLON,JINY+1)+ZPRIM(JLON,JINY))*.5
-      ZC(1) = ZDC*.5
-!          2.2.1.2 Economization of the power series (5th to 3rd order)
-      ZC(2)=(130.*(ZDR-ZDL)-17.*(ZDRR-ZDLL))*ZCC2
-      ZC(3)=(452.*(ZDR-2.*ZDC+ZDL)-33.*(ZDRR-2.*ZDC+ZDLL))*ZCC3
-!          2.2.1.3 Limiting
-      ZC(3) = ZCURVLIM(ZC(3),ZC(2))
-      ZLIMR = ZMINMOD( ZFRAC( (ZDR-ZDC)*.5,       2.*( ZC(2)+ZC(3) ) ) )
-      ZLIML = ZMINMOD( ZFRAC( (ZDL-ZDC)*.5, ZLIMR*2.*(-ZC(2)+ZC(3) ) ) )
-      ZLIM  = ZLIMR*ZLIML
-      ZC(2) = ZLIM*ZC(2)
-      ZC(3) = ZLIM*ZC(3)
-!          2.2.5.4 Back to real coefficients
-      ZC(1:3) = ZDHLAT_IN(JINYSTA+JINY+1)*ZC(1:3)
-!          2.2.4.5 Evaluation
-      ZPRIMY(JLON,JOUTY)= ZC(0)+ZC(1)*ZY+ZY2*(ZC(2)+ZC(3)*ZY)
-    ENDDO
-  ENDDO
-
-!          2.2.5 Take difference of primitive function to get output field
-!                (output longitude / output latitude)
-
-  DO JOUTY = 1, IBLATEND_OUT(JBL)-IBLATSTA_OUT(JBL)+1
-    JLAT = JOUTY+IBLATSTA_OUT(JBL)-1
-    ZDHI = 1./(ZDLAT_OUT(JLAT)*ZHLAT_OUT(JLAT))
-    DO JLON=1, IBLON_OUT(JBL)
-      JNUM=JNUM+1
-      PFLD_OUT(JNUM) =  (ZPRIMY(JLON,JOUTY)-ZPRIMY(JLON,JOUTY-1))*ZDHI
-    ENDDO
-  ENDDO
-ENDDO
-IF (ALLOCATED(ZPRIM ))  DEALLOCATE(ZPRIM )
-IF (ALLOCATED(ZPRIMY))  DEALLOCATE(ZPRIMY)
-IF (ALLOCATED(ZDIFY))   DEALLOCATE(ZDIFY)
-IF (ALLOCATED(ZOUTPRE)) DEALLOCATE(ZOUTPRE)
-
-IF (ALLOCATED(ZPRIMX)) DEALLOCATE(ZPRIMX)
-IF (ALLOCATED(ZFLD_IN)) DEALLOCATE(ZFLD_IN)
-IF (ALLOCATED(ZDIFX)) DEALLOCATE(ZDIFX)
-
-
-END SUBROUTINE CONSINT
diff --git a/interpolation/copy_spec_from_ksec.c b/interpolation/copy_spec_from_ksec.c
new file mode 100644
index 0000000..c23d4b6
--- /dev/null
+++ b/interpolation/copy_spec_from_ksec.c
@@ -0,0 +1,239 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+
+
+#include "grib_api.h"
+#include "emos.h"
+#include <assert.h>
+
+extern int mars_interpolation;
+
+#define SET_EXTRA_LONG(x,y)     do { assert(packing_spec->extra_settings_count<80); packing_spec->extra_settings[packing_spec->extra_settings_count].name = #x; packing_spec->extra_settings[packing_spec->extra_settings_count].type = GRIB_TYPE_LONG;   packing_spec->extra_settings[packing_spec->extra_settings_count].long_value = y; packing_spec->extra_settings_count++; } while(0)
+#define SET_EXTRA_DOUBLE(x,y)   do { assert(packing_spec->extra_settings_count<80); packing_spec->extra_settings[packing_spec->extra_settings_count].name = #x; packing_spec->extra_settings[packing_spec->extra_settings_count].type = GRIB_TYPE_DOUBLE; packing_spec->extra_settings[packing_spec->extra_settings_count].double_value = y; packing_spec->extra_settings_count++; } while(0)
+
+
+int copy_spec_from_ksec(grib_util_grid_spec* spec,grib_util_packing_spec* packing_spec) {
+    int err=0;
+
+    fortint isec1[ISECTION_1] = {0,};
+    fortint isec2[ISECTION_2] = {0,};
+    fortint isec3[ISECTION_3] = {0,};
+    fortint isec4[ISECTION_4] = {0,};
+
+    fortfloat rsec2[ISECTION_2] = {0,};
+    fortfloat zsec3[ISECTION_3] = {0,};
+
+    long    rg_def[ISECTION_2] = {0,};
+    char *intf2_debug = getenv("INTF2_DEBUG");
+
+    if((err = int2_gasetup( isec1, isec2, isec3, isec4, rsec2, zsec3 )) != 0)
+    {
+        return err;
+    }
+
+    memset(spec,         0, sizeof(grib_util_grid_spec));
+    memset(packing_spec, 0, sizeof(grib_util_packing_spec));
+
+    switch (isec4[3]) {
+        case 1:
+            packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX;
+            break;
+        case 2:
+            packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE;
+            packing_spec->packing      = GRIB_UTIL_PACKING_USE_PROVIDED;
+            break;
+        case 3:
+            packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_JPEG;
+            break;
+        case 4:
+            packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;
+            break;
+        case 7:
+            packing_spec->packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER;
+            break;
+        default :
+            printf("invalid isec4[3] = %d\n",isec4[3]);
+            abort();
+    }
+    packing_spec->bitsPerValue     = isec4[1];
+
+    /* TODO: get that from emoslib */
+    if(intf2_debug){
+        printf("YYYYYYYYYY  packing: %d    -----  bitsPerValue: %d \n", isec4[3],isec4[1]);
+        printf("missing value XXXXXXXXXX %f\n", zsec3[1]);
+    }
+
+    spec->missingValue = zsec3[1];
+
+
+    if(intf2_debug){
+        printf("missing value XXXXXXXXXX %f \n", spec->missingValue);
+        printf("SIZES double=%d  fortfloat=%d\n", sizeof(double), sizeof(fortfloat));
+        printf("is BITMAP present %d\n", isec1[4]);
+    }
+
+    switch(isec2[0]) {
+
+        case 0:
+        case 10:
+            spec->grid_type                          = GRIB_UTIL_GRID_SPEC_REGULAR_LL;
+            spec->Nj                                 = isec2[2];
+            spec->Ni                                 = isec2[1];
+
+            /* EMOS-214: pick REAL values from parallel data structure rsec2 (the ones requiring sub-millidegree precision) */
+            spec->iDirectionIncrementInDegrees       = rsec2[8];  /* isec2[8]/1000.0; */
+            spec->jDirectionIncrementInDegrees       = rsec2[9];  /* isec2[9]/1000.0; */
+
+            spec->latitudeOfFirstGridPointInDegrees  = rsec2[3];  /* isec2[3]/1000.0; */
+            spec->longitudeOfFirstGridPointInDegrees = rsec2[4];  /* isec2[4]/1000.0; */
+            spec->latitudeOfLastGridPointInDegrees   = rsec2[6];  /* isec2[6]/1000.0; */
+            spec->longitudeOfLastGridPointInDegrees  = rsec2[7];  /* isec2[7]/1000.0; */
+
+            if (isec2[0]==10) {
+                spec->grid_type                        = GRIB_UTIL_GRID_SPEC_ROTATED_LL;
+                spec->uvRelativeToGrid                 = isec2[18]==8 ? 1 : 0;
+                spec->latitudeOfSouthernPoleInDegrees  = rsec2[12];  /* isec2[12]/1000.0; */
+                spec->longitudeOfSouthernPoleInDegrees = rsec2[13];  /* isec2[13]/1000.0; */
+            }
+
+            spec->bitmapPresent = (isec1[4]==192 || isec1[4]==64)? 1:0;
+
+            break;
+
+        case 4:
+            spec->grid_type                          = GRIB_UTIL_GRID_SPEC_REGULAR_GG;
+            spec->Nj                                 = isec2[2];
+            spec->Ni                                 = isec2[1];
+            spec->N                                  = isec2[9];
+            if (isec2[16]!=0) {
+                spec->grid_type = GRIB_UTIL_GRID_SPEC_REDUCED_GG;
+
+                /* allocate & copy pl array */
+                spec->pl_size = (long)(isec2[2]);
+                long* pl = (long*)malloc( spec->pl_size * sizeof(long) );
+                assert(pl);
+                long i;
+                for (i=0; i<spec->pl_size; ++i) {
+                    pl[i] = isec2[22+i];
+                }
+                assert(!spec->pl);
+                spec->pl = pl;
+            }
+            else {
+
+                /* EMOS-214: pick REAL values from parallel data structure rsec2 (the ones requiring sub-millidegree precision) */
+                spec->iDirectionIncrementInDegrees   = rsec2[8];  /* isec2[8]/1000.0; */
+
+            }
+
+            /* EMOS-214: pick REAL values from parallel data structure rsec2 (the ones requiring sub-millidegree precision) */
+            spec->latitudeOfFirstGridPointInDegrees  = rsec2[3];  /* isec2[3]/1000.0; */
+            spec->longitudeOfFirstGridPointInDegrees = rsec2[4];  /* isec2[4]/1000.0; */
+            spec->latitudeOfLastGridPointInDegrees   = rsec2[6];  /* isec2[6]/1000.0; */
+            spec->longitudeOfLastGridPointInDegrees  = rsec2[7];  /* isec2[7]/1000.0; */
+
+            spec->bitmapPresent = (isec1[4]==192 || isec1[4]==64)? 1:0;
+
+
+            /* grib_api to set global area in full precision for gaussian grid */
+            packing_spec->extra_settings_count=1;
+            packing_spec->extra_settings[0].type = GRIB_TYPE_LONG;
+            packing_spec->extra_settings[0].name = "global";
+            packing_spec->extra_settings[0].long_value = int2_global();
+
+            break;
+
+        case 14:
+            spec->grid_type                          = GRIB_UTIL_GRID_SPEC_ROTATED_GG;
+            spec->Nj                                 = isec2[2];
+            spec->Ni                                 = isec2[1];
+            spec->N                                  = isec2[9];
+
+            /* EMOS-214: pick REAL values from parallel data structure rsec2 (the ones requiring sub-millidegree precision) */
+            spec->iDirectionIncrementInDegrees       = rsec2[8];  /* isec2[8]/1000.0; */
+
+            if (isec2[16]!=0) {
+                /* There is no rotated-reduced, is there ? */
+                abort();
+            }
+
+            /* EMOS-214: pick REAL values from parallel data structure rsec2 (the ones requiring sub-millidegree precision) */
+            spec->latitudeOfFirstGridPointInDegrees  = rsec2[3];  /* isec2[3]/1000.0; */
+            spec->longitudeOfFirstGridPointInDegrees = rsec2[4];  /* isec2[4]/1000.0; */
+            spec->latitudeOfLastGridPointInDegrees   = rsec2[6];  /* isec2[6]/1000.0; */
+            spec->longitudeOfLastGridPointInDegrees  = rsec2[7];  /* isec2[7]/1000.0; */
+
+            spec->latitudeOfSouthernPoleInDegrees    = rsec2[12];  /* isec2[12]/1000.0; */
+            spec->longitudeOfSouthernPoleInDegrees   = rsec2[13];  /* isec2[13]/1000.0; */
+
+            spec->bitmapPresent = (isec1[4]==192 || isec1[4]==64)? 1:0;
+
+            break;
+
+
+        case 50:
+            spec->grid_type = GRIB_UTIL_GRID_SPEC_SH;
+            spec->truncation = isec2[1]; /* truncationJ */
+            packing_spec->truncateLaplacian=1;
+
+            break;
+
+        case 26:
+            spec->grid_type = GRIB_UTIL_GRID_SPEC_REDUCED_LL;
+            break;
+
+        default:
+            fprintf(stdout,"INTF2: ERROR - unknown repres: %d\n", isec2[0]);
+            return -2;
+            break;
+    }
+
+    /* ocean special case */
+    if (isec1[36]==4) {
+        /* Bitmap always present for ocean */
+
+        SET_EXTRA_LONG(dataRepresentationType , (isec1[59] == 3 && isec1[60] == 4)? 0 : 192);
+        SET_EXTRA_LONG(coordinate4OfFirstGridPoint,isec1[61]);
+        SET_EXTRA_LONG(coordinate3OfFirstGridPoint,isec1[62]);
+        SET_EXTRA_LONG(coordinate4OfLastGridPoint,isec1[63]);
+        SET_EXTRA_LONG(coordinate3OfLastGridPoint,isec1[64]);
+        SET_EXTRA_LONG(iIncrement,isec1[65]);
+        SET_EXTRA_LONG(jIncrement,isec1[66]);
+        SET_EXTRA_LONG(flagForNormalOrStaggeredGrid,isec1[68]);
+        SET_EXTRA_LONG(flagForIrregularGridCoordinateList,0);
+        SET_EXTRA_LONG(numberInTheGridCoordinateList,0);
+        SET_EXTRA_LONG(flagShowingPostAuxiliaryArrayInUse,0);
+        SET_EXTRA_LONG(flagShowingPostAuxiliaryArrayInUse,1);
+        SET_EXTRA_LONG(sizeOfPostAuxiliaryArrayPlusOne,0);
+
+    }
+
+#define D(a) if(intf2_debug) printf("YYYYYYYYYYYY %s -> %g\n", #a, (double)spec->a);
+    D(grid_type);
+    D(Ni);
+    D(Nj);
+    D(iDirectionIncrementInDegrees);
+    D(jDirectionIncrementInDegrees);
+    D(longitudeOfFirstGridPointInDegrees);
+    D(longitudeOfLastGridPointInDegrees);
+    D(latitudeOfFirstGridPointInDegrees);
+    D(latitudeOfLastGridPointInDegrees);
+    D(latitudeOfSouthernPoleInDegrees);
+    D(longitudeOfSouthernPoleInDegrees);
+    D(N);
+    D(bitmapPresent);
+    D(missingValue);
+    D(pl_size);
+    D(truncation);
+#undef D
+
+    return 0;
+}
diff --git a/interpolation/csum.F b/interpolation/csum.F
deleted file mode 100644
index 4ee5953..0000000
--- a/interpolation/csum.F
+++ /dev/null
@@ -1,80 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      COMPLEX FUNCTION CSUM (KN, UVEC, KNCX)                         
-C                                                                       
-C---->
-C**** *CSUM* - ROUTINE WHICH IMPLEMENTS THE BLAS ROUTINE OF THE         
-C              SAME NAME                                                
-C                                                                       
-C     PURPOSE.                                                          
-C     --------                                                          
-C                                                                       
-C     SIMPLE REPLACEMENT FOR IBM                                        
-C                                                                       
-C**   INTERFACE.                                                        
-C     ----------                                                        
-C                                                                       
-C     * CV = CSUM (KN, UVEC, KNCX) *                                    
-C                                                                       
-C                                                                       
-C     METHOD.                                                           
-C     -------                                                           
-C                                                                       
-C     CREATE COMPLEX SUM OF COMPLEX VECTOR                              
-C                                                                       
-C     EXTERNALS.                                                        
-C     ----------                                                        
-C                                                                       
-C     NONE                                                              
-C                                                                       
-C     REFERENCE.                                                        
-C     ----------                                                        
-C                                                                       
-C     NONE                                                              
-C                                                                       
-C     AUTHOR.                                                           
-C     -------                                                           
-C                                                                       
-C     K. FIELDING         * ECMWF *     FEB 1992.                       
-C                                                                       
-C     MODIFICATIONS.                                                    
-C     --------------                                                    
-C                                                                       
-C     NONE                                                              
-C                                                                       
-C     COMMON BLOCKS USED                                                
-C     -------------------                                               
-C                                                                       
-C     NONE                                                              
-C                                                                       
-C----<
-      INTEGER KN, KNCX                                                  
-      COMPLEX UVEC (*)                                               
-C                                                                       
-      INTEGER IP                                                        
-      COMPLEX CHOLD                                                  
-C                                                                       
-C     1.    MAIN LOOP OF CODE                                           
-C           ----------------------------------------------              
-C                                                                       
-  100 CONTINUE                                                          
-      CHOLD = (0.0D0, 0.0D0)                                            
-C                                                                       
-      DO 110 IP = 0, KN - 1                                             
-         CHOLD = CHOLD + UVEC (1 + IP * KNCX)                           
-  110 CONTINUE                                                          
-C                                                                       
-      CSUM = CHOLD                                                      
-C                                                                       
-C     END OF ROUTINE                                                    
-C                                                                       
-      RETURN                                                            
-      END                                                               
diff --git a/interpolation/current.h b/interpolation/current.h
index 6d0488f..ce1f316 100644
--- a/interpolation/current.h
+++ b/interpolation/current.h
@@ -1,11 +1,11 @@
 C
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 C**** "current.h"
@@ -28,12 +28,10 @@ C     NIGAUSO - Resolution of input gaussian field definition
 C               currently held in RIGAUSS, MILLEN.
 C     NOGAUSO - Resolution of output gaussian field definition
 C               currently held in ROGAUSS, NOLPTS.
-C     HIGAUST - Type (R,F,U) of input gaussian field definition
+C     HIGAUST - Type (R,O,F,U) of input gaussian field definition
 C               currently held in RIGAUSS, MILLEN.
-C     HOGAUST - Type (R,F,U) of output gaussian field definition
+C     HOGAUST - Type (R,O,F,U) of output gaussian field definition
 C               currently held in ROGAUSS, NOLPTS.
-C     HIGAUST
-C     HOGAUST
 C
 C     Author
 C     ______
diff --git a/interpolation/debug.h b/interpolation/debug.h
deleted file mode 100644
index 2d21c38..0000000
--- a/interpolation/debug.h
+++ /dev/null
@@ -1,97 +0,0 @@
-C
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-C**** "debug.h" - This include file contains a set of basic constants
-C                 interpolation
-C
-C     PURPOSE
-C     _______
-C
-C     Basic constants for the interpolation library
-C
-C     INTERFACE
-C     _________
-C
-C     #include "debug.h"
-C
-C     Input parameters
-C     ________________
-C
-C     NONE
-C
-C     Common block usage
-C     __________________
-C
-C     NONE
-C
-C     EXTERNALS
-C     _________
-C
-C     NONE
-C
-C     METHOD
-C     ______
-C
-C     NONE
-C
-C     REFERENCE
-C     _________
-C
-C     NONE
-C
-C     COMMENTS
-C     ________
-C
-C     Contains sections 0 to 4
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Dec 1993
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     NONE
-C
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Area definitions which are really local
-C     _______________________________________________________
-C
-      COMMON /DEBUG/ IIAREA, IOAREA
diff --git a/grib_api_merging/describe_input_field.c b/interpolation/describe_input_field.c
old mode 100755
new mode 100644
similarity index 100%
rename from grib_api_merging/describe_input_field.c
rename to interpolation/describe_input_field.c
diff --git a/interpolation/dpath_tables_interpol.F b/interpolation/dpath_tables_interpol.F
deleted file mode 100644
index 25df21e..0000000
--- a/interpolation/dpath_tables_interpol.F
+++ /dev/null
@@ -1,129 +0,0 @@
-C Copyright 1981-2015 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities
-C granted to it by virtue of its status as an intergovernmental organisation
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION DPATH_TABLES_INTERPOL(DPATH)
-C
-C---->
-C**** DPATH_TABLES_INTERPOL
-C
-C     Purpose
-C     -------
-C
-C     This routine returns the directory path for interpolation tables.
-C     Returned path (as argument) has path separator suffixed (/).
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = DPATH_TABLES_INTERPOL(DPATH)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     DPATH - argument in which tables directory path is returned
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     DPATH_TABLES_INTERPOL - length of path string, 0 if not successful
-C
-C
-C     Method
-C     ------
-C
-C     It respects this order (each overriding the previous, if set):
-C     - suitable default value
-C     - compile-time definition of INTERPOL_TABLES_PATH
-C     - run-time env. variable EMOSLIB_FILES
-C     - ...                    HIRLAM_LSM_PATH
-C     - ...                    MARS_LSM_PATH
-C
-C
-C     Externals
-C     ---------
-C
-C     GETENV  - Read environment variable
-C
-C
-C     Author
-C     ------
-C
-C     P. Maciel      ECMWF      February 2015
-C
-C----<
-
-
-C*    Section 0. Definition of variables
-      IMPLICIT NONE
-
-      CHARACTER*256 DPATH
-      CHARACTER*256 TMPDPATH
-      INTEGER IDX
-
-      CHARACTER*13  ENVPATH1
-      CHARACTER*15  ENVPATH2
-      CHARACTER*13  ENVPATH3
-      CHARACTER*39  DEFPATH1
-      CHARACTER*256 DEFPATH2
-
-      PARAMETER (ENVPATH1 = 'EMOSLIB_FILES')
-      PARAMETER (ENVPATH2 = 'HIRLAM_LSM_PATH')
-      PARAMETER (ENVPATH3 = 'MARS_LSM_PATH')
-      PARAMETER (DEFPATH1 = '/usr/local/apps/libemos/tables/interpol')
-#ifdef INTERPOL_TABLES_PATH
-      DATA DEFPATH2 /
-     x INTERPOL_TABLES_PATH
-     X/
-#else
-      DATA DEFPATH2 / ' ' /
-#endif
-
-
-C*    Section 1. initialize: reset paths and return value
-  100 CONTINUE
-      DPATH = ' '
-      TMPDPATH = ' '
-      DPATH_TABLES_INTERPOL = 0;
-
-
-C*    Section 2. Attempt reading env. variables, in order of priority
-  200 CONTINUE
-      CALL GETENV(ENVPATH3,TMPDPATH)
-      IF (INDEX(TMPDPATH,' ').EQ.1) CALL GETENV(ENVPATH2,TMPDPATH)
-      IF (INDEX(TMPDPATH,' ').EQ.1) CALL GETENV(ENVPATH1,TMPDPATH)
-
-      IDX = INDEX(TMPDPATH,' ') - 1
-      IF (IDX.GT.0) THEN
-        DPATH = TMPDPATH(1:IDX)
-        GOTO 900
-      END IF
-
-
-C*    Section 3. set default, possibly overriden by compile definition
-C     (definition is for base directory, so interpol/ need appending)
-  300 CONTINUE
-      DPATH = DEFPATH1
-      IDX = INDEX(DEFPATH2,' ') - 1
-      IF (IDX.GT.0) DPATH = DEFPATH2(1:IDX) // '/interpol'
-
-
-C*    Section 9. Append /, return path string length (otherwise zero)
-  900 CONTINUE
-      IDX = INDEX(DPATH,' ')
-      IF (IDX.GT.1) THEN
-        DPATH(IDX:IDX) = '/'
-        DPATH_TABLES_INTERPOL = IDX
-      END IF
-      RETURN
-      END
-
diff --git a/interpolation/dpath_tables_interpol.F90 b/interpolation/dpath_tables_interpol.F90
new file mode 100644
index 0000000..cb51b24
--- /dev/null
+++ b/interpolation/dpath_tables_interpol.F90
@@ -0,0 +1,129 @@
+! Copyright 1981-2015 ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence
+! Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities
+! granted to it by virtue of its status as an intergovernmental organisation
+! nor does it submit to any jurisdiction.
+!
+
+      INTEGER FUNCTION DPATH_TABLES_INTERPOL(DPATH)
+!
+!---->
+!**** DPATH_TABLES_INTERPOL
+!
+!     Purpose
+!     -------
+!
+!     This routine returns the directory path for interpolation tables.
+!     Returned path (as argument) has path separator suffixed (/).
+!
+!
+!     Interface
+!     ---------
+!
+!     IRET = DPATH_TABLES_INTERPOL(DPATH)
+!
+!
+!     Input parameters
+!     ----------------
+!
+!     DPATH - argument in which tables directory path is returned
+!
+!
+!     Output parameters
+!     -----------------
+!
+!     DPATH_TABLES_INTERPOL - length of path string, 0 if not successful
+!
+!
+!     Method
+!     ------
+!
+!     It respects this order (each overriding the previous, if set):
+!     - suitable default value
+!     - compile-time definition of INTERPOL_TABLES_PATH
+!     - run-time env. variable EMOSLIB_FILES
+!     - ...                    HIRLAM_LSM_PATH
+!     - ...                    MARS_LSM_PATH
+!
+!
+!     Externals
+!     ---------
+!
+!     GETENV  - Read environment variable
+!
+!
+!     Author
+!     ------
+!
+!     P. Maciel      ECMWF      February 2015
+!
+!----<
+
+
+!*    Section 0. Definition of variables
+      IMPLICIT NONE
+
+      CHARACTER*256 DPATH
+      CHARACTER*256 TMPDPATH
+      INTEGER IDX
+
+      CHARACTER*13  ENVPATH1
+      CHARACTER*15  ENVPATH2
+      CHARACTER*13  ENVPATH3
+      CHARACTER*39  DEFPATH1
+      CHARACTER*256 DEFPATH2
+
+      PARAMETER (ENVPATH1 = 'EMOSLIB_FILES')
+      PARAMETER (ENVPATH2 = 'HIRLAM_LSM_PATH')
+      PARAMETER (ENVPATH3 = 'MARS_LSM_PATH')
+      PARAMETER (DEFPATH1 = '/usr/local/apps/libemos/tables/interpol')
+#ifdef INTERPOL_TABLES_PATH
+      DATA DEFPATH2 / &
+       INTERPOL_TABLES_PATH &
+      /
+#else
+      DATA DEFPATH2 / ' ' /
+#endif
+
+
+!*    Section 1. initialize: reset paths and return value
+  100 CONTINUE
+      DPATH = ' '
+      TMPDPATH = ' '
+      DPATH_TABLES_INTERPOL = 0;
+
+
+!*    Section 2. Attempt reading env. variables, in order of priority
+  200 CONTINUE
+      CALL GETENV(ENVPATH3,TMPDPATH)
+      IF (INDEX(TMPDPATH,' ').EQ.1) CALL GETENV(ENVPATH2,TMPDPATH)
+      IF (INDEX(TMPDPATH,' ').EQ.1) CALL GETENV(ENVPATH1,TMPDPATH)
+
+      IDX = INDEX(TMPDPATH,' ') - 1
+      IF (IDX.GT.0) THEN
+        DPATH = TMPDPATH(1:IDX)
+        GOTO 900
+      END IF
+
+
+!*    Section 3. set default, possibly overriden by compile definition
+!     (definition is for base directory, so interpol/ need appending)
+  300 CONTINUE
+      DPATH = DEFPATH1
+      IDX = INDEX(DEFPATH2,' ') - 1
+      IF (IDX.GT.0) DPATH = DEFPATH2(1:IDX) // '/interpol'
+
+
+!*    Section 9. Append /, return path string length (otherwise zero)
+  900 CONTINUE
+      IDX = INDEX(DPATH,' ')
+      IF (IDX.GT.1) THEN
+        DPATH(IDX:IDX) = '/'
+        DPATH_TABLES_INTERPOL = IDX
+      END IF
+      RETURN
+      END
+
diff --git a/interpolation/dssarea.F b/interpolation/dssarea.F
index 8e9d093..be7432f 100644
--- a/interpolation/dssarea.F
+++ b/interpolation/dssarea.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION DSSAREA( EW, NS, NORTH, WEST, SOUTH, EAST )
+      INTEGER FUNCTION DSSAREA(EW,NS,NORTH,WEST,SOUTH,EAST)
 C
 C---->
 C**** DSSAREA
@@ -23,7 +23,7 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = DSSAREA( EW, NS, NORTH, WEST, SOUTH, EAST )
+C     IRET = DSSAREA(EW,NS,NORTH,WEST,SOUTH,EAST)
 C
 C     Input
 C     -----
@@ -67,8 +67,8 @@ C     Method
 C     ------
 C
 C     If default (0/0/0/0) selected for input, input area is set
-C       - to global for lat/long grid 
-C       - to global for gaussian grid 
+C       - to global for lat/long grid
+C       - to global for gaussian grid
 C
 C     Output area is adjusted:
 C
@@ -101,7 +101,6 @@ C
 C
 #include "parim.h"
 #include "nifld.common"
-#include "nofld.common"
 C
 C     Parameters
 C
@@ -129,21 +128,22 @@ C     Local variables
 C
 #if (defined hp) && (!defined INTEGER_8)
       INTEGER INORTH, IWEST, ISOUTH, IEAST, IEW, INS
-      INTEGER NWEST, NEAST
+      INTEGER NWEST
 #else
       INTEGER*8 INORTH, IWEST, ISOUTH, IEAST, IEW, INS
-      INTEGER*8 NWEST, NEAST
+      INTEGER*8 NWEST
 #endif
+      CHARACTER*1 HTYPE
       INTEGER NGAUSS, NOLD, IRET, KPTS, NWEPTS, NNSPTS
-      DIMENSION KPTS(JPGTRUNC*2)
-      DATA NOLD /0/
       REAL RNORTH, RSOUTH
       REAL ONORTH, OWEST, OSOUTH, OEAST
-      LOGICAL LDEFIN, LGAUSS, LSPHERE
       REAL RGAUSS, RESEW
-      DIMENSION RGAUSS(JPGTRUNC*2)
       REAL*8 DEW, DNS, DNORTH, DWEST, DSOUTH, DEAST
       REAL*8 EPS
+      LOGICAL LDEFIN, LGAUSS, LSPHERE
+      DIMENSION KPTS(JPGTRUNC*2)
+      DIMENSION RGAUSS(JPGTRUNC*2)
+      DATA NOLD /0/
 C
 C     Externals
 C
@@ -213,7 +213,8 @@ C
 C
         IF( NGAUSS.NE.NOLD ) THEN
           NOLD = NGAUSS
-          CALL JGETGG( NOLD, 'F', RGAUSS, KPTS, IRET)
+          HTYPE = 'F'
+          CALL JGETGG(NOLD,HTYPE,RGAUSS,KPTS,IRET)
           IF( IRET.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'DSSAREA: Failed to pick up gaussian ', JPQUIET)
@@ -232,7 +233,7 @@ C
   200 CONTINUE
 C
       LDEFIN = ( (NORTH.EQ.0).AND.(WEST.EQ.0).AND.
-     X           (SOUTH.EQ.0).AND.(EAST.EQ.0) ) 
+     X           (SOUTH.EQ.0).AND.(EAST.EQ.0) )
 C
       IF( LDEFIN ) THEN
 C
@@ -258,6 +259,8 @@ C
         ELSE
 C
 C         Gaussian grid ..
+C WARN: (issue EMOS-199) EAST calculation is only for [F|N] grids, O
+C (octahedral) has a finer resolution at the equator for the same NGAUSS
 C
           INORTH = JNORSGG( 90.0, RGAUSS, NGAUSS, 0)
           NORTH  = RGAUSS(INORTH)
@@ -444,7 +447,7 @@ cs
         CALL INTLOGR(JP_WARN,
      X    'DSSAREA: Changed South to', SOUTH)
       ENDIF
-        
+
       IF( .NOT.LGAUSS ) THEN
 C
 C       Regular lat/long grid only ..
diff --git a/interpolation/dummy.F b/interpolation/dummy.F
deleted file mode 100644
index 98672e1..0000000
--- a/interpolation/dummy.F
+++ /dev/null
@@ -1,18 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE DUMMY()
-C---->
-C
-C     Dummy routine to satisfy makefile.
-C
-C----<
-      RETURN
-      END
diff --git a/interpolation/dummy2.F b/interpolation/dummy2.F
deleted file mode 100644
index 5d64c87..0000000
--- a/interpolation/dummy2.F
+++ /dev/null
@@ -1,18 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE DUMMY2()
-C---->
-C
-C     Dummy routine to satisfy makefile.
-C
-C----<
-      RETURN
-      END
diff --git a/interpolation/emos.c b/interpolation/emos.c
new file mode 100644
index 0000000..3636d69
--- /dev/null
+++ b/interpolation/emos.c
@@ -0,0 +1,125 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "emos.h"
+
+#ifdef FORTRAN_UPPERCASE
+#define outrep_  OUTREP
+#define gettru_  GETTRU
+#define setrep_  SETREP
+#define chkout_  CHKOUT
+#define global_  GLOBAL
+#define intf_    INTF
+#define intout_  INTOUT
+#define intin_   INTIN
+#define gasetup_ GASETUP
+#define intuvs_  INTUVS
+#define intvecy_ INTVECY
+#define estima_  ESTIMA
+#endif
+
+#ifdef FORTRAN_NO_UNDERSCORE
+#define outrep_  outrep
+#define gettru_  gettru
+#define setrep_  setrep
+#define chkout_  chkout
+#define global_  global
+#define intf_    intf
+#define intout_  intout
+#define intin_   intin
+#define gasetup_ gasetup
+#define intuvs_  intuvs
+#define intvecy_ intvecy
+#define estima_  estima
+#endif
+
+
+
+fortint int2_estima()
+{
+    return estima_();
+}
+
+fortint int2_global()
+{
+    return global_();
+}
+
+fortint int2_chkout()
+{
+    return chkout_();
+}
+
+fortint int2_setrep(fortint output_flag)
+{
+    return setrep_(&output_flag);
+}
+
+fortint int2_gettru()
+{
+    return gettru_();
+}
+
+fortint int2_outrep()
+{
+    return outrep_();
+}
+
+fortint int2_intf( fortfloat in_array[], fortint in_array_length, fortfloat *out_array, fortint *out_array_length)
+{
+    char  in_grib[1];
+    char  out_grib[500000];
+
+    return intf_(in_grib, &in_array_length, in_array, out_grib, out_array_length, out_array);
+}
+
+fortint int2_intout(const char* param,fortint iv[],fortfloat dv[],const char* cv)
+{
+    char *intf2_debug = getenv("INTF2_DEBUG");
+
+    if(!cv) cv = "";
+    if(intf2_debug)
+    {
+        printf("int2_intout: %s\n",param);
+    }
+    return intout_(param,iv,dv,cv,strlen(param),strlen(cv));
+}
+
+fortint int2_intin(const char* param,fortint iv[],fortfloat dv[],const char* cv)
+{
+    if(!cv) cv = "";
+    return intin_(param,iv,dv,cv,strlen(param),strlen(cv));
+}
+
+fortint int2_gasetup( fortint isec1[], fortint isec2[], fortint isec3[], fortint isec4[], fortfloat rsec2[], fortfloat zsec3[])
+{
+    return gasetup_( isec1, isec2, isec3, isec4, rsec2, zsec3 );
+}
+
+fortint int2_intuvy(fortfloat vort_in[],fortfloat div_in[] , fortint in_array_length, fortfloat *vort_out, fortfloat *div_out, fortint *out_array_length)
+{
+    return intuvy_( vort_in, div_in , &in_array_length, vort_out, div_out, out_array_length);
+}
+
+fortint int2_intuvu(fortfloat vort_in[],fortfloat div_in[] , fortint in_array_length, fortfloat *vort_out, fortfloat *div_out, fortint *out_array_length)
+{
+    return intuvu_( vort_in, div_in , &in_array_length, vort_out, div_out, out_array_length);
+}
+
+fortint int2_intvecy(fortfloat u_in[],fortfloat v_in[] , fortint in_array_length, fortfloat *u_out, fortfloat *v_out, fortint *out_array_length)
+{
+    return intvecy_( u_in, v_in , &in_array_length, u_out, v_out, out_array_length);
+}
+
diff --git a/interpolation/emos.h b/interpolation/emos.h
new file mode 100644
index 0000000..52fda5e
--- /dev/null
+++ b/interpolation/emos.h
@@ -0,0 +1,41 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+#include "common/fortint.h"
+#include "common/fortreal.h"
+#define     ISECTION_0  2
+#define     ISECTION_1  1024  /* WARN: (in parim.h this is different??) */  /* beware of  for ocean data */
+#define     ISECTION_2  5000
+#define     ISECTION_3  3     /* WARN: (in parim.h this is different??) */
+#define     ISECTION_4  512   /* WARN: (in parim.h this is different??) */
+
+#define     RSECTION_2  512   /* WARN: (in parim.h this is different??) */
+#define     RSECTION_3  2
+#define     RSECTION_4  1
+
+
+fortint int2_global();
+fortint outrep_();
+fortint estima_();
+fortint gettru_();
+fortint setrep_(fortint*);
+fortint chkout_();
+fortint global_();
+fortint intf_(const char*, fortint*, fortfloat[], const char*, fortint*, fortfloat[]);
+fortint intout_(const char*, fortint[], fortfloat[], const char*, fortint, fortint);
+fortint intin_(const char*, fortint[], fortfloat[], const char*, fortint, fortint);
+fortint gasetup_( fortint isec1[], fortint isec2[], fortint isec3[], fortint isec4[], fortfloat rsec2[], fortfloat zsec3[]);
+fortint intuvs_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+fortint intuvy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+fortint intuvu_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+fortint intvecy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+fortint int2_intvecy(fortfloat[],fortfloat[] , fortint, fortfloat*, fortfloat*, fortint*);
+
+
diff --git a/interpolation/estima.F b/interpolation/estima.F
index 63b9474..48e683f 100644
--- a/interpolation/estima.F
+++ b/interpolation/estima.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -17,7 +17,7 @@ C     -------
 C
 C     Calculate size of scratch space required for output field of
 C     interpolation.
-C     
+C
 C
 C     Interface
 C     ---------
@@ -48,7 +48,6 @@ C     Externals
 C     ---------
 C
 C     INTLOG  - Log error message
-C     JNORSGG - Calculate gaussian latitude
 C
 C
 C     Author
@@ -63,19 +62,6 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grfixed.h"
-C
-C     Local variables
-C
-      INTEGER LOOP
-      REAL PNORTH, PWEST, PSOUTH, PEAST, GRID, TEMP
-C
-C     Externals
-C
-      EXTERNAL JNORSGG, NUMPTWE
-      INTEGER JNORSGG, NUMPTWE
-C
-C     Statement functions
 C
 C     -----------------------------------------------------------------|
 C     Section 1.  Initialise.
@@ -107,10 +93,11 @@ C
   500 CONTINUE
 C
       IF(NOGAUSS.GT.0) THEN
-       ESTIMA = NOGAUSS * NOGAUSS * 8
+C       ESTIMA = NOGAUSS * NOGAUSS * 8
+        ESTIMA = (2*NOGAUSS) * (4*NOGAUSS + 20)  ! account for RGG/octahedral
         CALL INTLOG(JP_DEBUG,'ESTIMA: Gaussian Number = ', NOGAUSS)
-       CALL INTLOG(JP_DEBUG,'ESTIMA: any gaussian= ',ESTIMA)
-       GOTO 900
+        CALL INTLOG(JP_DEBUG,'ESTIMA: any gaussian= ',ESTIMA)
+        GOTO 900
       ENDIF
 C
 C     -----------------------------------------------------------------|
diff --git a/interpolation/eulavgg.F b/interpolation/eulavgg.F
deleted file mode 100644
index f8725f1..0000000
--- a/interpolation/eulavgg.F
+++ /dev/null
@@ -1,145 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE EULAVGG(NEWFLD, NEXT, INROW, RLAT, RLON,
-     X                   POLELAT, POLELON, FIELD, NGAUSS, TYPE)
-C
-C---->
-C**** EULAVGG
-C
-C     PURPOSE
-C     _______
-C
-C     Generates values along a latitude in a rotated gaussian grid.
-C     (reverses the operations carried out by GGVALUE).
-C
-C     INTERFACE
-C     _________
-C
-C     CALL EULAVGG(NEWFLD, NEXT, INROW, RLAT, RLON,
-C    X             POLELAT, POLELON, FIELD, NGAUSS, TYPE)
-C
-C
-C     Input parameters
-C     ________________
-C
-C     NEWFLD  - the field of values being created
-C     NEXT    - start offset of the latitude row being created
-C     INROW   - the number of points in the latitude row
-C     RLAT    = target point latitude in the rotated grid
-C     RLON    = target point longitude in the rotated grid
-C     POLELAT = latitude of the rotated South Pole
-C     POLELON = longitude of the rotated South Pole
-C     FIELD   = original unrotated gaussian field values
-C     NGAUSS  = original unrotated gaussian field number
-C     TYPE    = original unrotated gaussian field type
-C             = 'F' for full (regular) gaussian field
-C             = 'R' for reduced (quasi) gaussian field
-C
-C     Output parameters
-C     ________________
-C
-C     NEWFLD(NEXT) to NEWFLD(NEXT+INROW-1) contains the latitude row
-C     values.
-C
-C
-C     METHOD
-C     ______
-C
-C     Rotates the lat/long positions of points along the latitude row
-C     in a rotated gaussian grid back to positions in the unrotated grid
-C     and then interpolates vsalue from the original grid.
-C
-C
-C     EXTERNALS
-C     _________
-C
-C     LL2XYZ  - Converts a latitude/longitude position to (x,y,z)
-C               wrt axes through the centre of the globe. The z-axis
-C               runs from the south to north pole. The x- and y-axes
-C               are in the plane of the equator with the x-axis
-C               pointing out through lat/long (0,0).
-C     YROTATE - Rotates the globe about the y-axis.
-C     XYZ2LL  - Converts an (x,y,z) position to a latitude/longitude.
-C     GGINTRP - Interpolates a value from an existing grid.
-C
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C
-C     COMMENTS
-C     ________
-C
-C     The input field is assumed to be global in extent, and a known
-C     definition, either N160 or N80 (reduced or regular).
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      ECMWF       April 1996
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None.
-C
-C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-      REAL NEWFLD, RLAT, RLON, POLELAT, POLELON, FIELD
-      DIMENSION NEWFLD(*), RLON(*), FIELD(*)
-      INTEGER NEXT, INROW, NGAUSS
-      CHARACTER*1 TYPE
-C
-C     Parameters
-      INTEGER JPMAXGG
-      PARAMETER( JPMAXGG = 1280 )
-C
-C     Local variables
-      REAL X(JPMAXGG), Y(JPMAXGG), Z(JPMAXGG)
-      REAL RX(JPMAXGG),RY(JPMAXGG),RZ(JPMAXGG)
-      REAL OLAT(JPMAXGG),OLON(JPMAXGG)
-      INTEGER LOOP
-C
-C     Adjust the target row points longitude to add back the longitude
-C     rotation
-      DO LOOP = 1, INROW
-        OLON(LOOP) = RLON(LOOP) - POLELON
-        IF( OLON(LOOP).LT.0.0 )   OLON(LOOP) = OLON(LOOP) + 360.0
-        IF( OLON(LOOP).GE.360.0 ) OLON(LOOP) = OLON(LOOP) - 360.0
-      ENDDO
-C
-C     Convert the target row points lat/long to (x,y,z) coordinates
-      CALL LL2XYZ(RLAT,OLON,X,Y,Z,INROW)
-C
-C     Rotate the target row points forward through the original latitude
-C     rotation
-      CALL YROTATE((90.0+POLELAT),X,Y,Z,RX,RY,RZ,INROW)
-C
-C     Convert the target row points adjusted (x,y,z) coordinates to
-C     lat/long in the original grid (after longitude rotation)
-      CALL XYZ2LL(RX,RY,RZ,OLAT,OLON,INROW)
-C
-C     Interpolate the rotated grid to the target row points
-      CALL GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,FIELD,NGAUSS,TYPE)
-C
-      RETURN
-      END
diff --git a/interpolation/fixarea.F b/interpolation/fixarea.F
index 0b53422..f13d6c1 100644
--- a/interpolation/fixarea.F
+++ b/interpolation/fixarea.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -40,14 +40,14 @@ C     Method
 C     ------
 C
 C     If default (0/0/0/0) selected for input, input area is set
-C       - to global for spherical harmonics 
-C       - to global for lat/long grid 
-C       - to global for gaussian grid 
+C       - to global for spherical harmonics
+C       - to global for lat/long grid
+C       - to global for gaussian grid
 C
 C     If default (0/0/0/0) selected for output, output area is set
-C       - to same as input area for lat/long grid 
-C       - to same as input area for regular gaussian grid 
-C       - to global for reduced gaussian grid 
+C       - to same as input area for lat/long grid
+C       - to same as input area for regular gaussian grid
+C       - to global for reduced gaussian grid
 C
 C     (Currently, subareas are not supported for reduced gaussian fields.
 C      Should work OK; but need to correct setup of values in GRIB
@@ -81,6 +81,7 @@ C
 #include "nofld.common"
 #include "grfixed.h"
 #include "intf.h"
+#include "current.h"
 C
 C     Parameters
 C
@@ -200,7 +201,7 @@ cs              NOAREA(4) = 36000000
         ENDIF
 
       LDEFIN = ( (NIAREA(1) .EQ. 0) .AND. (NIAREA(2) .EQ. 0) .AND.
-     X           (NIAREA(3) .EQ. 0) .AND. (NIAREA(4) .EQ. 0) ) 
+     X           (NIAREA(3) .EQ. 0) .AND. (NIAREA(4) .EQ. 0) )
 
 C
       IF( LDEFIN ) THEN
@@ -345,23 +346,18 @@ C       If input is gaussian, check if it is global to within
 C       a tolerance of 0.1 degrees.
 C
         IF ( (NIREPR.EQ.JPGAUSSIAN) .OR. (NIREPR.EQ.JPQUASI) ) THEN
-          LGLOBAL = .TRUE.
-          INORTH    = NINT( RIGAUSS(1) * PPMULT )
-          IF( IABS(NIAREA(1)-INORTH).GT.1000) LGLOBAL = .FALSE.
-          ISOUTH    = - INORTH
-          IF( IABS(NIAREA(3)-ISOUTH).GT.1000) LGLOBAL = .FALSE.
-          IF( NIAREA(2).NE.0 ) LGLOBAL = .FALSE.
-C Sinisa added case east less than 0
-          IF ( NIAREA(4).GT.0 ) THEN
-            IEAST = NIAREA(4)
-          ELSE
-            IEAST = JP360 + NIAREA(4)
-          ENDIF
-          IEAST = JP360 - (JP90/NIGAUSS)
-          IF( NIREPR.EQ.JPGAUSSIAN ) THEN
-             IF( IABS(JP360 - IEAST - (JP90/NIGAUSS)).GT.1000)
-     X          LGLOBAL = .FALSE.
-          ENDIF
+          INORTH = NINT( RIGAUSS(1) * PPMULT )
+          ISOUTH = -INORTH
+c         EMOS-199: adjusted for reduced_gg/octahedral
+c         IEAST  = JP360 - (JP90/NIGAUSS)
+          IEAST  = JP360 - (JP360/MILLEN(NIGAUSS))
+          LGLOBAL = (NIAREA(2).EQ.0)
+     X      .AND. (IABS(NIAREA(1)-INORTH).LE.1000)
+     X      .AND. (IABS(NIAREA(3)-ISOUTH).LE.1000)
+     X      .AND. (IABS(NIAREA(4)-IEAST ).LE.1000 .OR.
+     X        NIREPR.EQ.JPGAUSSIAN .OR. .TRUE. )
+C         NOTE: a similar (but useless) test was done here before adding
+C         .TRUE. be replicate the same (useless) behaviour
         ENDIF
 C
 C       Spectral output ..
@@ -419,7 +415,9 @@ C         Is output grid specification the same as the input?
               NOAREA(1) = JP90
               NOAREA(2) = 0
               NOAREA(3) = -JP90
-              NOAREA(4) = JP360 - (JP90/NOGAUSS)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c             NOAREA(4) = JP360 - (JP90/NOGAUSS)
+              NOAREA(4) = JP360 - (JP360/NOLPTS(NOGAUSS))
             ELSE
               NOAREA(1) = NIAREA(1)
               NOAREA(2) = NIAREA(2)
@@ -436,10 +434,12 @@ C           Different grid resolutions
             EW = FLOAT( NOGAUSS )
             NS = 0.0
             IF( (NOREPR.EQ.JPGAUSSIAN) .AND. LGLOBAL ) THEN
-              NORTH = 90.0
-              WEST  = 0.0
+              NORTH =  90.0
+              WEST  =   0.0
               SOUTH = -90.0
-              EAST  = 360.0 - (360.0/(EW*4.0))
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c             EAST  = 360.0 - (360.0/(EW*4.0))
+              EAST  = 360.0 - (360.0/FLOAT(NOLPTS(NOGAUSS)))
             ELSE
               NORTH = FLOAT( NIAREA(1) ) / PPMULT
               WEST  = FLOAT( NIAREA(2) ) / PPMULT
@@ -458,13 +458,14 @@ C           Different grid resolutions
 C
 C           If regular lat/long input, check if output west longitude
 C           reachs to full globe
-            IF (NIREPR .EQ. JPREGULAR) THEN
-              ITEMP = NIAREA(4)+NIGRID(1)
-              IF ( ITEMP.EQ.JP360 ) NOAREA(4) = JP360 - (JP90/NOGAUSS)
+            ITEMP = NIAREA(4)+NIGRID(1)
+            IF( (NIREPR.EQ.JPREGULAR .AND. ITEMP.EQ.JP360) .OR.
+     X          (NIREPR.EQ.JPSPHERE) .OR.
+     X          (NIREPR.EQ.JPSPHROT) ) THEN
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c             NOAREA(4) = JP360 - (JP90/NOGAUSS)
+              NOAREA(4) = JP360 - (JP360/NOLPTS(NOGAUSS))
             ENDIF
-C
-            IF (NIREPR .EQ. JPSPHERE) NOAREA(4) = JP360 - (JP90/NOGAUSS)
-            IF (NIREPR .EQ. JPSPHROT) NOAREA(4) = JP360 - (JP90/NOGAUSS)
           ENDIF
         ENDIF
 C
@@ -502,6 +503,17 @@ C
       NOAREA(2) = NINT( WEST  * PPMULT + 0.1)
       NOAREA(3) = NINT( SOUTH * PPMULT + 0.1)
       NOAREA(4) = NINT( EAST  * PPMULT + 0.1)
+
+C EMOS-199: [F|N] grids assume max(pl)=4*N, however O grids have
+C max(pl)=4*+16 and AREACHK doesn't know of the difference
+C The code below only checks if the adjusted EAST matches what
+C would happen on a [F|N] global grid, and corrects it for an O grid.
+      IF ( (NOREPR.EQ.JPQUASI)
+     X  .AND. (HOGAUST.EQ.'O'
+     X  .AND. NOAREA(2).EQ.0
+     X  .AND. NOAREA(4).EQ.(JP360-JP90/NOGAUSS) ))
+     X  NOAREA(4) = JP360 - (JP360/NOLPTS(NOGAUSS))
+
 C
 C ------------------------------------------------------------------
 C*    Section 9.   Closedown.
diff --git a/interpolation/forced_fftw.F b/interpolation/forced_fftw.F
new file mode 100644
index 0000000..4bf0e79
--- /dev/null
+++ b/interpolation/forced_fftw.F
@@ -0,0 +1,29 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+C     Determine if FFTW should be used, instead of the usual FFT99 (as
+C     per the environment)
+
+      LOGICAL FUNCTION FORCED_FFTW(FORCED)
+
+      IMPLICIT NONE
+
+      LOGICAL FORCED
+      CHARACTER*12 YFLAG
+
+C     Set if FORCED, or set by env
+      FORCED_FFTW = FORCED
+      IF( .NOT. FORCED_FFTW ) THEN
+        CALL GETENV('EMOSLIB_FORCED_FFTW', YFLAG)
+        FORCED_FFTW = (YFLAG(1:1).EQ.'1')
+      ENDIF
+
+      END
+
diff --git a/interpolation/fortdefs.h b/interpolation/fortdefs.h
deleted file mode 100644
index e74f77c..0000000
--- a/interpolation/fortdefs.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-#ifndef FORTDEFS_H
-#define FORTDEFS_H
-
-#ifdef REAL_8
-#define fortreal long double
-#define fortint  int
-#else
-#define fortreal float
-#define fortint  int
-#endif
-
-#endif /* end of FORTDEFS_H */
diff --git a/interpolation/gasetup.F b/interpolation/gasetup.F
index cd401ca..09c4041 100644
--- a/interpolation/gasetup.F
+++ b/interpolation/gasetup.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION GASETUP( KSEC1, KSEC2, KSEC3, KSEC4, ZASEC3)
+      INTEGER FUNCTION GASETUP(KSEC1,KSEC2,KSEC3,KSEC4,RSEC2,ZASEC3)
 C
 C---->
 C**** GASETUP
@@ -16,30 +16,33 @@ C
 C     Purpose
 C     -------
 C
-C     Setup GRIB sections 2 and 4 for the new interpolation product.
-C
-C     Added because of merging with grib_api
+C     Setup GRIB sections 1, 2, 3 & 4 for the new interpolation product.
+C     For grib_api.
 C
 C     Interface
 C     ---------
 C
-C     IRET GASETUP( KSEC2, KSEC4)
+C     IRET GASETUP(KSEC1,KSEC2,KSEC3,KSEC4,RSEC2,ZASEC3)
 C
 C     Input
 C     -----
 C
-C     KSEC1   - Section 1 values (for GRIB_API)
-C     KSEC2   - Section 2 values (for GRIB_API)
-C     KSEC3   - Section 3 values (for GRIB_API)
-C     KSEC4   - Section 4 values (for GRIB_API)
+C     KSEC1   - Section 1 values
+C     KSEC2   - Section 2 values
+C     KSEC3   - Section 3 values
+C     KSEC4   - Section 4 values
+C     RSEC2   - Section 2 values, auxiliary (for floating numbers requiring sub-millidegree representations)
+C     ZASEC3  - ?
 C
 C     Output
 C     ------
 C
-C     KSEC1   - Modified section 2 values (for GRI_API)
-C     KSEC2   - Modified section 2 values (for GRI_API)
-C     KSEC3   - Modified section 3 values (for GRI_API)
-C     KSEC4   - Modified section 4 values (for GRI_API)
+C     KSEC1   - Section 1 values (modified)
+C     KSEC2   - Section 2 values (modified)
+C     KSEC3   - Section 3 values (modified)
+C     KSEC4   - Section 4 values (modified)
+C     RSEC2   - Section 2 values, auxiliary (for floating numbers requiring sub-millidegree representations)
+C     ZASEC3  - ?
 C
 C     Method
 C     ------
@@ -67,6 +70,7 @@ C
 #include "nifld.common"
 #include "nofld.common"
 #include "intf.h"
+#include "grfixed.h"
 C
 C     Parameter(s)
 C
@@ -75,14 +79,14 @@ C
 C
 C     Function arguments
 C
-      INTEGER KSEC1, KSEC2,KSEC3, KSEC4, REPRES, NOPAAPI
-      REAL ZASEC3
-      DIMENSION KSEC1(*), KSEC2(*),KSEC3(*), KSEC4(*), ZASEC3(*)
+      INTEGER KSEC1(*), KSEC2(*), KSEC3(*), KSEC4(*)
+      REAL RSEC2(JPGRIB_ISEC2), ZASEC3(*)
 C
 C     Local variables
 C
-      LOGICAL LIROTAT, LOROTAT, LFRAME, LBITMAP
+      LOGICAL LIROTAT, LOROTAT
       INTEGER ILOOP, ITEMP
+      REAL RTEMP
 C
 C***********************************************************************
 C     Section 1.   Startup.
@@ -93,8 +97,6 @@ C
       GASETUP = 0
 C
 C     Check a recognized data representation type is being processed
-        
-       REPRES = NOREPR
 C
       IF ( (NOREPR .NE.JPREGULAR  ) .AND.
      X     (NOREPR .NE.JPREGROT   ) .AND.
@@ -103,7 +105,7 @@ C
      X     (NOREPR .NE.JPQUASI    ) .AND.
      X     (NOREPR .NE.JPQGGROT   ) .AND.
      X     (NOREPR .NE.JPSPHROT   ) .AND.
-     X     (NOREPR .NE.JPREDLL   ) .AND.
+     X     (NOREPR .NE.JPREDLL    ) .AND.
      X     (NOREPR .NE.JPSPHERE   ) ) GOTO 910
 C
 C     Set flags if input is rotated or if a rotation angle has been given
@@ -173,7 +175,14 @@ C       Number of points along a meridian
 C
         KSEC2(3) = NONS
 C
-C       Latitude and longitude of first grid point
+C       Resolution flag, increments are given
+C
+        KSEC2(6) = 128
+C
+C       Latitude and longitude of first/last grid point
+C       La1/Lo1 - NOAAPI(1): north, NOAAPI(2): west
+C       La2/Lo2 - NOAAPI(3): south, NOAAPI(4): east
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
 C
         IF( NOAAPI(1).GE.0 ) THEN
           KSEC2(4) = (NOAAPI(1)+(JPMICRO/2)) / JPMICRO
@@ -185,13 +194,6 @@ C
         ELSE
           KSEC2(5) = (NOAAPI(2)-(JPMICRO/2)) / JPMICRO
         ENDIF
-C
-C       Resolution flag, increments are given
-C
-        KSEC2(6) = 128
-C
-C       Latitude and longitude of last grid point
-C
         IF( NOAAPI(3).GE.0 ) THEN
           KSEC2(7) = (NOAAPI(3)+(JPMICRO/2)) / JPMICRO
         ELSE
@@ -202,15 +204,20 @@ C
         ELSE
           KSEC2(8) = (NOAAPI(4)-(JPMICRO/2)) / JPMICRO
         ENDIF
+        RSEC2(4:5) = FLOAT(NOAAPI(1:2))/JPMULT
+        RSEC2(7:8) = FLOAT(NOAAPI(3:4))/JPMULT
 C
 C       Flip latitudes if they run from south to north
 C       Set scanning mode flags
 C
-        IF( KSEC2(4).LT.KSEC2(7) ) THEN
+        IF( NOAAPI(1).LT.NOAAPI(3) ) THEN
           IF( LNOGRID ) THEN
             ITEMP = KSEC2(7)
             KSEC2(7) = KSEC2(4)
             KSEC2(4) = ITEMP
+            RTEMP = RSEC2(7)
+            RSEC2(7) = RSEC2(4)
+            RSEC2(4) = ITEMP
             KSEC2(11) = 0
           ELSE
             KSEC2(11) = 64
@@ -220,9 +227,12 @@ C
         ENDIF
 C
 C       i and j  direction increments
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
 C
-        KSEC2(9)  = (NOGRID(1) + (JPMICRO/2)) / JPMICRO
+        KSEC2( 9) = (NOGRID(1) + (JPMICRO/2)) / JPMICRO
         KSEC2(10) = (NOGRID(2) + (JPMICRO/2)) / JPMICRO
+        RSEC2( 9) = FLOAT(NOGRID(1))/JPMULT
+        RSEC2(10) = FLOAT(NOGRID(2))/JPMULT
 C
 C       Following left same as for input product
 C       - no.of vertical coordinate parameters,
@@ -230,6 +240,7 @@ C       - lat/long of southern pole of rotation
 C       - lat/long of pole of stretching
 C
 C       If rotated, put in new lat/long of southern pole of rotation
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
 C
         IF( LIROTAT.OR.LOROTAT ) THEN
           IF( NOROTA(1).GE.0 ) THEN
@@ -242,6 +253,7 @@ C
           ELSE
             KSEC2(14) = (NOROTA(2) - (JPMICRO/2)) / JPMICRO
           ENDIF
+          RSEC2(13:14) = FLOAT(NOROTA(1:2))/JPMULT
         ENDIF
 C
 C       Regular grid flag
@@ -262,9 +274,9 @@ C
 C     OCEAN
         IF(LOCEAN) THEN
 c there is always bitmap for ocean
-         ZASEC3(2) = RMISSGV
-         KSEC3(2)  = int(RMISSGV)
-         KSEC1(5)  = 192
+          ZASEC3(2) = RMISSGV
+          KSEC3(2)  = int(RMISSGV)
+          KSEC1(5)  = 192
 c-------------------
           KSEC1(37) = 4
           KSEC1(60) = NIOCO3
@@ -275,12 +287,12 @@ c-------------------
           KSEC1(65) = NOOCO3L
           KSEC1(66) = NOOIINC
           KSEC1(67) = NOOJINC
-          KSEC1(68) = NOOIRGR  
-          KSEC1(69) = NOONOST  
-          KSEC1(71) = 0  
-          KSEC1(72) = 0  
-          KSEC1(73) = 0  
-          KSEC1(74) = 0  
+          KSEC1(68) = NOOIRGR
+          KSEC1(69) = NOONOST
+          KSEC1(71) = 0
+          KSEC1(72) = 0
+          KSEC1(73) = 0
+          KSEC1(74) = 0
         ENDIF
       ENDIF
 C
@@ -290,10 +302,8 @@ C***********************************************************************
 C
  320  CONTINUE
 C
-      IF ( (NOREPR.EQ.JPGAUSSIAN).OR.
-     X     (NOREPR.EQ.JPFGGROT).OR.
-     X     (NOREPR.EQ.JPQUASI).OR.
-     X     (NOREPR.EQ.JPQGGROT) ) THEN
+      IF ( NOREPR.EQ.JPQUASI    .OR. NOREPR.EQ.JPQGGROT .OR.
+     X     NOREPR.EQ.JPGAUSSIAN .OR. NOREPR.EQ.JPFGGROT ) THEN
 C
 C       Number of points along a parallel
 C
@@ -308,7 +318,19 @@ C       Number of points along a meridian
 C
         KSEC2(3) = NONS
 C
-C       Latitude and longitude of first grid point
+C       Resolution flag
+C       For a regular gaussian grid only, increments are given
+C
+        IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPFGGROT) ) THEN
+          KSEC2(6) = 128
+        ELSE
+          KSEC2(6) = 0
+        ENDIF
+C
+C       Latitude and longitude of first/last grid point
+C       La1/Lo1 - NOAAPI(1): north, NOAAPI(2): west
+C       La2/Lo2 - NOAAPI(3): south, NOAAPI(4): east
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
 C
         IF( NOAAPI(1).GE.0 ) THEN
           KSEC2(4) = (NOAAPI(1)+(JPMICRO/2)) / JPMICRO
@@ -320,19 +342,6 @@ C
         ELSE
           KSEC2(5) = (NOAAPI(2)-(JPMICRO/2)) / JPMICRO
         ENDIF
-C
-C       Resolution flag
-C
-C       For a regular gaussian grid only, increments are given
-C
-        IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPFGGROT) ) THEN
-          KSEC2(6) = 128
-        ELSE
-          KSEC2(6) = 0
-        ENDIF
-C
-C       Latitude and longitude of last grid point
-C
         IF( NOAAPI(3).GE.0 ) THEN
           KSEC2(7) = (NOAAPI(3)+(JPMICRO/2)) / JPMICRO
         ELSE
@@ -343,15 +352,27 @@ C
         ELSE
           KSEC2(8) = (NOAAPI(4)-(JPMICRO/2)) / JPMICRO
         ENDIF
+        RSEC2(4:5) = FLOAT(NOAAPI(1:2))/JPMULT
+        RSEC2(7:8) = FLOAT(NOAAPI(3:4))/JPMULT
+        IF( (.NOT. LNOAREA .AND. (
+     X      (NOREPR.EQ.JPQUASI    .OR. NOREPR.EQ.JPQGGROT))) .OR.
+     X      (LGLOBL .AND.
+     X      (NOREPR.EQ.JPGAUSSIAN .OR. NOREPR.EQ.JPFGGROT)) ) THEN
+          RSEC2(4) = ROGAUSS(1)
+          RSEC2(5) = 0
+          RSEC2(7) = ROGAUSS(NOGAUSS*2)
+          RSEC2(8) = 360. - 360./FLOAT(NOLPTS(NOGAUSS))
+        ENDIF
 C
 C       i direction increment
 C
-C       For a regular gaussian grid, only 
+C       For a regular gaussian grid, only
 C
+        KSEC2(9) = 0
+        RSEC2(9) = 0.
         IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPFGGROT) ) THEN
           KSEC2(9) = (((JP90)/NOGAUSS)+(JPMICRO/2)) / JPMICRO
-        ELSE
-          KSEC2(9) = 0
+          RSEC2(9) = (FLOAT(JP90)/FLOAT(NOGAUSS))/JPMULT
         ENDIF
 C
 C       Number of parallels between a pole and the Equator
@@ -368,6 +389,7 @@ C       - lat/long of southern pole of rotation
 C       - lat/long of pole of stretching
 C
 C       If rotated, put in new lat/long of southern pole of rotation
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
 C
         IF( LIROTAT.OR.LOROTAT ) THEN
           IF( NOROTA(1).GE.0 ) THEN
@@ -380,6 +402,7 @@ C
           ELSE
             KSEC2(14) = (NOROTA(2) - (JPMICRO/2)) / JPMICRO
           ENDIF
+          RSEC2(13:14) = FLOAT(NOROTA(1:2))/JPMULT
         ENDIF
 C
 C       Regular grid flag
@@ -405,9 +428,9 @@ C       For reduced grid, move in number of points along each parallel
 C
           IF( (NOREPR.EQ.JPQUASI) .OR.
      X        (NOREPR.EQ.JPQGGROT) ) THEN
-          DO 325 ILOOP = 1, KSEC2(3)
+          DO ILOOP = 1, KSEC2(3)
             KSEC2(22+ILOOP) = NOLPTS(ILOOP)
- 325      CONTINUE
+          ENDDO
         ENDIF
 C
       ENDIF
@@ -442,6 +465,7 @@ C       - lat/long of pole of stretching
 C       - reserved words 17-22
 C
 C       If rotated, put in new lat/long of southern pole of rotation
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
 C
         IF( LIROTAT.OR.LOROTAT ) THEN
           IF( NOROTA(1).GE.0 ) THEN
@@ -454,6 +478,7 @@ C
           ELSE
             KSEC2(14) = (NOROTA(2) - (JPMICRO/2)) / JPMICRO
           ENDIF
+          RSEC2(13:14) = FLOAT(NOROTA(1:2))/JPMULT
         ENDIF
       ENDIF
 C
@@ -555,7 +580,7 @@ C
       KSEC4(9)  = 0
       KSEC4(10) = 0
       KSEC4(11) = 0
-C     
+C
 C     Reserved words, set to 0
 C
       KSEC4(12) = 0
@@ -577,16 +602,12 @@ C       KSEC4(20), pentagonal resolution parameter M for packing of subset,
 C                  unchanged from input
 C
       ELSE
-        DO 410 ILOOP = 16, 20
-          KSEC4(ILOOP) = 0
- 410    CONTINUE
+        KSEC4(16:20) = 0
       ENDIF
 C
 C     Words 21-33 reserved, set to zero.
 C
-      DO 420 ILOOP = 21, 33
-        KSEC4(ILOOP) = 0
- 420  CONTINUE
+      KSEC4(21:33) = 0
 C
 C***********************************************************************
 C     Section 9.   Closedown
diff --git a/interpolation/gb2gb.F b/interpolation/gb2gb.F
deleted file mode 100644
index 077eab2..0000000
--- a/interpolation/gb2gb.F
+++ /dev/null
@@ -1,367 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION GB2GB(
-     X  INGRIB,INSIZE,OUTGRIB,OUTSIZE,OUT_EW,OUT_NS,OUTAREA)
-C
-C---->
-C**** GB2GB
-C
-C     Purpose
-C     -------
-C
-C     Create a subset of an input regular latitude/longitude
-C     gridpoint field.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = GB2GB(INGRIB,INSIZE,OUTGRIB,OUTSIZE,OUT_EW,OUT_NS,OUTAREA)
-C
-C     Input
-C     -----
-C
-C     INGRIB  - Input regular latitude/longitude gridpoint field in GRIB
-C               format. 
-C     INSIZE  - Size in words (integers) of input GRIB product.
-C     OUT_EW  - East-west increment of output field (millidegrees).
-C     OUT_NS  - North-south increment of output field (millidegrees).
-C     OUTAREA - Area boundaries for output field (N/W/S/E millidegrees).
-C
-C
-C     Output
-C     ------
-C
-C     OUTGRIB - Output regular latitude/longitude gridpoint field in GRIB
-C               format.
-C     OUTSIZE - Size in words (integers) of output GRIB product.
-C
-C     Returns - length in words (integers) of output GRIB product if OK,
-C               negative if error.
-C
-C
-C     Method
-C     ------
-C
-C     Area boundaries for output field are adjusted if necessary to fit
-C     the grid (N/W/S/E millidegrees).
-C
-C
-C     Externals
-C     ---------
-C
-C     GRIBEX  - Unpack and pack GRIB products.
-C     AREACHK - Fixup input/output field area according to grid
-C     INTLOG  - Logs output messages
-C     JDEBUG  - Checks whether the debug flag is to be turned on.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     March 1999
-C
-C----<
-C
-      IMPLICIT NONE
-C
-#include "jparams.h"
-#include "parim.h"
-#include "nofld.common"
-C
-C     Function arguments
-C
-      INTEGER INGRIB,INSIZE,OUTGRIB,OUTSIZE,OUT_EW,OUT_NS,OUTAREA
-      DIMENSION INGRIB(*),OUTGRIB(OUTSIZE),OUTAREA(4)
-C
-C     Local variables
-C
-      INTEGER ISEC0,ISEC1,ISEC2,ISEC3,ISEC4
-      DIMENSION ISEC0(2),ISEC1(1024),ISEC2(1024),ISEC3(2),ISEC4(512)
-      INTEGER ILENP,ILENG,IWORD,IRET,IPOINT
-C
-      REAL PSEC2,PSEC3,PSEC4
-      DIMENSION PSEC2(512),PSEC3(2),PSEC4(1)
-C
-      INTEGER NVALSI,NVALSO
-      REAL ZSEC4I,ZSEC4O
-      DIMENSION ZSEC4I(1),ZSEC4O(1)
-      POINTER ( NPOINTI, ZSEC4I )
-      POINTER ( NPOINTO, ZSEC4O )
-C
-      INTEGER AREA(4)
-      INTEGER INC_EW,INC_NS,N_EW,N_NS,I_EW,I_NS,LOOPO,LOOPI,NEXT
-      INTEGER NWEST,NEAST,OWEST,OEAST
-      REAL EW,NS,NORTH,WEST,SOUTH,EAST
-      LOGICAL LDEBUG, LDUDEW
-      CHARACTER*1 HFUNC
-C
-C     Externals
-C
-      INTEGER  AREACHK
-      EXTERNAL AREACHK
-C
-C ------------------------------------------------------------------
-C     Section 1. Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      GB2GB = -1
-C
-      CALL JDEBUG( )
-      LDEBUG = ( NDBG.GT.0 )
-C
-      DO LOOPO = 1, 4
-        AREA(LOOPO) = OUTAREA(LOOPO)
-      ENDDO
-C
-C     Unpack input GRIB header.
-C
-      IRET = 1
-      ISEC3(2) = 1E-21
-      PSEC3(2) = 1.0E-21
-      CALL GRIBEX(ISEC0,ISEC1,ISEC2,PSEC2,ISEC3,PSEC3,ISEC4,
-     X            PSEC4,ILENP,INGRIB,INSIZE,IWORD,'J',IRET)
-      IF( IRET.GT.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,'GB2GB: GRIBEX "J" option error',IRET)
-        GOTO 900
-      ENDIF
-C
-C     Ensure that it is a regular latitude/longitude grid.
-C
-      IF( ISEC2(1).NE.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,
-     X      'GB2GB: Input not regular lat/long. Type =',ISEC2(1))
-        GOTO 900
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 2. Check that output grid is a subset of the input grid.
-C ------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-C     Fixup input/output field area definitions according to grid
-C     specification.
-C
-      EW    = REAL(OUT_EW) / 1000.0
-      NS    = REAL(OUT_NS) / 1000.0
-      NORTH = REAL(AREA(1)) / 1000.0
-      WEST  = REAL(AREA(2)) / 1000.0
-      SOUTH = REAL(AREA(3)) / 1000.0
-      EAST  = REAL(AREA(4)) / 1000.0
-      IRET = AREACHK( EW, NS, NORTH, WEST, SOUTH, EAST )
-      IF( IRET.NE.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,'GB2GB: AREACHK failed:',IRET)
-        GOTO 900
-      ENDIF
-C
-      OUT_EW = NINT(EW * 1000.0)
-      OUT_NS = NINT(NS * 1000.0)
-      AREA(1) = NINT(NORTH * 1000.0)
-      AREA(2) = NINT(WEST  * 1000.0)
-      AREA(3) = NINT(SOUTH * 1000.0)
-      AREA(4) = NINT(EAST  * 1000.0)
-C
-C     Check (sub)area limits
-C
-C     North and south ..
-C
-      IF( (AREA(1).GT.ISEC2(4)) .OR.
-     X    (AREA(3).LT.ISEC2(7)) ) THEN
-        IF( LDEBUG ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'GB2GB: North/south outside input GRIB area',JPQUIET)
-          CALL INTLOG(JP_ERROR,'GB2GB: Requested north  = ',OUTAREA(1))
-          CALL INTLOG(JP_ERROR,'GB2GB: Requested south  = ',OUTAREA(3))
-          CALL INTLOG(JP_ERROR,'GB2GB: Input GRIB north = ',ISEC2(4))
-          CALL INTLOG(JP_ERROR,'GB2GB: Input GRIB south = ',ISEC2(7))
-          GOTO 900
-        ENDIF
-      ENDIF
-C
-C     East and west ..
-C
-      NWEST = AREA(2)
-      NEAST = AREA(4)
-      OWEST = ISEC2(5)
-      OEAST = ISEC2(8)
-C
-      LDUDEW = 
-     X  ((NWEST.LT.0).AND.(OWEST.LT.0).AND.(NWEST.LT.OWEST)).OR.
-     X  ((NWEST.GT.0).AND.(OWEST.GT.0).AND.(NWEST.LT.OWEST)).OR.
-     X  ((NWEST.LT.0).AND.(OWEST.GT.0).AND.(NWEST.LT.(OWEST-36000))).OR.
-     X  ((NWEST.GT.0).AND.(OWEST.LT.0).AND.(NWEST.LT.(OWEST+36000))).OR.
-     X  ((NEAST.LT.0).AND.(OEAST.LT.0).AND.(NEAST.GT.OEAST)).OR.
-     X  ((NEAST.GT.0).AND.(OEAST.GT.0).AND.(NEAST.GT.OEAST)).OR.
-     X  ((NEAST.LT.0).AND.(OEAST.GT.0).AND.(NEAST.GT.(OEAST-36000))).OR.
-     X  ((NEAST.GT.0).AND.(OEAST.LT.0).AND.(NEAST.GT.(OEAST+36000)))
-C
-      IF( LDUDEW ) THEN
-        IF( LDEBUG ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'GB2GB: East/west outside input GRIB area',JPQUIET)
-          CALL INTLOG(JP_ERROR,'GB2GB: Requested west  = ',OUTAREA(2))
-          CALL INTLOG(JP_ERROR,'GB2GB: Requested east  = ',OUTAREA(4))
-          CALL INTLOG(JP_ERROR,'GB2GB: Input GRIB west = ',ISEC2(5))
-          CALL INTLOG(JP_ERROR,'GB2GB: Input GRIB east = ',ISEC2(8))
-        ENDIF
-        GOTO 900
-      ENDIF
-C
-      IF( NWEST.LT.0 ) NWEST = NWEST + 360000
-      IF( NEAST.LT.0 ) NEAST = NEAST + 360000
-      IF( NEAST.LT.NWEST ) NEAST = NEAST + 360000
-      IF( OWEST.LT.0 ) OWEST = OWEST + 360000
-      IF( OEAST.LT.0 ) OEAST = OEAST + 360000
-      IF( OEAST.LT.OWEST ) OEAST = OEAST + 360000
-C
-C     Check increments
-C
-      INC_EW = OUT_EW / ISEC2(9)
-      IF( (INC_EW*ISEC2(9)).NE.OUT_EW ) THEN
-        IF( LDEBUG ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'GB2GB: East-west step not multiple of input grid',JPQUIET)
-          CALL INTLOG(JP_ERROR,'GB2GB: Requested step  = ',OUT_EW)
-          CALL INTLOG(JP_ERROR,'GB2GB: Input GRIB step = ',ISEC2(9))
-        ENDIF
-        GOTO 900
-      ENDIF
-C
-      INC_NS = OUT_NS / ISEC2(10)
-      IF( (INC_NS*ISEC2(10)).NE.OUT_NS ) THEN
-        IF( LDEBUG ) THEN
-          CALL INTLOG(JP_ERROR,
-     X     'GB2GB: North-south step not multiple of input grid',JPQUIET)
-          CALL INTLOG(JP_ERROR,'GB2GB: Requested step  = ',OUT_NS)
-          CALL INTLOG(JP_ERROR,'GB2GB: Input GRIB step = ',ISEC2(10))
-        ENDIF
-        GOTO 900
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 3. Generate new grid.
-C ------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Get memory for input GRIB values.
-C
-      NVALSI = ISEC2(2)*ISEC2(3)
-      CALL JMEMHAN(3,NPOINTI,NVALSI,1,IRET)
-      IF( IRET.NE.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,'GB2GB: JMEMHAN failed for input',IRET)
-        GOTO 900
-      ENDIF
-C
-C     Get memory for output GRIB values.
-C
-      N_EW = ( (NEAST - NWEST) / OUT_EW ) + 1
-      N_NS = ( (AREA(1) - AREA(3)) / OUT_NS ) + 1
-      NVALSO = N_EW * N_NS
-      CALL JMEMHAN(4,NPOINTO,NVALSO,1,IRET)
-      IF( IRET.NE.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,'GB2GB: JMEMHAN failed for output',IRET)
-        GOTO 900
-      ENDIF
-C
-C     Unpack input GRIB values.
-C
-      IRET = 1
-      CALL GRIBEX(ISEC0,ISEC1,ISEC2,PSEC2,ISEC3,PSEC3,ISEC4,
-     X            ZSEC4I,NVALSI,INGRIB,INSIZE,IWORD,'D',IRET)
-      IF( IRET.GT.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,'GB2GB: GRIBEX "D" option error',IRET)
-        GOTO 900
-      ENDIF
-C
-C     Select points for new grid.
-C
-      I_EW = (NWEST / ISEC2(9) ) + 1
-      I_NS = ((90000-AREA(1)) / ISEC2(10) ) + 1
-C
-      NEXT = 1
-      DO LOOPO = I_NS, (I_NS-1+N_NS*INC_NS),INC_NS
-        DO LOOPI = I_EW, (I_EW-1+N_EW*INC_EW),INC_EW
-          IPOINT = MOD(ISEC2(2)+LOOPI-1,ISEC2(2))+1
-          ZSEC4O(NEXT) = ZSEC4I((LOOPO-1)*ISEC2(2)+IPOINT)
-          NEXT = NEXT + 1
-        ENDDO
-      ENDDO
-C
-C ------------------------------------------------------------------
-C     Section 4. Pack new grid into GRIB.
-C ------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-      ISEC2(2)  = N_EW
-      ISEC2(3)  = N_NS
-      ISEC2(4)  = OUTAREA(1)
-      ISEC2(5)  = OUTAREA(2)
-      ISEC2(7)  = OUTAREA(3)
-      ISEC2(8)  = OUTAREA(4)
-      ISEC2(9)  = OUT_EW
-      ISEC2(10) = OUT_NS
-C
-      ISEC4(1)  = N_NS * N_EW
-      IF( (NOACC.GT.0).AND.(NOACC.LT.30) ) ISEC4(2) = NOACC
-C
-C     PACKING specified can be second-order, simple or archive value
-C
-      IF( NOHFUNC.EQ.'K' ) THEN
-        HFUNC = 'K'
-        ISEC4(4)  = 64
-        ISEC4(6)  = 16
-        ISEC4(9)  = 32
-        ISEC4(10) = 16
-        ISEC4(12) = 8
-        ISEC4(13) = 4
-        ISEC4(14) = 0
-        ISEC4(15) = -1
-      ELSE IF( NOHFUNC.EQ.'S' ) THEN
-        HFUNC = 'C'
-        ISEC4(4)  = 0
-        ISEC4(6)  = 0
-      ELSE IF( NOHFUNC.EQ.'A' ) THEN
-        IF( ISEC4(4).EQ.64 ) THEN
-          HFUNC = 'K'
-        ELSE
-          HFUNC = 'C'
-        ENDIF
-      ENDIF
-C
-      IRET = 1
-      CALL GRIBEX(ISEC0,ISEC1,ISEC2,PSEC2,ISEC3,PSEC3,ISEC4,
-     X            ZSEC4O,NVALSO,OUTGRIB,OUTSIZE,IWORD,HFUNC,IRET)
-      IF( IRET.GT.0 ) THEN
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_ERROR,'GB2GB: GRIBEX "C" option error',IRET)
-        GOTO 900
-      ENDIF
-      GB2GB = IWORD
-C
-C ------------------------------------------------------------------
-C     Section 9. Return.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/gghtype.F b/interpolation/gghtype.F
new file mode 100644
index 0000000..232e4eb
--- /dev/null
+++ b/interpolation/gghtype.F
@@ -0,0 +1,73 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence 
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities 
+C granted to it by virtue of its status as an intergovernmental organisation 
+C nor does it submit to any jurisdiction.
+C
+
+      CHARACTER*1 FUNCTION GGHTYPE(REPR,KNUM,KPTS)
+C
+C---->
+C**** *GGHTYPE*
+C
+C     PURPOSE
+C     _______
+C
+C     Return Gaussian grid type, from field representation, grid number
+C     and array with the number of points at each latitude
+C
+C
+C     Input parameters
+C     ________________
+C
+C     KNUM - Gaussian grid number
+C     REPR - Field representation, including:
+C              Spherical harmonic
+C              Regular Gaussian grid
+C              Reduced Gaussian grid
+C              Latitude/longitude grid
+C     KPTS - Array giving number of points at each gaussian 
+C            latitude, both hemispheres (pl array)
+C
+C
+C     Output parameters
+C     -----------------
+C
+C     Returns non-blank if format detected successfully, one of:
+C       'R' for reduced ("quasi-regular"),
+C       'O' for reduced/octahedral,
+C       'F' for full,
+C
+C----<
+      IMPLICIT NONE
+#include "parim.h"
+
+
+C     Arguments
+      INTEGER REPR, KNUM, KPTS(*)
+
+
+C     Local variables
+      CHARACTER*1 F, R
+      LOGICAL ISOCTAHEDRAL, ISGGVALID
+      EXTERNAL ISOCTAHEDRAL, ISGGVALID
+      F = 'F'
+      R = 'R'
+
+
+C     Check for validity of combinations (F|[RO]###)
+      GGHTYPE = ' '
+      IF( (REPR.EQ.JPGAUSSIAN.OR.REPR.EQ.JPFGGROT)
+     .  .AND. ISGGVALID(F,KNUM) ) THEN
+        GGHTYPE = F
+      ELSEIF( (REPR.EQ.JPQUASI.OR.REPR.EQ.JPQGGROT.OR.REPR.EQ.JPSTRGG)
+     .  .AND. ISGGVALID(R,KNUM) ) THEN
+        GGHTYPE = R
+        IF( ISOCTAHEDRAL(KNUM,KPTS) ) GGHTYPE='O'
+      ENDIF
+
+      ENDFUNCTION
+
diff --git a/interpolation/ggintrp.F b/interpolation/ggintrp.F
index e4d673e..41d652e 100644
--- a/interpolation/ggintrp.F
+++ b/interpolation/ggintrp.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      SUBROUTINE GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,TYPE,FIELD)
+      SUBROUTINE GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,HTYPE,FIELD)
 C
 C---->
 C**** GGINTRP
@@ -22,22 +22,23 @@ C
 C     INTERFACE
 C     _________
 C
-C     CALL GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,TYPE,FIELD)
+C     CALL GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,HTYPE,FIELD)
 C
 C
 C     Input parameters
 C     ________________
 C
-C     NEWFLD  - The field of values being created
-C     NEXT    - Start offset of the latitude row being created
-C     INROW   - The number of points in the latitude row
-C     OLAT    - Latitude of target point
-C     OLON    - Longitude of target point
-C     FIELD   - Original gaussian field
-C     NGAUSS  - Gaussian field number
-C     TYPE    - Original unrotated gaussian field type
-C               = 'F' for full (regular) gaussian field
-C               = 'R' for reduced (quasi) gaussian field
+C     NEWFLD   - The field of values being created
+C     NEXT     - Start offset of the latitude row being created
+C     INROW    - The number of points in the latitude row
+C     OLAT     - Latitude of target point
+C     OLON     - Longitude of target point
+C     FIELD    - Original gaussian field
+C     NGAUSS   - Gaussian field number
+C     HTYPE    - Gaussian grid type (original, unrotated)
+C                = 'R' for reduced ("quasi-regular") Gaussian field,
+C                = 'O' for reduced/octahedral Gaussian field,
+C                = 'F' for full (regular) gaussian field
 C
 C     Output parameters
 C     ________________
@@ -111,13 +112,13 @@ C
       REAL NEWFLD, OLAT, OLON, FIELD
       DIMENSION NEWFLD(*), OLAT(*), OLON(*), FIELD(*)
       INTEGER NEXT, INROW, NGAUSS
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
       INTEGER LOOP, IVALUE
       INTEGER NORTH, SOUTH, IWESTN, IWESTS, IEASTN, IEASTS
-      REAL NSTEP, SSTEP
+      REAL NSTEP, SSTEP, PEAST
       DIMENSION NORTH(JPMAXGG), SOUTH(JPMAXGG)
       DIMENSION IWESTN(JPMAXGG), IWESTS(JPMAXGG)
       DIMENSION IEASTN(JPMAXGG), IEASTS(JPMAXGG)
@@ -155,34 +156,37 @@ C
 C
 C     Get gaussian grid definition (first time only)
 C
-      IF ( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.TYPE) ) THEN
+      IF ( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.HTYPE) ) THEN
 C
         CALL INTLOG(JP_DEBUG,
      X    'GGINTRP: Get gaussian grid type:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
+        CALL INTLOG(JP_DEBUG,HTYPE,JPQUIET)
         CALL INTLOG(JP_DEBUG, 'GGINTRP: grid number:',NGAUSS)
 C
-        CALL JGETGG(NGAUSS,TYPE,GLATS,NGPTS,KRET)
+        CALL JGETGG(NGAUSS,HTYPE,GLATS,NGPTS,KRET)
         IF( KRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X      'GGINTRP: Failed to get gaussian grid definition:',JPQUIET)
           CALL INTLOG(JP_ERROR, 'GGINTRP: grid type:',JPQUIET)
-          CALL INTLOG(JP_ERROR, TYPE,JPQUIET)
+          CALL INTLOG(JP_ERROR, HTYPE,JPQUIET)
           CALL INTLOG(JP_ERROR, 'GGINTRP: grid number:',NGAUSS)
-          STOP 
+          CALL ABORTX ('GGINTRP')
         ENDIF
 C
 C       Build array of offsets in field to start of each latitude line
 C
         CALL INTLOG(JP_DEBUG,'GGINTRP: Build row offsets',JPQUIET)
-        IF( TYPE.EQ.'R') THEN
-          CALL JMKOFGG(TYPE,1,NGAUSS*2,0.0,360.0,NGAUSS,NGPTS,KOFSET)
+        IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' .OR.
+     X      HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     X      HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) THEN
+C         (this value will not be used by JMKOFGG)
+          PEAST = 360.
         ELSE
-          CALL JMKOFGG(TYPE,1,NGAUSS*2,0.0,(360.0-(90.0/NGAUSS)),
-     X                 NGAUSS,NGPTS,KOFSET)
+          PEAST = 360. - (90./NGAUSS)
         ENDIF
+        CALL JMKOFGG(HTYPE,1,NGAUSS*2,0.0,PEAST,NGAUSS,NGPTS,KOFSET)
         OLDGAUS = NGAUSS
-        OLDTYPE = TYPE
+        OLDTYPE = HTYPE
       ENDIF
 C
 C     _______________________________________________________
diff --git a/interpolation/ggrotat.F b/interpolation/ggrotat.F
index 0c0419c..9f73850 100644
--- a/interpolation/ggrotat.F
+++ b/interpolation/ggrotat.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION GGROTAT(OLDFLD, NEWFLD, NUMPTS, POLELAT, POLELON,
-     X                         TYPE, NGAUSS)
+     X                         HTYPE, NGAUSS)
 C
 C---->
 C**** GGROTAT
@@ -22,24 +22,26 @@ C
 C     INTERFACE
 C     _________
 C
-C     IRET = GGROTAT(OLDFLD,NEWFLD,NUMPTS,POLELAT,POLELON,TYPE,NGAUSS)
+C     IRET = GGROTAT(OLDFLD,NEWFLD,NUMPTS,POLELAT,POLELON,HTYPE,NGAUSS)
 C
 C
 C     Input parameters
 C     ________________
 C
-C     OLDFLD  = Original gaussian grid field.
-C     NUMPTS  = Total number of points in the original field.
-C     POLELAT = Latitude of the South Pole of rotation.
-C     POLELON = Longitude of the South Pole of rotation.
-C     TYPE    = 'R' if the gaussian field is reduced (quasi) gaussian.
-C             = 'F' if the gaussian field is regular (full) gaussian.
-C     NGAUSS  = Gaussian grid number (number of latitude rows between
-C               the pole and the equator).
+C     OLDFLD   - Original gaussian grid field.
+C     NUMPTS   - Total number of points in the original field.
+C     POLELAT  - Latitude of the South Pole of rotation.
+C     POLELON  - Longitude of the South Pole of rotation.
+C     NGAUSS   - Gaussian grid number
+C     HTYPE    - Gaussian grid type
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
+C                = 'U' for user-defined reduced gaussian grid
 C
 C     Output parameters
 C     ________________
-C    
+C
 C     NEWFLD  = New gaussian grid field.
 C               (This can be the same array as OLDFLD).
 C
@@ -113,7 +115,7 @@ C
       REAL OLDFLD, NEWFLD, POLELAT, POLELON
       INTEGER NUMPTS, NGAUSS
       DIMENSION OLDFLD(NUMPTS), NEWFLD(NUMPTS)
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -126,7 +128,7 @@ C
       SAVE GLATS, NGPTS, OLDGAUS, OLDTYPE
 C
       INTEGER NEXT, NEXLAT, INROW, LOOP, KRET
-      REAL STEPLON, CUTOFF, RLAT, RLON
+      REAL STEPLON, RLAT, RLON
       DIMENSION RLON(JPMAXGG*2)
 C
       INTEGER ISIZE
@@ -152,18 +154,18 @@ C
       CALL INTLOGR(JP_DEBUG,
      X  'GGROTAT: Longitude of the South Pole of rotation = ',POLELON)
       CALL INTLOG(JP_DEBUG,'GGROTAT: Get gaussian grid type:',JPQUIET)
-      CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
+      CALL INTLOG(JP_DEBUG,HTYPE,JPQUIET)
       CALL INTLOG(JP_DEBUG,'GGROTAT: grid number:',NGAUSS)
 C
 C     Get gaussian grid definition (first time only)
 C
-      IF( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.TYPE)) THEN
+      IF( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.HTYPE)) THEN
         CALL INTLOG(JP_DEBUG,
      X    'GGROTAT: Get definitions for gaussian grid type:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
+        CALL INTLOG(JP_DEBUG,HTYPE,JPQUIET)
         CALL INTLOG(JP_DEBUG,'GGROTAT: grid number:',NGAUSS)
 C
-        CALL JGETGG(NGAUSS,TYPE,GLATS,NGPTS,KRET)
+        CALL JGETGG(NGAUSS,HTYPE,GLATS,NGPTS,KRET)
         IF( KRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X      'GGROTAT: Failed to get gaussian grid definition:',JPQUIET)
@@ -171,7 +173,7 @@ C
           GOTO 900
         ENDIF
         OLDGAUS = NGAUSS
-        OLDTYPE = TYPE
+        OLDTYPE = HTYPE
       ENDIF
 C
 C     Allocate work space if not already done.
@@ -215,12 +217,12 @@ C
 C       Rotate the current line of latitude
 C
         CALL GGVALUE(NEWFLD,NEXT,INROW,RLAT,RLON,
-     X               POLELAT,POLELON,NGAUSS,TYPE,DUMI)
+     X               POLELAT,POLELON,NGAUSS,HTYPE,DUMI)
 C
         NEXT = NEXT + INROW
 C
       ENDDO
-       NUMPTS = NEXT
+      NUMPTS = NEXT
 C
 C     _______________________________________________________
 C
diff --git a/interpolation/ggvalue.F b/interpolation/ggvalue.F
index d2060c2..7063d2c 100644
--- a/interpolation/ggvalue.F
+++ b/interpolation/ggvalue.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       SUBROUTINE GGVALUE(NEWFLD, NEXT, INROW, RLAT, RLON,
-     X                   POLELAT, POLELON, NGAUSS, TYPE, FIELD)
+     X                   POLELAT, POLELON, NGAUSS, HTYPE, FIELD)
 C
 C---->
 C**** GGVALUE
@@ -23,24 +23,26 @@ C     INTERFACE
 C     _________
 C
 C     CALL GGVALUE(NEWFLD, NEXT, INROW, RLAT, RLON,
-C    X             POLELAT, POLELON, NGAUSS, TYPE, FIELD)
+C    X             POLELAT, POLELON, NGAUSS, HTYPE, FIELD)
 C
 C
 C     Input parameters
 C     ________________
 C
-C     NEWFLD  - The field of values being created
-C     NEXT    - Start offset of the latitude row being created
-C     INROW   - The number of points in the latitude row
-C     RLAT    - Target point latitude in the rotated grid
-C     RLON    - Target point longitude in the rotated grid
-C     POLELAT - Latitude of the rotated South Pole
-C     POLELON - Longitude of the rotated South Pole
-C     FIELD   - Original unrotated gaussian field values
-C     NGAUSS  - Original unrotated gaussian field number
-C     TYPE    - Original unrotated gaussian field type
-C               = 'F' for full (regular) gaussian field
-C               = 'R' for reduced (quasi) gaussian field
+C     NEWFLD   - The field of values being created
+C     NEXT     - Start offset of the latitude row being created
+C     INROW    - The number of points in the latitude row
+C     RLAT     - Target point latitude in the rotated grid
+C     RLON     - Target point longitude in the rotated grid
+C     POLELAT  - Latitude of the rotated South Pole
+C     POLELON  - Longitude of the rotated South Pole
+C     FIELD    - Original unrotated gaussian field values
+C     NGAUSS   - Gaussian grid number (original, unrotated)
+C     HTYPE    - Gaussian grid type (original, unrotated)
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
+C                = 'U' for user-defined reduced gaussian grid
 C
 C     Output parameters
 C     ________________
@@ -112,7 +114,7 @@ C
       REAL NEWFLD, RLAT, RLON, POLELAT, POLELON, FIELD
       DIMENSION NEWFLD(*), RLON(*), FIELD(*)
       INTEGER NEXT, INROW, NGAUSS
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -140,14 +142,14 @@ C     rotation
 C
       DO LOOP = 1, INROW
         OLON(LOOP) = OLON(LOOP) + POLELON
-        IF( OLON(LOOP).LT.0.0 )   OLON(LOOP) = OLON(LOOP) + 360.0
-        IF( OLON(LOOP).GE.360.0 ) OLON(LOOP) = OLON(LOOP) - 360.0
+        IF( OLON(LOOP).LT.  0. ) OLON(LOOP) = OLON(LOOP) + 360.0
+        IF( OLON(LOOP).GE.360. ) OLON(LOOP) = OLON(LOOP) - 360.0
       ENDDO
 C
 C     Interpolate the original unrotated grid to the points in the
 C     rotated line
 C
-      CALL GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,TYPE,FIELD)
+      CALL GGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,HTYPE,FIELD)
 C
       RETURN
       END
diff --git a/interpolation/gmapbit.c b/interpolation/gmapbit.c
index 5a9ddcd..2e093ed 100644
--- a/interpolation/gmapbit.c
+++ b/interpolation/gmapbit.c
@@ -1,15 +1,16 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 #include "bitmap.h"
+#include "common/fortint.h"
 
 fortint GMAPBIT(
   char ** bitmap,
diff --git a/interpolation/grprs.h b/interpolation/grprs.h
deleted file mode 100644
index dc4e010..0000000
--- a/interpolation/grprs.h
+++ /dev/null
@@ -1,16 +0,0 @@
-C
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-C     Common blocks holding default or user supplied values for printing.
-C
-      LOGICAL GRPRSET
-      INTEGER GRPRSM
-C
-      COMMON /GRPRSCM/ GRPRSM, GRPRSET
diff --git a/interpolation/hgengg.F b/interpolation/hgengg.F
index d18a900..775ee92 100644
--- a/interpolation/hgengg.F
+++ b/interpolation/hgengg.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION HGENGG(AREA,POLE,KGNNEW,HGTYPE,KNPTS,GNLATS,
+      INTEGER FUNCTION HGENGG(AREA,POLE,KGNNEW,HTYPE,KNPTS,GNLATS,
      X                        IGSIZE,RLAT,RLON,NUMPTS)
 C
 C---->
@@ -24,23 +24,25 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = HGENGG(AREA,POLE,KGNNEW,HGTYPE,KNPTS,IGSIZE,
+C     IRET = HGENGG(AREA,POLE,KGNNEW,HTYPE,KNPTS,IGSIZE,
 C    X              RLAT,RLON,NUMPTS)
 C
 C
 C     Input parameters
 C     ----------------
 C
-C     AREA    - Limits of area (N/W/S/E)
-C     POLE    - Pole of rotation (lat/long)
-C     KGNNEW  - Gaussian number for field
-C     HGTYPE  - Type of new gaussian field
-C               'F' = full, ie regular
-C               'R' = reduced, ie quasi-regular
-C     KNPTS   - Array containing number of points at each latitude
-C     GNLATS  - Array containing list of gaussian latitudes
-C     IGSIZE  - The size of the array to fill with the gaussian field
-C     NUMPTWE - Calculate number of grid pts in range from west to east
+C     AREA     - Limits of area (N/W/S/E)
+C     POLE     - Pole of rotation (lat/long)
+C     KGNNEW   - Gaussian grid number
+C     HTYPE    - Gaussian grid type
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
+C                = 'U' for a user-defined gaussian grid
+C     KNPTS    - Array containing number of points at each latitude
+C     GNLATS   - Array containing list of gaussian latitudes
+C     IGSIZE   - The size of the array to fill with the gaussian field
+C     NUMPTWE  - Calculate number of grid pts in range from west to east
 C
 C
 C     Output parameters
@@ -133,7 +135,7 @@ C
 C
 C     Function arguments
 C
-      CHARACTER*1 HGTYPE
+      CHARACTER*1 HTYPE
       INTEGER KGNNEW,KNPTS(KGNNEW*2),IGSIZE,NUMPTS
       REAL AREA(4),POLE(2),RLAT(*),RLON(*), GNLATS(KGNNEW*2)
 C
@@ -184,7 +186,9 @@ C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
-      GRID = 360.0 / REAL(KGNNEW*4)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     GRID = 360.0 / REAL(KGNNEW*4)
+      GRID = 360.0 / REAL(KNPTS(KGNNEW))
       IGRIDNI = NINT(GRID*JSCALE)
 C
       NUMPTS = 0
@@ -203,9 +207,11 @@ C
           IF( NO1NS.EQ.0 ) NO1NS = LOOPO
           NONS = NONS + 1
 C
-C         Grid step varies for a reduced (quasi-regular) gaussian grid
+C         Grid step varies for "quasi-regular"/octahedral reduced Gaussian grids
 C
-          IF( HGTYPE.EQ.'R' ) THEN
+          IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' .OR.
+     X        HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     X        HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) THEN
             GRID = 360.0 / REAL(KNPTS(LOOPO))
             IGRIDNI = NINT(GRID*JSCALE)
           ENDIF
diff --git a/interpolation/hgenllw.F b/interpolation/hgenllw.F
deleted file mode 100644
index d1d96e0..0000000
--- a/interpolation/hgenllw.F
+++ /dev/null
@@ -1,257 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HGENLLW(AREA,POLE,GRID,NLON,NLAT,
-     X                         RCLAT,RCLON,RLAT,RLON)
-C
-C---->
-C**** HGENLLW
-C
-C     Purpose
-C     -------
-C
-C     This routine calculates the original latitude and longitude
-C     values (before rotation) for a rotated grid for wind fields.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HGENLLW(AREA,POLE,GRID,NLON,NLAT,RCLAT,RCLON,RLAT,RLON)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     AREA - Limits of area (N/W/S/E)
-C     POLE - Pole of rotation (lat/long)
-C     GRID - Grid increments (i/j)
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     NLON  - Number of points along a parallel in the rotated grid.
-C     NLAT  - Number of points along a meridien in the rotated grid.
-C     RCLAT - Vector of latitude values for the points in current grid.
-C     RCLON - Vector of longitude values for the points in current grid.
-C     RLAT  - Vector of orginal latitude values for the points in
-C             the rotated grid.
-C     RLON  - Vector of orginal longitude values for the points in
-C             the rotated grid.
-C
-C     Returns 0 if function successful, non-zero otherwise.
-C
-C     Common block usage
-C     ------------------
-C
-C     None.
-C
-C
-C     Method
-C     ------
-C
-C     The vector of points runs from West to East in rows, the rows
-C     run from North to South.
-C
-C
-C     Externals
-C     ---------
-C
-C     INTLOG  - Log error message.
-C     JDEBUG  - Tests if debug output required.
-C     HLL2XYZ - Converts a latitude/longitude position to (x,y,z)
-C               wrt axes through the centre of the globe. The z-axis
-C               runs from the south to north pole. The x- and y-axes
-C               are in the plane of the equator with the x-axis
-C               pointing out through lat/long (0,0).
-C     YROTATE - Rotates the globe about the new y-axis.
-C     XYZ2LL  - Converts an (x,y,z) position to a latitude/longitude.
-C     JMALLOC - Dynamically allocate memory
-C     JFREE   - Free dynamically allocated memory
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      January 2001
-C
-C
-C     Modifications
-C     -------------
-C
-C     None.
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-#include "parim.h"
-C
-C     Parameters
-C
-      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S, JLAT, JLON
-      REAL JSCALE
-      PARAMETER (JNORTH = 1 )
-      PARAMETER (JWEST  = 2 )
-      PARAMETER (JSOUTH = 3 )
-      PARAMETER (JEAST  = 4 )
-      PARAMETER (JW_E  = 1 )
-      PARAMETER (JN_S  = 2 )
-      PARAMETER (JLAT  = 1 )
-      PARAMETER (JLON  = 2 )
-      PARAMETER (JSCALE  = 1000.0 )
-C
-C     Function arguments
-C
-      REAL AREA(4),POLE(2),GRID(2), RCLAT(*),RCLON(*),RLAT(*),RLON(*)
-      INTEGER NLON,NLAT
-C
-C     Local variables
-C
-      INTEGER NEXT, LOOP, LOOPI, LOOPO, IGRIDNI, IGRIDNJ
-      INTEGER ISIZE, ISIZOLD, NBYTES
-      REAL ZLAT, X(1), Y(1), Z(1)
-      REAL RX(1), RY(1), RZ(1)
-      POINTER( IPX, X )
-      POINTER( IPY, Y )
-      POINTER( IPZ, Z )
-      POINTER( IPRX, RX )
-      POINTER( IPRY, RY )
-      POINTER( IPRZ, RZ )
-C
-      DATA ISIZOLD/-1/
-      SAVE ISIZOLD,IPX,IPY,IPZ,IPRX,IPRY,IPRZ
-C
-C     Externals
-C
-#ifdef POINTER_64
-      INTEGER*8 JMALLOC
-#else
-      INTEGER JMALLOC
-#endif
-C
-C     -----------------------------------------------------------------|
-C     Section 1.  Initialise.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      HGENLLW = 0
-C
-      CALL JDEBUG()
-C
-C     -----------------------------------------------------------------|
-C     Section 2.  Calculate current grid latitudes and longitudes
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-      NLON = 1 + INT((AREA(JEAST) - AREA(JWEST)) / GRID(JW_E))
-      NLAT = 1 + INT((AREA(JNORTH) - AREA(JSOUTH)) / GRID(JN_S))
-      IGRIDNI = NINT(GRID(JW_E)*JSCALE)
-      IGRIDNJ = NINT(GRID(JN_S)*JSCALE)
-C
-      NEXT = 1
-      DO LOOPO = 1, NLAT
-        ZLAT = AREA(JNORTH) - REAL((LOOPO-1)*IGRIDNJ)/JSCALE
-        DO LOOPI = 1, NLON
-          RCLON(NEXT) = AREA(JWEST) + REAL((LOOPI-1)*IGRIDNI)/JSCALE
-          IF( RCLON(NEXT).LT.0.0 ) RCLON(NEXT) = RCLON(NEXT) + 360.0
-          RCLAT(NEXT) = ZLAT
-          NEXT = NEXT + 1
-        ENDDO
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 3.  Get some space for rotating the lat/longs
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-      ISIZE = NLAT *NLON
-      IF( ISIZE.GT.ISIZOLD ) THEN
-C
-        IF( ISIZOLD.GT.0 ) CALL JFREE(IPX)
-C
-        NBYTES = 6*ISIZE*JPRLEN
-C
-        IPX = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPX = IPX/(1024*1024*1024*4)
-#endif
-        IF( IPX.EQ.0 ) THEN
-          CALL INTLOG(JP_WARN,'HGENLLW: Memory allocate fail',JPQUIET)
-          HGENLLW = 1
-          GOTO 900
-        ENDIF
-C
-        IPY  = IPX  + (ISIZE*JPRLEN)
-        IPZ  = IPY  + (ISIZE*JPRLEN)
-        IPRX = IPZ  + (ISIZE*JPRLEN)
-        IPRY = IPRX + (ISIZE*JPRLEN)
-        IPRZ = IPRY + (ISIZE*JPRLEN)
-C
-        ISIZOLD = ISIZE
-C
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 4.  Calculate the lat/longs before rotation
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-C     Convert the rotated row points lat/longs to (x,y,z) coordinates
-C
-      CALL HLL2XYZ(RCLAT,RCLON,X,Y,Z,ISIZE)
-C
-C     Rotate the rotated row points back through the original latitude
-C     rotation
-C
-      CALL YROTATE(-(90.0+POLE(JLAT)),X,Y,Z,RX,RY,RZ,ISIZE)
-C
-C     Convert the rotated row points adjusted (x,y,z) coordinates to
-C     lat/long in the original grid (but still containing the
-C     longitude rotation)
-C
-      CALL XYZ2LL(RX,RY,RZ,RLAT,RLON,ISIZE)
-C
-C     Adjust the rotated line longitudes to remove the longitude
-C     rotation
-C
-      DO LOOP = 1, ISIZE
-        RLON(LOOP) = RLON(LOOP) + POLE(JLON)
-        IF( RLON(LOOP).LT.0.0 )   RLON(LOOP) = RLON(LOOP) + 360.0
-        IF( RLON(LOOP).GE.360.0 ) RLON(LOOP) = RLON(LOOP) - 360.0
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 9.  Return
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/hgetlsm.F b/interpolation/hgetlsm.F
index af4b6e7..cc0afa5 100644
--- a/interpolation/hgetlsm.F
+++ b/interpolation/hgetlsm.F
@@ -8,7 +8,7 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION HGETLSM(KGAUSS,OLDLSM,KSIZE)
+      INTEGER FUNCTION HGETLSM(KGAUSS,HTYPE,OLDLSM,KSIZE)
 C
 C---->
 C**** HGETLSM
@@ -30,6 +30,7 @@ C     Input parameters
 C     ----------------
 C
 C     KGAUSS - Gaussian number of the reduced gaussian field
+C     HTYPE  - Gaussian type of the reduced gaussian field ('R','O')
 C     KSIZE  - Number of bytes to read into OLDLSM
 C
 C
@@ -100,20 +101,21 @@ C
 C
 C     Function arguments
 C
-      INTEGER KGAUSS, KSIZE
+      INTEGER KGAUSS
+      CHARACTER*1 HTYPE
       REAL OLDLSM(*)
-
-      INTEGER DPATH_TABLES_INTERPOL
-      EXTERNAL DPATH_TABLES_INTERPOL
-
+      INTEGER KSIZE
 C
 C     Local variables
 C
       CHARACTER*256 FILENAME
-      CHARACTER*7 VPP
       CHARACTER*4 YGAUSS
       INTEGER IOFFS, IUNIT, IRET
-
+C
+C     Externals
+C
+      INTEGER DPATH_TABLES_INTERPOL
+      EXTERNAL DPATH_TABLES_INTERPOL
 C
 C     -----------------------------------------------------------------|
 C     Section 1.  Initialise.
@@ -144,8 +146,13 @@ C
 C
 C     Complete the filename
 C
-      WRITE(YGAUSS,'(I4.4)') KGAUSS
-      FILENAME = FILENAME(1:IOFFS) // 'LSM_GG_' // YGAUSS
+      IF( HTYPE.EQ.'R' ) THEN
+        WRITE(YGAUSS,'(I4.4)') KGAUSS
+        FILENAME = FILENAME(1:IOFFS) // 'LSM_GG_' // YGAUSS
+      ELSE
+        WRITE(YGAUSS,'(I0)') KGAUSS
+        FILENAME = FILENAME(1:IOFFS) // 'LSM_' // HTYPE // YGAUSS
+      ENDIF
       IOFFS = INDEX(FILENAME,' ')
 C
       IF (LNNLSM_CY41R1) FILENAME(IOFFS:) = '_CY41R1'
diff --git a/interpolation/hirlam.F b/interpolation/hirlam.F
index 4cf22b3..d834812 100644
--- a/interpolation/hirlam.F
+++ b/interpolation/hirlam.F
@@ -8,8 +8,8 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION HIRLAM(L12PNT,OLDFLD,KOUNT,KGAUSS,AREA,
-     X                        POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
+      INTEGER FUNCTION HIRLAM(L12PNT,OLDFLD,KOUNT,KGAUSS,
+     X  HTYPE,AREA,POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
 C
 C---->
 C**** HIRLAM
@@ -24,8 +24,8 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = HIRLAM(L12PNT,OLDFLD,KOUNT,KGAUSS,AREA,
-C    X               POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
+C     IRET = HIRLAM(L12PNT,OLDFLD,KOUNT,KGAUSS,HTYPE,AREA,POLE,GRID,
+C    X              NEWFLD,KSIZE,NLON,NLAT)
 C
 C
 C     Input parameters
@@ -34,22 +34,27 @@ C
 C     L12PNT - Chooses between 12-point and 4-point interpolation
 C              = .TRUE. for 12-point horizontal
 C              = .FALSE. for 4-point
-C     OLDFLD  - The array of values from the gaussian field
-C     KOUNT   - Number of values in OLDFLD
-C     KGAUSS  - Gaussian number for the gaussian field
-C     AREA    - Limits of output area (N/W/S/E)
-C     POLE    - Pole of rotation (lat/long)
-C     GRID    - Output lat/long grid increments (we/ns)
-C     KSIZE   - The size of the output array to fill with the regular
-C               lat/long field
+C     OLDFLD - Array of values from the (old) gaussian field
+C     KOUNT  - Number of values in OLDFLD
+C     KGAUSS - Gaussian grid number
+C     HTYPE  - Gaussian grid type
+C              = 'R' for reduced ("quasi-regular"),
+C              = 'O' for reduced/octahedral,
+C              = 'F' for full,
+C              = 'U' for a user-defined gaussian grid
+C     AREA   - Limits of output area (N/W/S/E)
+C     POLE   - Pole of rotation (lat/long)
+C     GRID   - Output lat/long grid increments (we/ns)
+C     KSIZE  - The size of the output array to fill with the regular
+C              lat/long field
 C
 C
 C     Output parameters
 C     -----------------
 C
-C     NEWFLD  - The array of values for the regular lat/long field
-C     NLON    - Number of longitudes in the regular lat/long field
-C     NLAT    - Number of latitudes in the regular lat/long field
+C     NEWFLD - The array of values for the regular lat/long field
+C     NLON   - Number of longitudes in the regular lat/long field
+C     NLAT   - Number of latitudes in the regular lat/long field
 C
 C     Returns 0 if function successful, non-zero otherwise.
 C
@@ -129,22 +134,20 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
+#include "grfixed.h"
 C
 C     Parameters
 C
-      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S, JLAT, JLON
-      INTEGER JP12PT, JP4PT, JPNEARN
-      PARAMETER (JP12PT  = 0)
-      PARAMETER (JP4PT   = 1)
-      PARAMETER (JPNEARN = 2)
-      PARAMETER (JNORTH = 1 )
-      PARAMETER (JWEST  = 2 )
-      PARAMETER (JSOUTH = 3 )
-      PARAMETER (JEAST  = 4 )
-      PARAMETER (JW_E  = 1 )
-      PARAMETER (JN_S  = 2 )
-      PARAMETER (JLAT  = 1 )
-      PARAMETER (JLON  = 2 )
+      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S
+      INTEGER JP12PT, JP4PT
+      PARAMETER (JP12PT = 0)
+      PARAMETER (JP4PT  = 1)
+      PARAMETER (JNORTH = 1)
+      PARAMETER (JWEST  = 2)
+      PARAMETER (JSOUTH = 3)
+      PARAMETER (JEAST  = 4)
+      PARAMETER (JW_E   = 1)
+      PARAMETER (JN_S   = 2)
 C
 C     Function arguments
 C
@@ -152,14 +155,16 @@ C
       INTEGER KOUNT, KGAUSS, KSIZE, NLON, NLAT
       REAL AREA(4), POLE(2), GRID(2)
       REAL OLDFLD(*), NEWFLD(KSIZE)
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
       INTEGER NEXT, LOOP, IRET, NLEN, NBYTES, NUMBER
       INTEGER NEAREST, NEND, COUNT
       INTEGER NJPR,  NJPB
-      INTEGER ITEMP
+      INTEGER NGSPEC_TMP
       INTEGER IOGAUSS,IOREPR
+      CHARACTER*1 HTYPE_TMP
 C
       LOGICAL LNEW, LFIRST
       INTEGER KSCHEME(1),NEIGH(12,1), KLA(1)
@@ -211,6 +216,7 @@ C
 C     Externals
 C
       LOGICAL FORCED_NEAREST_NEIGHBOUR
+      LOGICAL ISOCTAHEDRAL
       INTEGER HNEI12
       INTEGER HGENGRD
 #ifdef POINTER_64
@@ -253,8 +259,15 @@ C
      X    FNAME//': precipitation threshold not applied',JPQUIET)
       ENDIF
 
+      IF( HTYPE.NE.'O' .AND. HTYPE.NE.'R' .AND. HTYPE.NE.'U'
+     X .AND. HTYPE.NE.'F' ) THEN
+        CALL INTLOG(JP_ERROR,
+     X    FNAME//': Gaussian type unsupported ('//HTYPE//')',JPQUIET)
+        HIRLAM = 1
+        GOTO 900
+      ENDIF
 
-C     Use nearest neighbour if required
+C     Set interpolation method (use nearest neighbour if required)
       LVEGGY = FORCED_NEAREST_NEIGHBOUR(LMETHOD,NITABLE,NIPARAM)
       IF( LVEGGY ) CALL INTLOG(JP_DEBUG,
      X  FNAME//': nearest neighbour processing',JPQUIET)
@@ -293,16 +306,8 @@ C
 C     Build up offsets to start of each latitude in original field(s)
 C
       IF( (KGAUSS.NE.IOGAUSS).OR.(IOREPR.NE.NIREPR) ) THEN
-        IF( NIREPR.EQ.JPGAUSSIAN ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      FNAME//': trying for regular gaussian N',KGAUSS)
-          CALL JGETGG(KGAUSS,'F',GLATS,KPTS,IRET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      FNAME//': trying for reduced gaussian N',KGAUSS)
-          CALL JGETGG(KGAUSS,'R',GLATS,KPTS,IRET)
-        ENDIF
-C
+        CALL INTLOG(JP_DEBUG,FNAME//': trying Gaussian '//HTYPE,KGAUSS)
+        CALL JGETGG(KGAUSS,HTYPE,GLATS,KPTS,IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X      FNAME//': JGETGG failed to get gaussian data',JPQUIET)
@@ -316,25 +321,22 @@ C
         ENDDO
 C
 C
-C     Check whether number of gaussian points agrees with grid
-C     specification. If not and grid is N80/N160, try the 12-pt
-C     specification.
+C       Check whether number of gaussian points agrees with grid specification.
+C       If not and grid is N80/N160 non-octahedral, try the 12-pt specification.
 C
-       NUMBER = (IOFFS(KGAUSS*2+1) - 1)
+        NUMBER = (IOFFS(KGAUSS*2+1) - 1)
         IF( NUMBER.NE.KOUNT ) THEN
-          IF( (KGAUSS.EQ.80).OR.(KGAUSS.EQ.160) ) THEN
-            ITEMP  = NGSPEC
+          IF( (KGAUSS.EQ.80).OR.(KGAUSS.EQ.160) .AND.
+     X        (NIREPR.EQ.JPQUASI) .AND.
+     X        (.NOT. ISOCTAHEDRAL(NIGAUSS,MILLEN)) ) THEN
+            NGSPEC_TMP = NGSPEC
             NGSPEC = 12
-            IF( NIREPR.EQ.JPQUASI ) THEN
-              CALL INTLOG(JP_DEBUG,
-     X      FNAME//': trying for 12-pt reduced gaussian N',KGAUSS)
-              CALL JGETGG(KGAUSS,'R',GLATS,KPTS,IRET)
-            ELSE
-              CALL INTLOG(JP_DEBUG,
-     X      FNAME//': trying for 12-pt regular gaussian N',KGAUSS)
-              CALL JGETGG(KGAUSS,'F',GLATS,KPTS,IRET)
-            ENDIF
-            NGSPEC = ITEMP
+            HTYPE_TMP = 'F'
+            IF( NIREPR.EQ.JPQUASI ) HTYPE_TMP = 'R'
+            CALL INTLOG(JP_DEBUG,
+     X        FNAME//': trying 12-pt Gaussian '//HTYPE_TMP,KGAUSS)
+            CALL JGETGG(KGAUSS,HTYPE_TMP,GLATS,KPTS,IRET)
+            NGSPEC = NGSPEC_TMP
 C
             IF( IRET.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,
@@ -350,20 +352,16 @@ C
 C
             NUMBER = (IOFFS(KGAUSS*2+1) - 1)
             IF( NUMBER.NE.KOUNT ) THEN
-              CALL INTLOG(JP_ERROR,
-     X          FNAME//': Given number of points =',KOUNT)
-              CALL INTLOG(JP_ERROR,
-     X          FNAME//': Expected number of pts =',NUMBER)
+           CALL INTLOG(JP_ERROR,FNAME//': Given no. of points =',KOUNT)
+           CALL INTLOG(JP_ERROR,FNAME//': Expected no. of pts =',NUMBER)
               HIRLAM = 4
               GOTO 900
             ENDIF
 C
           ELSE
 C
-            CALL INTLOG(JP_ERROR,
-     X        FNAME//': Given number of points =',KOUNT)
-            CALL INTLOG(JP_ERROR,
-     X        FNAME//': Expected number of pts =',NUMBER)
+           CALL INTLOG(JP_ERROR,FNAME//': Given no. of points =',KOUNT)
+           CALL INTLOG(JP_ERROR,FNAME//': Expected no. of pts =',NUMBER)
             HIRLAM = 4
             GOTO 900
           ENDIF
@@ -377,9 +375,7 @@ C     Preserve the input field
 C     (in case OLDFLD and NEWFLD are the same arrays)
 C
       NUMBER = (IOFFS(KGAUSS*2+1) - 1)
-      DO LOOP = 1, NUMBER
-        OLD(LOOP) = OLDFLD(LOOP)
-      ENDDO
+      OLD(1:NUMBER) = OLDFLD(1:NUMBER)
 C
 C     -----------------------------------------------------------------|
 C     Section 2.  Generate the lat/long points for the output grid
diff --git a/interpolation/hirlamw.F b/interpolation/hirlamw.F
index fe69e15..313f7f1 100644
--- a/interpolation/hirlamw.F
+++ b/interpolation/hirlamw.F
@@ -8,8 +8,8 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION HIRLAMW(L12PNT,OLDFLDU,OLDFLDV,KOUNT,KGAUSS,AREA,
-     X                        POLE,GRID,NEWFLDU,NEWFLDV,KSIZE,NLON,NLAT)
+      INTEGER FUNCTION HIRLAMW(L12PNT,OLDFLDU,OLDFLDV,KOUNT,KGAUSS,
+     X  HTYPE,AREA,POLE,GRID,NEWFLDU,NEWFLDV,KSIZE,NLON,NLAT)
 C
 C---->
 C**** HIRLAMW
@@ -24,20 +24,25 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = HIRLAMW(L12PNT,OLDFLDU,OLDFLDV,KOUNT,KGAUSS,AREA,
+C     IRET = HIRLAMW(L12PNT,OLDFLDU,OLDFLDV,KOUNT,KGAUSS,HTYPE,AREA,
 C    X               POLE,GRID,NEWFLDU,NEWFLDV,KSIZE,NLON,NLAT)
 C
 C
 C     Input parameters
 C     ----------------
 C
-C     L12PNT - Chooses between 12-point and 4-point interpolation
-C              = .TRUE. for 12-point horizontal
-C              = .FALSE. for 4-point
+C     L12PNT  - Chooses between 12-point and 4-point interpolation
+C               = .TRUE. for 12-point horizontal
+C               = .FALSE. for 4-point
 C     OLDFLDU - The array of values from the gaussian U field
 C     OLDFLDV - The array of values from the gaussian V field
 C     KOUNT   - Number of values in OLDFLDU/V
 C     KGAUSS  - Gaussian number for the gaussian field
+C     HTYPE   - Gaussian grid type
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full,
+C               = 'U' for a user-defined gaussian grid
 C     AREA    - Limits of output area (N/W/S/E)
 C     POLE    - Pole of rotation (lat/long)
 C     GRID    - Output lat/long grid increments (we/ns)
@@ -129,22 +134,20 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
+#include "grfixed.h"
 C
 C     Parameters
 C
-      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S, JLAT, JLON
-      INTEGER JP12PT, JP4PT, JPNEARN
-      PARAMETER (JP12PT  = 0)
-      PARAMETER (JP4PT   = 1)
-      PARAMETER (JPNEARN = 2)
-      PARAMETER (JNORTH = 1 )
-      PARAMETER (JWEST  = 2 )
-      PARAMETER (JSOUTH = 3 )
-      PARAMETER (JEAST  = 4 )
-      PARAMETER (JW_E  = 1 )
-      PARAMETER (JN_S  = 2 )
-      PARAMETER (JLAT  = 1 )
-      PARAMETER (JLON  = 2 )
+      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S
+      INTEGER JP12PT, JP4PT
+      PARAMETER (JP12PT = 0)
+      PARAMETER (JP4PT  = 1)
+      PARAMETER (JNORTH = 1)
+      PARAMETER (JWEST  = 2)
+      PARAMETER (JSOUTH = 3)
+      PARAMETER (JEAST  = 4)
+      PARAMETER (JW_E   = 1)
+      PARAMETER (JN_S   = 2)
 C
 C     Function arguments
 C
@@ -153,11 +156,13 @@ C
       REAL AREA(4), POLE(2), GRID(2)
       REAL OLDFLDU(*), NEWFLDU(KSIZE)
       REAL OLDFLDV(*), NEWFLDV(KSIZE)
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
       INTEGER NEXT, LOOP, IRET, NLEN, NBYTES, NUMBER
       INTEGER NPREV, COUNTU, COUNTV, NEAREST
+      CHARACTER*1 HPREV
 C
       LOGICAL LNEW, LFIRST
       INTEGER KSCHEME(1),NEIGH(12,1), KLA(1)
@@ -197,13 +202,14 @@ C
 C
       REAL OLDU(KOUNT), OLDV(KOUNT)
 C
-      CHARACTER*7 FUNCNAME
-      PARAMETER  (FUNCNAME = 'HIRLAMW')
+      CHARACTER*7 FNAME
+      PARAMETER  (FNAME = 'HIRLAMW')
 C
       DATA IGGOLD/-1/, ILLOLD/-1/
       DATA NUMBER/-1/
       DATA LNEW/.FALSE./, LFIRST/.TRUE./
       DATA NPREV/-1/
+      DATA HPREV/' '/
 C
       SAVE LNEW, LFIRST
       SAVE IPKSCHE, IPNEIGH, IPKLA, IPPWTS
@@ -212,6 +218,7 @@ C
       SAVE ILLOLD, IPRLAT, IPRLON
       SAVE NUMBER
       SAVE NPREV
+      SAVE HPREV
       SAVE IPRCLAT, IPRCLON, IPRDIR
       SAVE IPC, IPS, IPU, IPV
 C
@@ -250,11 +257,19 @@ C
       CALL JDEBUG()
 C
       IF( L12PNT ) THEN
-        CALL INTLOG(JP_DEBUG,FUNCNAME//': 12-pt interpolation',JPQUIET)
+        CALL INTLOG(JP_DEBUG,FNAME//': 12-pt interpolation',JPQUIET)
       ELSE
-        CALL INTLOG(JP_DEBUG,FUNCNAME//': 4-pt interpolation',JPQUIET)
+        CALL INTLOG(JP_DEBUG,FNAME//': 4-pt interpolation',JPQUIET)
       ENDIF
-C
+
+      IF( HTYPE.NE.'O' .AND. HTYPE.NE.'R' .AND. HTYPE.NE.'U'
+     X .AND. HTYPE.NE.'F' ) THEN
+        CALL INTLOG(JP_ERROR,
+     X    FNAME//': Gaussian type unsupported ('//HTYPE//')',JPQUIET)
+        HIRLAMW = 1
+        GOTO 900
+      ENDIF
+
 C     Dynamically allocate memory for gaussian grid information.
 C
       IGG = KGAUSS*2
@@ -270,7 +285,7 @@ C
 #endif
         IF( IPKPTS.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocate fail',JPQUIET)
+     X      FNAME//': Memory allocate fail',JPQUIET)
           HIRLAMW = 1
           GOTO 900
         ENDIF
@@ -280,21 +295,18 @@ C
 C
         IGGOLD = IGG
         NPREV = -1
+        HPREV = ' '
 C
       ENDIF
 C
 C     Build up offsets to start of each latitude in original field(s)
 C
-      IF( KGAUSS.NE.NPREV ) THEN
-        IF( NIREPR.EQ.JPGAUSSIAN ) THEN
-          CALL JGETGG(KGAUSS,'F',GLATS,KPTS,IRET)
-        ELSE
-          CALL JGETGG(KGAUSS,'R',GLATS,KPTS,IRET)
-        ENDIF
-C
+      IF( KGAUSS.NE.NPREV .AND. HPREV.NE.HTYPE) THEN
+        CALL INTLOG(JP_DEBUG,FNAME//': trying Gaussian '//HTYPE,KGAUSS)
+        CALL JGETGG(KGAUSS,HTYPE,GLATS,KPTS,IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': JGETGG failed to get gaussian data',JPQUIET)
+     X      FNAME//': JGETGG failed to get gaussian data',JPQUIET)
           HIRLAMW = 2
           GOTO 900
         ENDIF
@@ -306,24 +318,21 @@ C
 C
         NUMBER = (IOFFS(KGAUSS*2+1) - 1)
         IF( NUMBER.NE.KOUNT ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Given no. of points =',KOUNT)
-          CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Expected no. of pts =',NUMBER)
+          CALL INTLOG(JP_ERROR,FNAME//': Given no. of points =',KOUNT)
+          CALL INTLOG(JP_ERROR,FNAME//': Expected no. of pts =',NUMBER)
           HIRLAMW = 3
           GOTO 900
         ENDIF
 C
         NPREV = KGAUSS
+        HPREV = HTYPE
       ENDIF
 C
 C     Preserve the input fields
 C     (in case OLDFLDx and NEWFLDx are the same arrays)
 C
-      DO LOOP = 1, NUMBER
-        OLDU(LOOP) = OLDFLDU(LOOP)
-        OLDV(LOOP) = OLDFLDV(LOOP)
-      ENDDO
+      OLDU(1:NUMBER) = OLDFLDU(1:NUMBER)
+      OLDV(1:NUMBER) = OLDFLDV(1:NUMBER)
 C
 C     -----------------------------------------------------------------|
 C     Section 2.  Generate the lat/long points for the output grid
@@ -342,8 +351,8 @@ C
 C     Check that given array is big enough for the new field.
 C
       IF( NLEN.GT.KSIZE ) THEN
-        CALL INTLOG(JP_ERROR,FUNCNAME//': Given array size = ',KSIZE)
-        CALL INTLOG(JP_ERROR,FUNCNAME//': Required size = = ',NLEN)
+        CALL INTLOG(JP_ERROR,FNAME//': Given array size = ',KSIZE)
+        CALL INTLOG(JP_ERROR,FNAME//': Required size = = ',NLEN)
         HIRLAMW = 5
         GOTO 900
       ENDIF
@@ -364,20 +373,19 @@ C
         IPRLON = IPRLON/(1024*1024*1024*4)
 #endif
         IF( IPRLON.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocate fail',JPQUIET)
+          CALL INTLOG(JP_ERROR,FNAME//': Memory allocate fail',JPQUIET)
           HIRLAMW = 6
           GOTO 900
         ENDIF
 C
-        IPRLAT  = IPRLON + (ILL*JPRLEN)
-        IPRCLON = IPRLAT + (ILL*JPRLEN)
+        IPRLAT  = IPRLON  + (ILL*JPRLEN)
+        IPRCLON = IPRLAT  + (ILL*JPRLEN)
         IPRCLAT = IPRCLON + (ILL*JPRLEN)
         IPRDIR  = IPRCLAT + (ILL*JPRLEN)
-        IPC     = IPRDIR + (ILL*JPRLEN)
-        IPS     = IPC    + (ILL*JPRLEN)
-        IPU     = IPS    + (ILL*JPRLEN)
-        IPV     = IPU    + (ILL*JPRLEN)
+        IPC     = IPRDIR  + (ILL*JPRLEN)
+        IPS     = IPC     + (ILL*JPRLEN)
+        IPU     = IPS     + (ILL*JPRLEN)
+        IPV     = IPU     + (ILL*JPRLEN)
 C
         ILLOLD = ILL
 C
@@ -386,7 +394,7 @@ C
       IRET = HGENGRW(AREA,POLE,GRID,NLON,NLAT,RCLAT,RCLON,RLAT,RLON)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': HGENGRW failed to get lat/lon grid',JPQUIET)
+     X      FNAME//': HGENGRW failed to get lat/lon grid',JPQUIET)
         HIRLAMW = 7
         GOTO 900
       ENDIF
@@ -410,8 +418,7 @@ C
         IPPDLO0 = IPPDLO0/(1024*1024*1024*4)
 #endif
         IF( IPPDLO0.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocate fail',JPQUIET)
+          CALL INTLOG(JP_ERROR,FNAME//': Memory allocate fail',JPQUIET)
           HIRLAMW = 8
           GOTO 900
         ENDIF
@@ -435,7 +442,7 @@ C
      X              KSCHEME,PDLAT,PDLO0,PDLO1,PDLO2,PDLO3,KLA,NEIGH)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': HNEI12 failed to find neighbours',JPQUIET)
+     X      FNAME//': HNEI12 failed to find neighbours',JPQUIET)
         HIRLAMW = 9
         GOTO 900
       ENDIF
diff --git a/interpolation/hirlsm.F b/interpolation/hirlsm.F
index abf8500..9f757f6 100644
--- a/interpolation/hirlsm.F
+++ b/interpolation/hirlsm.F
@@ -8,8 +8,8 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION HIRLSM(L12PNT,OLDFLD,KOUNT,KGAUSS,AREA,
-     X                        POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
+      INTEGER FUNCTION HIRLSM(L12PNT,OLDFLD,KOUNT,KGAUSS,
+     X  HTYPE,AREA,POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
 C
 C---->
 C**** HIRLSM
@@ -25,8 +25,8 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = HIRLSM(L12PNT,OLDFLD,KOUNT,KGAUSS,AREA,
-C    X              POLE,GRID,NEWFLD,KSIZE,NLON,NLAT)
+C     IRET = HIRLSM(L12PNT,OLDFLD,KOUNT,KGAUSS,HTYPE,AREA,POLE,GRID,
+C    X              NEWFLD,KSIZE,NLON,NLAT)
 C
 C
 C     Input parameters
@@ -37,7 +37,12 @@ C              = .TRUE. for 12-point horizontal
 C              = .FALSE. for 4-point
 C     OLDFLD - Array of values from the (old) reduced gaussian field
 C     KOUNT  - Number of values in OLDFLD
-C     KGAUSS - Gaussian number of the reduced gaussian field
+C     KGAUSS - Gaussian grid number
+C     HTYPE  - Gaussian grid type
+C              = 'R' for reduced ("quasi-regular"),
+C              = 'O' for reduced/octahedral,
+C              = 'F' for full,
+C              = 'U' for a user-defined gaussian grid
 C     AREA   - Limits of output area (N/W/S/E)
 C     POLE   - Pole of rotation (lat/long)
 C     GRID   - Output lat/long grid increments (we/ns)
@@ -48,9 +53,9 @@ C
 C     Output parameters
 C     -----------------
 C
-C     NEWFLD  - The array of values for the regular lat/long field
-C     NLON    - Number of longitudes in the regular lat/long field
-C     NLAT    - Number of latitudes in the regular lat/long field
+C     NEWFLD - The array of values for the regular lat/long field
+C     NLON   - Number of longitudes in the regular lat/long field
+C     NLAT   - Number of latitudes in the regular lat/long field
 C
 C     Returns 0 if function successful, non-zero otherwise.
 C
@@ -135,19 +140,16 @@ C
 C
 C     Parameters
 C
-      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S, JLAT, JLON
-      INTEGER JP12PT, JP4PT, JPNEARN
-      PARAMETER (JP12PT  = 0)
-      PARAMETER (JP4PT   = 1)
-      PARAMETER (JPNEARN = 2)
-      PARAMETER (JNORTH = 1 )
-      PARAMETER (JWEST  = 2 )
-      PARAMETER (JSOUTH = 3 )
-      PARAMETER (JEAST  = 4 )
-      PARAMETER (JW_E  = 1 )
-      PARAMETER (JN_S  = 2 )
-      PARAMETER (JLAT  = 1 )
-      PARAMETER (JLON  = 2 )
+      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S
+      INTEGER JP12PT, JP4PT
+      PARAMETER (JP12PT = 0)
+      PARAMETER (JP4PT  = 1)
+      PARAMETER (JNORTH = 1)
+      PARAMETER (JWEST  = 2)
+      PARAMETER (JSOUTH = 3)
+      PARAMETER (JEAST  = 4)
+      PARAMETER (JW_E   = 1)
+      PARAMETER (JN_S   = 2)
 C
 C     Function arguments
 C
@@ -155,6 +157,7 @@ C
       INTEGER KOUNT, KGAUSS, KSIZE, NLON, NLAT
       REAL AREA(4), POLE(2), GRID(2)
       REAL OLDFLD(*), NEWFLD(KSIZE)
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -162,7 +165,7 @@ C
       INTEGER NEAREST, NEND, COUNT
       INTEGER NJPR,  NJPB
       INTEGER NPREV
-      INTEGER loop1, INUM
+      INTEGER INUM
       INTEGER IOSIZE, INSIZE
       INTEGER NEWSIZE
       REAL OLDAREA(4), OLDPOLE(2), OLDGRID(2)
@@ -178,7 +181,10 @@ C
       POINTER (IPPWTS,  PWTS)
       LOGICAL LVEGGY
       CHARACTER*12 Y1FLAG, Y2FLAG
-      LOGICAL LNEWSPC, LOLDNEW, LSOIL, LITAL, LVEGGY2
+      LOGICAL LNEWSPC, LOLDNEW
+      LOGICAL LSOIL  ! Special processing for soil parameters
+      LOGICAL LITAL
+      LOGICAL LVEGGY2
       INTEGER KSCHEMEN(1)
       REAL PWTSN(12,1)
       POINTER (IPKSCHEN, KSCHEMEN)
@@ -206,8 +212,8 @@ C
 C
       REAL OLD(KOUNT)
 C
-      CHARACTER*7 FUNCNAME
-      PARAMETER  (FUNCNAME = 'HIRLSM ')
+      CHARACTER*7 FNAME
+      PARAMETER  (FNAME = 'HIRLSM ')
 C
       DATA IGGOLD/-1/, ILLOLD/-1/
       DATA NUMBER/-1/
@@ -262,18 +268,25 @@ C
       CALL JDEBUG()
 C
       IF( L12PNT ) THEN
-        CALL INTLOG(JP_DEBUG,FUNCNAME//': 12-pt interpolation',JPQUIET)
+        CALL INTLOG(JP_DEBUG,FNAME//': 12-pt interpolation',JPQUIET)
       ELSE
-        CALL INTLOG(JP_DEBUG,FUNCNAME//': 4-pt interpolation',JPQUIET)
+        CALL INTLOG(JP_DEBUG,FNAME//': 4-pt interpolation',JPQUIET)
       ENDIF
 C
       CALL CHKPREC()
       IF( LPREC )THEN
         CALL INTLOG(JP_DEBUG,
-     X    FUNCNAME//': precipitation threshold applied',JPQUIET)
+     X    FNAME//': precipitation threshold applied',JPQUIET)
       ELSE
         CALL INTLOG(JP_DEBUG,
-     X    FUNCNAME//': precipitation threshold not applied',JPQUIET)
+     X    FNAME//': precipitation threshold not applied',JPQUIET)
+      ENDIF
+
+      IF( HTYPE.NE.'O' .AND. HTYPE.NE.'R' .AND. HTYPE.NE.'U' ) THEN
+        CALL INTLOG(JP_ERROR,
+     X    FNAME//': Gaussian type unsupported ('//HTYPE//')',JPQUIET)
+        HIRLSM = 1
+        GOTO 900
       ENDIF
 
 
@@ -310,11 +323,11 @@ C         intout interpolation="nearest neighbour" )
       ENDIF
 
       IF( LVEGGY ) CALL INTLOG(JP_DEBUG,
-     X  FUNCNAME//': nearest neighbour processing: vegetation',JPQUIET)
+     X  FNAME//': nearest neighbour processing: vegetation',JPQUIET)
       IF( LSOIL  ) CALL INTLOG(JP_DEBUG,
-     X  FUNCNAME//': nearest neighbour processing: soil',      JPQUIET)
+     X  FNAME//': nearest neighbour processing: soil',      JPQUIET)
       IF( LITAL  ) CALL INTLOG(JP_DEBUG,
-     X  FUNCNAME//': nearest neighbour processing: new',       JPQUIET)
+     X  FNAME//': nearest neighbour processing: new',       JPQUIET)
 
 
 C
@@ -333,7 +346,7 @@ C
 #endif
         IF( IPKPTS.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocate fail',JPQUIET)
+     X      FNAME//': Memory allocate fail',JPQUIET)
           HIRLSM = 1
           GOTO 900
         ENDIF
@@ -352,13 +365,12 @@ CC    LOLDNEW = (KGAUSS.NE.NPREV)  this forces reloading the LSM always!
       LOLDNEW = .TRUE.
 C
 C     Build up offsets to start of each latitude in original field(s)
-C
       IF( LOLDNEW ) THEN
-C
-        CALL JGETGG(KGAUSS,'R',GLATS,KPTS,IRET)
+        CALL INTLOG(JP_DEBUG,FNAME//': trying Gaussian '//HTYPE,KGAUSS)
+        CALL JGETGG(KGAUSS,HTYPE,GLATS,KPTS,IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': JGETGG failed to get gaussian data',JPQUIET)
+     X      FNAME//': JGETGG failed to get gaussian data',JPQUIET)
           HIRLSM = 2
           GOTO 900
         ENDIF
@@ -373,10 +385,8 @@ C
 C
       NUMBER = (IOFFS(KGAUSS*2+1) - 1)
       IF( NUMBER.NE.KOUNT ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    FUNCNAME//': Given number of points =',KOUNT)
-        CALL INTLOG(JP_ERROR,
-     X    FUNCNAME//': Expected number of pts =',NUMBER)
+        CALL INTLOG(JP_ERROR,FNAME//': Given no. of points =',KOUNT)
+        CALL INTLOG(JP_ERROR,FNAME//': Expected no. of pts =',NUMBER)
         HIRLSM = 4
         GOTO 900
       ENDIF
@@ -384,9 +394,7 @@ C
 C     Preserve the input field
 C     (in case OLDFLD and NEWFLD are the same arrays)
 C
-      DO LOOP = 1, NUMBER
-        OLD(LOOP) = OLDFLD(LOOP)
-      ENDDO
+      OLD(1:NUMBER) = OLDFLD(1:NUMBER)
 C
 C     If old land-sea mask has changed, pick up different land-sea mask
 C
@@ -400,7 +408,7 @@ C
           IPOLDLS = JMALLOC(IOSIZE)
           IF( IPOLDLS.EQ.0 ) THEN
             CALL INTLOG(JP_ERROR,
-     X        FUNCNAME//': Memory allocate fail',JPQUIET)
+     X        FNAME//': Memory allocate fail',JPQUIET)
             HIRLSM = 4
             GOTO 900
           ENDIF
@@ -409,12 +417,12 @@ C
 C       Read values for different land-sea mask in memory
 C
         NEWSIZE = NUMBER*JPRLEN
-        IRET = HGETLSM(KGAUSS,OLDLSM,NEWSIZE)
+        IRET = HGETLSM(KGAUSS,HTYPE,OLDLSM,NEWSIZE)
 Cs        IRET = HGETLSM(KGAUSS,OLDLSM,IOSIZE)
 
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': HGETLSM failed to get LSM data',JPQUIET)
+     X      FNAME//': HGETLSM failed to get LSM data',JPQUIET)
           HIRLSM = 4
           GOTO 900
         ENDIF
@@ -438,8 +446,8 @@ C
 C     Check that given array is big enough for the new field.
 C
       IF( NLEN.GT.KSIZE ) THEN
-        CALL INTLOG(JP_ERROR,FUNCNAME//': Given array size = ',KSIZE)
-        CALL INTLOG(JP_ERROR,FUNCNAME//': Required size = = ',NLEN)
+        CALL INTLOG(JP_ERROR,FNAME//': Given array size = ',KSIZE)
+        CALL INTLOG(JP_ERROR,FNAME//': Required size = = ',NLEN)
         HIRLSM = 5
         GOTO 900
       ENDIF
@@ -461,7 +469,7 @@ C
 #endif
         IF( IPRLON.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocate fail',JPQUIET)
+     X      FNAME//': Memory allocate fail',JPQUIET)
           HIRLSM = 6
           GOTO 900
         ENDIF
@@ -475,7 +483,7 @@ C
       IRET = HGENGRD(AREA,POLE,GRID,NLON,NLAT,RLAT,RLON)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
-     X    FUNCNAME//': HGENGRD failed to get lat/lon grid data',JPQUIET)
+     X    FNAME//': HGENGRD failed to get lat/lon grid data',JPQUIET)
         HIRLSM = 7
         GOTO 900
       ENDIF
@@ -506,7 +514,7 @@ C
 #endif
         IF( IPPDLO0.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocate fail',JPQUIET)
+     X      FNAME//': Memory allocate fail',JPQUIET)
           HIRLSM = 8
           GOTO 900
         ENDIF
@@ -566,7 +574,7 @@ C
         IPNEWLS = JMALLOC(INSIZE)
         IF( IPNEWLS.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,
-     X      FUNCNAME//': Memory allocation fail',JPQUIET)
+     X      FNAME//': Memory allocation fail',JPQUIET)
           HIRLSM = 4
           GOTO 900
         ENDIF
@@ -579,7 +587,7 @@ C
      X              KSCHEME,PDLAT,PDLO0,PDLO1,PDLO2,PDLO3,KLA,NEIGH)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
-     X    FUNCNAME//': HNEI12 failed to find neighbours',JPQUIET)
+     X    FNAME//': HNEI12 failed to find neighbours',JPQUIET)
         HIRLSM = 9
         GOTO 900
       ENDIF
@@ -640,7 +648,7 @@ C
      X              KSCHEME,PDLAT,PDLO0,PDLO1,PDLO2,PDLO3,KLA,NEIGH)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
-     X    FUNCNAME//': HNEI12 failed to find neighbours',JPQUIET)
+     X    FNAME//': HNEI12 failed to find neighbours',JPQUIET)
         HIRLSM = 5
         GOTO 900
       ENDIF
diff --git a/interpolation/hneill.F b/interpolation/hneill.F
index 91f9f90..30c4fd8 100644
--- a/interpolation/hneill.F
+++ b/interpolation/hneill.F
@@ -92,7 +92,6 @@ C     ---------
 C
 C     INTLOG  - Log error message.
 C     JDEBUG  - Tests if debug output required.
-C     JMALLOC - Dynamically allocate memory
 C     JFREE   - Free dynamically allocated memory
 C
 C
@@ -150,23 +149,10 @@ C
 C
 C     Local variables
 C
-      INTEGER NEXT, LOOP, NBYTES, NOLDLAT, NOLDLON
+      INTEGER NEXT, LOOP, NOLDLAT, NOLDLON
       INTEGER NLAT0, NLAT1, NLAT2, NLAT3, NLAT(12), NLONG(12)
       INTEGER NLONG1, NLONG2, NLONG5
       REAL PLATINC, PLONINC
-      INTEGER NPREV, ISIZE, ISIZOLD
-C
-      DATA ISIZOLD/-1/, NPREV/-1/
-      SAVE ISIZOLD,NPREV
-C
-C     Externals
-C
-      INTEGER JNORSGG
-#ifdef POINTER_64
-      INTEGER*8 JMALLOC
-#else
-      INTEGER JMALLOC
-#endif
 C
 C     Statement functions
 C
diff --git a/interpolation/hntfaph.F b/interpolation/hntfaph.F
index a6b81ac..6fb27be 100644
--- a/interpolation/hntfaph.F
+++ b/interpolation/hntfaph.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -58,7 +58,7 @@ C     INTLOG  - Log error message.
 C     INTLOGR - Log error message.
 C     JDEBUG  - Checks environment to switch on/off debug
 C     FIXAREA - Fixup input/output field area definitions.
-C     HSP2GG  - Find suitable gaussian grid for spectral truncation
+C     HSH2GG  - Find suitable gaussian grid/spectral truncation
 C     HIRLAM  - Creates rotated lat/long field from reduced gaussian
 C     HIRLSM  - Creates rotated lat/long field from reduced gaussian
 C               using land-sea mask
@@ -73,7 +73,6 @@ C     ------
 C
 C     J.D.Chambers     ECMWF     January 31, 2001
 C
-C
 C----<
 C
 C     -----------------------------------------------------------------|
@@ -89,10 +88,9 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grfixed.h"
 #include "intf.h"
-#include "jparams.h"
 #include "current.h"
+#include "grfixed.h"
 C
 C     Parameters
 C
@@ -101,33 +99,64 @@ C
 C
 C     Local variables
 C
-      LOGICAL LUSELSM, LDEBUG, LSP2RGG, LLATOUT
-      INTEGER NUMPTS, NGAUSS, NLON, NLAT, NUVFLAG, NTRUNC, NCOUNT
-      INTEGER IWORD, IERR, LOOP, IRET, ISIZE, KPTS(JPGTRUNC*2)
-      INTEGER ISHIZE
-      INTEGER ITEMP,K,I,J,IM,JM
-      REAL PLATS(JPGTRUNC*2),AREA(4),GRID(2),POLE(2),WEST,EAST
-      REAL OLDGRID(2)
-      REAL TEMP(1440,1440)
       CHARACTER*1 HOLDTYP
-C
-      REAL SWORK(1), RGGRID(1), ZNFLDO(1)
+      CHARACTER*1 HTYPE
+      INTEGER     IERR
+      INTEGER     IRET
+      INTEGER     ISHIZE
+      INTEGER     ISIZE
+      INTEGER     ITEMP,K,I,J,IM,JM
+      INTEGER     IWORD
+      INTEGER     KPTS(JPGTRUNC*2)
+      INTEGER     LOOP
+      INTEGER     NCOUNT
+      INTEGER     NGAUSS
+      INTEGER     NLAT
+      INTEGER     NLON
+      INTEGER     NTRUNC
+      INTEGER     NUMPTS
+      INTEGER     NUVFLAG
+      LOGICAL     LLATOUT
+      LOGICAL     LSP2RGG
+      LOGICAL     LUSELSM
+      REAL        AREA(4)
+      REAL        EAST
+      REAL        EW
+      REAL        GRID(2)
+      REAL        NS
+      REAL        OLDGRID(2)
+      REAL        PLATS(JPGTRUNC*2)
+      REAL        POLE(2)
+      REAL        RGGRID(1)
+      REAL        SWORK(1)
+      REAL        TEMP(1440,1440)
+      REAL        WEST
+      REAL        ZNFLDO(1)
 #ifndef _CRAYFTN
 #ifdef POINTER_64
-      INTEGER*8 ISWORK, IRGGRID, IZNFLDO
+      INTEGER*8 IRGGRID
+      INTEGER*8 ISWORK
+      INTEGER*8 IZNFLDO
 #endif
 #endif
-      POINTER ( ISWORK, SWORK)
-      POINTER ( IRGGRID, RGGRID)
-      POINTER ( IZNFLDO, ZNFLDO )
+      POINTER (IRGGRID, RGGRID)
+      POINTER (ISWORK,  SWORK)
+      POINTER (IZNFLDO, ZNFLDO)
 C
-      SAVE IZNFLDO,ISWORK, IRGGRID
+      SAVE IRGGRID
+      SAVE ISWORK
+      SAVE IZNFLDO
 C
 C     Externals
 C
-      INTEGER HSP2GG, HIRLAM, HIRLSM, HRG2GG, HLL2LL, FIXAREA,PDDEFS
-      INTEGER HSP2GG2,HSP2GG3
+      CHARACTER*1 GGHTYPE
+      INTEGER HSH2GG, HIRLAM, HIRLSM, HRG2GG, FIXAREA, PDDEFS, AURESOL
+      INTEGER HLL2LL
       LOGICAL LSMFLD
+      EXTERNAL GGHTYPE
+      EXTERNAL HSH2GG, HIRLAM, HIRLSM, HRG2GG, FIXAREA, PDDEFS, AURESOL
+      EXTERNAL HLL2LL
+      EXTERNAL LSMFLD
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -136,12 +165,6 @@ C
   100 CONTINUE
 C
       HNTFAPH = 0
-C
-C     Check if debug option turned on
-C
-      CALL JDEBUG()
-      LDEBUG = ( NDBG.NE.0 )
-C
       LSP2RGG = .FALSE.
 C
 C     -----------------------------------------------------------------|
@@ -172,20 +195,20 @@ C
 
         IM = ISEC2(2)
         JM = ISEC2(3)
-         K=0
-         DO J=JM,1,-1
-           DO I=1,IM
-              K=K+1
-              TEMP(I,J) = ZNFELDI(K)
-           END DO
-         END DO
-         K=0
-         DO J=1,JM
-           DO I=1,IM
-              K=K+1
-              ZNFELDI(K) = TEMP(I,J)
-           END DO
-         END DO
+        K=0
+        DO J=JM,1,-1
+          DO I=1,IM
+            K=K+1
+            TEMP(I,J) = ZNFELDI(K)
+          END DO
+        END DO
+        K=0
+        DO J=1,JM
+          DO I=1,IM
+            K=K+1
+            ZNFELDI(K) = TEMP(I,J)
+          END DO
+        END DO
 
       ENDIF
 
@@ -208,7 +231,7 @@ C
       NCOUNT = ISEC4(1)
 C
       LLATOUT = (NOREPR.EQ.JPREGROT).OR.(NOREPR.EQ.JPREGULAR)
-C
+
       IF( .NOT.LNOROTA ) GOTO 900
 C
 C     -----------------------------------------------------------------|
@@ -217,18 +240,15 @@ C     -----------------------------------------------------------------|
 C
   300 CONTINUE
 C
-      IF( LDEBUG ) THEN
-        CALL INTLOG(JP_DEBUG,'HNTFAPH: Rotate field.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'HNTFAPH: South pole lat  ',NOROTA(1))
-        CALL INTLOG(JP_DEBUG,'HNTFAPH: South pole long ',NOROTA(2))
-      ENDIF
+      CALL INTLOG(JP_DEBUG,'HNTFAPH: Rotate field.',JPQUIET)
+      CALL INTLOG(JP_DEBUG,'HNTFAPH: South pole lat  ',NOROTA(1))
+      CALL INTLOG(JP_DEBUG,'HNTFAPH: South pole long ',NOROTA(2))
 C
 C     Fill area limits (handles case when default 0/0/0/0 given)
 C
       IRET = FIXAREA()
       IF( IRET.NE.0 ) THEN
-        IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X    'HNTFAPH: area fixup failed',JPQUIET)
+        CALL INTLOG(JP_ERROR,'HNTFAPH: area fixup failed',JPQUIET)
         HNTFAPH = JPROUTINE + 3
         GOTO 900
       ENDIF
@@ -250,136 +270,141 @@ C     -----------------------------------------------------------------|
 C
   400 CONTINUE
 C
-
       IF( (NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT) ) THEN
 C
 C       Convert spectral to suitable global reduced gaussian grid
 C
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'HNTFAPH: Spectral to suitable reduced gaussian',JPQUIET)
 C
         NIRESO = ISEC2(2)
         NTRUNC = ISEC2(2)
-      IF(LNORESO) THEN
-         NTRUNC = NORESO
-         IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
+        IF( LNORESO ) THEN
+          NTRUNC = NORESO
+          NGAUSS = 0
+          HTYPE  = ''
+          NS = 0.
+          EW = 0.
+          IRET = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,PLATS,ISIZE)
           IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+            CALL INTLOG(JP_ERROR,
+     X        'HNTFAPH: problem getting data for reduced grid',NTRUNC)
+            HNTFAPH = JPROUTINE + 4
+            GOTO 900
+          ENDIF
+          GOTO 401
+        ENDIF
+
+        IF( LARESOL ) THEN
+          NS = 0.
+          EW = 0.
+          IF( LLATOUT ) THEN
+            NS = GRID(1)
+            EW = GRID(2)
+            NTRUNC = 0
+            NGAUSS = 0
+            HTYPE = ''
+          ELSE
+            HTYPE = 'R'
+          ENDIF
+          IRET = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,PLATS,ISIZE)
+          IF( IRET.NE.0 ) THEN
+            CALL INTLOG(JP_ERROR,
      X        'HNTFAPH: problem getting data for reduced grid',NTRUNC)
             HNTFAPH = JPROUTINE + 4
             GOTO 900
           ENDIF
-         IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,'HNTFAPH: Spectral truncation:', NTRUNC)
-          CALL INTLOG(JP_DEBUG,'HNTFAPH: Gaussian number : ',NGAUSS)
-         ENDIF
-        GOTO 401
-       ENDIF
-       IF(LARESOL ) THEN
-        IF(LLATOUT) THEN
-         IRET = HSP2GG2(NTRUNC,GRID(1),GRID(2),NGAUSS,KPTS,PLATS,ISIZE)
-        ELSE
-         IRET = HSP2GG3(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
         ENDIF
-         IF( IRET.NE.0 ) THEN
-           IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X       'HNTFAPH: problem getting data for reduced grid',NTRUNC)
-           HNTFAPH = JPROUTINE + 4
-           GOTO 900
-         ENDIF
-       ENDIF
-c---------------------------------------------------------------------
+
 C       Truncate if a smaller resolution has been requested
 C
   401 CONTINUE
       IF( NTRUNC.LT.NIRESO ) THEN
-       IF( LDEBUG ) THEN
-       CALL INTLOG(JP_DEBUG,'HNTFAPH: Truncation changed from: ',NIRESO)
+       CALL INTLOG(JP_DEBUG,'HNTFAPH: Truncation changed from:',NIRESO)
        CALL INTLOG(JP_DEBUG,'HNTFAPH: to: ',NTRUNC)
-       CALL INTLOG(JP_DEBUG,'HNTFAPH: Gaussian number is : ',NGAUSS)
-       ENDIF
-C
-            ISHIZE =  (NTRUNC+1)*(NTRUNC+4)
-              CALL JMEMHAN( 3, IZNFLDO, ISHIZE, 1, IERR)
-              IF( IERR.NE.0 ) THEN
-                CALL INTLOG(JP_FATAL,
-     X            'HNTFAPH: Get scratch space failed',JPQUIET)
-                HNTFAPH = JPROUTINE + 4
-                GOTO 900
-              ENDIF
+       CALL INTLOG(JP_DEBUG,'HNTFAPH: Gaussian number is:',NGAUSS)
 C
-C         Generate spherical harmonics with output truncation
-C
-          CALL SH2SH( ZNFELDI, NIRESO, ZNFLDO, NTRUNC )
-C
-C         Move new spherical harmonics to 'input' array
-C
-          DO LOOP = 1, ISHIZE
-            ZNFELDI(LOOP) = ZNFLDO(LOOP)
-          ENDDO
+        ISHIZE =  (NTRUNC+1)*(NTRUNC+4)
+        CALL JMEMHAN( 3, IZNFLDO, ISHIZE, 1, IERR)
+        IF( IERR.NE.0 ) THEN
+          CALL INTLOG(JP_FATAL,
+     X      'HNTFAPH: Get scratch space failed',JPQUIET)
+          HNTFAPH = JPROUTINE + 4
+          GOTO 900
+        ENDIF
+
+C       Generate spherical harmonics with output truncation
+        CALL SH2SH( ZNFELDI, NIRESO, ZNFLDO, NTRUNC )
+
+C       Move new spherical harmonics to 'input' array
+        ZNFELDI(1:ISHIZE) = ZNFLDO(1:ISHIZE)
 
       ELSE
-C
-          IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+          CALL INTLOG(JP_DEBUG,
      X      'HNTFAPH: Spectral to suitable reduced gaussian',JPQUIET)
 C
           NTRUNC = ISEC2(2)
-          IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
+          NGAUSS = 0
+          HTYPE  = ''
+          NS = 0.
+          EW = 0.
+          IRET = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,PLATS,ISIZE)
           IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+            CALL INTLOG(JP_ERROR,
      X        'HNTFAPH: problem getting data for reduced grid',NTRUNC)
             HNTFAPH = JPROUTINE + 4
             GOTO 900
           ENDIF
-         IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,'HNTFAPH: Spectral truncation:', NTRUNC)
-          CALL INTLOG(JP_DEBUG,'HNTFAPH: Gaussian number : ',NGAUSS)
-         ENDIF
-      ENDIF
+
+        ENDIF
+
 C
 C       Dynamically allocate memory for global reduced gaussian grid
 C
         CALL JMEMHAN( 18, IRGGRID, ISIZE, 1, IRET)
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: memory alloc for reduced grid fail',JPQUIET)
           HNTFAPH = JPROUTINE + 4
           GOTO 900
         ENDIF
-C
+
 C       Set flag to show field is not a wind component
-C
         NUVFLAG = 0
-C
+
 C       Create the reduced gaussian grid
-C
         HOLDTYP = HOGAUST
         WEST = 0.0
         EAST = 360.0 - (360.0/(NGAUSS*4))
+c       EMOS-199: adjusted for reduced_gg/octahedral
+        IF (HTYPE.EQ.'O')  EAST = 360.0 - (360.0/FLOAT(KPTS(NGAUSS)))
+        IF (HTYPE.NE.'R' .AND. HTYPE.NE.'O' .AND.
+     X      HTYPE.NE.'F' .AND. HTYPE.NE.'U') THEN
+          HTYPE = 'R'
+        ENDIF
         CALL JAGGGP(ZNFELDI,NTRUNC,PLATS(1),PLATS(NGAUSS*2),WEST,
-     X              EAST,NGAUSS,'R',KPTS,RGGRID,NUVFLAG,IRET)
+     X              EAST,NGAUSS,HTYPE,KPTS,RGGRID,NUVFLAG,IRET)
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: spectral to reduced gaussian failed',JPQUIET)
           HNTFAPH = JPROUTINE + 4
           GOTO 900
         ENDIF
         HOGAUST = HOLDTYP
-C
+
         NCOUNT = 0
         DO LOOP = 1, (NGAUSS*2)
           NCOUNT= NCOUNT + KPTS(LOOP)
         ENDDO
-C
+
         LSP2RGG = .TRUE.
-C
+
         IF( NOREPR.EQ.JPFGGROT ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+          CALL INTLOG(JP_DEBUG,
      X      'HNTFAPH: Convert gaussian to rotated gaussian',JPQUIET)
-C
           GOTO 600
-C
         ENDIF
+
       ENDIF
 C
 C     -----------------------------------------------------------------|
@@ -388,12 +413,12 @@ C     -----------------------------------------------------------------|
 C
   500 CONTINUE
 C
-      IF( (LSP2RGG.AND.LLATOUT) .OR.
-     X    ( (NIREPR.EQ.JPGAUSSIAN).AND.LLATOUT) .OR.
-     X    ( (NIREPR.EQ.JPQUASI).AND.LLATOUT)    ) THEN
+      IF( (LLATOUT) .AND. (
+     X        (NIREPR.EQ.JPQUASI) .OR.
+     X        (NIREPR.EQ.JPGAUSSIAN) .OR.
+     X        (LSP2RGG) )) THEN
 C
-        IF( LDEBUG )
-     X    CALL INTLOG(JP_DEBUG,'HNTFAPH: Gauss to lat/lon',JPQUIET)
+        CALL INTLOG(JP_DEBUG,'HNTFAPH: Gauss to lat/lon',JPQUIET)
 C
 C       Dynamically allocate memory for rotated lat/long grid
 C
@@ -409,9 +434,9 @@ C
         ISIZE  = NUMPTS
         CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: memory alloc for lat/long grid fail',JPQUIET)
-          HNTFAPH = JPROUTINE + 7
+          HNTFAPH = JPROUTINE + 5
           GOTO 900
         ENDIF
 C
@@ -421,11 +446,11 @@ C       If original field was spectral, ...
 C
         IF( LSP2RGG ) THEN
           IF( LUSELSM ) THEN
-            IRET = HIRLSM(LO12PT,RGGRID,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                    SWORK,ISIZE,NLON,NLAT)
+            IRET = HIRLSM(LO12PT,RGGRID,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
           ELSE
-            IRET = HIRLAM(LO12PT,RGGRID,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                    SWORK,ISIZE,NLON,NLAT)
+            IRET = HIRLAM(LO12PT,RGGRID,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
           ENDIF
 C
         ELSE
@@ -434,19 +459,20 @@ C       If original field was gaussian, ...
 C
           IRET = PDDEFS()
           NGAUSS = ISEC2(10)
-cs          IF( LUSELSM ) THEN
+          HTYPE  = GGHTYPE(NIREPR,NGAUSS,MILLEN)
+cs        IF( LUSELSM ) THEN
           IF( LSM ) THEN
-            IRET = HIRLSM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                    SWORK,ISIZE,NLON,NLAT)
+            IRET = HIRLSM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
           ELSE
-            IRET = HIRLAM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                    SWORK,ISIZE,NLON,NLAT)
+            IRET = HIRLAM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
           ENDIF
 C
         ENDIF
 C
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: HIRLAM rotation failed',JPQUIET)
           HNTFAPH = JPROUTINE + 7
           GOTO 900
@@ -467,17 +493,18 @@ C
      X    (LSP2RGG.AND.(NOREPR.EQ.JPQGGROT)) .OR.
      X    (((NIREPR.EQ.JPQUASI).OR.(NIREPR.EQ.JPGAUSSIAN)) .AND.
      X     (NOREPR.EQ.JPFGGROT).OR.(NOREPR.EQ.JPQGGROT)) ) THEN
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'HNTFAPH: Gaussian to reduced gaussian',JPQUIET)
 C
 C       Dynamically allocate memory for rotated lat/long grid
 C
-        ISIZE = NOGAUSS * NOGAUSS * 8 
+C       ISIZE = NOGAUSS * NOGAUSS * 8
+        ISIZE = (2*NOGAUSS) * (4*NOGAUSS + 20)  ! account for RGG/octahedral
         CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: memory alloc for gaussian grid fail',JPQUIET)
-          HNTFAPH = JPROUTINE + 8
+          HNTFAPH = JPROUTINE + 6
           GOTO 900
         ENDIF
 C
@@ -496,9 +523,9 @@ C
      X                  NOGAUSS,HOGAUST,SWORK,ISIZE,NUMPTS)
         ENDIF
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: HRG2GG rotation failed',JPQUIET)
-          HNTFAPH = JPROUTINE + 8
+          HNTFAPH = JPROUTINE + 6
           GOTO 900
         ENDIF
 C
@@ -537,7 +564,7 @@ C
         ISIZE  = NUMPTS
         CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: memory alloc for lat/long grid fail',JPQUIET)
           HNTFAPH = JPROUTINE + 7
           GOTO 900
@@ -549,7 +576,7 @@ C
      X                NLON,NLAT)
 C
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X      'HNTFAPH: HLL2LL rotation failed',JPQUIET)
           HNTFAPH = JPROUTINE + 7
           GOTO 900
@@ -559,17 +586,10 @@ C
         ISEC4(1) = NOWE * NONS
 C
       ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 8.   Move rotated field back into field original array.
-C     -----------------------------------------------------------------|
-C
-  800 CONTINUE
-C
-      DO LOOP = 1, NUMPTS
-        ZNFELDI(LOOP) = SWORK(LOOP)
-      ENDDO
-C
+
+C     move rotated field back into field original array
+      ZNFELDI(1:NUMPTS) = SWORK(1:NUMPTS)
+
 C     -----------------------------------------------------------------|
 C*    Section 9.   Closedown.
 C     -----------------------------------------------------------------|
diff --git a/interpolation/hntfaps.F b/interpolation/hntfaps.F
index 2ee7831..60020d9 100644
--- a/interpolation/hntfaps.F
+++ b/interpolation/hntfaps.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -110,45 +110,42 @@ C
 C
 C     Local variables
 C
-      REAL POLELAT, POLELON
-      CHARACTER*1 TYPE
-      INTEGER IWORD, IERR, KPR
-      INTEGER NUMPTS, NGAUSS
-      INTEGER ISIZE, NBYTES, ITRUNC, LOOP, IRET
+      INTEGER IERR
+      INTEGER IRET
+      INTEGER ISIZE
+      INTEGER ITRUNC
+      INTEGER IWORD
+      INTEGER KPR
+      INTEGER NBYTES
+      LOGICAL LOK
+      LOGICAL LSPLIT
+      REAL    POLELAT
+      REAL*8  DLAT
+      REAL*8  DLON
+      REAL*8  LATLIM
+#if (!defined REAL_8)
+      INTEGER LOOP
+#endif
+      DATA NBYTES/4/
       DATA ISIZE/0/
+      SAVE ISIZE
 C
-      REAL SWORK
-      DIMENSION SWORK(1)
+      REAL   SWORK(1)
+      REAL*8 DWORK(1)
+      REAL*8 DATA(1)
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 ISWORK
-#endif
-#endif
-      POINTER ( ISWORK, SWORK)
-C
-      REAL*8 DWORK
-      DIMENSION DWORK(1)
-#ifndef _CRAYFTN
-#ifdef POINTER_64
       INTEGER*8 IDWORK
-#endif
-#endif
-      POINTER ( IDWORK, DWORK)
-C
-      REAL*8 DATA
-      DIMENSION DATA(1)
-#ifndef _CRAYFTN
-#ifdef POINTER_64
       INTEGER*8 IDATA
 #endif
 #endif
-      POINTER ( IDATA, DATA)
-C
-      SAVE ISIZE, ISWORK, IDWORK, IDATA
-C
-      REAL*8 DLON, DLAT, LATLIM
-      LOGICAL LOK, LSPLIT
-      DATA NBYTES/4/
+      POINTER (ISWORK, SWORK)
+      POINTER (IDWORK, DWORK)
+      POINTER (IDATA,  DATA)
+      SAVE ISWORK
+      SAVE IDWORK
+      SAVE IDATA
 C
 C     Externals
 C
diff --git a/interpolation/hntfau.F b/interpolation/hntfau.F
index a9b4f2a..538c734 100644
--- a/interpolation/hntfau.F
+++ b/interpolation/hntfau.F
@@ -73,8 +73,6 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grfixed.h"
-#include "intf.h"
 C
 C     Parameters
 C
@@ -85,48 +83,30 @@ C     Function arguments
 C
       INTEGER INGRIB(*),INLEN
 C
-C     Local variables
-C
-      INTEGER IRET
-C
 C     Externals
 C
       INTEGER  HNTFAUS, HNTFAUH
       EXTERNAL HNTFAUS, HNTFAUH
 C
 C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
+C*    Section 1.   Split handling in case there are rotations to do.
 C     -----------------------------------------------------------------|
 C
   100 CONTINUE
 C
-      HNTFAU = 0
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.   Split handling in case there are rotations to do.
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
 C     Is the interpolation from SH to SH?
 C
       IF( ((NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT)) .AND.
      X    ((NOREPR.EQ.JPSPHERE).OR.(NOREPR.EQ.JPSPHROT)) ) THEN
 C
-        IRET = HNTFAUS(INGRIB,INLEN)
+        HNTFAU = HNTFAUS(INGRIB,INLEN)
 C
       ELSE
 C
-        IF( LIMISSA ) THEN
-          CALL INTLOG(JP_DEBUG,'HNTFAU: Use missing value',JPQUIET)
-          LIMISSV = .TRUE.
-        ENDIF
-        IRET = HNTFAUH(INGRIB,INLEN)
+        HNTFAU = HNTFAUH(INGRIB,INLEN)
 C
       ENDIF
 C
-      IF( IRET.NE.0 ) HNTFAU = JPROUTINE
-C
 C     -----------------------------------------------------------------|
 C*    Section 9.   Closedown.
 C     -----------------------------------------------------------------|
diff --git a/interpolation/hntfauh.F b/interpolation/hntfauh.F
index 1148ceb..0c5b56c 100644
--- a/interpolation/hntfauh.F
+++ b/interpolation/hntfauh.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -16,7 +16,7 @@ C
 C     Purpose
 C     -------
 C
-C     Prepare to interpolate input field...
+C     Prepare to interpolate to grid point field.
 C
 C
 C     Interface
@@ -54,7 +54,7 @@ C     INTLOG  - Log error message.
 C     INTLOGR - Log error message.
 C     JDEBUG  - Checks environment to switch on/off debug
 C     FIXAREA - Fixup input/output field area definitions.
-C     HSP2GG  - Find suitable gaussian grid for spectral truncation
+C     HSH2GG  - Find suitable gaussian grid/spectral truncation
 C     HIRLAM  - Creates rotated lat/long field from reduced gaussian
 C     HIRLSM  - Creates rotated lat/long field from reduced gaussian
 C               using land-sea mask
@@ -84,56 +84,75 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grfixed.h"
 #include "intf.h"
-#include "jparams.h"
 #include "current.h"
-#include "intlog.h"
+#include "grfixed.h"
 C
 C     Parameters
 C
       INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 40150 )
-      INTEGER JPLEN, JPNM
-      PARAMETER ( JPNM = JPSTRUNC )
-      PARAMETER ( JPLEN = (JPNM+1)*(JPNM+2) )
+      PARAMETER (JPROUTINE = 40150)
 C
 C     Local variables
 C
-      LOGICAL LUSELSM, LSP2RGG, LLATOUT
-      INTEGER NUMPTS, NGAUSS, NLON, NLAT, NUVFLAG, NTRUNC, NCOUNT
-      INTEGER IWORD, IERR, LOOP, IRET, ISIZE, KPTS(JPGTRUNC*2)
-      INTEGER ISHIZE
-      INTEGER ITEMP,K,I,J,IM,JM
-      REAL PLATS(JPGTRUNC*2),AREA(4),GRID(2),POLE(2),WEST,EAST
-
-C     REAL TEMP(1440,1440): EMOS-113: changed to dynamic memory allocation
-      REAL TEMP(1536,1536)
-
       CHARACTER*1 HOLDTYP
-C
-      REAL SWORK(1), RGGRID(1), ZNFLDO(1)
+      CHARACTER*1 HTYPE
+      INTEGER     IERR
+      INTEGER     IRET
+      INTEGER     ISHIZE
+      INTEGER     ISIZE
+      INTEGER     ITEMP,K,I,J,IM,JM
+      INTEGER     KPTS(JPGTRUNC*2)
+      INTEGER     LOOP
+      INTEGER     NCOUNT
+      INTEGER     NGAUSS
+      INTEGER     NLAT
+      INTEGER     NLON
+      INTEGER     NTRUNC
+      INTEGER     NUMPTS
+      INTEGER     NUVFLAG
+      LOGICAL     LLATOUT
+      LOGICAL     LSP2RGG
+      LOGICAL     LUSELSM
+      REAL        AREA(4)
+      REAL        EAST
+      REAL        EW
+      REAL        GRID(2)
+      REAL        NS
+      REAL        PLATS(JPGTRUNC*2)
+      REAL        POLE(2)
+      REAL        RGGRID(1)
+      REAL        SWORK(1)
+C     REAL        TEMP(1440,1440): EMOS-113: changed to dynamic memory allocation
+      REAL        TEMP(1536,1536)
+      REAL        WEST
+      REAL        ZNFLDO(1)
 #ifndef _CRAYFTN
 #ifdef POINTER_64
-      INTEGER*8 ISWORK, IRGGRID, IZNFLDO
+      INTEGER*8 IRGGRID
+      INTEGER*8 ISWORK
+      INTEGER*8 IZNFLDO
 #endif
 #endif
-      POINTER ( ISWORK, SWORK)
-      POINTER ( IRGGRID, RGGRID)
-      POINTER ( IZNFLDO, ZNFLDO )
+      POINTER (IRGGRID, RGGRID)
+      POINTER (ISWORK,  SWORK)
+      POINTER (IZNFLDO, ZNFLDO)
 C
-      SAVE IZNFLDO, ISWORK, IRGGRID
+      SAVE IRGGRID
+      SAVE ISWORK
+      SAVE IZNFLDO
+C
+      DATA ISIZE/0/
 C
 C     Externals
 C
-      INTEGER HSP2GG, HIRLAM, HIRLSM, HRG2GG, FIXAREA, PDDEFS
-      INTEGER HSP2GG2,HSP2GG3
+      CHARACTER*1 GGHTYPE
+      INTEGER HSH2GG, HIRLAM, HIRLSM, HRG2GG, FIXAREA, PDDEFS, AURESOL
       LOGICAL LSMFLD
-C
-      REAL POLELAT, POLELON
-      CHARACTER*1 TYPE
-      INTEGER NBYTES, ITRUNC
-      DATA ISIZE/0/
+      EXTERNAL GGHTYPE
+      EXTERNAL HSH2GG, HIRLAM, HIRLSM, HRG2GG, FIXAREA, PDDEFS, AURESOL
+      EXTERNAL LSMFLD
+
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -145,6 +164,10 @@ C
       IRET    = 0
 C
       NCOUNT = INLEN
+      IF( LIMISSA ) THEN
+        CALL INTLOG(JP_DEBUG,'HNTFAUH: Use missing value',JPQUIET)
+        LIMISSV = .TRUE.
+      ENDIF
 C
 C     -----------------------------------------------------------------|
 C*    Section 2.   Store input data.
@@ -163,12 +186,9 @@ C
         ENDIF
         IZNJDCI = 1952999238
       ENDIF
-C
+
 C     Move unpacked values in from user array
-C
-      DO LOOP = 1, INLEN
-        ZNFELDI( LOOP ) = FLDIN( LOOP )
-      ENDDO
+      ZNFELDI(1:INLEN) = FLDIN(1:INLEN)
       IF (NISCNM.EQ.64) THEN
         CALL INTLOG(JP_DEBUG,
      X    'HNTFAUH: Scanning flag west-east/south-north',NISCNM)
@@ -176,365 +196,332 @@ C
         NIAREA(1) = NIAREA(3)
         NIAREA(3) = ITEMP
 
-
         IM = NIWE
         JM = NINS
         K=0
         DO J=JM,1,-1
           DO I=1,IM
             K=K+1
-              TEMP(I,J) = ZNFELDI(K)
+            TEMP(I,J) = ZNFELDI(K)
           END DO
         END DO
         K=0
         DO J=1,JM
           DO I=1,IM
             K=K+1
-              ZNFELDI(K) = TEMP(I,J)
+            ZNFELDI(K) = TEMP(I,J)
           END DO
         END DO
 
-
       ENDIF
 C
       LLATOUT = (NOREPR.EQ.JPREGROT).OR.(NOREPR.EQ.JPREGULAR)
+
+      IF( .NOT.LNOROTA ) GOTO 900
+C
 C     -----------------------------------------------------------------|
 C*    Section 3.   Handle rotation, if necessary.
 C     -----------------------------------------------------------------|
 C
   300 CONTINUE
 C
-C     Is rotation required?
-C
-      IF( LNOROTA ) THEN
+      CALL INTLOG(JP_DEBUG,'HNTFAUH: Rotate field.',JPQUIET)
+      CALL INTLOG(JP_DEBUG,'HNTFAUH: South pole lat  ',NOROTA(1))
+      CALL INTLOG(JP_DEBUG,'HNTFAUH: South pole long ',NOROTA(2))
 C
-        IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: Rotate field.',JPQUIET)
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: South pole lat  ',NOROTA(1))
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: South pole long ',NOROTA(2))
-        ENDIF
+C     Fill area limits (handles case when default 0/0/0/0 given)
 C
-C       Fill area limits (handles case when default 0/0/0/0 given)
-C
-        IRET = FIXAREA()
-        IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X      'HNTFAUH: area fixup failed',JPQUIET)
-          HNTFAUH = JPROUTINE + 3
-          GOTO 900
-        ENDIF
+      IRET = FIXAREA()
+      IF( IRET.NE.0 ) THEN
+        CALL INTLOG(JP_ERROR,'HNTFAUH: area fixup failed',JPQUIET)
+        HNTFAUH = JPROUTINE + 3
+        GOTO 900
+      ENDIF
 C
-        AREA(1) = REAL(NOAREA(1))/PPMULT
-        AREA(2) = REAL(NOAREA(2))/PPMULT
-        AREA(3) = REAL(NOAREA(3))/PPMULT
-        AREA(4) = REAL(NOAREA(4))/PPMULT
+      AREA(1) = REAL(NOAREA(1))/PPMULT
+      AREA(2) = REAL(NOAREA(2))/PPMULT
+      AREA(3) = REAL(NOAREA(3))/PPMULT
+      AREA(4) = REAL(NOAREA(4))/PPMULT
 C
-        GRID(1) = REAL(NOGRID(1))/PPMULT
-        GRID(2) = REAL(NOGRID(2))/PPMULT
+      GRID(1) = REAL(NOGRID(1))/PPMULT
+      GRID(2) = REAL(NOGRID(2))/PPMULT
 C
-        POLE(1) = REAL(NOROTA(1))/PPMULT
-        POLE(2) = REAL(NOROTA(2))/PPMULT
+      POLE(1) = REAL(NOROTA(1))/PPMULT
+      POLE(2) = REAL(NOROTA(2))/PPMULT
 C
 C     -----------------------------------------------------------------|
 C*    Section 4.   Spectral to rotated grid-point
 C     -----------------------------------------------------------------|
 C
-  400   CONTINUE
+  400 CONTINUE
 C
-        LSP2RGG = .FALSE.
+      LSP2RGG = .FALSE.
       IF( (NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT) ) THEN
 C
-C         Convert spectral to suitable global reduced gaussian grid
+C       Convert spectral to suitable global reduced gaussian grid
 C
-          IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
-     X      'HNTFAUH: Spectral to suitable reduced gaussian',JPQUIET)
+        CALL INTLOG(JP_DEBUG,
+     X    'HNTFAUH: Spectral to suitable reduced gaussian',JPQUIET)
 C
-          NTRUNC = NIRESO
-c---------------------------------------------------------------------
-      IF(LNORESO) THEN
-         NTRUNC = NORESO
-         IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
+        NTRUNC = NIRESO
+
+        IF( LNORESO ) THEN
+          NTRUNC = NORESO
+          NGAUSS = 0
+          HTYPE  = ''
+          NS = 0.
+          EW = 0.
+          IRET = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,PLATS,ISIZE)
           IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+            CALL INTLOG(JP_ERROR,
      X        'HNTFAUH: problem getting data for reduced grid',NTRUNC)
             HNTFAUH = JPROUTINE + 4
             GOTO 900
           ENDIF
-         IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: Spectral truncation:', NTRUNC)
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: Gaussian number : ',NGAUSS)
-         ENDIF
-        GOTO 401
-       ENDIF
+          GOTO 401
+        ENDIF
 
-       IF(LARESOL ) THEN
-        IF(LLATOUT) THEN
-         IRET = HSP2GG2(NTRUNC,GRID(1),GRID(2),NGAUSS,KPTS,PLATS,ISIZE)
-        ELSE
-         IRET = HSP2GG3(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
+        IF( LARESOL ) THEN
+          NS = 0.
+          EW = 0.
+          IF( LLATOUT ) THEN
+            NS = GRID(1)
+            EW = GRID(2)
+            NTRUNC = 0
+            NGAUSS = 0
+            HTYPE = ''
+          ELSE
+            HTYPE = 'R'
+          ENDIF
+          IRET = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,PLATS,ISIZE)
+          IF( IRET.NE.0 ) THEN
+            CALL INTLOG(JP_ERROR,
+     X        'HNTFAUH: problem getting data for reduced grid',NTRUNC)
+            HNTFAUH = JPROUTINE + 4
+            GOTO 900
+          ENDIF
         ENDIF
-         IF( IRET.NE.0 ) THEN
-           IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X       'HNTFAUH: problem getting data for reduced grid',NTRUNC)
-           HNTFAUH = JPROUTINE + 4
-           GOTO 900
-         ENDIF
-       ENDIF
-c---------------------------------------------------------------------
-cs            IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
-cs            IF( IRET.NE.0 ) THEN
-cs              IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-cs     X         'HNTFAUH: problem getting data for reduced gridl',NTRUNC)
-cs              HNTFAUH = JPROUTINE + 4
-cs              GOTO 900
-cs            ENDIF
 
-cs         NCOUNT = ISIZE
-c---------------------------------------------------------------------
 C       Truncate if a smaller resolution has been requested
 C
   401 CONTINUE
       IF( NTRUNC.LT.NIRESO ) THEN
-       IF( LDEBUG ) THEN
-       CALL INTLOG(JP_DEBUG,'HNTFAUH: Truncation changed from: ',NIRESO)
+       CALL INTLOG(JP_DEBUG,'HNTFAUH: Truncation changed from:',NIRESO)
        CALL INTLOG(JP_DEBUG,'HNTFAUH: to: ',NTRUNC)
-       CALL INTLOG(JP_DEBUG,'HNTFAUH: Gaussian number is : ',NGAUSS)
-       ENDIF
-C
-            ISHIZE =  (NTRUNC+1)*(NTRUNC+4)
-              CALL JMEMHAN( 3, IZNFLDO, ISHIZE, 1, IERR)
-              IF( IERR.NE.0 ) THEN
-                CALL INTLOG(JP_FATAL,
-     X            'HNTFAUH: Get scratch space failed',JPQUIET)
-                HNTFAUH = JPROUTINE + 4
-                GOTO 900
-              ENDIF
-C
-C         Generate spherical harmonics with output truncation
-C
-          CALL SH2SH( ZNFELDI, NIRESO, ZNFLDO, NTRUNC )
-C
-C         Move new spherical harmonics to 'input' array
-C
-          DO LOOP = 1, ISHIZE
-            ZNFELDI(LOOP) = ZNFLDO(LOOP)
-          ENDDO
+       CALL INTLOG(JP_DEBUG,'HNTFAUH: Gaussian number is:',NGAUSS)
+C
+        ISHIZE =  (NTRUNC+1)*(NTRUNC+4)
+        CALL JMEMHAN( 3, IZNFLDO, ISHIZE, 1, IERR)
+        IF( IERR.NE.0 ) THEN
+          CALL INTLOG(JP_FATAL,
+     X      'HNTFAUH: Get scratch space failed',JPQUIET)
+          HNTFAUH = JPROUTINE + 4
+          GOTO 900
+        ENDIF
+
+C       Generate spherical harmonics with output truncation
+        CALL SH2SH( ZNFELDI, NIRESO, ZNFLDO, NTRUNC )
+
+C       Move new spherical harmonics to 'input' array
+        ZNFELDI(1:ISHIZE) = ZNFLDO(1:ISHIZE)
 
       ELSE
-C
-          IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+          CALL INTLOG(JP_DEBUG,
      X      'HNTFAUH: Spectral to suitable reduced gaussian',JPQUIET)
 C
           NTRUNC = NIRESO
-          IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,PLATS,ISIZE)
+          NGAUSS = 0
+          HTYPE  = ''
+          NS = 0.
+          EW = 0.
+          IRET = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,PLATS,ISIZE)
           IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+            CALL INTLOG(JP_ERROR,
      X        'HNTFAUH: problem getting data for reduced grid',NTRUNC)
             HNTFAUH = JPROUTINE + 4
             GOTO 900
           ENDIF
-         IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: Spectral truncation:', NTRUNC)
-          CALL INTLOG(JP_DEBUG,'HNTFAUH: Gaussian number : ',NGAUSS)
-         ENDIF
-       ENDIF
-c---------------------------------------------------------------------
-C
-C         Dynamically allocate memory for global reduced gaussian grid
-C
-          CALL JMEMHAN( 18, IRGGRID, ISIZE, 1, IRET)
-          IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X        'HNTFAUH: memory alloc for reduced grid fail',JPQUIET)
-            HNTFAUH = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-C
-C         Set flag to show field is not a wind component
-C
-          NUVFLAG = 0
+
+        ENDIF
+
 C
-C         Create the reduced gaussian grid
+C       Dynamically allocate memory for global reduced gaussian grid
 C
-          HOLDTYP = HOGAUST
-          WEST = 0.0
-          EAST = 360.0 - (360.0/(NGAUSS*4))
-          CALL JAGGGP(ZNFELDI,NTRUNC,PLATS(1),PLATS(NGAUSS*2),WEST,
-     X                EAST,NGAUSS,'R',KPTS,RGGRID,NUVFLAG,IRET)
-          IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X        'HNTFAUH: spectral to reduced gaussian failed',JPQUIET)
-            HNTFAUH = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-          HOGAUST = HOLDTYP
+        CALL JMEMHAN( 18, IRGGRID, ISIZE, 1, IRET)
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HNTFAUH: memory alloc for reduced grid fail',JPQUIET)
+          HNTFAUH = JPROUTINE + 4
+          GOTO 900
+        ENDIF
+
+C       Set flag to show field is not a wind component
+        NUVFLAG = 0
+
+C       Create the reduced gaussian grid
+        HOLDTYP = HOGAUST
+        WEST = 0.0
+        EAST = 360.0 - (360.0/(NGAUSS*4))
+c       EMOS-199: adjusted for reduced_gg/octahedral
+        IF (HTYPE.EQ.'O')  EAST = 360.0 - (360.0/FLOAT(KPTS(NGAUSS)))
+        IF (HTYPE.NE.'R' .AND. HTYPE.NE.'O' .AND.
+     X      HTYPE.NE.'F' .AND. HTYPE.NE.'U') THEN
+          HTYPE = 'R'
+        ENDIF
+        CALL JAGGGP(ZNFELDI,NTRUNC,PLATS(1),PLATS(NGAUSS*2),WEST,
+     X              EAST,NGAUSS,HTYPE,KPTS,RGGRID,NUVFLAG,IRET)
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HNTFAUH: spectral to reduced gaussian failed',JPQUIET)
+          HNTFAUH = JPROUTINE + 4
+          GOTO 900
+        ENDIF
+        HOGAUST = HOLDTYP
 
         NCOUNT = 0
         DO LOOP = 1, (NGAUSS*2)
           NCOUNT= NCOUNT + KPTS(LOOP)
         ENDDO
-C
-          LSP2RGG = .TRUE.
-C
-C     -----------------------------------------------------------------|
-C*    Section 5.   Complete the spectral to rotated lat/long
-C     -----------------------------------------------------------------|
-C
-  500     CONTINUE
-C
-          IF( NOREPR.EQ.JPREGROT ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
-     X        'HNTFAUH: Convert gaussian to rotated lat/long',JPQUIET)
-C
-            GOTO 700
-C
-          ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 6.   Complete the spectral to rotated gaussian
-C     -----------------------------------------------------------------|
-C
-  600   CONTINUE
-C
-          IF( NOREPR.EQ.JPFGGROT ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
-     X        'HNTFAUH: Convert gaussian to rotated gaussian',JPQUIET)
-C
-            GOTO 800
-          ENDIF
 
+        LSP2RGG = .TRUE.
+
+        IF( NOREPR.EQ.JPFGGROT ) THEN
+          CALL INTLOG(JP_DEBUG,
+     X      'HNTFAUH: Convert gaussian to rotated gaussian',JPQUIET)
+          GOTO 600
         ENDIF
+
+      ENDIF
 C
 C     -----------------------------------------------------------------|
-C*    Section 7.   Gaussian to rotated lat/long
+C*    Section 5.   Gaussian to rotated lat/long
 C     -----------------------------------------------------------------|
 C
-  700   CONTINUE
+  500 CONTINUE
 C
-        IF( (LSP2RGG.AND.(NOREPR.EQ.JPREGROT)) .OR.
-     X      ( ((NIREPR.EQ.JPQUASI).OR.(NIREPR.EQ.JPGAUSSIAN)) .AND.
-     X      (NOREPR.EQ.JPREGROT) ) ) THEN
-          IF( LDEBUG )
-     X      CALL INTLOG(JP_DEBUG,'HNTFAUH: Gauss to lat/lon',JPQUIET)
+      IF( (NOREPR.EQ.JPREGROT) .AND. (
+     X        (NIREPR.EQ.JPQUASI) .OR.
+     X        (NIREPR.EQ.JPGAUSSIAN) .OR.
+     X        (LSP2RGG) )) THEN
 C
-C         Dynamically allocate memory for rotated lat/long grid
+        CALL INTLOG(JP_DEBUG,'HNTFAUH: Gauss to lat/lon',JPQUIET)
 C
-          NLON = 1 + NINT(FLOAT((NOAREA(JPEAST)  - NOAREA(JPWEST))) /
-     X           NOGRID(JPWESTEP))
-          NLAT = 1 + NINT(FLOAT((NOAREA(JPNORTH) - NOAREA(JPSOUTH))) /
-     X           NOGRID(JPNSSTEP))
+C       Dynamically allocate memory for rotated lat/long grid
 C
-          NUMPTS = NLON * NLAT
-          ISIZE  = NUMPTS
-          CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
-          IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X        'HNTFAUH: memory alloc for lat/long grid fail',JPQUIET)
-            HNTFAUH = JPROUTINE + 7
-            GOTO 900
-          ENDIF
+        NLON = 1 + NINT(FLOAT((NOAREA(JPEAST)  - NOAREA(JPWEST))) /
+     X         NOGRID(JPWESTEP))
+        NLAT = 1 + NINT(FLOAT((NOAREA(JPNORTH) - NOAREA(JPSOUTH))) /
+     X         NOGRID(JPNSSTEP))
 C
-          LUSELSM = LSMFLD()
+        NUMPTS = NLON * NLAT
+        ISIZE  = NUMPTS
+        CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HNTFAUH: memory alloc for lat/long grid fail',JPQUIET)
+          HNTFAUH = JPROUTINE + 5
+          GOTO 900
+        ENDIF
 C
-C         If original field was spectral, ...
+        LUSELSM = LSMFLD()
 C
-          IF( LSP2RGG ) THEN
-            IF( LUSELSM ) THEN
-              IRET = HIRLSM(LO12PT,RGGRID,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                      SWORK,ISIZE,NLON,NLAT)
-            ELSE
-              IRET = HIRLAM(LO12PT,RGGRID,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                      SWORK,ISIZE,NLON,NLAT)
-            ENDIF
+C       If original field was spectral, ...
 C
+        IF( LSP2RGG ) THEN
+          IF( LUSELSM ) THEN
+            IRET = HIRLSM(LO12PT,RGGRID,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
           ELSE
+            IRET = HIRLAM(LO12PT,RGGRID,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
+          ENDIF
 C
-C         If original field was gaussian, ...
+        ELSE
 C
-          IRET = PDDEFS()
-            NGAUSS = NIGAUSS
-cs            IF( LUSELSM ) THEN
-            IF( LSM ) THEN
-              IRET = HIRLSM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                      SWORK,ISIZE,NLON,NLAT)
-            ELSE
-              IRET = HIRLAM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,AREA,POLE,GRID,
-     X                      SWORK,ISIZE,NLON,NLAT)
-            ENDIF
+C       If original field was gaussian, ...
 C
+          IRET = PDDEFS()
+          NGAUSS = NIGAUSS
+          HTYPE  = GGHTYPE(NIREPR,NIGAUSS,MILLEN)
+cs        IF( LUSELSM ) THEN
+          IF( LSM ) THEN
+            IRET = HIRLSM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
+          ELSE
+            IRET = HIRLAM(LO12PT,ZNFELDI,NCOUNT,NGAUSS,HTYPE,AREA,POLE,
+     X                    GRID,SWORK,ISIZE,NLON,NLAT)
           ENDIF
 C
-cs   setting size of output field
-          OUTLROT = NLON * NLAT
-          IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X        'HNTFAUH: HIRLAM rotation failed',JPQUIET)
-            HNTFAUH = JPROUTINE + 7
-            GOTO 900
-          ENDIF
+        ENDIF
 C
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HNTFAUH: HIRLAM rotation failed',JPQUIET)
+          HNTFAUH = JPROUTINE + 5
+          GOTO 900
         ENDIF
 C
+cs      setting size of output field
+        OUTLROT = NLON * NLAT
+C
+      ENDIF
+C
 C     -----------------------------------------------------------------|
-C*    Section 8.   Gaussian to rotated gaussian
+C*    Section 6.   Gaussian to rotated gaussian
 C     -----------------------------------------------------------------|
 C
-  800   CONTINUE
+  600 CONTINUE
 C
-        IF( (LSP2RGG.AND.(NOREPR.EQ.JPFGGROT)) .OR.
+      IF( (LSP2RGG.AND.(NOREPR.EQ.JPFGGROT)) .OR.
      X      (((NIREPR.EQ.JPQUASI).OR.(NIREPR.EQ.JPGAUSSIAN)) .AND.
-     X      (NOREPR.EQ.JPFGGROT)) ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
-     X      'HNTFAUH: Gaussian to reduced gaussian',JPQUIET)
-C
-C         Dynamically allocate memory for rotated lat/long grid
+     X     (NOREPR.EQ.JPFGGROT)) ) THEN
+        CALL INTLOG(JP_DEBUG,
+     X    'HNTFAUH: Gaussian to reduced gaussian',JPQUIET)
 C
-          ISIZE = NOGAUSS * NOGAUSS * 8 
-          CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
-          IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X        'HNTFAUH: memory alloc for gaussian grid fail',JPQUIET)
-            HNTFAUH = JPROUTINE + 8
-            GOTO 900
-          ENDIF
+C       Dynamically allocate memory for rotated lat/long grid
 C
-C         If original field was spectral, ...
+C       ISIZE = NOGAUSS * NOGAUSS * 8
+        ISIZE = (2*NOGAUSS) * (4*NOGAUSS + 20)  ! account for RGG/octahedral
+        CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HNTFAUH: memory alloc for gaussian grid fail',JPQUIET)
+          HNTFAUH = JPROUTINE + 6
+          GOTO 900
+        ENDIF
 C
-          IF( LSP2RGG ) THEN
-            IRET = HRG2GG(LO12PT,RGGRID,NGAUSS,AREA,POLE,
-     X                    NOGAUSS,HOGAUST,SWORK,ISIZE,NUMPTS)
+C       If original field was spectral, ...
 C
-          ELSE
+        IF( LSP2RGG ) THEN
+          IRET = HRG2GG(LO12PT,RGGRID,NGAUSS,AREA,POLE,
+     X                  NOGAUSS,HOGAUST,SWORK,ISIZE,NUMPTS)
 C
-C         If original field was gaussian, ...
+        ELSE
 C
-            NGAUSS = NIGAUSS
-            IRET = HRG2GG(LO12PT,ZNFELDI,NGAUSS,AREA,POLE,
-     X                    NOGAUSS,HOGAUST,SWORK,ISIZE,NUMPTS)
-          ENDIF
-cs   setting size of output field
-          OUTLROT = NUMPTS
-          IF( IRET.NE.0 ) THEN
-            IF( LDEBUG ) CALL INTLOG(JP_ERROR,
-     X        'HNTFAUH: HRG2GG rotation failed',JPQUIET)
-            HNTFAUH = JPROUTINE + 8
-            GOTO 900
-          ENDIF
+C       If original field was gaussian, ...
 C
+          NGAUSS = NIGAUSS
+          IRET = HRG2GG(LO12PT,ZNFELDI,NGAUSS,AREA,POLE,
+     X                  NOGAUSS,HOGAUST,SWORK,ISIZE,NUMPTS)
+        ENDIF
+cs      setting size of output field
+        OUTLROT = NUMPTS
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HNTFAUH: HRG2GG rotation failed',JPQUIET)
+          HNTFAUH = JPROUTINE + 6
+          GOTO 900
         ENDIF
 C
+      ENDIF
+
+C     move rotated field back into field original array
+      ZNFELDI(1:NUMPTS) = SWORK(1:NUMPTS)
+
 C     -----------------------------------------------------------------|
 C*    Section 9.   Closedown.
 C     -----------------------------------------------------------------|
 C
-C       Move rotated field back into field original array.
-C
-        DO LOOP = 1, NUMPTS
-          ZNFELDI(LOOP) = SWORK(LOOP)
-        ENDDO
-C
-      ENDIF
-C
   900 CONTINUE
 C
       RETURN
diff --git a/interpolation/hntfaus.F b/interpolation/hntfaus.F
index 6c63651..311a1e4 100644
--- a/interpolation/hntfaus.F
+++ b/interpolation/hntfaus.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -79,9 +79,12 @@ C     ------
 C
 C     J.D.Chambers     ECMWF     February 2001
 C
-C
 C----<
 C
+C     -----------------------------------------------------------------|
+C*    Section 0.   Variables
+C     -----------------------------------------------------------------|
+C
       IMPLICIT NONE
 C
 C     Function arguments
@@ -105,47 +108,41 @@ C
 C
 C     Local variables
 C
-      REAL POLELAT, POLELON
-      CHARACTER*1 TYPE
-      INTEGER NUMPTS, NGAUSS
-      INTEGER ISIZE, NBYTES, ITRUNC, LOOP, IRET
-      DATA ISIZE/0/
-C
-      REAL SWORK
-      DIMENSION SWORK(1)
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 ISWORK
-#endif
-#endif
-      POINTER ( ISWORK, SWORK)
-C
-      REAL*8 DWORK
-      DIMENSION DWORK(1)
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IDWORK
-#endif
-#endif
-      POINTER ( IDWORK, DWORK )
-C
-      REAL*8 DATA
-      DIMENSION DATA(1)
+      INTEGER     IRET
+      INTEGER     ISIZE
+      INTEGER     ITRUNC
+      INTEGER     LOOP
+      INTEGER     NBYTES
+      INTEGER     NUMPTS
+      LOGICAL     LOK
+      LOGICAL     LSPLIT
+      REAL        POLELAT
+      REAL        SWORK(1)
+      REAL*8      DATA(1)
+      REAL*8      DLAT
+      REAL*8      DLON
+      REAL*8      DWORK(1)
+      REAL*8      LATLIM
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 IDATA
+      INTEGER*8 IDWORK
+      INTEGER*8 ISWORK
 #endif
 #endif
-      POINTER ( IDATA, DATA)
+      POINTER (IDATA,  DATA)
+      POINTER (IDWORK, DWORK)
+      POINTER (ISWORK, SWORK)
 C
-      SAVE ISIZE, ISWORK, IDWORK, IDATA
+      SAVE IDATA
+      SAVE IDWORK
+      SAVE ISIZE
+      SAVE ISWORK
 C
-      REAL*8 DLON, DLAT, LATLIM
-      LOGICAL LOK, LSPLIT
+      DATA ISIZE/0/
       DATA NBYTES/4/
 C
 C     Externals
-      INTEGER GGROTAT
       LOGICAL JACOBI
       EXTERNAL JACOBI
 C
@@ -154,11 +151,12 @@ C*    Section 1.   Initialise
 C     -----------------------------------------------------------------|
 C
   100 CONTINUE
+C
       HNTFAUS = 0
-      IRET = 0
+      IRET    = 0
 C
 C     -----------------------------------------------------------------|
-C*    Section 1.   Store data internally.
+C*    Section 2.   Store input data.
 C     -----------------------------------------------------------------|
 C
   200 CONTINUE
diff --git a/interpolation/hntfbu.F b/interpolation/hntfbu.F
deleted file mode 100644
index 6f6e378..0000000
--- a/interpolation/hntfbu.F
+++ /dev/null
@@ -1,434 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HNTFBU( FLDIN,INLEN,FLDOUT,OUTLEN)
-C
-C---->
-C**** HNTFBU
-C
-C     Purpose
-C     -------
-C
-C     Interpolate input field...
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HNTFBU( FLDIN,INLEN,FLDOUT,OUTLEN)
-C
-C     Input
-C     -----
-C
-C     FLDIN  - Input field (unpacked).
-C     INLEN  - Input field length (words).
-C
-C
-C     Output
-C     ------
-C
-C     FLDOUT  - Output field (unpacked).
-C     OUTLEN  - Output field length (words).
-C
-C
-C     Method
-C     ------
-C
-C     Call interpolation routines; then repack if GRIB output.
-C
-C     Currently, subareas are not supported for reduced gaussian fields.
-C     (Works OK; but need to setup values in GRIB product for number of
-C      points in each latitude row)
-C
-C
-C     Externals
-C     ---------
-C
-C     IARCNTL - Control interp. quasi reg.Gauss -> Gaussian or lat/long
-C     IAGCNTL - Control interpolation reg.Gaussian or lat/long fields.
-C     JSH2SH  - Changes resolution of a field of spectral coefficients.
-C     JALLGP  - Converts spectral input fields to lat/long grid fields.
-C     JALLWN  - Converts spectral input wind fields to lat/long grids.
-C     JAGGGP  - Converts spectral input fields to a gaussian grid field.
-C     IBASINI - Ensure basic interpolation setup is done.
-C     RESET_C - Reset interpolation handling options using GRIB product.
-C     JMEMHAN - Handles memory allocation.
-C     IGLSIZE - Evaluate array sizes for reg. lat/long and area.
-C     IGSIZE  - Evaluate array sizes for a regular Gaussian.
-C     IRSIZE  - Evaluate array sizes for a quasi reg Gaussian.
-C     FIXAREA - Fixup area definition to correspond to grid definitions
-C     ISCRSZ  - Calculate number of values in generated field.
-C     INTLOG  - Log error message.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Aug 1994
-C
-C     J.D.Chambers     ECMWF        Feb 1997
-C     Allow for 64-bit pointers
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-      INTEGER INLEN,OUTLEN
-      REAL FLDIN(*),FLDOUT(*)
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "intf.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      INTEGER JPALLOC, JPSCR16
-      PARAMETER (JPROUTINE = 26600 )
-      PARAMETER (JPALLOC = 1 )
-      PARAMETER (JPSCR16 = 16 )
-C
-C     Local variables
-C
-      INTEGER IERR, ISIZE, IUV
-      REAL PNORTH, PSOUTH, PWEST, PEAST, PLATINC, PLONINC
-      LOGICAL OIWEGLOBE, OINPOLE, OISPOLE
-      LOGICAL OOWEGLOBE, OONPOLE, OOSPOLE
-      INTEGER KILN, KITOTAL, KOLN, KOTOTAL, KPR, KERR
-      INTEGER LOOP
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IZNFLDO
-#endif
-#endif
-      REAL ZNFLDO
-      POINTER ( IZNFLDO, ZNFLDO )
-      DIMENSION ZNFLDO( 1 )
-C
-C     Externals
-      INTEGER IGLSIZE, IGSIZE, IRSIZE, IARCNTL, IAGCNTL
-      INTEGER FIXAREA, ISCRSZ
-C
-C ------------------------------------------------------------------
-C*    Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-      HNTFBU = 0
-      IERR = 0
-      KPR = 0
-C
-C     Allocate work array ZNFELDI if not already done.
-C
-      IF( IZNJDCI.NE.1952999238 ) THEN
-        CALL JMEMHAN( 19, IZNFLDI, JPEXPAND, 1, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_WARN,'HNTFBU: znfeldi allocate fail',JPQUIET)
-          HNTFBU = IERR
-          GOTO 900
-        ENDIF
-        IZNJDCI = 1952999238
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 3.   Interpolation spherical harmonics to spherical
-C                  harmonics
-C ------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-      IF ( ((NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT)) .AND.
-     X     ((NOREPR.EQ.JPSPHERE).OR.(NOREPR.EQ.JPSPHROT)) ) THEN
-C
-C       Get scratch space for interpolation
-C
-        ISIZE = ISCRSZ()
-        IF ( ISIZE .LE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'HNTFBU: Get scratch space failed',ISIZE)
-          HNTFBU = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-        CALL JMEMHAN( JPSCR16, IZNFLDO, ISIZE, JPALLOC, IERR)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'HNTFBU: Get scratch space fail',JPQUIET)
-          HNTFBU = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-C
-        CALL SH2SH( ZNFELDI, NIRESO, ZNFLDO, NORESO )
-C
-        GOTO 700
-C
-C     If not spectral -> spectral transformation, make sure the input
-C     and output area definitions have been setup.
-C
-      ELSE
-C
-C       Fixup area definition to correspond to grid definitions
-C
-        IERR = FIXAREA()
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'HNTFBU: Fixup area definition failed.',JPQUIET)
-          HNTFBU = JPROUTINE + 9
-          GOTO 900
-        ENDIF
-C
-C       Setup geographical limits
-C
-        PNORTH = FLOAT( NOAREA(1) ) / PPMULT
-        PWEST  = FLOAT( NOAREA(2) ) / PPMULT
-        PSOUTH = FLOAT( NOAREA(3) ) / PPMULT
-        PEAST  = FLOAT( NOAREA(4) ) / PPMULT
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 4.   Interpolation spherical harmonics to grid point.
-C ------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-      IF ( (NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT) ) THEN
-C
-        ISIZE = ISCRSZ()
-        IF ( ISIZE .LE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'HNTFBU: Get scratch space failed',ISIZE)
-          HNTFBU = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-C
-        CALL JMEMHAN( JPSCR16, IZNFLDO, ISIZE, JPALLOC, IERR)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'HNTFBU: Get scratch space fail',JPQUIET)
-          HNTFBU = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-C
-C       If rotation involved, it has already been done (in hntfau)
-C       and values are in znfeldi.
-C
-        IF( LNOROTA ) THEN
-          DO LOOP = 1, ISIZE
-            FLDOUT(LOOP) = ZNFELDI(LOOP)
-          ENDDO
-          OUTLEN = ISIZE
-          GOTO 900
-        ENDIF
-C
-C       Get scratch space for interpolation
-C
-C
-C       Setup wind flag
-        IF ( LWIND ) THEN
-          IUV = 1
-        ELSE
-          IUV = 0
-        ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 4.1  Interpolation spherical harmonics to grid point.
-C ------------------------------------------------------------------
-C
-  410 CONTINUE
-C
-        IF ( NOREPR.EQ.JPREGULAR ) THEN
-C
-C         -> latitude/longitude grid
-C
-          PLONINC = FLOAT( NOGRID(1) ) / PPMULT
-          PLATINC = FLOAT( NOGRID(2) ) / PPMULT
-          IF ( LWIND ) THEN
-            CALL JALLWN( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   PLATINC, PLONINC, ZNFLDO, IERR)
-          ELSE
-            CALL JALLGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   PLATINC, PLONINC, ZNFLDO, IERR)
-          ENDIF
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HNTFBU: Interpolation of gaussian field failed.',JPQUIET)
-            HNTFBU = JPROUTINE + 3
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C
-        IF ( NOREPR .EQ. JPGAUSSIAN) THEN
-C
-C         -> regular gaussian grid
-C
-          CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                 NOGAUSS, 'U', NOLPTS, ZNFLDO, IUV, IERR)
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HNTFBU: Interpolation of gaussian field failed.',JPQUIET)
-            HNTFBU = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C
-        IF ( NOREPR .EQ. JPQUASI) THEN
-C
-C         -> reduced gaussian grid
-C
-          CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                 NOGAUSS, 'U', NOLPTS, ZNFLDO, IUV, IERR)
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HNTFBU: Interpolation of gaussian field failed.',JPQUIET)
-            HNTFBU = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C       Dropthrough => unrecognized output field type
-C
-        IERR   = JPROUTINE + 1
-        CALL INTLOG(JP_ERROR,
-     X    'HNTFBU: Unrecognized output field type.',NOREPR)
-        HNTFBU = IERR
-        GOTO 900
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 5.   Interpolate Gaussian grid to grid point.
-C ------------------------------------------------------------------
-C
-  500 CONTINUE
-C
-C     Setup flags for input and output fields
-C
-      KERR = 1
-      IF (NIREPR .EQ. JPQUASI) THEN
-        IERR = IRSIZE( NIGAUSS, NIAREA, MILLEN, NIWE, NINS, KILN,
-     X                 KITOTAL, RIGAUSS, OIWEGLOBE, OINPOLE, OISPOLE,
-     X                 KPR, KERR)
-      ELSE IF ( NIREPR .EQ. JPGAUSSIAN ) THEN
-          IERR = IGSIZE( NIGAUSS, NIAREA, NIWE, NINS, KILN, RIGAUSS,
-     X                    OIWEGLOBE, OINPOLE, OISPOLE, KPR, KERR)
-      ELSE
-        IERR = IGLSIZE( NIGRID, NIAREA, NIWE, NINS, KILN, OIWEGLOBE,
-     X                  OINPOLE, OISPOLE, KPR, KERR)
-      ENDIF
-C
-      NONS = 0
-      NOWE = 0
-      IF (NOREPR .EQ. JPQUASI) THEN
-        IERR = IRSIZE( NOGAUSS, NOAREA, NOLPTS, NOWE, NONS, KOLN,
-     X                 KOTOTAL, ROGAUSS, OOWEGLOBE, OONPOLE, OOSPOLE,
-     X                 KPR, KERR)
-      ELSE IF ( NOREPR .EQ. JPGAUSSIAN ) THEN
-          IERR = IGSIZE( NOGAUSS, NOAREA, NOWE, NONS, KOLN, ROGAUSS,
-     X                    OOWEGLOBE, OONPOLE, OOSPOLE, KPR, KERR)
-      ELSE
-        IERR = IGLSIZE( NOGRID, NOAREA, NOWE, NONS, KOLN, OOWEGLOBE,
-     X                  OONPOLE, OOSPOLE, KPR, KERR)
-      ENDIF
-C
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HNTFBU: Interpolation of gaussian field failed.',IERR)
-        HNTFBU = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-C
-C
-C ------------------------------------------------------------------
-C     Section 5.1  Interpolate reduced Gaussian grid to grid point.
-C ------------------------------------------------------------------
-C
-  510 CONTINUE
-C
-C
-      ISIZE = ISCRSZ()
-      IF ( ISIZE .LE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'HNTFBU: Get scratch space failed.',ISIZE)
-        HNTFBU = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-      CALL JMEMHAN( JPSCR16, IZNFLDO, ISIZE, JPALLOC, IERR)
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'HNTFBU: Get scratch space fail.',JPQUIET)
-        HNTFBU = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-      IF (NIREPR .EQ. JPQUASI) THEN
-        IERR = IARCNTL( ZNFELDI, JPEXPAND, ZNFLDO, ISIZE, KILN,
-     X                  OIWEGLOBE, OINPOLE, OISPOLE, KOLN, OOWEGLOBE,
-     X                  OONPOLE, OOSPOLE, KPR ,KERR)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'HNTFBU: Interpolation of gaussian field failed.',IERR)
-          HNTFBU = JPROUTINE + 7
-          GOTO 900
-        ENDIF
-C
-        GOTO 700
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 6.   Interpolate regular grid point to grid point.
-C ------------------------------------------------------------------
-C
-  600 CONTINUE
-C
-      IERR = IAGCNTL( ZNFELDI, JPEXPAND, ZNFLDO, ISIZE, KILN,
-     X                OIWEGLOBE, OINPOLE, OISPOLE, KOLN, OOWEGLOBE,
-     X                OONPOLE, OOSPOLE, KPR, KERR)
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HNTFBU: Interpolation of gaussian field failed.',IERR)
-        HNTFBU = JPROUTINE + 8
-        GOTO 900
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 7.   Move unpacked values to user array.
-C ------------------------------------------------------------------
-C
-  700 CONTINUE
-C
-      DO 710 LOOP = 1, ISIZE
-        FLDOUT( LOOP ) = ZNFLDO( LOOP )
- 710  CONTINUE
-C
-C     Return the number of values, the unpacked array length
-C
-      OUTLEN = ISIZE
-C
-C ------------------------------------------------------------------
-C*    Section 9.   Closedown.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing
-C
-      LCHANGE = .FALSE.
-      LSMCHNG = .FALSE.
-C
-      RETURN
-      END
diff --git a/interpolation/hrg2gg.F b/interpolation/hrg2gg.F
index aae1e7d..b29c235 100644
--- a/interpolation/hrg2gg.F
+++ b/interpolation/hrg2gg.F
@@ -9,7 +9,7 @@ C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION HRG2GG(L12PNT,OLDFLD,KGNOLD,AREA,POLE,
-     X                        KGNNEW,HGTYPE,NEWFLD,KSIZE,NUMPTS)
+     X                        KGNNEW,HTYPE,NEWFLD,KSIZE,NUMPTS)
 C
 C---->
 C**** HRG2GG
@@ -25,30 +25,31 @@ C     Interface
 C     ---------
 C
 C     IRET = HRG2GG(L12PNT,OLDFLD,KGNOLD,AREA,POLE,
-C    X              KGNNEW,HGTYPE,NEWFLD,KSIZE,NUMPTS)
+C    X              KGNNEW,HTYPE,NEWFLD,KSIZE,NUMPTS)
 C
 C
 C     Input parameters
 C     ----------------
 C
-C     L12PNT - Chooses between 12-point and 4-point interpolation
-C     OLDFLD - Array of values from the old (reduced) gaussian field
-C     KGNOLD - Gaussian number for the old gaussian field
-C     AREA   - Limits of area (N/W/S/E)
-C     POLE   - Pole of rotation (lat/long)
-C     KGNNEW - Gaussian number for the new gaussian field
-C     HGTYPE - Type of new gaussian field
-C              'F' = full, ie regular
-C              'R' = reduced, ie quasi-regular
-C     KSIZE  - The size of the array to fill with the regular
-C              lat/long field
+C     L12PNT  - Chooses between 12-point and 4-point interpolation
+C     OLDFLD  - Array of values from the old (reduced) gaussian field
+C     KGNOLD  - Gaussian number for the old gaussian field
+C     AREA    - Limits of area (N/W/S/E)
+C     POLE    - Pole of rotation (lat/long)
+C     KGNNEW  - Gaussian grid number (for the new field)
+C     HTYPE   - Gaussian grid type (for the new field)
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full
+C     KSIZE   - The size of the array to fill with the regular
+C               lat/long field
 C
 C
 C     Output parameters
 C     -----------------
 C
-C     NEWFLD - The array of values for the gaussian field
-C     NUMPTS - Number of points in the new gaussian field.
+C     NEWFLD  - The array of values for the gaussian field
+C     NUMPTS  - Number of points in the new gaussian field.
 C
 C     Returns 0 if function successful, non-zero otherwise.
 C
@@ -149,7 +150,7 @@ C
       LOGICAL L12PNT
       INTEGER KGNOLD, KGNNEW, KSIZE, NUMPTS
       REAL AREA(4), POLE(2), OLDFLD(*), NEWFLD(KSIZE)
-      CHARACTER*1 HGTYPE
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -274,11 +275,11 @@ C
 C     Build up offsets to start of each latitude in the original field.
 C
       IF( KGNOLD.NE.NOPREV ) THEN
-        CALL JGETGG(KGNOLD,'R',GLATS,KPTS,IRET)
+        CALL JGETGG(KGNOLD,HTYPE,GLATS,KPTS,IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X      'HRG2GG: JGETGG failed to get gaussian data',JPQUIET)
-          HRG2GG = 2
+          HRG2GG = 1
           GOTO 900
         ENDIF
 C
@@ -301,7 +302,7 @@ C
 #endif
         IF( IOLD.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,'HRG2GG: Memory allocation fail',JPQUIET)
-          HRG2GG = 3
+          HRG2GG = 1
           GOTO 900
         ENDIF
 C
@@ -338,7 +339,7 @@ C
 #endif
         IF( IPKNPTS.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,'HRG2GG: Memory allocation fail',JPQUIET)
-          HRG2GG = 1
+          HRG2GG = 2
           GOTO 900
         ENDIF
 C
@@ -348,36 +349,29 @@ C
         NNPREV = -1
       ENDIF
 C
-      IF( HGTYPE.EQ.'F' ) THEN
-        IF( (KGNNEW.NE.NNPREV).OR.(HGTYPE.NE.NNTYPE) ) THEN
-          NLEN = KGNNEW * KGNNEW * 8
-          CALL JGETGG(KGNNEW,'F',GNLATS,KNPTS,IRET)
-          IF( IRET.NE.0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HRG2GG: JGETGG failed to get gaussian data',JPQUIET)
-            HRG2GG = 2
-            GOTO 900
-          ENDIF
-          NNPREV = KGNNEW
-          NNTYPE = HGTYPE
+      IF( (KGNNEW.NE.NNPREV).OR.(HTYPE.NE.NNTYPE) ) THEN
+        IF( HTYPE.NE.'F' .AND. HTYPE.NE.'f' .AND.
+     X      HTYPE.NE.'O' .AND. HTYPE.NE.'o' ) THEN
+          HTYPE = 'R'
+        ENDIF
+        CALL JGETGG(KGNNEW,HTYPE,GNLATS,KNPTS,IRET)
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HRG2GG: JGETGG failed to get gaussian data',JPQUIET)
+          HRG2GG = 2
+          GOTO 900
         ENDIF
-      ELSE
-        IF( (KGNNEW.NE.NNPREV).OR.(HGTYPE.NE.NNTYPE) ) THEN
-          CALL JGETGG(KGNNEW,'R',GNLATS,KNPTS,IRET)
-          IF( IRET.NE.0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HRG2GG: JGETGG failed to get gaussian data',JPQUIET)
-            HRG2GG = 2
-            GOTO 900
-          ENDIF
 C
+        IF( HTYPE.EQ.'F' .OR. HTYPE.EQ.'f' ) THEN
+          NLEN = KGNNEW * KGNNEW * 8
+        ELSE
           NLEN = 0
           DO LOOP = 1, KGNNEW*2
             NLEN = NLEN + KNPTS(LOOP)
           ENDDO
-          NNPREV = KGNNEW
-          NNTYPE = HGTYPE
         ENDIF
+        NNPREV = KGNNEW
+        NNTYPE = HTYPE
       ENDIF
 C
 C     Check that given array is big enough for the new field.
@@ -385,7 +379,7 @@ C
       IF( NLEN.GT.KSIZE ) THEN
         CALL INTLOG(JP_ERROR,'HRG2GG: Given array size = ',KSIZE)
         CALL INTLOG(JP_ERROR,'HRG2GG: Required size = ',NLEN)
-        HRG2GG = 4
+        HRG2GG = 2
         GOTO 900
       ENDIF
 C
@@ -406,7 +400,7 @@ C
 #endif
         IF( IPRLON.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,'HRG2GG: Memory allocation fail',JPQUIET)
-          HRG2GG = 5
+          HRG2GG = 2
           GOTO 900
         ENDIF
 C
@@ -416,12 +410,12 @@ C
 C
       ENDIF
 C
-      IRET = HGENGG(AREA,POLE,KGNNEW,HGTYPE,KNPTS,GNLATS,ILL,
+      IRET = HGENGG(AREA,POLE,KGNNEW,HTYPE,KNPTS,GNLATS,ILL,
      X              RLAT,RLON,NUMPTS)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'HRG2GG: HGENGG failed to get lat/lon grid data',JPQUIET)
-        HRG2GG = 6
+        HRG2GG = 2
         GOTO 900
       ENDIF
 C
@@ -445,7 +439,7 @@ C
 #endif
         IF( IPPDLO0.EQ.0 ) THEN
           CALL INTLOG(JP_ERROR,'HRG2GG: Memory allocation fail',JPQUIET)
-          HRG2GG = 7
+          HRG2GG = 3
           GOTO 900
         ENDIF
 C
@@ -470,7 +464,7 @@ C
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'HRG2GG: HNEI12 failed to find neighbours',JPQUIET)
-        HRG2GG = 8
+        HRG2GG = 3
         GOTO 900
       ENDIF
 C
diff --git a/interpolation/hrg2ggw.F b/interpolation/hrg2ggw.F
index ab5df50..e533532 100644
--- a/interpolation/hrg2ggw.F
+++ b/interpolation/hrg2ggw.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION HRG2GGW(L12PNT,OLDFLDU,OLDFLDV,KSIZEUV,
-     X                         KGNOLD,AREA,POLE,KGNNEW,HGTYPE,
+     X                         KGNOLD,AREA,POLE,KGNNEW,HTYPE,
      X                         NEWFLDU,NEWFLDV,KSIZE,NUMPTS)
 C
 C---->
@@ -18,16 +18,15 @@ C
 C     Purpose
 C     -------
 C
-C     This routine creates rotated gaussian U and V fields from
-C     reduced U and V gaussian fields using 12-point horizontal
-C     interpolation.
+C     This routine creates rotated gaussian U and V fields from reduced U and V
+C     gaussian fields using 12-point horizontal interpolation.
 C
 C
 C     Interface
 C     ---------
 C
 C     INTEGER FUNCTION HRG2GGW(L12PNT,OLDFLDU,OLDFLDV,KSIZEUV,
-C    X                         KGNOLD,AREA,POLE,KGNNEW,HGTYPE,
+C    X                         KGNOLD,AREA,POLE,KGNNEW,HTYPE,
 C    X                         NEWFLDU,NEWFLDV,KSIZE,NUMPTS)
 C
 C
@@ -41,10 +40,11 @@ C     KSIZEUV - Number of values in each old (reduced) gaussian field
 C     KGNOLD  - Gaussian number for the old gaussian field
 C     AREA    - Limits of area (N/W/S/E)
 C     POLE    - Pole of rotation (lat/long)
-C     KGNNEW  - Gaussian number for the new gaussian field
-C     HGTYPE  - Type of new gaussian field
-C               'F' = full, ie regular
-C               'R' = reduced, ie quasi-regular
+C     KGNNEW  - Gaussian grid number (for the new field)
+C     HTYPE   - Gaussian grid type (for the new field)
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full
 C     KSIZE   - The size of the array to fill with the regular
 C               lat/long field
 C
@@ -52,9 +52,9 @@ C
 C     Output parameters
 C     -----------------
 C
-C     NEWFLDU - The array of values for the new U gaussian field 
-C     NEWFLDV - The array of values for the new V gaussian field 
-C     NUMPTS  - Number of points in each new gaussian field.
+C     NEWFLDU - The array of values for the new U gaussian field
+C     NEWFLDV - The array of values for the new V gaussian field
+C     NUMPTS  - Number of points in the new gaussian fields.
 C
 C     Returns 0 if function successful, non-zero otherwise.
 C
@@ -89,7 +89,7 @@ C
 C     Externals
 C     ---------
 C
-C     INTLOG  - Log error message.
+C     INTLOG  - Logs messages
 C     JMALLOC - Dynamically allocate memory
 C     JFREE   - Free dynamically allocated memory
 C     JGETGG  - Reads the definition of a gaussian grid
@@ -150,10 +150,11 @@ C
 C     Function arguments
 C
       LOGICAL L12PNT
-      INTEGER KSIZEUV, KGNOLD, KGNNEW, KSIZE, NUMPTS
+      INTEGER KGNOLD, KGNNEW, KSIZE, NUMPTS
       REAL AREA(4), POLE(2), OLDFLDU(*), OLDFLDV(*)
-      REAL NEWFLDU(KSIZE),NEWFLDV(KSIZE)
-      CHARACTER*1 HGTYPE
+      REAL NEWFLDU(KSIZE), NEWFLDV(KSIZE)
+      INTEGER KSIZEUV
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -256,7 +257,7 @@ C
         IPKPTS = IPKPTS/(1024*1024*1024*4)
 #endif
         IF( IPKPTS.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocate fail',JPQUIET)
+      CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocation fail',JPQUIET)
           HRG2GGW = 1
           GOTO 900
         ENDIF
@@ -272,7 +273,7 @@ C
 C     Build up offsets to start of each latitude in the original field.
 C
       IF( KGNOLD.NE.NOPREV ) THEN
-        CALL JGETGG(KGNOLD,'R',GLATS,KPTS,IRET)
+        CALL JGETGG(KGNOLD,HTYPE,GLATS,KPTS,IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X      'HRG2GGW: JGETGG failed to get gaussian data',JPQUIET)
@@ -288,13 +289,8 @@ C
 C       Allocate memory to hold the input fields
 C       (in case OLDFLDU/OLDFLDV and NEWFLD are the same arrays)
 C
-        IF( IOLDU.GT.0 ) THEN
-          CALL JFREE(IOLDU)
-        ENDIF
-
-        IF( IOLDV.GT.0 ) THEN
-          CALL JFREE(IOLDV)
-        ENDIF
+        IF( IOLDU.GT.0 ) CALL JFREE(IOLDU)
+        IF( IOLDV.GT.0 ) CALL JFREE(IOLDV)
 C
         NUMBER = (IOFFS(KGNOLD*2+1) - 1)
         NBYTES = NUMBER * JPRLEN
@@ -306,7 +302,7 @@ C
         IOLDV = IOLDV/(1024*1024*1024*4)
 #endif
         IF( (IOLDU.EQ.0).OR.(IOLDV.EQ.0) ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocate fail',JPQUIET)
+      CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocation fail',JPQUIET)
           HRG2GGW = 3
           GOTO 900
         ENDIF
@@ -328,6 +324,7 @@ C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
+C
 C     Dynamically allocate memory for gaussian grid information.
 C
       INN = KGNNEW*2
@@ -343,7 +340,7 @@ C
         IPKNPTS = IPKNPTS/(1024*1024*1024*4)
 #endif
         IF( IPKNPTS.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocate fail',JPQUIET)
+      CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocation fail',JPQUIET)
           HRG2GGW = 1
           GOTO 900
         ENDIF
@@ -354,36 +351,29 @@ C
         NNPREV = -1
       ENDIF
 C
-      IF( HGTYPE.EQ.'F' ) THEN
-        IF( (KGNNEW.NE.NNPREV).OR.(HGTYPE.NE.NNTYPE) ) THEN
-          NLEN = KGNNEW * KGNNEW * 8
-          CALL JGETGG(KGNNEW,'F',GNLATS,KNPTS,IRET)
-          IF( IRET.NE.0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HRG2GGW: JGETGG failed to get gaussian data',JPQUIET)
-            HRG2GGW = 2
-            GOTO 900
-          ENDIF
-          NNPREV = KGNNEW
-          NNTYPE = HGTYPE
+      IF( (KGNNEW.NE.NNPREV).OR.(HTYPE.NE.NNTYPE) ) THEN
+        IF( HTYPE.NE.'F' .AND. HTYPE.NE.'f' .AND.
+     X      HTYPE.NE.'O' .AND. HTYPE.NE.'o' ) THEN
+          HTYPE = 'R'
+        ENDIF
+        CALL JGETGG(KGNNEW,HTYPE,GNLATS,KNPTS,IRET)
+        IF( IRET.NE.0 ) THEN
+          CALL INTLOG(JP_ERROR,
+     X      'HRG2GGW: JGETGG failed to get gaussian data',JPQUIET)
+          HRG2GGW = 2
+          GOTO 900
         ENDIF
-      ELSE
-        IF( (KGNNEW.NE.NNPREV).OR.(HGTYPE.NE.NNTYPE) ) THEN
-          CALL JGETGG(KGNNEW,'R',GNLATS,KNPTS,IRET)
-          IF( IRET.NE.0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'HRG2GGW: JGETGG failed to get gaussian data',JPQUIET)
-            HRG2GGW = 2
-            GOTO 900
-          ENDIF
 C
+        IF( HTYPE.EQ.'F' .OR. HTYPE.EQ.'f' ) THEN
+          NLEN = KGNNEW * KGNNEW * 8
+        ELSE
           NLEN = 0
           DO LOOP = 1, KGNNEW*2
             NLEN = NLEN + KNPTS(LOOP)
           ENDDO
-          NNPREV = KGNNEW
-          NNTYPE = HGTYPE
         ENDIF
+        NNPREV = KGNNEW
+        NNTYPE = HTYPE
       ENDIF
 C
 C     Check that given array is big enough for the new field.
@@ -411,25 +401,25 @@ C
         IPRLON = IPRLON/(1024*1024*1024*4)
 #endif
         IF( IPRLON.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocate fail',JPQUIET)
+      CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocation fail',JPQUIET)
           HRG2GGW = 5
           GOTO 900
         ENDIF
 C
-        IPRLAT = IPRLON + (ILL*JPRLEN)
-        IPRCLON = IPRLAT + (ILL*JPRLEN)
+        IPRLAT  = IPRLON  + (ILL*JPRLEN)
+        IPRCLON = IPRLAT  + (ILL*JPRLEN)
         IPRCLAT = IPRCLON + (ILL*JPRLEN)
         IPRDIR  = IPRCLAT + (ILL*JPRLEN)
-        IPC     = IPRDIR + (ILL*JPRLEN)
-        IPS     = IPC    + (ILL*JPRLEN)
-        IPU     = IPS    + (ILL*JPRLEN)
-        IPV     = IPU    + (ILL*JPRLEN)
+        IPC     = IPRDIR  + (ILL*JPRLEN)
+        IPS     = IPC     + (ILL*JPRLEN)
+        IPU     = IPS     + (ILL*JPRLEN)
+        IPV     = IPU     + (ILL*JPRLEN)
 C
         ILLOLD = ILL
 C
       ENDIF
 C
-      IRET = HGENGG(AREA,POLE,KGNNEW,HGTYPE,KNPTS,GNLATS,ILL,
+      IRET = HGENGG(AREA,POLE,KGNNEW,HTYPE,KNPTS,GNLATS,ILL,
      X              RLAT,RLON,NUMPTS)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
@@ -459,7 +449,7 @@ C
         IPPDLO0 = IPPDLO0/(1024*1024*1024*4)
 #endif
         IF( IPPDLO0.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocate fail',JPQUIET)
+      CALL INTLOG(JP_ERROR,'HRG2GGW: Memory allocation fail',JPQUIET)
           HRG2GGW = 7
           GOTO 900
         ENDIF
@@ -589,3 +579,4 @@ C
 C
       RETURN
       END
+
diff --git a/interpolation/hrg2ll.F b/interpolation/hrg2ll.F
deleted file mode 100644
index 0755800..0000000
--- a/interpolation/hrg2ll.F
+++ /dev/null
@@ -1,443 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HRG2LL(L12PNT,OLDFLD,KGAUSS,AREA,POLE,GRID,
-     X                        NEWFLD,KSIZE,NLON,NLAT)
-C
-C---->
-C**** HRG2LL
-C
-C     Purpose
-C     -------
-C
-C     This routine creates a rotated regular lat/long field from a
-C     reduced gaussian field using 12-point horizontal interpolation.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HRG2LL(L12PNT,OLDFLD,KGAUSS,AREA,POLE,GRID,NEWFLD,KSIZE,
-C    X              NLON,NLAT)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     L12PNT - Chooses between 12-point and 4-point interpolation
-C     OLDFLD - The array of values from the reduced gaussian field
-C     KGAUSS - Gaussian number for the reduced gaussian field
-C     AREA   - Limits of area (N/W/S/E)
-C     POLE   - Pole of rotation (lat/long)
-C     GRID   - Grid increments (i/j)
-C     KSIZE  - The size of the array to fill with the regular
-C              lat/long field
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     NEWFLD - The array of values for the regular lat/long field 
-C     NLON   - Number of longitudes in the regular lat/long field
-C     NLAT   - Number of latitudes in the regular lat/long field
-C
-C     Returns 0 if function successful, non-zero otherwise.
-C
-C     Common block usage
-C     ------------------
-C
-C
-C
-C     Method
-C     ------
-C
-C     Numbering of the points (I is the interpolation point):
-C
-C                   13       5       6      14
-C
-C                    7       1       2       8
-C                               (I)
-C                    9       3       4      10
-C
-C                   15      11      12      16
-C
-C     The 12-point interpolation is not possible if either of the top
-C     two rows is above the original field northern latitude. The
-C     nearest neighbour is used if both rows are above, and a 4-pt
-C     bilinear interpolation is used if the top row is above.
-C     Similarily, if either of the bottom two rows is below the original
-C     field southern latitude.
-C
-C
-C     Externals
-C     ---------
-C
-C     INTLOG  - Log error message.
-C     JMALLOC - Dynamically allocate memory
-C     JFREE   - Free dynamically allocated memory
-C     JGETGG  - Reads the definition of a gaussian grid
-C     HGENLL  - Calculates original lat/long (before rotation) for
-C               a rotated grid
-C     HNEI12  - Finds neighbours for points for interpolation
-C     HWTS12  - Calculates weightings for points for interpolation
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      January 2001
-C
-C
-C     Modifications
-C     -------------
-C
-C     None.
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nofld.common"
-C
-C     Parameters
-C
-      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S, JLAT, JLON
-      INTEGER JP12PT, JP4PT, JPNEARN
-      PARAMETER (JP12PT  = 0)
-      PARAMETER (JP4PT   = 1)
-      PARAMETER (JPNEARN = 2)
-      PARAMETER (JNORTH = 1 )
-      PARAMETER (JWEST  = 2 )
-      PARAMETER (JSOUTH = 3 )
-      PARAMETER (JEAST  = 4 )
-      PARAMETER (JW_E  = 1 )
-      PARAMETER (JN_S  = 2 )
-      PARAMETER (JLAT  = 1 )
-      PARAMETER (JLON  = 2 )
-C
-C     Function arguments
-C
-      LOGICAL L12PNT
-      INTEGER KGAUSS, KSIZE, NLON, NLAT
-      REAL AREA(4), POLE(2), GRID(2), OLDFLD(*), NEWFLD(KSIZE)
-C
-C     Local variables
-C
-      INTEGER NEXT, LOOP, IRET, NLEN, NPREV, NBYTES, NUMBER
-C
-      LOGICAL LNEW, LFIRST
-      INTEGER KSCHEME(1),NEIGH(12,1), KLA(1)
-      REAL PWTS(12,1)
-      POINTER (IPKSCHE, KSCHEME)
-      POINTER (IPNEIGH, NEIGH)
-      POINTER (IPKLA,   KLA)
-      POINTER (IPPWTS,  PWTS)
-C
-      REAL PDLO0(1),PDLO1(1),PDLO2(1),PDLO3(1),PDLAT(1)
-      POINTER (IPPDLO0, PDLO0)
-      POINTER (IPPDLO1, PDLO1)
-      POINTER (IPPDLO2, PDLO2)
-      POINTER (IPPDLO3, PDLO3)
-      POINTER (IPPDLAT, PDLAT)
-C
-      INTEGER IGG, IGGOLD
-      INTEGER KPTS(1)
-      REAL GLATS(1)
-      INTEGER IOFFS(1)
-      POINTER (IPKPTS,  KPTS)
-      POINTER (IPIOFFS, IOFFS)
-      POINTER (IPGLATS, GLATS)
-C
-      INTEGER ILL, ILLOLD
-      REAL RLAT(1),RLON(1)
-      POINTER (IPRLAT, RLAT)
-      POINTER (IPRLON, RLON)
-C
-      REAL OLD(1)
-      POINTER (IOLD,   OLD)
-C
-      DATA NPREV/-1/
-      DATA LNEW/.FALSE./, LFIRST/.TRUE./
-      DATA IGGOLD/-1/, ILLOLD/-1/, IOLD/0/
-C
-      SAVE LNEW, LFIRST
-      SAVE IPKSCHE, IPNEIGH, IPKLA, IPPWTS
-      SAVE IPPDLO0, IPPDLO1, IPPDLO2, IPPDLO3, IPPDLAT
-      SAVE NPREV, IGGOLD, IPKPTS, IPIOFFS, IPGLATS
-      SAVE ILLOLD, IPRLAT, IPRLON, IOLD
-C
-C     Externals
-C
-      INTEGER HNEI12, HGENLL
-#ifdef POINTER_64
-      INTEGER*8 JMALLOC
-#else
-      INTEGER JMALLOC
-#endif
-C
-C     -----------------------------------------------------------------|
-C     Section 1.  Initialise.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      HRG2LL = 0
-C
-      CALL JDEBUG()
-C
-C     Dynamically allocate memory for gaussian grid information.
-C
-      IGG = KGAUSS*2
-C
-      IF( IGG.GT.IGGOLD ) THEN
-C
-        IF( IGGOLD.GT.0 ) CALL JFREE(IPKPTS)
-C
-        NBYTES = (IGG*JPRLEN) + (2*IGG+1)*JPBYTES
-C
-        IPKPTS = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPKPTS = IPKPTS/(1024*1024*1024*4)
-#endif
-        IF( IPKPTS.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LL: Memory allocation fail',JPQUIET)
-          HRG2LL = 1
-          GOTO 900
-        ENDIF
-C
-        IPGLATS = IPKPTS  + (IGG*JPBYTES)
-        IPIOFFS = IPGLATS + (IGG*JPRLEN)
-C
-        IGGOLD = IGG
-        NPREV = -1
-C
-      ENDIF
-C
-C     Build up offsets to start of each latitude in the original field.
-C
-      IF( KGAUSS.NE.NPREV ) THEN
-        CALL JGETGG(KGAUSS,'R',GLATS,KPTS,IRET)
-        IF( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'HRG2LL: JGETGG failed to get gaussian data',JPQUIET)
-          HRG2LL = 2
-          GOTO 900
-        ENDIF
-C
-        IOFFS(1) = 1
-        DO LOOP = 2, (KGAUSS*2+1)
-          IOFFS(LOOP) = IOFFS(LOOP-1) + KPTS(LOOP-1)
-        ENDDO
-C
-C       Allocate memory to hold the input field
-C       (in case OLDFLD and NEWFLD are the same arrays)
-C
-        IF( IOLD.GT.0 ) CALL JFREE(IOLD)
-C
-        NUMBER = (IOFFS(KGAUSS*2+1) - 1)
-        NBYTES = NUMBER * JPRLEN
-C
-        IOLD = JMALLOC(NBYTES)
-#ifdef hpR64
-        IOLD = IOLD/(1024*1024*1024*4)
-#endif
-        IF( IOLD.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LL: Memory allocation fail',JPQUIET)
-          HRG2LL = 3
-          GOTO 900
-        ENDIF
-C
-        NPREV = KGAUSS
-      ENDIF
-C
-C     Preserve the input field
-C
-      NUMBER = (IOFFS(KGAUSS*2+1) - 1)
-      DO LOOP = 1, NUMBER
-        OLD(LOOP) = OLDFLD(LOOP)
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 2.  Generate the lat/long points for the output grid
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-      NLON = 1 + NINT((AREA(JEAST) - AREA(JWEST)) / GRID(JW_E))
-      NLAT = 1 + NINT((AREA(JNORTH) - AREA(JSOUTH)) / GRID(JN_S))
-C
-      NLEN = NLON * NLAT
-
-      NOWE = NLON
-      NONS = NLAT
-C
-C     Check that given array is big enough for the new field.
-C
-      IF( NLEN.GT.KSIZE ) THEN
-        CALL INTLOG(JP_ERROR,'HRG2LL: Given array size = ',KSIZE)
-        CALL INTLOG(JP_ERROR,'HRG2LL: Required size = ',NLEN)
-        HRG2LL = 4
-        GOTO 900
-      ENDIF
-C
-C     Dynamically allocate memory for lat/long arrays.
-C
-      ILL = NLEN
-      IF( ILL.GT.ILLOLD ) THEN
-C
-        LNEW = .TRUE.
-C
-        IF( ILLOLD.GT.0 ) CALL JFREE(IPRLON)
-C
-        NBYTES = 2*ILL*JPRLEN
-C
-        IPRLON = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPRLON = IPRLON/(1024*1024*1024*4)
-#endif
-        IF( IPRLON.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LL: Memory allocation fail',JPQUIET)
-          HRG2LL = 5
-          GOTO 900
-        ENDIF
-C
-        IPRLAT = IPRLON + (ILL*JPRLEN)
-C
-        ILLOLD = ILL
-C
-      ENDIF
-C
-      IRET = HGENLL(AREA,POLE,GRID,NLON,NLAT,RLAT,RLON)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HRG2LL: HGENLL failed to get lat/lon grid data',JPQUIET)
-        HRG2LL = 6
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 3.  Find neighbours for each point for interpolation.
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-C     Dynamically allocate memory for interpolation arrays.
-C
-      IF( LNEW ) THEN
-C
-        IF( .NOT.LFIRST ) CALL JFREE(IPPDLO0)
-C
-        NBYTES = (17*JPRLEN + 14*JPBYTES) * ILL
-C
-        IPPDLO0 = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPPDLO0 = IPPDLO0/(1024*1024*1024*4)
-#endif
-        IF( IPPDLO0.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LL: Memory allocation fail',JPQUIET)
-          HRG2LL = 7
-          GOTO 900
-        ENDIF
-C
-        IPPDLO1 = IPPDLO0 + (ILL*JPRLEN)
-        IPPDLO2 = IPPDLO1 + (ILL*JPRLEN)
-        IPPDLO3 = IPPDLO2 + (ILL*JPRLEN)
-        IPPDLAT = IPPDLO3 + (ILL*JPRLEN)
-        IPPWTS  = IPPDLAT + (ILL*JPRLEN)
-        IPKSCHE = IPPWTS  + (12*ILL*JPRLEN)
-        IPKLA   = IPKSCHE + (ILL*JPBYTES)
-        IPNEIGH = IPKLA   + (ILL*JPBYTES)
-C
-        LFIRST = .FALSE.
-        LNEW   = .FALSE.
-C
-      ENDIF
-C
-C     Find neighbours.
-C
-      IRET = HNEI12(L12PNT,NLEN,RLAT,RLON,KGAUSS,KPTS,GLATS,
-     X              KSCHEME,PDLAT,PDLO0,PDLO1,PDLO2,PDLO3,KLA,NEIGH)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HRG2LL: HNEI12 failed to find neighbours',JPQUIET)
-        HRG2LL = 8
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 4.  Perform the 12-point horizontal interpolation.
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-C     Setup the 12-point horizontal interpolation weights
-C
-      CALL HWTS12
-     X  (NLEN,KSCHEME,KLA,PDLAT,GLATS,PDLO0,PDLO1,PDLO2,PDLO3,NEIGH,
-     X   PWTS)
-C
-C     Calculate the interpolated grid point values
-C
-      DO LOOP = 1, NLEN
-        IF( KSCHEME(LOOP).EQ.JP12PT ) THEN
-          NEWFLD(LOOP) =
-     X      OLD(NEIGH( 1,LOOP)) * PWTS( 1,LOOP) +
-     X      OLD(NEIGH( 2,LOOP)) * PWTS( 2,LOOP) +
-     X      OLD(NEIGH( 3,LOOP)) * PWTS( 3,LOOP) +
-     X      OLD(NEIGH( 4,LOOP)) * PWTS( 4,LOOP) +
-     X      OLD(NEIGH( 5,LOOP)) * PWTS( 5,LOOP) +
-     X      OLD(NEIGH( 6,LOOP)) * PWTS( 6,LOOP) +
-     X      OLD(NEIGH( 7,LOOP)) * PWTS( 7,LOOP) +
-     X      OLD(NEIGH( 8,LOOP)) * PWTS( 8,LOOP) +
-     X      OLD(NEIGH( 9,LOOP)) * PWTS( 9,LOOP) +
-     X      OLD(NEIGH(10,LOOP)) * PWTS(10,LOOP) +
-     X      OLD(NEIGH(11,LOOP)) * PWTS(11,LOOP) +
-     X      OLD(NEIGH(12,LOOP)) * PWTS(12,LOOP)
-C
-        ELSE IF( KSCHEME(LOOP).EQ.JP4PT ) THEN
-          NEWFLD(LOOP) =
-     X      OLD(NEIGH( 1,LOOP)) * PWTS( 1,LOOP) +
-     X      OLD(NEIGH( 2,LOOP)) * PWTS( 2,LOOP) +
-     X      OLD(NEIGH( 3,LOOP)) * PWTS( 3,LOOP) +
-     X      OLD(NEIGH( 4,LOOP)) * PWTS( 4,LOOP)
-C
-        ELSE
-          DO NEXT = 1, 4
-            IF( NEIGH(NEXT,LOOP).NE.0 )  
-     X        NEWFLD(LOOP) = OLD(NEIGH(NEXT,LOOP))
-          ENDDO
-C
-        ENDIF
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 9.  Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/hrg2llw.F b/interpolation/hrg2llw.F
deleted file mode 100644
index 08b426f..0000000
--- a/interpolation/hrg2llw.F
+++ /dev/null
@@ -1,520 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HRG2LLW(L12PNT,OLDFLDU,OLDFLDV,KGAUSS,AREA,POLE,
-     X                         GRID,NEWFLDU,NEWFLDV,KSIZE,NLON,NLAT)
-C
-C---->
-C**** HRG2LLW
-C
-C     Purpose
-C     -------
-C
-C     This routine creates a rotated regular lat/long field from a
-C     reduced gaussian field using 12-point horizontal interpolation.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HRG2LLW(L12PNT,OLDFLDU,OLDFLDV,KGAUSS,AREA,POLE,GRID,
-C    X               NEWFLDU,NEWFLDV,KSIZE,NLON,NLAT)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     L12PNT - Chooses between 12-point and 4-point interpolation
-C     OLDFLDU - The array of values from the reduced gaussian U field
-C     OLDFLDV - The array of values from the reduced gaussian V field
-C     KGAUSS  - Gaussian number for the reduced gaussian field
-C     AREA    - Limits of area (N/W/S/E)
-C     POLE    - Pole of rotation (lat/long)
-C     GRID    - Grid increments (i/j)
-C     KSIZE   - The size of the array to fill with the regular
-C               lat/long field
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     NEWFLDU - The array of values for the regular lat/long U field 
-C     NEWFLDV - The array of values for the regular lat/long V field 
-C     NLON    - Number of longitudes in the regular lat/long field
-C     NLAT    - Number of latitudes in the regular lat/long field
-C
-C     Returns 0 if function successful, non-zero otherwise.
-C
-C     Common block usage
-C     ------------------
-C
-C     nifld.common
-C     nofld.common
-C
-C
-C     Method
-C     ------
-C
-C     Numbering of the points (I is the interpolation point):
-C
-C                   13       5       6      14
-C
-C                    7       1       2       8
-C                               (I)
-C                    9       3       4      10
-C
-C                   15      11      12      16
-C
-C     The 12-point interpolation is not possible if either of the top
-C     two rows is above the original field northern latitude. The
-C     nearest neighbour is used if both rows are above, and a 4-pt
-C     bilinear interpolation is used if the top row is above.
-C     Similarily, if either of the bottom two rows is below the original
-C     field southern latitude.
-C
-C
-C     Externals
-C     ---------
-C
-C     INTLOG  - Log error message.
-C     JMALLOC - Dynamically allocate memory
-C     JFREE   - Free dynamically allocated memory
-C     JGETGG  - Reads the definition of a gaussian grid
-C     HGENLLW - Calculates original lat/long (before rotation) for
-C               a rotated grid for wind fields.
-C     HNEI12  - Finds neighbours for points for interpolation
-C     HWTS12  - Calculates weightings for points for interpolation
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      January 2001
-C
-C
-C     Modifications
-C     -------------
-C
-C     None.
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-C
-C     Parameters
-C
-      INTEGER JNORTH, JSOUTH, JWEST, JEAST, JW_E, JN_S, JLAT, JLON
-      INTEGER JP12PT, JP4PT, JPNEARN
-      PARAMETER (JP12PT  = 0)
-      PARAMETER (JP4PT   = 1)
-      PARAMETER (JPNEARN = 2)
-      PARAMETER (JNORTH = 1 )
-      PARAMETER (JWEST  = 2 )
-      PARAMETER (JSOUTH = 3 )
-      PARAMETER (JEAST  = 4 )
-      PARAMETER (JW_E  = 1 )
-      PARAMETER (JN_S  = 2 )
-      PARAMETER (JLAT  = 1 )
-      PARAMETER (JLON  = 2 )
-C
-C     Function arguments
-C
-      LOGICAL L12PNT
-      INTEGER KGAUSS, KSIZE, NLON, NLAT
-      REAL AREA(4), POLE(2), GRID(2)
-      REAL OLDFLDU(*), OLDFLDV(*)
-      REAL NEWFLDU(KSIZE), NEWFLDV(KSIZE)
-C
-C     Local variables
-C
-      INTEGER NEXT, LOOP, IRET, NLEN, NPREV, NBYTES, NUMBER
-C
-      LOGICAL LNEW, LFIRST
-      INTEGER KSCHEME(1),NEIGH(12,1), KLA(1)
-      REAL PWTS(12,1)
-      POINTER (IPKSCHE, KSCHEME)
-      POINTER (IPNEIGH, NEIGH)
-      POINTER (IPKLA,   KLA)
-      POINTER (IPPWTS,  PWTS)
-C
-      REAL PDLO0(1),PDLO1(1),PDLO2(1),PDLO3(1),PDLAT(1)
-      POINTER (IPPDLO0, PDLO0)
-      POINTER (IPPDLO1, PDLO1)
-      POINTER (IPPDLO2, PDLO2)
-      POINTER (IPPDLO3, PDLO3)
-      POINTER (IPPDLAT, PDLAT)
-C
-      INTEGER IGG, IGGOLD
-      INTEGER KPTS(1)
-      REAL GLATS(1)
-      INTEGER IOFFS(1)
-      POINTER (IPKPTS,  KPTS)
-      POINTER (IPIOFFS, IOFFS)
-      POINTER (IPGLATS, GLATS)
-C
-      INTEGER ILL, ILLOLD
-      REAL RCLAT(1),RCLON(1),RLAT(1),RLON(1),RDIR(1),C(1),S(1),U(1),V(1)
-      POINTER (IPRCLAT, RCLAT)
-      POINTER (IPRCLON, RCLON)
-      POINTER (IPRLAT, RLAT)
-      POINTER (IPRLON, RLON)
-      POINTER (IPRDIR, RDIR)
-      POINTER (IPC, C)
-      POINTER (IPS, S)
-      POINTER (IPU, U)
-      POINTER (IPV, V)
-C
-      REAL OLDU(1), OLDV(1)
-      POINTER (IOLDU, OLDU)
-      POINTER (IOLDV, OLDV)
-C
-      DATA NPREV/-1/
-      DATA LNEW/.FALSE./, LFIRST/.TRUE./
-      DATA IGGOLD/-1/, ILLOLD/-1/, IOLDU/0/, IOLDV/0/
-C
-      SAVE LNEW, LFIRST
-      SAVE IPKSCHE, IPNEIGH, IPKLA, IPPWTS
-      SAVE IPPDLO0, IPPDLO1, IPPDLO2, IPPDLO3, IPPDLAT
-      SAVE NPREV, IGGOLD, IPKPTS, IPIOFFS, IPGLATS
-      SAVE ILLOLD,IPRCLAT,IPRCLON,IPRLAT,IPRLON,IPRDIR,IOLDU,IOLDV
-      SAVE IPC, IPS, IPU, IPV
-C
-C     Externals
-C
-      INTEGER HNEI12, HGENLLW
-#ifdef POINTER_64
-      INTEGER*8 JMALLOC
-#else
-      INTEGER JMALLOC
-#endif
-C
-C     Statement function
-C
-      REAL A, RADIAN
-C
-C     Convert degrees to radians
-C
-      RADIAN(A) = (A) * 0.0174532925
-C
-C     -----------------------------------------------------------------|
-C     Section 1.  Initialise.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      HRG2LLW = 0
-C
-      CALL JDEBUG()
-C
-C     Dynamically allocate memory for gaussian grid information.
-C
-      IGG = KGAUSS*2
-C
-      IF( IGG.GT.IGGOLD ) THEN
-C
-        IF( IGGOLD.GT.0 ) CALL JFREE(IPKPTS)
-C
-        NBYTES = (IGG*JPRLEN) + (2*IGG+1)*JPBYTES
-C
-        IPKPTS = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPKPTS = IPKPTS/(1024*1024*1024*4)
-#endif
-        IF( IPKPTS.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LLW: Memory allocate fail',JPQUIET)
-          HRG2LLW = 1
-          GOTO 900
-        ENDIF
-C
-        IPGLATS = IPKPTS  + (IGG*JPBYTES)
-        IPIOFFS = IPGLATS + (IGG*JPRLEN)
-C
-        IGGOLD = IGG
-        NPREV = -1
-C
-      ENDIF
-C
-C     Build up offsets to start of each latitude in original fields.
-C
-      IF( KGAUSS.NE.NPREV ) THEN
-        CALL JGETGG(KGAUSS,'R',GLATS,KPTS,IRET)
-        IF( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'HRG2LLW: JGETGG failed to get gaussian data',JPQUIET)
-          HRG2LLW = 2
-          GOTO 900
-        ENDIF
-C
-        IOFFS(1) = 1
-        DO LOOP = 2, (KGAUSS*2+1)
-          IOFFS(LOOP) = IOFFS(LOOP-1) + KPTS(LOOP-1)
-        ENDDO
-C
-C       Allocate memory to preserve the input fields
-C       (in case OLDFLDx and NEWFLDx are the same arrays)
-C
-        IF( IOLDU.GT.0 ) CALL JFREE(IOLDU)
-C
-        NUMBER = (IOFFS(KGAUSS*2+1) - 1)
-        NBYTES = 2 * NUMBER * JPRLEN
-C
-        IOLDU = JMALLOC(NBYTES)
-#ifdef hpR64
-        IOLDU = IOLDU/(1024*1024*1024*4)
-#endif
-        IF( IOLDU.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LLW: Memory allocate fail',JPQUIET)
-          HRG2LLW = 3
-          GOTO 900
-        ENDIF
-        IOLDV = IOLDU + (NUMBER * JPRLEN)
-C
-        NPREV = KGAUSS
-      ENDIF
-C
-C     Preserve the input fields
-C
-      DO LOOP = 1, NUMBER
-        OLDU(LOOP) = OLDFLDU(LOOP)
-        OLDV(LOOP) = OLDFLDV(LOOP)
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 2.  Generate the lat/long points for the output grid
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-      NLON = 1 + INT((AREA(JEAST) - AREA(JWEST)) / GRID(JW_E))
-      NLAT = 1 + INT((AREA(JNORTH) - AREA(JSOUTH)) / GRID(JN_S))
-C
-      NLEN = NLON * NLAT
-
-      NOWE = NLON
-      NONS = NLAT
-C
-C     Check that given array is big enough for the new field.
-C
-      IF( NLEN.GT.KSIZE ) THEN
-        CALL INTLOG(JP_ERROR,'HRG2LLW: Given array size = ',KSIZE)
-        CALL INTLOG(JP_ERROR,'HRG2LLW: Required size = ',NLEN)
-        HRG2LLW = 4
-        GOTO 900
-      ENDIF
-C
-C     Dynamically allocate memory for lat/long arrays.
-C
-      ILL = NLEN
-      IF( ILL.GT.ILLOLD ) THEN
-C
-        LNEW = .TRUE.
-C
-        IF( ILLOLD.GT.0 ) CALL JFREE(IPRLON)
-C
-        NBYTES = 9*ILL*JPRLEN
-C
-        IPRLON = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPRLON = IPRLON/(1024*1024*1024*4)
-#endif
-        IF( IPRLON.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LLW: Memory allocate fail',JPQUIET)
-          HRG2LLW = 5
-          GOTO 900
-        ENDIF
-C
-        IPRLAT  = IPRLON + (ILL*JPRLEN)
-        IPRCLON = IPRLAT + (ILL*JPRLEN)
-        IPRCLAT = IPRCLON + (ILL*JPRLEN)
-        IPRDIR  = IPRCLAT + (ILL*JPRLEN)
-        IPC     = IPRDIR + (ILL*JPRLEN)
-        IPS     = IPC    + (ILL*JPRLEN)
-        IPU     = IPS    + (ILL*JPRLEN)
-        IPV     = IPU    + (ILL*JPRLEN)
-C
-        ILLOLD = ILL
-C
-      ENDIF
-C
-      IRET = HGENLLW(AREA,POLE,GRID,NLON,NLAT,RCLAT,RCLON,RLAT,RLON)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HRG2LLW: HGENLLW failed to get lat/lon grid data',JPQUIET)
-        HRG2LLW = 6
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 3.  Find neighbours for each point for interpolation.
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-C     Dynamically allocate memory for interpolation arrays.
-C
-      IF( LNEW ) THEN
-C
-        IF( .NOT.LFIRST ) CALL JFREE(IPPDLO0)
-C
-        NBYTES = (17*JPRLEN + 14*JPBYTES) * ILL
-C
-        IPPDLO0 = JMALLOC(NBYTES)
-#ifdef hpR64
-        IPPDLO0 = IPPDLO0/(1024*1024*1024*4)
-#endif
-        IF( IPPDLO0.EQ.0 ) THEN
-          CALL INTLOG(JP_ERROR,'HRG2LLW: Memory allocate fail',JPQUIET)
-          HRG2LLW = 7
-          GOTO 900
-        ENDIF
-C
-        IPPDLO1 = IPPDLO0 + (ILL*JPRLEN)
-        IPPDLO2 = IPPDLO1 + (ILL*JPRLEN)
-        IPPDLO3 = IPPDLO2 + (ILL*JPRLEN)
-        IPPDLAT = IPPDLO3 + (ILL*JPRLEN)
-        IPPWTS  = IPPDLAT + (ILL*JPRLEN)
-        IPKSCHE = IPPWTS  + (12*ILL*JPRLEN)
-        IPKLA   = IPKSCHE + (ILL*JPBYTES)
-        IPNEIGH = IPKLA   + (ILL*JPBYTES)
-C
-        LFIRST = .FALSE.
-C
-      ENDIF
-C
-C     Find neighbours.
-C
-      IRET = HNEI12(L12PNT,NLEN,RLAT,RLON,KGAUSS,KPTS,GLATS,
-     X              KSCHEME,PDLAT,PDLO0,PDLO1,PDLO2,PDLO3,KLA,NEIGH)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HRG2LLW: HNEI12 failed to find neighbours',JPQUIET)
-        HRG2LLW = 8
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 4.  Perform the 12-point horizontal interpolation.
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-C     Setup the 12-point horizontal interpolation weights
-C
-      CALL HWTS12
-     X  (NLEN,KSCHEME,KLA,PDLAT,GLATS,PDLO0,PDLO1,PDLO2,PDLO3,NEIGH,
-     X   PWTS)
-C
-C     Calculate the interpolated grid point values
-C
-      DO LOOP = 1, NLEN
-        IF( KSCHEME(LOOP).EQ.JP12PT ) THEN
-          U(LOOP) =
-     X      OLDU(NEIGH( 1,LOOP)) * PWTS( 1,LOOP) +
-     X      OLDU(NEIGH( 2,LOOP)) * PWTS( 2,LOOP) +
-     X      OLDU(NEIGH( 3,LOOP)) * PWTS( 3,LOOP) +
-     X      OLDU(NEIGH( 4,LOOP)) * PWTS( 4,LOOP) +
-     X      OLDU(NEIGH( 5,LOOP)) * PWTS( 5,LOOP) +
-     X      OLDU(NEIGH( 6,LOOP)) * PWTS( 6,LOOP) +
-     X      OLDU(NEIGH( 7,LOOP)) * PWTS( 7,LOOP) +
-     X      OLDU(NEIGH( 8,LOOP)) * PWTS( 8,LOOP) +
-     X      OLDU(NEIGH( 9,LOOP)) * PWTS( 9,LOOP) +
-     X      OLDU(NEIGH(10,LOOP)) * PWTS(10,LOOP) +
-     X      OLDU(NEIGH(11,LOOP)) * PWTS(11,LOOP) +
-     X      OLDU(NEIGH(12,LOOP)) * PWTS(12,LOOP)
-          V(LOOP) =
-     X      OLDV(NEIGH( 1,LOOP)) * PWTS( 1,LOOP) +
-     X      OLDV(NEIGH( 2,LOOP)) * PWTS( 2,LOOP) +
-     X      OLDV(NEIGH( 3,LOOP)) * PWTS( 3,LOOP) +
-     X      OLDV(NEIGH( 4,LOOP)) * PWTS( 4,LOOP) +
-     X      OLDV(NEIGH( 5,LOOP)) * PWTS( 5,LOOP) +
-     X      OLDV(NEIGH( 6,LOOP)) * PWTS( 6,LOOP) +
-     X      OLDV(NEIGH( 7,LOOP)) * PWTS( 7,LOOP) +
-     X      OLDV(NEIGH( 8,LOOP)) * PWTS( 8,LOOP) +
-     X      OLDV(NEIGH( 9,LOOP)) * PWTS( 9,LOOP) +
-     X      OLDV(NEIGH(10,LOOP)) * PWTS(10,LOOP) +
-     X      OLDV(NEIGH(11,LOOP)) * PWTS(11,LOOP) +
-     X      OLDV(NEIGH(12,LOOP)) * PWTS(12,LOOP)
-C
-        ELSE IF( KSCHEME(LOOP).EQ.JP4PT ) THEN
-          U(LOOP) =
-     X      OLDU(NEIGH( 1,LOOP)) * PWTS( 1,LOOP) +
-     X      OLDU(NEIGH( 2,LOOP)) * PWTS( 2,LOOP) +
-     X      OLDU(NEIGH( 3,LOOP)) * PWTS( 3,LOOP) +
-     X      OLDU(NEIGH( 4,LOOP)) * PWTS( 4,LOOP)
-          V(LOOP) =
-     X      OLDV(NEIGH( 1,LOOP)) * PWTS( 1,LOOP) +
-     X      OLDV(NEIGH( 2,LOOP)) * PWTS( 2,LOOP) +
-     X      OLDV(NEIGH( 3,LOOP)) * PWTS( 3,LOOP) +
-     X      OLDV(NEIGH( 4,LOOP)) * PWTS( 4,LOOP)
-C
-        ELSE
-          DO NEXT = 1, 4
-            IF( NEIGH(NEXT,LOOP).NE.0 ) THEN
-              U(LOOP) = OLDU(NEIGH(NEXT,LOOP))
-              V(LOOP) = OLDV(NEIGH(NEXT,LOOP))
-            ENDIF
-          ENDDO
-C
-        ENDIF
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 5.  Adjust the U and V components to new (rotated) axes
-C     -----------------------------------------------------------------|
-C
-  500 CONTINUE
-C
-      DO LOOP = 1, NLEN
-        RDIR(LOOP) = 0.0
-      ENDDO
-C
-      CALL HPSHGPW(RCLON,RCLAT,RLON,RLAT,RDIR,NLEN,POLE)
-C
-      DO LOOP = 1, NLEN
-        RDIR(LOOP) = RADIAN(RDIR(LOOP))
-      ENDDO
-C
-      DO LOOP = 1, NLEN
-        C(LOOP) = COS(RDIR(LOOP))
-        S(LOOP) = SIN(RDIR(LOOP))
-      ENDDO
-C
-      DO LOOP = 1, NLEN
-        NEWFLDU(LOOP) = U(LOOP)*C(LOOP) - V(LOOP)*S(LOOP)
-        NEWFLDV(LOOP) = U(LOOP)*S(LOOP) + V(LOOP)*C(LOOP)
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 9.  Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/hsh2gg.F b/interpolation/hsh2gg.F
new file mode 100644
index 0000000..4f95f18
--- /dev/null
+++ b/interpolation/hsh2gg.F
@@ -0,0 +1,262 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      INTEGER FUNCTION HSH2GG(NS,EW,KTRUNC,KNUM,HTYPE,KPTS,PLATS,KSIZE)
+C
+C---->
+C**** HSH2GG
+C
+C     Purpose
+C     -------
+C
+C     Finds a suitable Gaussian grid and/or spectral truncation for a
+C     given spectral truncation and/or lat/long increments. There are
+C     three modes (by order of precedence):
+C     - providing NS,EW sets KTRUNC (using AURESOL) and KNUM/HTYPE
+C     - providing KTRUNC sets KNUM/HTYPE
+C     - providing KNUM sets KTRUNC
+C     With KNUM/HTYPE set, the Gaussian grid definition is obtained with
+C     JGETGG.
+C     Parameters with value zero are assumed not provided.
+C     Historically, this merges the functionality of:
+C     - HSP2GG
+C     - HSP2GG2
+C     - HSP2GG3
+C
+C
+C     Interface
+C     ---------
+C
+C     IRET = HSH2GG(NS,EW,KTRUNC,KNUM,HTYPE,KPTS,PLATS,KSIZE)
+C
+C
+C     Input parameters
+C     ----------------
+C     NS     - North-South increment
+C     EW     - East-West increment
+C
+C
+C     Input/output parameters
+C     ----------------
+C     KTRUNC - The spectral truncation
+C     KNUM   - Gaussian grid number
+C     HTYPE  - Gaussian grid type
+C              = 'R' for reduced ("quasi-regular"),
+C              = 'O' for reduced/octahedral,
+C              = 'F' for full,
+C              = 'U' for a user-defined Gaussian grid
+C
+C
+C     Output parameters
+C     -----------------
+C     KPTS   - Array giving number of points along each line of latitude
+C              in the reduced Gaussian grid (both hemispheres)
+C     PLATS  - Array giving Gaussian latitudes (both hemispheres)
+C     KSIZE  - The number of points in the reduced Gaussian grid
+C
+C     Returns 0 if all OK, otherwise there is an error.
+C
+C
+C     Externals
+C     ---------
+C
+C     JGETGG  - Reads the definition of a Gaussian grid
+C     AURESOL - Returns the default truncation for a given
+C               latitude--longitude grid resolution
+C
+C
+C     Author
+C     ------
+C
+C     J.D.Chambers      ECMWF      February 2001
+C
+C
+C     Modifications
+C     -------------
+C
+C     S.Curic     ECMWF      March 2005
+C     Added checking for a automatic trancation T255, T399, T799, T2047
+C     and corresponding Gaussian grid.
+C
+C     S.Curic     ECMWF      April 2008
+C     Added checking for a automatic trancation T1279
+C     and corresponding Gaussian grid.
+C
+C     S.Curic     ECMWF      Semptember 2009
+C     Match T255 and T213 against N128 instead of N160
+C     upon Alan Geer request
+C
+C
+C----<
+C     -----------------------------------------------------------------|
+C*    Section 0. Definition of variables
+C     -----------------------------------------------------------------|
+
+      IMPLICIT NONE
+#include "parim.h"
+#include "jparams.h"
+
+C     Function arguments
+      INTEGER KTRUNC, KNUM, KPTS(*), KSIZE
+      REAL NS, EW, PLATS(*)
+      CHARACTER*1 HTYPE
+
+C     Local variables
+      INTEGER I, IRET
+      REAL STEP
+
+C     Externals
+      INTEGER AURESOL
+      EXTERNAL AURESOL
+
+C     -----------------------------------------------------------------|
+C     Section 1.  Initialise
+C     -----------------------------------------------------------------|
+
+      HSH2GG = 0
+
+C     -----------------------------------------------------------------|
+C     Section 2.  Set adequate truncation/grid number
+C     -----------------------------------------------------------------|
+
+
+C     if lat/long increments are provided, set automatic KTRUNC truncation
+      IF( (KTRUNC.EQ.0) .AND. (KNUM.EQ.0) ) KTRUNC = AURESOL(NS,EW)
+
+
+C     from a given truncation (KTRUNC) find a Gaussian number (KNUM)
+      IF (KTRUNC.NE.0) THEN
+        IF( KTRUNC.NE.  63 .AND. KTRUNC.NE.  64 .AND.
+     .      KTRUNC.NE.  95 .AND. KTRUNC.NE.  96 .AND.
+     .      KTRUNC.NE. 106 .AND. KTRUNC.NE. 107 .AND.
+     .      KTRUNC.NE. 159 .AND. KTRUNC.NE. 160 .AND.
+     .      KTRUNC.NE. 191 .AND. KTRUNC.NE. 192 .AND.
+     .      KTRUNC.NE. 213 .AND. KTRUNC.NE. 214 .AND.
+     .      KTRUNC.NE. 255 .AND. KTRUNC.NE. 256 .AND.
+     .      KTRUNC.NE. 319 .AND. KTRUNC.NE. 320 .AND.
+     .      KTRUNC.NE. 399 .AND. KTRUNC.NE. 400 .AND.
+     .      KTRUNC.NE. 511 .AND. KTRUNC.NE. 512 .AND.
+     .      KTRUNC.NE. 639 .AND. KTRUNC.NE. 640 .AND.
+     .      KTRUNC.NE. 799 .AND. KTRUNC.NE. 800 .AND.
+     .      KTRUNC.NE.1279 .AND. KTRUNC.NE.1280 .AND.
+     .      KTRUNC.NE.2047 .AND. KTRUNC.NE.2048 ) THEN
+          CALL INTLOG(JP_ERROR,'HSH2GG: truncation unsupported',KTRUNC)
+          HSH2GG = 2
+          GOTO 900
+        ENDIF
+        STEP = MIN(ABS(NS),ABS(EW))
+        IF(     (KTRUNC.EQ.  63).OR.(KTRUNC.EQ.  64).OR.
+     .          (KTRUNC.EQ.  95).OR.(KTRUNC.EQ.  96).OR.
+     .          (STEP.GE.2.5) ) THEN                         ! 2.5  <= step        -> T63
+          KNUM =   48
+        ELSEIF( (KTRUNC.EQ. 106).OR.(KTRUNC.EQ. 107).OR.
+     .          (KTRUNC.EQ. 159).OR.(KTRUNC.EQ. 160).OR.
+     .          (STEP.GE.1.5) ) THEN                         ! 1.5  <= step < 2.5  -> T106
+          KNUM =   80
+        ELSEIF( (KTRUNC.EQ. 191).OR.(KTRUNC.EQ. 192).OR.
+     .          (STEP.GE.0.4 .AND. .FALSE.) ) THEN           ! 1.5  <= step < 2.5  -> T191 (commented)
+          KNUM =   96
+        ELSEIF( (KTRUNC.EQ. 213).OR.(KTRUNC.EQ. 214).OR.
+     .          (KTRUNC.EQ. 255).OR.(KTRUNC.EQ. 256).OR.     ! Enfo 2004
+     .          (STEP.GE.0.6) ) THEN                         ! 0.6  <= step < 1.5  -> T213
+          KNUM =  128
+        ELSEIF( (KTRUNC.EQ. 319).OR.(KTRUNC.EQ. 320).OR.
+     .          (STEP.GE.0.4) ) THEN                         ! 0.4  <= step < 0.6  -> T319
+          KNUM =  160
+        ELSEIF( (KTRUNC.EQ. 399).OR.(KTRUNC.EQ. 400) ) THEN  ! Enfo 2005
+          KNUM =  200
+        ELSEIF( (KTRUNC.EQ. 511).OR.(KTRUNC.EQ. 512).OR.     ! Oper 2004
+     .          (STEP.GE.0.3) ) THEN                         ! 0.3  <= step < 0.4  -> T511
+          KNUM =  256
+        ELSEIF( (KTRUNC.EQ. 639).OR.(KTRUNC.EQ. 640) ) THEN
+          KNUM =  320
+        ELSEIF( (KTRUNC.EQ. 799).OR.(KTRUNC.EQ. 800).OR.     ! Oper 2005
+     .          (STEP.GE.0.15) ) THEN                        ! 0.15 <= step < 0.3  -> T799
+          KNUM =  400
+        ELSEIF( (KTRUNC.EQ.1279).OR.(KTRUNC.EQ.1280).OR.     ! Jan Haseler
+     .          (STEP.GE.0.09) ) THEN                        ! 0.09 <= step < 0.15 -> T1279
+          KNUM =  640
+        ELSEIF( (KTRUNC.EQ.2047).OR.(KTRUNC.EQ.2048).OR.     ! Mariano
+     .          (STEP.LT.0.09) ) THEN                        ! 0.09 <= step < 0.15 -> T1279
+          KNUM = 1024
+        ENDIF
+        HTYPE = 'R'
+
+
+C     from a given Gaussian number (KNUM) find a truncation (KTRUNC)
+      ELSEIF (KNUM.NE.0) THEN
+        IF( KNUM.NE.  48 .AND. KNUM.NE.  80 .AND. KNUM.NE.  96 .AND.
+     .      KNUM.NE. 128 .AND. KNUM.NE. 160 .AND. KNUM.NE. 200 .AND.
+     .      KNUM.NE. 256 .AND. KNUM.NE. 320 .AND. KNUM.NE. 400 .AND.
+     .      KNUM.NE. 640 .AND. KNUM.NE.1024 ) THEN
+        CALL INTLOG(JP_ERROR,'HSH2GG: Gaussian number unsupported',KNUM)
+          HSH2GG = 2
+          GOTO 900
+        ENDIF
+        IF(     KNUM.EQ.  48 ) THEN
+C         KTRUNC =   63
+          KTRUNC =   95
+        ELSEIF( KNUM.EQ.  80 ) THEN
+          KTRUNC =  159
+        ELSEIF( KNUM.EQ.  96 ) THEN
+          KTRUNC =  191              ! Elias 2014
+        ELSEIF( KNUM.EQ. 128 ) THEN
+C         KTRUNC =  213
+          KTRUNC =  255              ! Enfo 2004
+        ELSEIF( KNUM.EQ. 160 ) THEN
+          KTRUNC =  319
+        ELSEIF( KNUM.EQ. 200 ) THEN
+          KTRUNC =  399              ! Enfo 2005
+        ELSEIF( KNUM.EQ. 256 ) THEN
+          KTRUNC =  511              ! Oper 2004
+        ELSEIF( KNUM.EQ. 320 ) THEN
+          KTRUNC =  639
+        ELSEIF( KNUM.EQ. 400 ) THEN
+          KTRUNC =  799              ! Oper 2005
+        ELSEIF( KNUM.EQ. 640 ) THEN
+          KTRUNC = 1279              ! Jan Haseler
+        ELSEIF( KNUM.EQ.1024 ) THEN
+          KTRUNC = 2047              ! Mariano
+        ENDIF
+
+      ENDIF
+
+C     -----------------------------------------------------------------|
+C     Section 3.  Get the reduced Gaussian grid and count points
+C     -----------------------------------------------------------------|
+
+      CALL INTLOG(JP_DEBUG,'HSH2GG: spectral truncation:',KTRUNC)
+      CALL INTLOG(JP_DEBUG,'HSH2GG: Gaussian grid: '//HTYPE,KNUM)
+      IF( HTYPE.NE.'R' .AND. HTYPE.NE.'O' .AND.
+     X    HTYPE.NE.'F' .AND. HTYPE.NE.'U' ) THEN
+        CALL INTLOG(JP_ERROR,
+     X    'HSH2GG: Gaussian type unsupported: '//HTYPE,JPQUIET)
+        HSH2GG = 3
+        GOTO 900
+      ENDIF
+      CALL JGETGG(KNUM,HTYPE,PLATS,KPTS,IRET)
+      IF( IRET.NE.0 ) THEN
+        CALL INTLOG(JP_ERROR, 'HSH2GG: JGETGG failed',JPQUIET)
+        HSH2GG = 3
+      ELSE
+        KSIZE = 0
+        DO I = 1, KNUM*2
+          KSIZE = KSIZE + KPTS(I)
+        ENDDO
+      ENDIF
+
+C     -----------------------------------------------------------------|
+C     Section 9.  Return
+C     -----------------------------------------------------------------|
+
+  900 CONTINUE
+      RETURN
+
+      END
diff --git a/interpolation/hsp2gg.F b/interpolation/hsp2gg.F
deleted file mode 100644
index 94f5e54..0000000
--- a/interpolation/hsp2gg.F
+++ /dev/null
@@ -1,183 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HSP2GG(KTRUNC,KGAUSS,KPTS,PLATS,KSIZE)
-C
-C---->
-C**** HSP2GG
-C
-C     Purpose
-C     -------
-C
-C     This routine finds a suitable gaussian grid for a given
-C     spectral truncation.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HSP2GG(KTRUNC,KGAUSS,KPTS,KSIZE)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     KTRUNC - The spectral truncation
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     KGAUSS - The gaussian number
-C     KPTS   - Array giving number of points along each line of latitude
-C              in the reduced gaussian grid (both hemispheres)
-C     PLATS  - Array giving gaussian latitudes (both hemispheres)
-C     KSIZE  - The number of points in the reduced gaussian grid
-C
-C     Returns 0 if all OK, otherwise there is an error.
-C
-C
-C     Common block usage
-C     ------------------
-C
-C     None
-C
-C
-C     Method
-C     ------
-C
-C     None
-C
-C
-C     Externals
-C     ---------
-C
-C     JGETGG - Reads the definition of a gaussian grid
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      February 2001
-C
-C
-C     Modifications
-C     -------------
-C
-C     S.Curic     ECMWF      March 2005
-C     Added checking for a automatic trancation T255, T399, T799, T2047 
-C     and corresponding gaussian grid.
-C
-C     S.Curic     ECMWF      April 2008
-C     Added checking for a automatic trancation T1279
-C     and corresponding gaussian grid.
-C
-C
-C     S.Curic     ECMWF      Semptember 2009
-C     Match T255 and T213 against N128 instead of N160
-C     upon Alan Geer request
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Function arguments
-C
-      INTEGER KTRUNC, KGAUSS, KPTS(*), KSIZE
-      REAL PLATS(*)
-C
-C     Local variables
-C
-      INTEGER LOOP, IRET
-C
-C
-C     -----------------------------------------------------------------|
-C     Section 1.  Initialise.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      HSP2GG = 0
-C
-      IF( (KTRUNC.EQ.2047).OR.(KTRUNC.EQ.2048) ) THEN      ! Mariano
-        KGAUSS = 1024
-      ELSE IF( (KTRUNC.EQ.1279).OR.(KTRUNC.EQ.1280) ) THEN ! Jan Haseler
-        KGAUSS = 640
-      ELSE IF( (KTRUNC.EQ.799).OR.(KTRUNC.EQ.800) ) THEN   ! Oper 2005
-        KGAUSS = 400
-      ELSE IF( (KTRUNC.EQ.639).OR.(KTRUNC.EQ.640) ) THEN
-        KGAUSS = 320
-      ELSE IF( (KTRUNC.EQ.511).OR.(KTRUNC.EQ.512) ) THEN   ! Oper 2004
-        KGAUSS = 256
-      ELSE IF( (KTRUNC.EQ.399).OR.(KTRUNC.EQ.400) ) THEN   ! Enfo 2005
-        KGAUSS = 200
-      ELSE IF( (KTRUNC.EQ.319).OR.(KTRUNC.EQ.320) ) THEN
-        KGAUSS = 160
-      ELSE IF( (KTRUNC.EQ.255).OR.(KTRUNC.EQ.256) ) THEN   ! Enfo 2004
-        KGAUSS = 128
-      ELSE IF( (KTRUNC.EQ.213).OR.(KTRUNC.EQ.214) ) THEN
-        KGAUSS = 128
-      ELSE IF( (KTRUNC.EQ.191).OR.(KTRUNC.EQ.192) ) THEN
-        KGAUSS = 96
-      ELSE IF( (KTRUNC.EQ.159).OR.(KTRUNC.EQ.160) ) THEN
-        KGAUSS = 80
-      ELSE IF( (KTRUNC.EQ.106).OR.(KTRUNC.EQ.107) ) THEN
-        KGAUSS = 80
-      ELSE IF( (KTRUNC.EQ.95) .OR.(KTRUNC.EQ.96 ) ) THEN
-        KGAUSS = 48
-      ELSE IF( (KTRUNC.EQ.63) .OR.(KTRUNC.EQ.64 ) ) THEN
-        KGAUSS = 48
-      ELSE
-        CALL INTLOG(JP_ERROR,'HSP2GG: Unmatched truncation',KTRUNC)
-        HSP2GG = 1
-        GOTO 900
-      ENDIF
-C
-C     Get the reduced gaussian grid information and count the
-C     number of points.
-C
-      CALL JGETGG(KGAUSS,'R',PLATS,KPTS,IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HSP2GG: JGETGG failed to get gaussian data',JPQUIET)
-        HSP2GG = 2
-        GOTO 900
-      ENDIF
-C
-      KSIZE = 0
-      DO LOOP = 1, KGAUSS*2
-        KSIZE = KSIZE + KPTS(LOOP)
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Section 9.  Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/hsp2gg2.F b/interpolation/hsp2gg2.F
deleted file mode 100644
index 7706271..0000000
--- a/interpolation/hsp2gg2.F
+++ /dev/null
@@ -1,232 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HSP2GG2(KTRUNC,NS,EW,KGAUSS,KPTS,PLATS,KSIZE)
-C
-C---->
-C**** HSP2GG2
-C
-C     Purpose
-C     -------
-C
-C     This routine finds a suitable gaussian grid for a given
-C     spectral truncation.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HSP2GG2(KTRUNC,KGAUSS,KPTS,KSIZE)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     KTRUNC - The spectral truncation
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     KGAUSS - The gaussian number
-C     KPTS   - Array giving number of points along each line of latitude
-C              in the reduced gaussian grid (both hemispheres)
-C     PLATS  - Array giving gaussian latitudes (both hemispheres)
-C     KSIZE  - The number of points in the reduced gaussian grid
-C
-C     Returns 0 if all OK, otherwise there is an error.
-C
-C
-C     Common block usage
-C     ------------------
-C
-C     None
-C
-C
-C     Method
-C     ------
-C
-C     None
-C
-C
-C     Externals
-C     ---------
-C
-C     JGETGG - Reads the definition of a gaussian grid
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      February 2001
-C
-C
-C     Modifications
-C     -------------
-C
-C     S.Curic     ECMWF      March 2005
-C     Added checking for a automatic trancation T255, T399, T799, T2047 
-C     and corresponding gaussian grid.
-C
-C     S.Curic     ECMWF      April 2008
-C     Added checking for a automatic trancation T1279
-C     and corresponding gaussian grid.
-C
-C
-C     S.Curic     ECMWF      Semptember 2009
-C     Match T255 and T213 against N128 instead of N160
-C     upon Alan Geer request
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Function arguments
-C
-      INTEGER KTRUNC, KGAUSS, KPTS(*), KSIZE
-      REAL NS, EW, STEP
-      REAL PLATS(*)
-#include "jparams.h"
-C
-C     Local variables
-C
-      INTEGER LOOP, IRET
-      LOGICAL LDEBUG
-C
-C
-C     -----------------------------------------------------------------|
-C     Section 1.  Initialise.
-C     -----------------------------------------------------------------|
-      STEP = MIN(ABS(NS),ABS(EW))
-C
-  100 CONTINUE
-C
-      HSP2GG2 = 0
-c
-      CALL JDEBUG()
-      LDEBUG = ( NDBG.NE.0 )
-
-C     2.5 and greater -> T63
-C
-      IF( STEP.GE.2.5 ) THEN
-        KTRUNC = 63
-        KGAUSS  = 48
-        GOTO 890
-      ENDIF
-C
-C     1.5 to 2.5      -> T106
-C
-      IF( STEP.GE.1.5 ) THEN
-        KTRUNC = 106
-        KGAUSS = 80
-        GOTO 890
-      ENDIF
-C
-C     1.5 to 2.5      -> T191
-C
-CCC      IF( STEP.GE.0.4 ) THEN
-CCC        KTRUNC = 191
-CCC        KGAUSS  = 96
-CCC        GOTO 890
-CCC      ENDIF
-C
-C     0.6 to 1.5      -> T213
-C
-      IF( STEP.GE.0.6 ) THEN
-        KTRUNC = 213
-        KGAUSS  = 128
-        GOTO 890
-      ENDIF
-C
-C     0.4 to 0.6      -> T319
-C
-      IF( STEP.GE.0.4 ) THEN
-        KTRUNC = 319
-        KGAUSS  = 160
-        GOTO 890
-      ENDIF
-C
-C     0.3 to 0.4      -> T511
-C
-      IF( STEP.GE.0.3 ) THEN
-        KTRUNC  = 511
-        KGAUSS  = 256
-        GOTO 890
-      ENDIF
-C
-C     0.15 to 0.3      -> T799
-C
-      IF( STEP.GE.0.15 ) THEN
-        KTRUNC  = 799
-        KGAUSS  = 400
-        GOTO 890
-      ENDIF
-
-C
-C     0.09 to 0.15      -> T1279
-C
-      IF( STEP.GE.0.09 ) THEN
-        KTRUNC  = 1279
-        KGAUSS  = 640
-        GOTO 890
-      ENDIF
-c
-      KTRUNC  = 2047
-      KGAUSS  = 1024
-C
-C     Get the reduced gaussian grid information and count the
-C     number of points.
-C
-  890 CONTINUE
-      CALL JGETGG(KGAUSS,'R',PLATS,KPTS,IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HSP2GG2: JGETGG failed to get gaussian data',JPQUIET)
-        HSP2GG2 = 2
-        GOTO 900
-      ENDIF
-C
-      KSIZE = 0
-      DO LOOP = 1, KGAUSS*2
-        KSIZE = KSIZE + KPTS(LOOP)
-      ENDDO
-
-      IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X    'HSP2GG2: Corresponding Spectral Truncation:',KTRUNC)
-          CALL INTLOG(JP_DEBUG,
-     X    'HSP2GG2: Corresponding Gaussian Number:',KGAUSS)
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 9.  Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/hsp2gg3.F b/interpolation/hsp2gg3.F
deleted file mode 100644
index c33f83e..0000000
--- a/interpolation/hsp2gg3.F
+++ /dev/null
@@ -1,193 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION HSP2GG3(KTRUNC,KGAUSS,KPTS,PLATS,KSIZE)
-C
-C---->
-C**** HSP2GG3
-C
-C     Purpose
-C     -------
-C
-C     This routine finds a suitable gaussian grid for a given
-C     spectral truncation.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = HSP2GG3(KTRUNC,KGAUSS,KPTS,KSIZE)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     KTRUNC - The spectral truncation
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     KGAUSS - The gaussian number
-C     KPTS   - Array giving number of points along each line of latitude
-C              in the reduced gaussian grid (both hemispheres)
-C     PLATS  - Array giving gaussian latitudes (both hemispheres)
-C     KSIZE  - The number of points in the reduced gaussian grid
-C
-C     Returns 0 if all OK, otherwise there is an error.
-C
-C
-C     Common block usage
-C     ------------------
-C
-C     None
-C
-C
-C     Method
-C     ------
-C
-C     None
-C
-C
-C     Externals
-C     ---------
-C
-C     JGETGG - Reads the definition of a gaussian grid
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      February 2001
-C
-C
-C     Modifications
-C     -------------
-C
-C     S.Curic     ECMWF      March 2005
-C     Added checking for a automatic trancation T255, T399, T799, T2047 
-C     and corresponding gaussian grid.
-C
-C     S.Curic     ECMWF      April 2008
-C     Added checking for a automatic trancation T1279
-C     and corresponding gaussian grid.
-C
-C
-C     S.Curic     ECMWF      Semptember 2009
-C     Match T255 and T213 against N128 instead of N160
-C     upon Alan Geer request
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Function arguments
-C
-      INTEGER KTRUNC, KGAUSS, KPTS(*), KSIZE
-      REAL PLATS(*)
-#include "jparams.h"
-C
-C     Local variables
-C
-      INTEGER LOOP, IRET
-      LOGICAL LDEBUG
-C
-C
-C     -----------------------------------------------------------------|
-C     Section 1.  Initialise.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      HSP2GG3 = 0
-
-      CALL JDEBUG()
-      LDEBUG = ( NDBG.NE.0 )
-C
-      IF(KGAUSS.EQ.1024) THEN      ! Mariano
-        KTRUNC = 2047
-      ELSEIF(KTRUNC.EQ.640) THEN ! Jan Haseler
-        KTRUNC = 1279
-      ELSEIF(KGAUSS.EQ.400) THEN   ! Oper 2005
-        KTRUNC = 799
-      ELSEIF(KGAUSS.EQ.320) THEN
-        KTRUNC = 639
-      ELSEIF(KGAUSS.EQ.256) THEN   ! Oper 2004
-        KTRUNC = 511
-      ELSEIF(KGAUSS.EQ.200) THEN   ! Enfo 2005
-        KTRUNC = 399
-      ELSEIF(KGAUSS.EQ.160) THEN
-        KTRUNC = 319
-      ELSEIF(KGAUSS.EQ.128) THEN   ! Enfo 2004
-        KTRUNC = 255
-      ELSEIF(KGAUSS.EQ.128) THEN
-        KTRUNC = 213
-      ELSEIF(KGAUSS.EQ.96) THEN   ! Elias 2014
-        KTRUNC = 191
-      ELSEIF(KGAUSS.EQ.80) THEN
-        KTRUNC = 159
-      ELSEIF(KGAUSS.EQ.48) THEN
-        KTRUNC = 95
-      ELSEIF(KGAUSS.EQ.48) THEN
-        KTRUNC = 63
-      ELSE
-        CALL INTLOG(JP_ERROR,'HSP2GG3: Unmatched truncation',KTRUNC)
-        HSP2GG3 = 1
-        GOTO 900
-      ENDIF
-C
-C     Get the reduced gaussian grid information and count the
-C     number of points.
-C
-      CALL JGETGG(KGAUSS,'R',PLATS,KPTS,IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'HSP2GG3: JGETGG failed to get gaussian data',JPQUIET)
-        HSP2GG3 = 2
-        GOTO 900
-      ENDIF
-C
-      KSIZE = 0
-      DO LOOP = 1, KGAUSS*2
-        KSIZE = KSIZE + KPTS(LOOP)
-      ENDDO
-
-      IF( LDEBUG ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X    'HSP2GG3: Output Gaussian number :',KGAUSS)
-          CALL INTLOG(JP_DEBUG,
-     X    'HSP2GG3: Corresponding Spectral Truncation:',KTRUNC)
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Section 9.  Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/iagcntl.F b/interpolation/iagcntl.F
index e1d08fe..5a83b47 100644
--- a/interpolation/iagcntl.F
+++ b/interpolation/iagcntl.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -164,7 +164,6 @@ C
 C     EXTERNALS
 C     _________
 C
-C     ABORTX     - Standard routine to kill task.
 C     IGDINS     - Calculate the distances between points in an
 C                  output latitude array and its North and South
 C                  neighbours in the input latitude array.
@@ -178,8 +177,6 @@ C     IGINT      - Calculate the basic unnormalised interpolation
 C                  weights.
 C     IGLGRID    - Generate the arrays of latitude and longitude
 C                  points for a regular latitude/longitude grid.
-C     IGLSIZE    - Evaluate the array sizes for a regular
-C                  latitude/longitude grid and area.
 C     IGLSMB     - Calculate the effects of the land-sea masks on
 C                  the unnormalised interpolation weights.
 C     IGLSMD     - Generate the land sea mask file information.
@@ -196,8 +193,6 @@ C     IGPREC     - Perform additional interpolation for
 C                  precipitation fields.
 C     ZPREC      - Perform additional interpolation processes
 C                  for precipitation
-C     IGSIZE     - Evaluate the array sizes for a Gaussian
-C                  truncation and area.
 C     IGTOG      - Perform basic interpolation between regular input
 C                  and output fields.
 C     INTLOG       - Logs messages.
@@ -261,7 +256,7 @@ C
       LOGICAL LFAIL, LERROR, LDEBUG, LREGIN, LREGOUT
       LOGICAL GINSPOLE, GIGLOBE, GISTAND, GONSPOLE, GOGLOBE, GOSTAND
       LOGICAL GPREC,LSM_VALUES
-      CHARACTER*120 YIFILE, YOFILE
+      CHARACTER*256 YIFILE, YOFILE
       CHARACTER*12 YFLAG
       INTEGER IIOFF, IIREC, IOOFF, IOREC, IERR
 C
@@ -421,18 +416,13 @@ C
         GINSPOLE = OINPOLE.AND.OISPOLE
         GIGLOBE  = OIWEGLOBE.AND.GINSPOLE
 C
+C       Output grid definition
+C
 C       Is the output field global North South
 C
         GONSPOLE = OONPOLE.AND.OOSPOLE
         GOGLOBE  = OOWEGLOBE.AND.GONSPOLE
-
-        IF(GOGLOBE.AND.NOAREA(2).EQ.0) THEN
-            LGLOBL = .TRUE.
-        ELSE
-            LGLOBL = .FALSE.
-        ENDIF
-C
-C       Output grid definition
+        LGLOBL   = (GOGLOBE.AND.NOAREA(2).EQ.0)
 C
         IF( NOREPR.EQ.JPGAUSSIAN ) THEN
 C
@@ -522,8 +512,8 @@ C
      X                   MNSIND, MNSDIST, KPR, KERR)
         IF( IAGCNTL.GT.0 ) GOTO 900
 C
-        IAGCNTL = IGDIWE(MILONG, NIWE, MOLONG, NOWE, OIWEGLOBE,
-     X                   MWEIND, MWEDIST, KPR, KERR)
+        IAGCNTL = IGDIWE(NIWE, NOWE, MWEIND, MWEDIST, NIAREA, NOAREA,
+     X    MILONG, MOLONG, OIWEGLOBE )  ! FIXME: remove
         IF( IAGCNTL.GT.0 ) GOTO 900
 C
 C       The end of primary initialisation
diff --git a/interpolation/iaidef.F b/interpolation/iaidef.F
deleted file mode 100644
index dc683a8..0000000
--- a/interpolation/iaidef.F
+++ /dev/null
@@ -1,553 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IAIDEF (KSEC1, KSEC2, KIAREA, KLLEN, OICHNG,
-     1   KPR, KERR)
-C
-C---->
-C**** *IAIDEF*
-C
-C     PURPOSE
-C     _______
-C
-C     Generate an input field definition from the GRIB definition.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IAIDEF (KSEC1, KSEC2, KIAREA, KLLEN, OICHNG, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     KSEC1      - The GRIB Section 1 array for the input field.
-C
-C     KSEC2      - The GRIB Section 2 array for the input field.
-C
-C     KIAREA     - The previous input field area used for comparison.
-C
-C     KLLEN      - The previous latitude line lengths for a quasi
-C                  regular Gaussian field used for comparison.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     KIAREA     - The area for this field.
-C
-C     KLLEN      - The latitude line lengths for a quasi regular
-C                  Gaussian field.
-C
-C     OICHNG     - A flag indicating whether the field definition has
-C                  changed since the previous call to this routine.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     21701 The data representation was not valid.
-C     21702 The scan mode was not valid.
-C
-C     Common block usage
-C     __________________
-C
-C     nifld.common - This file contains all the input field
-C                    definition variables.
-C
-C     LSMCHNG      - LSM change flag is set.
-C     LSM          - LSM usage flag is set.
-C     LSMPAR       - LSM parameter flag is set.
-C     LPREC        - Precipitation flag is set.
-C     LWIND        - Wind flag is set.
-C
-C     NIGAUSS      - Input field Gaussian truncation is used and set.
-C     NIGRID       - Input field grid definition (WE/NS) is used and
-C                    set.
-C     NINS         - Number of grid points in NS direction for input
-C                    field is used and set.
-C     NIPARAM      - Input field parameter number is used and set.
-C     NIREPR       - Input field representation is used and set.
-C     NISCNM       - Input field scanning mode is set.
-C     NITABLE      - Input field table number is used and set.
-C     NIWE         - Number of grid points in WE direction for input
-C                    field is used and set.
-C
-C     EXTERNALS
-C     _________
-C
-C     PRECIP       - Says if field is to have 'precipitation' treatment
-C     SETPAR       - Standard routine used to generate "missing" data
-C                    values for GRIB fields.
-C     INTLOG       - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     This routine uses sections 1 and 2 of the input GRIB field to
-C     generate the input field definition. This definition is
-C     compared with the previous field definition to see if any
-C     change of definition has occurred.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 3 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-C
-C     Subroutine arguments
-      LOGICAL OICHNG
-      INTEGER KPR, KERR
-      INTEGER KSEC1 (JPGRIB_ISEC1), KSEC2 (JPGRIB_ISEC2), KIAREA (4)
-      INTEGER KLLEN (*)
-C
-C     Local variables
-      LOGICAL GNLSM
-      INTEGER ITEMP, IMISS, IWEST, IEAST, IERR
-      INTEGER JSET
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 21700)
-C
-C     External functions
-C
-      LOGICAL PRECIP
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAIDEF: Section 1.',JPQUIET)
-C
-      IAIDEF = 0
-      IERR = 0
-      OICHNG = .FALSE.
-C
-C     Get GRIB missing data value
-C
-      CALL SETPAR (ITEMP, IMISS, KPR)
-C
-C     _______________________________________________________
-C
-C*    Section 2. Set Grib Section 2 variables and check consistency
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAIDEF: Section 2.',JPQUIET)
-C
-C     Representation
-C
-      IF (KSEC2 (JPSEC2_REP) .EQ. JPGAUSSIAN .AND.
-     1   KSEC2 (JPSEC2_QUASI) .EQ. 1) THEN
-         ITEMP = JPQUASI
-      ELSE
-         ITEMP = KSEC2 (JPSEC2_REP)
-      ENDIF
-C
-      IF (ITEMP .NE. NIREPR) THEN
-         NIREPR = ITEMP
-         OICHNG = .TRUE.
-      ENDIF
-C
-C     Only grid point input data allowed now
-C
-      IF (NIREPR .NE. JPQUASI .AND. NIREPR .NE. JPGAUSSIAN .AND.
-     X  NIREPR .NE. JPREGULAR) THEN
-        IAIDEF = JPROUTINE + 1
-        IF (KERR .GE. 0) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'IAIDEF: Illegal input representation = ',NIREPR)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAIDEF: Interpolation failing.',JPQUIET)
-        ENDIF
-        GO TO 900
-      ENDIF
-C
-C     scan mode
-C
-      NISCNM  = KSEC2 (JPSEC2_SCAN)
-C
-      IF (NISCNM .NE. 0) THEN
-        IAIDEF = JPROUTINE + 2
-        IF (KERR .GE. 0) THEN
-          CALL INTLOG(JP_ERROR,'IAIDEF: Illegal scan mode = ',NISCNM)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAIDEF: Interpolation failing.',JPQUIET)
-        ENDIF
-        GO TO 900
-      ENDIF
-C
-C     Number of lines North-South and West-East
-C
-      IF (KSEC2 (JPSEC2_NLAT) .NE. NINS) THEN
-        NINS = KSEC2 (JPSEC2_NLAT)
-        OICHNG = .TRUE.
-      ENDIF
-C
-      IF (NIREPR.NE.JPQUASI .AND. KSEC2(JPSEC2_NLONG).NE.NIWE) THEN
-        NIWE = KSEC2 (JPSEC2_NLONG)
-        OICHNG = .TRUE.
-      ENDIF
-C
-C     North, South, West and East limits
-C
-      IF (KSEC2 (JPSEC2_NORTH) * 10 .NE. KIAREA (JPNORTH) ) THEN
-        KIAREA (JPNORTH) = KSEC2 (JPSEC2_NORTH) * 10
-        OICHNG = .TRUE.
-      ENDIF
-C
-      IF (KSEC2 (JPSEC2_SOUTH) * 10 .NE. KIAREA (JPSOUTH) ) THEN
-        KIAREA (JPSOUTH) = KSEC2 (JPSEC2_SOUTH) * 10
-        OICHNG = .TRUE.
-      ENDIF
-C
-      IWEST = KSEC2 (JPSEC2_WEST) * 10
-C
-C     Make West and East points an ordered pair
-C
-      IF (NIREPR .EQ. JPQUASI) THEN
-        IEAST = 0
-      ELSE
-        IEAST = KSEC2 (JPSEC2_EAST) * 10
-C
-        IF (IEAST .LT. IWEST) THEN
-          IF (IEAST .LE. 0) THEN
-            IEAST = IEAST + JP360
-          ELSE
-            IWEST = IWEST - JP360
-          ENDIF
-        ENDIF
-      ENDIF
-C
-      IF (IEAST .NE. KIAREA (JPEAST) ) THEN
-        KIAREA (JPEAST) = IEAST
-        OICHNG = .TRUE.
-      ENDIF
-C
-      IF (IWEST .NE. KIAREA (JPWEST) ) THEN
-        KIAREA (JPWEST) = IWEST
-        OICHNG = .TRUE.
-      ENDIF
-C
-      IF (NIREPR .EQ. JPREGULAR) THEN
-C
-C       Direction increments for regular grids
-C
-        IF (KSEC2 (JPSEC2_DLONG) .EQ. IMISS) THEN
-          ITEMP = (KIAREA (JPEAST) - KIAREA (JPWEST) ) / NIWE + 1
-        ELSE
-          ITEMP = KSEC2 (JPSEC2_DLONG) * 10
-        ENDIF
-C
-        IF (NIGRID (JPWESTEP) .NE. ITEMP) THEN
-          NIGRID (JPWESTEP) = ITEMP
-          OICHNG = .TRUE.
-        ENDIF
-C
-        IF (KSEC2 (JPSEC2_DLAT) .EQ. IMISS) THEN
-          ITEMP = (KIAREA (JPNORTH) - KIAREA (JPSOUTH) ) / NINS + 1
-        ELSE
-          ITEMP = KSEC2 (JPSEC2_DLAT) * 10
-        ENDIF
-C
-        IF (NIGRID (JPNSSTEP) .NE. ITEMP) THEN
-          NIGRID (JPNSSTEP) = ITEMP
-          OICHNG = .TRUE.
-        ENDIF
-C
-      ELSE IF (NIREPR .EQ. JPGAUSSIAN) THEN
-C
-        IF (NIGAUSS .NE. KSEC2 (JPSEC2_GTRUNC) ) THEN
-          NIGAUSS = KSEC2 (JPSEC2_GTRUNC)
-          OICHNG = .TRUE.
-        ENDIF
-C
-      ELSE IF (NIREPR .EQ. JPQUASI) THEN
-C
-        IF (NIGAUSS .NE. KSEC2 (JPSEC2_GTRUNC) ) THEN
-          NIGAUSS = KSEC2 (JPSEC2_GTRUNC)
-          NIWE = NIGAUSS * 4
-          OICHNG = .TRUE.
-        ENDIF
-C
-C     Set line length definitions for Quasi regular field
-C
-        DO 210 JSET = 1, NINS
-          IF (KLLEN (JSET) .NE. KSEC2 (JPSEC2_QUDEF + JSET) ) THEN
-            KLLEN (JSET) = KSEC2 (JPSEC2_QUDEF + JSET)
-            OICHNG = .TRUE.
-          ENDIF
-  210   CONTINUE
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 3. Set Grib Section 1 variables and flags
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAIDEF: Section 3.',JPQUIET)
-C
-      NITABLE = KSEC1 (JPSEC1_TABLE)
-      NIPARAM = KSEC1 (JPSEC1_PARAM)
-C
-C     Setup ECMWF local definition number and stream if applicable
-C
-      IF( KSEC1(24).EQ.1 ) THEN
-        NILOCAL = KSEC1(37)
-        NISTREM = KSEC1(40)
-      ELSE
-        NILOCAL = 0
-        NISTREM = 0
-      ENDIF
-C
-      LPREC = PRECIP()
-C
-      IF (NITABLE .EQ. 1) THEN
-C
-C       WMO International table for meteorological parameters
-C
-        LWIND = NIPARAM .EQ. JP_WMO_U .OR. NIPARAM .EQ. JP_WMO_V
-C
-        LSMPAR = NIPARAM .EQ. JP_WMO_LSM
-C
-        GNLSM = .NOT. (NIPARAM .EQ. JP_WMO_MSL .OR. LSMPAR)
-C
-        IF (GNLSM .NEQV. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = GNLSM
-        ENDIF
-C
-      ELSE IF (NITABLE .EQ. 128) THEN
-C
-C       ECMWF local code table 2 for meteorological parameters
-C
-        LWIND = NIPARAM .EQ. JP_U .OR. NIPARAM .EQ. JP_V .OR.
-     X      NIPARAM .EQ. JP_10U .OR. NIPARAM .EQ. JP_10V
-C
-        LSMPAR = NIPARAM .EQ. JP_LSM
-C
-        GNLSM = .NOT. (NIPARAM .EQ. JP_MSL .OR. LSMPAR)
-C
-        IF (GNLSM .NEQV. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = GNLSM
-        ENDIF
-C
-      ELSE IF (NITABLE .EQ. 129) THEN
-C
-C       ECMWF local code table for gradients of parameters
-C
-        LWIND = .FALSE.
-        LSMPAR = .FALSE.
-C
-        IF (.NOT. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = .TRUE.
-        ENDIF
-C
-      ELSE IF (NITABLE .EQ. 130) THEN
-C
-C       ECMWF local code table for ASTEX experiments
-C
-        LWIND = .FALSE.
-        LSMPAR = .FALSE.
-C
-        IF (.NOT. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = .TRUE.
-        ENDIF
-C
-      ELSE IF (NITABLE .EQ. 131) THEN
-C
-C       ECMWF local code table for probability forecasts
-C
-        LWIND = .FALSE.
-        LSMPAR = .FALSE.
-C
-        IF (.NOT. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = .TRUE.
-        ENDIF
-C
-      ELSE IF (NITABLE .EQ. 140) THEN
-C
-C       ECMWF local code table for wave models
-C
-        LWIND = .FALSE.
-        LSMPAR = .FALSE.
-C
-        IF (.NOT. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = .TRUE.
-        ENDIF
-C
-      ELSE IF (NITABLE .EQ. 150) THEN
-C
-C       ECMWF local code table ocean data
-C
-        LWIND = .FALSE.
-        LSMPAR = .FALSE.
-C
-        IF (.NOT. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = .TRUE.
-        ENDIF
-C
-      ELSE
-C
-C       Unexpected code table found
-C
-        LWIND = .FALSE.
-        LSMPAR = .FALSE.
-C
-        IF (.NOT. LSM) THEN
-          LSMCHNG = .TRUE.
-          LSM = .TRUE.
-        ENDIF
-C
-      ENDIF
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'IAIDEF: Input field definition parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IAIDEF: Parameter value = ',NIPARAM)
-        CALL INTLOG(JP_DEBUG,'IAIDEF: Representation = ',NIREPR)
-        IF (NIWE .NE. 0) CALL INTLOG(JP_DEBUG,
-     X    'IAIDEF: Number W-E = ',NIWE)
-        IF (NINS .NE. 0) CALL INTLOG(JP_DEBUG,
-     X    'IAIDEF: Number N-S = ',NINS)
-        IF (NIREPR .EQ. JPGAUSSIAN .OR. NIREPR .EQ. JPQUASI)
-     X    CALL INTLOG(JP_DEBUG,'IAIDEF: Gaussian truncation = ',NIGAUSS)
-        IF (NIREPR .EQ. JPREGULAR .AND. NIGRID (1) .NE. 0) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Grid WE = ',NIGRID (1))
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Grid NS = ',NIGRID (2))
-        ENDIF
-        IF (KIAREA (1) .NE. 0) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Area North = ',KIAREA(1))
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Area West  = ',KIAREA(2))
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Area South = ',KIAREA(3))
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Area East  = ',KIAREA(4))
-        ENDIF
-C
-        CALL INTLOG(JP_DEBUG,'IAIDEF: Control flag status:',JPQUIET)
-C
-        IF( OICHNG ) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF:Input fld change TRUE',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,'IAIDEF:Input fld change FALSE',JPQUIET)
-        ENDIF
-C
-        IF( LSMCHNG ) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: LSM change TRUE',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,'IAIDEF: LSM change FALSE',JPQUIET)
-        ENDIF
-C
-        IF( LSM ) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: LSM flag TRUE',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,'IAIDEF: LSM flag FALSE',JPQUIET)
-        ENDIF
-C
-        IF( LWIND ) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Wind flag TRUE',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Wind flag FALSE',JPQUIET)
-        ENDIF
-C
-        IF( LPREC ) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Precipitn flag TRUE',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,'IAIDEF: Precipitn flag FALSE',JPQUIET)
-        ENDIF
-C
-        IF( LSMPAR ) THEN
-          CALL INTLOG(JP_DEBUG,'IAIDEF: LSM param flag TRUE',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,'IAIDEF: LSM param flag FALSE',JPQUIET)
-        ENDIF
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAIDEF: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/iaintgg.F b/interpolation/iaintgg.F
deleted file mode 100644
index 35003de..0000000
--- a/interpolation/iaintgg.F
+++ /dev/null
@@ -1,552 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IAINTGG (KIFELD, KILEN, PWEST, PEAST, PNORTH,
-     1   PSOUTH, KGAUSS, KOFELD, KOLEN, KOBITS, KPR, KERR)
-C
-C---->
-C**** *IAINTGG*
-C
-C     PURPOSE
-C     _______
-C
-C     The controlling routine for interpolating between a GRIB input
-C     field and a Gaussian output field.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IAINTGG (KIFELD, KILEN, PWEST, PEAST, PNORTH, PSOUTH,
-C    1   KGAUSS, KOFELD, KOLEN, KOBITS, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     KIFELD     - The input field provided by the calling routine.
-C
-C     KILEN      - The length of the input field.
-C
-C     PWEST      - The Western limit of the output field area.
-C
-C     PEAST      - The Eastern limit of the output field area.
-C
-C     PNORTH     - The Northern limit of the output field area.
-C
-C     PSOUTH     - The Southern limit of the output field area.
-C
-C     KGAUSS     - The Gaussian truncation for the output field.
-C
-C     KOLEN      - The length of the output field.
-C
-C     KOBITS     - The number of bits used for packing the output array.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     KOFELD     - The output field returned to the calling routine.
-C
-C     KOLEN      - The amount of the output array used for the packed
-C                  GRIB field.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     21501 The number of bits requested was outside the allowed
-C           range 0 to 24.
-C     21502 The input data representation was not valid when the GRIB
-C           field had been expanded.
-C
-C     Common block usage
-C     __________________
-C
-C     grfixed.h    - The include file contains all the array space
-C                    for grid to grid interpolation.
-C
-C     MILLEN       - The array of latitude line lengths for a quasi
-C                    regular input field is used.
-C     RIGAUSS      - Real array of input field Gaussian latitudes is
-C                    used.
-C     ROGAUSS      - Real array of output field Gaussian latitudes is
-C                    used.
-C
-C     ouspace.h    - This file contains the work space array
-C                    definitions for the arrays to hold the unpacked
-C                    real data from GRIB fields.
-C
-C     RIFELD       - The expanded input field is set and used.
-C     ROFELD       - The expanded output field is set and used.
-C
-C     nifld.common - This file contains all the input field
-C                    definition variables.
-C
-C     LCHANGE      - Process change flag is set.
-C
-C     NIAREA       - Input field area definition (N/W/S/E) is set.
-C     NIGAUSS      - Input field Gaussian truncation is used.
-C     NIGRID       - Input field grid definition (WE/NS) is used.
-C     NINS         - Number of grid points in NS direction for input
-C                    field is used.
-C     NIREPR       - Input field representation is used.
-C     NIWE         - Number of grid points in WE direction for input
-C                    field is used.
-C
-C     nofld.common - This file contains all the output field
-C                    definition variables.
-C
-C     NOACC        - Number of packing bits to be used for output
-C                    GRIB field is set.
-C     NOAREA       - Output field area definition (N/W/S/E) is set.
-C     NOGAUSS      - Output field Gaussian truncation is set.
-C     NONS         - Number of grid points in NS direction for output
-C                    field is set and used.
-C     NOWE         - Number of grid points in WE direction for output
-C                    field is set and used.
-C
-C     EXTERNALS
-C     _________
-C
-C     ABORTX     - Standard routine to kill task.
-C     GRIBEX     - Standard routine to unpack or pack a GRIB field.
-C     IAGCNTL    - Perform regular grid to grid point interpolation.
-C     IARCNTL    - Perform regular grid to grid point interpolation.
-C     IAIDEF     - Initialise the input field definition variables
-C                  from a GRIB definition
-C     IAOGDEF    - Initialise the output field definition variables
-C                  from the user supplied values.
-C     IARESET    - Create the output field definition in GRIB format.
-C     IARMEM     - Get space for the unpacked input and output
-C                  fields.
-C     IGLSIZE    - Evaluate the array sizes for a regular
-C                  latitude/longitude grid and area.
-C     IGSIZE     - Evaluate the array sizes for a Gaussian truncation
-C                  and area.
-C     IRSIZE     - Evaluate the array sizes for a quasi regular
-C                  Gaussian field.
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     This is purely a controlling routine with all the work being
-C     performed in the external routines.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 7 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "ouspace.h"
-C
-C     Function arguments
-C
-      INTEGER KGAUSS, KILEN, KOLEN, KOBITS, KPR, KERR
-      REAL PWEST, PEAST, PNORTH, PSOUTH
-      INTEGER KIFELD (*), KOFELD (*)
-C
-C     Local variables
-C
-      CHARACTER*1 HFUNC
-      LOGICAL GIWEGLOBE, GINPOLE, GISPOLE, GOWEGLOBE, GONPOLE,
-     1   GOSPOLE, GICHNG, GOCHNG
-      INTEGER IILN, ITOTAL, IOLN
-      INTEGER IIAREA (4), IOAREA (4)
-      INTEGER JLAT, JSET
-      INTEGER IERR
-      INTEGER ISEC0 (JPGRIB_ISEC0), ISEC1 (JPGRIB_ISEC1)
-      INTEGER ISEC2 (JPGRIB_ISEC2), ISEC3 (JPGRIB_ISEC3)
-      INTEGER ISEC4 (JPGRIB_ISEC4)
-      INTEGER ZSEC2 (JPGRIB_RSEC2), ZSEC3 (JPGRIB_RSEC3)
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 21500)
-C
-C     External functions
-C
-      INTEGER IAGCNTL, IARCNTL, IAIDEF, IAOGDEF, IARESET, IARMEM,
-     1   IGLSIZE, IGSIZE, IRSIZE
-C
-C     Transform definition variables that must be preserved
-C
-      SAVE IILN, IIAREA, IOLN, IOAREA, ITOTAL
-      SAVE GIWEGLOBE, GINPOLE, GISPOLE, GOWEGLOBE, GONPOLE,
-     1   GOSPOLE
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 1.',JPQUIET)
-C
-      IAINTGG = 0
-C
-      IERR = 0
-C
-      IF (KPR .GE. 1) THEN
-         CALL INTLOG(JP_DEBUG,'IAINTGG: Input parameters',JPQUIET)
-         CALL INTLOG(JP_DEBUG,'IAINTGG: Input array length = ',KILEN)
-         CALL INTLOG(JP_DEBUG,'IAINTGG: Output array length = ',KOLEN)
-         CALL INTLOG(JP_DEBUG,'IAINTGG: Gaussian truncation = ',KGAUSS)
-         CALL INTLOG(JP_DEBUG,'IAINTGG: Out field packing bits=',KOBITS)
-         CALL INTLOGR(JP_DEBUG,'IAINTGG: Area North = ',PNORTH)
-         CALL INTLOGR(JP_DEBUG,'IAINTGG: Area West = ',PWEST)
-         CALL INTLOGR(JP_DEBUG,'IAINTGG: Area South = ',PSOUTH)
-         CALL INTLOGR(JP_DEBUG,'IAINTGG: Area East = ',PEAST)
-      ENDIF
-C
-      IF (KOBITS .LT. 0 .OR. KOBITS .GT. 24) THEN
-        IAINTGG = JPROUTINE + 1
-        IF (KERR .GE. 0) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'IAINTGG: No. bits requested = ',KOBITS)
-          CALL INTLOG(JP_ERROR,
-     X      'IAINTGG: Range allowed is <0 - 24>',JPQUIET)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAINTGG: Interpolation failing.',JPQUIET)
-        ENDIF
-        GO TO 900
-      ENDIF
-C
-      NOACC = KOBITS
-C
-C     _______________________________________________________
-C
-C
-C*    Section 2. Input grid definition from GRIB file
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 2.',JPQUIET)
-C
-C     Unpack GRIB sections 0, 1 and 2 only
-C
-      IERR = KERR
-C
-C     CALL GRSDBG (KPR)
-C
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X   RIFELD, 1, KIFELD, KILEN, KOLEN, 'I', IERR)
-C
-      IF (IERR .NE. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-      IERR = IAIDEF (ISEC1, ISEC2, IIAREA, MILLEN, GICHNG, KPR, KERR)
-C
-      IF (IERR .GT. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-      IF (GICHNG) THEN
-C
-        DO 210 JSET = 1, 4
-          NIAREA (JSET) = IIAREA (JSET)
-  210   CONTINUE
-C
-        IF (NIREPR .EQ. JPGAUSSIAN) THEN
-C
-          IERR = IGSIZE (NIGAUSS, NIAREA, NIWE, NINS, IILN, RIGAUSS,
-     1         GIWEGLOBE, GINPOLE, GISPOLE, KPR, KERR)
-C
-          IF (IERR .GT. 0) THEN
-            IAINTGG = IERR
-            GO TO 900
-          ENDIF
-C
-          ITOTAL = NIWE * NINS
-C
-        ELSE IF (NIREPR .EQ. JPQUASI) THEN
-C
-          IERR = IRSIZE (NIGAUSS, NIAREA, MILLEN, NIWE, NINS, IILN,
-     1         ITOTAL, RIGAUSS, GIWEGLOBE, GINPOLE, GISPOLE, KPR, KERR)
-C
-          IF (IERR .GT. 0) THEN
-            IAINTGG = IERR
-            GO TO 900
-          ENDIF
-C
-        ELSE IF (NIREPR .EQ. JPREGULAR) THEN
-C
-          IERR = IGLSIZE (NIGRID, NIAREA, NIWE, NINS, IILN, GIWEGLOBE,
-     X         GINPOLE, GISPOLE, KPR, KERR)
-C
-          IF (IERR .GT. 0) THEN
-            IAINTGG = IERR
-            GO TO 900
-          ENDIF
-C
-          ITOTAL = NIWE * NINS
-C
-        ELSE
-C
-          IAINTGG = JPROUTINE + 2
-          IF (KERR .GE. 0) CALL INTLOG(JP_ERROR,
-     X      'IAINTGG: Invalid input representation = ',NIREPR)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAINTGG: Interpolation failing.',JPQUIET)
-          GO TO 900
-C
-        ENDIF
-      ELSE
-        IF (NIREPR .NE. JPQUASI) THEN
-          ITOTAL = NIWE * NINS
-        ELSE
-          ITOTAL = 0
-          DO 220 JLAT = 1, NINS
-            ITOTAL = ITOTAL + MILLEN (JLAT)
-  220     CONTINUE
-        ENDIF
-      ENDIF
-C
-      LCHANGE = LCHANGE .OR. GICHNG
-C
-C     _______________________________________________________
-C
-C*    Section 3. Output field definiton from parameters
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 3.',JPQUIET)
-C
-      IERR = IAOGDEF (PWEST, PEAST, PNORTH, PSOUTH, KGAUSS, IOAREA,
-     1   GOCHNG, GIWEGLOBE, GINPOLE, GISPOLE, NIAREA, KPR, KERR)
-C
-      IF (IERR .GT. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-      IF (GOCHNG) THEN
-C
-        DO 310 JSET = 1, 4
-          NOAREA (JSET) = IOAREA (JSET)
-  310   CONTINUE
-C
-        NOWE = 0
-        NONS = 0
-C
-        IERR = IGSIZE (NOGAUSS, NOAREA, NOWE, NONS, IOLN, ROGAUSS,
-     1      GOWEGLOBE, GONPOLE, GOSPOLE, KPR, KERR)
-C
-        IF (IERR .GT. 0) THEN
-          IAINTGG = IERR
-          GO TO 900
-        ENDIF
-      ENDIF
-C
-      LCHANGE = LCHANGE .OR. GOCHNG
-C
-C     _______________________________________________________
-C
-C*    Section 4. Get space for REAL input and output arrays
-C     _______________________________________________________
-C
-  400 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 4.',JPQUIET)
-C
-      IF (LCHANGE) THEN
-C
-        IERR = IARMEM (ITOTAL, NOWE * NONS, KPR, KERR)
-C
-        IF (IERR .GT. 0) THEN
-          IAINTGG = IERR
-          GO TO 900
-        ENDIF
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 5. Fully unpack the GRIB array
-C     _______________________________________________________
-C
-  500 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 5.',JPQUIET)
-C
-      IERR = KERR
-C
-C     CALL GRSDBG (KPR)
-C
-      ISEC3(2) = NINT(RMISSGV)
-      ZSEC3(2) = RMISSGV
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X   RIFELD, ITOTAL, KIFELD, KILEN, KOLEN, 'D', IERR)
-C
-      IF (IERR .NE. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 6. Basic interpolation from input to output field
-C     _______________________________________________________
-C
-  600 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 6.',JPQUIET)
-C
-      IF (NIREPR .EQ. JPQUASI) THEN
-        IERR = IARCNTL (RIFELD, ITOTAL, ROFELD, NOWE * NONS, IILN,
-     X      GIWEGLOBE, GINPOLE, GISPOLE, IOLN, GOWEGLOBE, GONPOLE,
-     X      GOSPOLE, KPR, KERR)
-      ELSE
-        IERR = IAGCNTL (RIFELD, ITOTAL, ROFELD, NOWE * NONS, IILN,
-     X      GIWEGLOBE, GINPOLE, GISPOLE, IOLN, GOWEGLOBE, GONPOLE,
-     X      GOSPOLE, KPR, KERR)
-      ENDIF
-C
-      IF (IERR .NE. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 7. Repack GRIB code
-C     _______________________________________________________
-C
-  700 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 7.',JPQUIET)
-C
-      IERR = IARESET (ISEC2, ISEC4, NOWE * NONS, KPR, KERR)
-C
-      IF (IERR .NE. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-      IERR = KERR
-C
-C     CALL GRSDBG (KPR)
-C
-C     PACKING specified can be second-order, simple or archive value
-C
-      IF( NOHFUNC.EQ.'K' ) THEN
-        HFUNC = 'K'
-        ISEC4(4)  = 64
-        ISEC4(6)  = 16
-        ISEC4(9)  = 32
-        ISEC4(10) = 16
-        ISEC4(12) = 8
-        ISEC4(13) = 4
-        ISEC4(14) = 0
-        ISEC4(15) = -1
-      ELSE IF( NOHFUNC.EQ.'S' ) THEN
-        HFUNC = 'C'
-        ISEC4(4)  = 0
-        ISEC4(6)  = 0
-      ELSE IF( NOHFUNC.EQ.'A' ) THEN
-        IF( ISEC4(4).EQ.64 ) THEN
-          HFUNC = 'K'
-        ELSE
-          HFUNC = 'C'
-        ENDIF
-      ENDIF
-C
-      IF( LIMISSV ) THEN
-        ISEC1(5) = 192
-        ISEC3(2) = NINT(RMISSGV)
-        ZSEC3(2) = RMISSGV
-      ENDIF
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X   ROFELD, NOWE * NONS, KOFELD, KOLEN, KOLEN, HFUNC, IERR)
-C
-      IF (IERR .NE. 0) THEN
-        IAINTGG = IERR
-        GO TO 900
-      ENDIF
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,
-     X  'IAINTGG: Output field length is ',KOLEN)
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTGG: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/iaintll.F b/interpolation/iaintll.F
deleted file mode 100644
index ea05749..0000000
--- a/interpolation/iaintll.F
+++ /dev/null
@@ -1,577 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IAINTLL (KIFELD, KILEN, PWEST, PEAST, PNORTH,
-     1   PSOUTH, PNSINC, PWEINC, KOFELD, KOLEN, KOBITS, KPR, KERR)
-C
-C---->
-C**** *IAINTLL*
-C
-C     PURPOSE
-C     _______
-C
-C     The global controlling routine for interpolating between a GRIB
-C     input field and a regular latitude longitude output field.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IAINTLL (KIFELD, KILEN, PWEST, PEAST, PNORTH, PSOUTH,
-C    1   PNSINC, PWEINC, KOFELD, KOLEN, KOBITS, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     KIFELD     - The input field provided by the calling routine.
-C
-C     KILEN      - The length of the input field.
-C
-C     PWEST      - The Western limit of the output field area.
-C
-C     PEAST      - The Eastern limit of the output field area.
-C
-C     PNORTH     - The Northern limit of the output field area.
-C
-C     PSOUTH     - The Southern limit of the output field area.
-C
-C     PNSINC     - The North-South stride for the output field.
-C
-C     PWEINC     - The West-East stride for the output field.
-C
-C     KOLEN      - The length of the output field.
-C
-C     KOBITS     - The number of bits used for packing the output array.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     KOFELD     - The output field returned to the calling routine.
-C
-C     KOLEN      - The amount of the output array used for the packed
-C                  GRIB field.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     21301 The number of bits requested was outside the allowed
-C           range 0 to 24.
-C     21302 The input data representation was not valid when the GRIB
-C           field had been expanded.
-C
-C     Common block usage
-C     __________________
-C
-C     grfixed.h    - The include file contains all the array space
-C                    for grid to grid interpolation.
-C
-C     MILLEN       - The array of latitude line lengths for a quasi
-C                    regular input field is used.
-C     RIGAUSS      - Real array of input field Gaussian latitudes is
-C                    used.
-C
-C     ouspace.h    - This file contains the work space array
-C                    definitions for the arrays to hold the unpacked
-C                    real data from GRIB fields.
-C
-C     RIFELD       - The expanded input field is set and used.
-C     ROFELD       - The expanded output field is set and used.
-C
-C     nifld.common - This file contains all the input field
-C                    definition variables.
-C
-C     LCHANGE      - Process change flag is set.
-C
-C     NIAREA       - Input field area definition (N/W/S/E) is set.
-C     NIGAUSS      - Input field Gaussian truncation is used.
-C     NIGRID       - Input field grid definition (WE/NS) is used.
-C     NINS         - Number of grid points in NS direction for input
-C                    field is used.
-C     NIREPR       - Input field representation is used.
-C     NIWE         - Number of grid points in WE direction for input
-C                    field is used.
-C
-C     nofld.common - This file contains all the output field
-C                    definition variables.
-C
-C     NOACC        - Number of packing bits to be used for output
-C                    GRIB field is set.
-C     NOAREA       - Output field area definition (N/W/S/E) is set.
-C     NOGRID       - Output field grid definition (WE/NS) is used..
-C     NONS         - Number of grid points in NS direction for output
-C                    field is set and used.
-C     NOWE         - Number of grid points in WE direction for output
-C                    field is set and used.
-C
-C     EXTERNALS
-C     _________
-C
-C     ABORTX     - Standard routine to kill task.
-C     GRIBEX     - Standard routine to unpack or pack a GRIB field.
-C     IAGCNTL    - Perform regular grid to grid point interpolation.
-C     IARCNTL    - Perform regular grid to grid point interpolation.
-C     IAIDEF     - Initialise the input field definition variables
-C                  from a GRIB definition
-C     IAOLDEF    - Initialise the output field definition variables
-C                  from the user supplied values.
-C     IARESET    - Create the output field definition in GRIB format.
-C     IARMEM     - Get space for the unpacked input and output
-C                  fields.
-C     IGLSIZE    - Evaluate the array sizes for a regular
-C                  latitude/longitude grid and area.
-C     IGSIZE     - Evaluate the array sizes for a Gaussian truncation
-C                  and area.
-C     IRSIZE     - Evaluate the array sizes for a quasi regular
-C                  Gaussian field.
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     This is purely a controlling routine with all the work being
-C     performed in the external routines.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 7 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "ouspace.h"
-C
-C     Dummy arguments
-C
-      INTEGER KILEN, KOLEN, KOBITS, KPR, KERR
-C
-      REAL PWEST, PEAST, PNORTH, PSOUTH, PNSINC, PWEINC
-C
-      INTEGER KIFELD (*), KOFELD (*)
-C
-C     Local variables
-C
-      CHARACTER*1 HFUNC
-      LOGICAL GIWEGLOBE, GINPOLE, GISPOLE, GOWEGLOBE, GONPOLE,
-     1   GOSPOLE, GICHNG, GOCHNG
-C
-      INTEGER IILN, ITOTAL, IOLN
-C
-      INTEGER IIAREA (4), IOAREA (4)
-C
-      INTEGER JLAT, JSET
-C
-      INTEGER IERR
-C
-      INTEGER ISEC0 (JPGRIB_ISEC0), ISEC1 (JPGRIB_ISEC1)
-      INTEGER ISEC2 (JPGRIB_ISEC2), ISEC3 (JPGRIB_ISEC3)
-      INTEGER ISEC4 (JPGRIB_ISEC4)
-C
-      INTEGER ZSEC2 (JPGRIB_RSEC2), ZSEC3 (JPGRIB_RSEC3)
-C
-      INTEGER JPROUTINE
-C
-      PARAMETER (JPROUTINE = 21300)
-C
-C     External functions
-C
-      INTEGER IAGCNTL, IARCNTL, IAIDEF, IAOLDEF, IARESET, IARMEM,
-     1   IGSIZE, IGLSIZE, IRSIZE
-C
-C     Transform definition variables that must be preserved
-C
-      SAVE IILN, IIAREA, IOLN, IOAREA, ITOTAL
-      SAVE GIWEGLOBE, GINPOLE, GISPOLE, GOWEGLOBE, GONPOLE,
-     1   GOSPOLE
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 1.',JPQUIET)
-C
-      IAINTLL = 0
-C
-      IERR = 0
-C
-      IF (KPR .GE. 1) THEN
-         CALL INTLOG(JP_DEBUG,'IAINTLL: Input parameters',JPQUIET)
-         CALL INTLOG(JP_DEBUG,'IAINTLL: Input array length = ',KILEN)
-         CALL INTLOG(JP_DEBUG,'IAINTLL: Output array length = ',KOLEN)
-         CALL INTLOG(JP_DEBUG,'IAINTLL: Out field packing bits=',KOBITS)
-         CALL INTLOGR(JP_DEBUG,'IAINTLL: W-E increment is ',PWEINC)
-         CALL INTLOGR(JP_DEBUG,'IAINTLL: N-S increment is ',PNSINC)
-         CALL INTLOGR(JP_DEBUG,'IAINTLL: Area North = ',PNORTH)
-         CALL INTLOGR(JP_DEBUG,'IAINTLL: Area West = ',PWEST)
-         CALL INTLOGR(JP_DEBUG,'IAINTLL: Area South = ',PSOUTH)
-         CALL INTLOGR(JP_DEBUG,'IAINTLL: Area East = ',PEAST)
-      ENDIF
-C
-      IF (KOBITS .LT. 0 .OR. KOBITS .GT. 24) THEN
-C
-        IAINTLL = JPROUTINE + 1
-        IF (KERR .GE. 0) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'IAINTLL: No. bits requested = ',KOBITS)
-          CALL INTLOG(JP_ERROR,
-     X      'IAINTLL: Range allowed is <0 - 24>',JPQUIET)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAINTLL: Interpolation failing.',JPQUIET)
-        ENDIF
-        GO TO 900
-C
-      ENDIF
-C
-      NOACC = KOBITS
-C
-C     _______________________________________________________
-C
-C
-C*    Section 2. Input grid definition from GRIB file
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 2.',JPQUIET)
-C
-C     Unpack GRIB sections 0, 1 and 2 only
-C
-      IERR = KERR
-C
-C     CALL GRSDBG (KPR)
-C
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     1   RIFELD, 1, KIFELD, KILEN, KOLEN, 'I', IERR)
-C
-      IF (IERR .NE. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-      IERR = IAIDEF (ISEC1, ISEC2, IIAREA, MILLEN, GICHNG, KPR, KERR)
-C
-      IF (IERR .GT. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-      IF (GICHNG) THEN
-C
-        DO 210 JSET = 1, 4
-          NIAREA (JSET) = IIAREA (JSET)
-  210   CONTINUE
-C
-        IF (NIREPR .EQ. JPGAUSSIAN) THEN
-C
-          IERR = IGSIZE (NIGAUSS, NIAREA, NIWE, NINS, IILN, RIGAUSS,
-     1         GIWEGLOBE, GINPOLE, GISPOLE, KPR, KERR)
-C
-          IF (IERR .GT. 0) THEN
-            IAINTLL = IERR
-            GO TO 900
-          ENDIF
-C
-          ITOTAL = NIWE * NINS
-C
-        ELSE IF (NIREPR .EQ. JPQUASI) THEN
-C
-          IERR = IRSIZE (NIGAUSS, NIAREA, MILLEN, NIWE, NINS, IILN,
-     1         ITOTAL, RIGAUSS, GIWEGLOBE, GINPOLE, GISPOLE, KPR, KERR)
-C
-          IF (IERR .GT. 0) THEN
-            IAINTLL = IERR
-            GO TO 900
-          ENDIF
-C
-        ELSE IF (NIREPR .EQ. JPREGULAR) THEN
-C
-          IERR = IGLSIZE (NIGRID, NIAREA, NIWE, NINS, IILN,
-     1         GIWEGLOBE, GINPOLE, GISPOLE, KPR, KERR)
-C
-          IF (IERR .GT. 0) THEN
-            IAINTLL = IERR
-            GO TO 900
-          ENDIF
-C
-          ITOTAL = NIWE * NINS
-C
-        ELSE
-C
-          IAINTLL = JPROUTINE + 2
-          IF (KERR .GE. 0) CALL INTLOG(JP_ERROR,
-     X      'IAINTLL: Invalid input representation = ',NIREPR)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAINTLL: Interpolation failing.',JPQUIET)
-
-          GO TO 900
-C
-        ENDIF
-C
-      ELSE
-        IF (NIREPR .NE. JPQUASI) THEN
-          ITOTAL = NIWE * NINS
-        ELSE
-          ITOTAL = 0
-          DO 220 JLAT = 1, NINS
-            ITOTAL = ITOTAL + MILLEN (JLAT)
-  220     CONTINUE
-        ENDIF
-      ENDIF
-C
-      LCHANGE = LCHANGE .OR. GICHNG
-C
-C     _______________________________________________________
-C
-C
-C*    Section 3. Output field definiton from parameters
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 3.',JPQUIET)
-C
-      IERR = IAOLDEF (PWEST, PEAST, PNORTH, PSOUTH, PNSINC, PWEINC,
-     1   IOAREA, GOCHNG, GIWEGLOBE, GINPOLE, GISPOLE, NIAREA, KPR,
-     2   KERR)
-C
-      IF (IERR .GT. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-      IF (GOCHNG) THEN
-C
-         DO 310 JSET = 1, 4
-            NOAREA (JSET) = IOAREA (JSET)
-  310    CONTINUE
-C
-         NOWE = 0
-         NONS = 0
-C
-         IERR = IGLSIZE (NOGRID, NOAREA, NOWE, NONS, IOLN, GOWEGLOBE,
-     1      GONPOLE, GOSPOLE, KPR, KERR)
-C
-         IF (IERR .GT. 0) THEN
-            IAINTLL = IERR
-            GO TO 900
-         ENDIF
-      ENDIF
-C
-      LCHANGE = LCHANGE .OR. GOCHNG
-C
-C     _______________________________________________________
-C
-C
-C*    Section 4. Get space for REAL input and output arrays
-C     _______________________________________________________
-C
-  400 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 4.',JPQUIET)
-C
-      IF (LCHANGE) THEN
-C
-         IERR = IARMEM (ITOTAL, NOWE * NONS, KPR, KERR)
-C
-         IF (IERR .GT. 0) THEN
-            IAINTLL = IERR
-            GO TO 900
-         ENDIF
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 5. Fully unpack the GRIB array
-C     _______________________________________________________
-C
-  500 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 5.',JPQUIET)
-C
-      IERR = KERR
-C
-C     CALL GRSDBG (KPR)
-C
-      ISEC3(2) = NINT(RMISSGV)
-      ZSEC3(2) = RMISSGV
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     1   RIFELD, ITOTAL, KIFELD, KILEN, KOLEN, 'D', IERR)
-C
-      IF (IERR .NE. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 6. Basic interpolation from input to output field
-C     _______________________________________________________
-C
-  600 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 6.',JPQUIET)
-C
-      IF (NIREPR .EQ. JPQUASI) THEN
-         IERR = IARCNTL (RIFELD, ITOTAL, ROFELD, NOWE * NONS, IILN,
-     1      GIWEGLOBE, GINPOLE, GISPOLE, IOLN, GOWEGLOBE, GONPOLE,
-     1      GOSPOLE, KPR, KERR)
-      ELSE
-         IERR = IAGCNTL (RIFELD, ITOTAL, ROFELD, NOWE * NONS, IILN,
-     1      GIWEGLOBE, GINPOLE, GISPOLE, IOLN, GOWEGLOBE, GONPOLE,
-     1      GOSPOLE, KPR, KERR)
-      ENDIF
-C
-      IF (IERR .NE. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 7. Repack GRIB code
-C     _______________________________________________________
-C
-  700 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 7.',JPQUIET)
-C
-      IERR = IARESET (ISEC2, ISEC4, NOWE * NONS, KPR, KERR)
-C
-      IF (IERR .NE. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-      IERR = KERR
-C
-C     CALL GRSDBG (KPR)
-C
-C     PACKING specified can be second-order, simple or archive value
-C
-      IF( NOHFUNC.EQ.'K' ) THEN
-        HFUNC = 'K'
-        ISEC4(4)  = 64
-        ISEC4(6)  = 16
-        ISEC4(9)  = 32
-        ISEC4(10) = 16
-        ISEC4(12) = 8
-        ISEC4(13) = 4
-        ISEC4(14) = 0
-        ISEC4(15) = -1
-      ELSE IF( NOHFUNC.EQ.'S' ) THEN
-        HFUNC = 'C'
-        ISEC4(4)  = 0
-        ISEC4(6)  = 0
-      ELSE IF( NOHFUNC.EQ.'A' ) THEN
-        IF( ISEC4(4).EQ.64 ) THEN
-          HFUNC = 'K'
-        ELSE
-          HFUNC = 'C'
-        ENDIF
-      ENDIF
-C
-      IF( LIMISSV ) THEN
-        ISEC1(5) = 192
-        ISEC3(2) = NINT(RMISSGV)
-        ZSEC3(2) = RMISSGV
-      ENDIF
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     1   ROFELD, NOWE * NONS, KOFELD, KOLEN, KOLEN, HFUNC, IERR)
-C
-      IF (IERR .NE. 0) THEN
-         IAINTLL = IERR
-         GO TO 900
-      ENDIF
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,
-     X  'IAINTLL: Output array length = ',KOLEN)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAINTLL: Section 9.',JPQUIET)
-C
- 9002 FORMAT (' IAINTLL ERROR', I6, ' - Input representation', I6,
-     1   ' is not valid')
-C
-      RETURN
-      END
diff --git a/interpolation/iaogdef.F b/interpolation/iaogdef.F
deleted file mode 100644
index c990cee..0000000
--- a/interpolation/iaogdef.F
+++ /dev/null
@@ -1,421 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IAOGDEF (PWEST, PEAST, PNORTH, PSOUTH,
-     1   KGAUSS, KAREA, OCHNG, OIWEGLOBE, OINPOLE, OISPOLE,
-     2   KIAREA, KPR, KERR)
-C
-C---->
-C**** *IAOGDEF*
-C
-C     PURPOSE
-C     _______
-C
-C     Set the output field definition variables.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IAOGDEF (PWEST, PEAST, PNORTH, PSOUTH, KGAUSS, KAREA,
-C    1   OCHNG, OIWEGLOBE, OINPOLE, OISPOLE, KIAREA, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PWEST      - The Western limit of the output field area.
-C
-C     PEAST      - The Eastern limit of the output field area.
-C
-C     PNORTH     - The Northern limit of the output field area.
-C
-C     PSOUTH     - The Southern limit of the output field area.
-C
-C     KGAUSS     - The Gaussian truncation for the output field.
-C
-C     KAREA      - The previous output field area used for checking
-C                  for definition changes.
-C
-C     OIWEGLOBE  - Flag indicating whether the INPUT field spans the
-C                  globe in the West-East direction.
-C
-C     OINPOLE    - Flag indicating whether the INPUT field includes
-C                  the North polar line of latitude.
-C
-C     OISPOLE    - Flag indicating whether the INPUT field includes
-C                  the South polar line of latitude.
-C
-C     KIAREA     - The input field area which will be used for an
-C                  uninitialised output field area when the input
-C                  field is not global.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     KAREA      - The output field area if the definition has changed.
-C
-C     OCHNG      - A flag variable indicating whether the definition
-C                  has changed.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     21601 An illegal Gaussian truncation was requested.
-C     21602 The default West-East output limits for a non-global
-C           input field did not match the increment.
-C     21603 Default North-South limits were specified for a
-C           non-global input field. This is not allowed for a
-C           Gaussian output field.
-C
-C     Common block usage
-C     __________________
-C
-C     nofld.common - This file contains all the output field
-C                    definition variables.
-C
-C     NOGAUSS      - Output field Gaussian truncation is set.
-C     NOREPR       - Output field representation is set.
-C     NOSCNM       - Output field scanning mode is set.
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     Check the output definition against the previous definition and
-C     update appropriate definition variables.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 3 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nofld.common"
-C
-C     Subroutine arguments
-C
-      LOGICAL OCHNG, OIWEGLOBE, OINPOLE, OISPOLE
-      INTEGER KGAUSS, KPR, KERR
-      INTEGER KAREA (4), KIAREA (4)
-      REAL PWEST, PEAST, PNORTH, PSOUTH
-C
-C     Local variables
-      LOGICAL GLOBE, GNS
-      INTEGER INORTH, ISOUTH, IWEST, IEAST, IWEINC, IWETMP, ITEMP
-      INTEGER IERR
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 21600)
-C
-C     External functions
-C
-C     Transform definition variables that must be preserved
-C
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOGDEF: Section 1.',JPQUIET)
-C
-      IAOGDEF = 0
-C
-      IERR = 0
-C
-      OCHNG = .FALSE.
-C
-      GNS = OINPOLE .AND. OISPOLE
-C
-      GLOBE = OIWEGLOBE .AND. GNS
-C
-      IF (KPR .GE. 1) THEN
-         CALL INTLOG(JP_DEBUG,'IAOGDEF: Input parameters',JPQUIET)
-         CALL INTLOG(JP_DEBUG,'IAOGDEF: Gaussian truncation = ',KGAUSS)
-         CALL INTLOGR(JP_DEBUG,'IAOGDEF: Area North = ',PNORTH)
-         CALL INTLOGR(JP_DEBUG,'IAOGDEF: Area West = ',PWEST)
-         CALL INTLOGR(JP_DEBUG,'IAOGDEF: Area South = ',PSOUTH)
-         CALL INTLOGR(JP_DEBUG,'IAOGDEF: Area East = ',PEAST)
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 2. Convert parameters to integer
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOGDEF: Section 2.',JPQUIET)
-C
-C     Representation
-C
-      IF (NOREPR .NE. JPGAUSSIAN) THEN
-         NOREPR = JPGAUSSIAN
-         OCHNG = .TRUE.
-      ENDIF
-C
-      NOSCNM = 0
-C
-C     North, South, West and East limits
-C
-      INORTH = NINT (PNORTH * PPMULT)
-      ISOUTH = NINT (PSOUTH * PPMULT)
-      IWEST = NINT (PWEST * PPMULT)
-      IEAST = NINT (PEAST * PPMULT)
-C
-C     Direction increments for regular grids
-C
-      IWEINC = JP90 / KGAUSS
-C
-      IF (IWEINC * KGAUSS .NE. JP90) THEN
-        IAOGDEF = JPROUTINE + 1
-        IF (KERR .GE. 0) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'IAOGDEF: Illegal gaussian truncation = ',KGAUSS)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IAOGDEF: Interpolation failing.',JPQUIET)
-        ENDIF
-        GO TO 900
-      ENDIF
-C
-C
-C     _______________________________________________________
-C
-C
-C*    Section 3. Adjust grid stride and area
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOGDEF: Section 3.',JPQUIET)
-C
-C     Global field if all area limits are 0
-C
-      IF (INORTH .EQ. 0 .AND. ISOUTH .EQ. 0 .AND.
-     X  IWEST .EQ. 0 .AND. IEAST .EQ. 0) THEN
-C
-        INORTH = JP90
-        ISOUTH = - JP90
-C
-        IF (GLOBE) THEN
-C
-          IWEST = 0
-          IEAST = JP360 - IWEINC
-C
-        ELSE
-          IF (GNS) THEN
-C
-            IWEST = KIAREA (JPWEST)
-            IEAST = KIAREA (JPEAST)
-C
-            IF (MOD (IEAST - IWEST, IWEINC) .NE. 0) THEN
-              IAOGDEF = JPROUTINE + 2
-              IF (KERR .GE. 0) THEN
-                CALL INTLOG(JP_ERROR,
-     X            'IAOGDEF: West-East increment ', IWEINC)
-                CALL INTLOG(JP_ERROR,
-     X            'IAOGDEF: does not match the range from ',IWEST)
-                CALL INTLOG(JP_ERROR,
-     X            'IAOGDEF: to ',IEAST)
-                IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X            'IAOGDEF: Interpolation failing.',JPQUIET)
-              ENDIF
-              GO TO 900
-            ENDIF
-          ELSE
-            IAOGDEF = JPROUTINE + 3
-              IF (KERR .GE. 0) THEN
-                CALL INTLOG(JP_ERROR,
-     X            'IAOGDEF: Must specify a range if Gaussian',JPQUIET)
-                CALL INTLOG(JP_ERROR,
-     X            'IAOGDEF: output and non-global input.',JPQUIET)
-                IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X            'IAOGDEF: Interpolation failing.',JPQUIET)
-              ENDIF
-              GO TO 900
-          ENDIF
-        ENDIF
-C
-      ELSE
-C
-C     Try to produce fields representable in GRIB for 0.5625 degree
-C     strides
-C
-        IF (IEAST .LT. IWEST) THEN
-          IF (IEAST .LE. 0) THEN
-            IEAST = IEAST + JP360
-          ELSE
-            IWEST = IWEST - JP360
-          ENDIF
-        ENDIF
-C
-        GLOBE = IEAST - IWEST + IWEINC .EQ. JP360 .OR.
-     X      IEAST - IWEST + IWEINC .EQ. 0
-C
-        IF (MOD (IWEINC, 10) .EQ. 5 .AND. .NOT. GLOBE) THEN
-          IWETMP = IWEINC * 2
-        ELSE
-          IWETMP = IWEINC
-        ENDIF
-C
-        IF (MOD (IEAST - IWEST, IWETMP) .NE. 0) THEN
-C
-          IF (MOD (IEAST, IWETMP) .NE. 0) THEN
-C
-            ITEMP = ABS (IEAST) / IWETMP
-C
-            IF (IEAST .GT. 0) THEN
-              IEAST = (ITEMP + 1) * IWETMP
-              IF (IEAST .GT. JP360) IEAST = IEAST - IWETMP
-            ELSE
-              IEAST = - ITEMP * IWETMP
-            ENDIF
-          ENDIF
-C
-          IF (MOD (IWEST, IWETMP) .NE. 0) THEN
-C
-            ITEMP = ABS (IWEST) / IWETMP
-C
-            IF (IWEST .LT. 0) THEN
-              IWEST = - (ITEMP + 1) * IWETMP
-              IF (IWEST .LT. - JP360) IWEST = IWEST + IWETMP
-            ELSE
-              IWEST = ITEMP * IWETMP
-            ENDIF
-          ENDIF
-        ENDIF
-      ENDIF
-C
-      IF (NOGAUSS .NE. KGAUSS) THEN
-        NOGAUSS = KGAUSS
-        OCHNG = .TRUE.
-      ENDIF
-C
-      IF (KAREA (JPNORTH) .NE. INORTH) THEN
-        KAREA (JPNORTH) = INORTH
-        OCHNG = .TRUE.
-      ENDIF
-C
-      IF (KAREA (JPSOUTH) .NE. ISOUTH) THEN
-        KAREA (JPSOUTH) = ISOUTH
-        OCHNG = .TRUE.
-      ENDIF
-C
-      IF (IWEST .NE. KAREA (JPWEST) ) THEN
-        KAREA (JPWEST) = IWEST
-        OCHNG = .TRUE.
-      ENDIF
-C
-      IF (IEAST .NE. KAREA (JPEAST) ) THEN
-        KAREA (JPEAST) = IEAST
-        OCHNG = .TRUE.
-      ENDIF
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Output field definition parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Representation is ',NOREPR)
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Gaussian truncation is ',NOGAUSS)
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Area North is ',KAREA(1))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Area West  is ',KAREA(2))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Area South is ',KAREA(3))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOGDEF: Area East  is ',KAREA(4))
-        IF( OCHNG ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      'IAOGDEF: Output field change is TRUE.',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      'IAOGDEF: Output field change is TRUE.',JPQUIET)
-        ENDIF
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOGDEF: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/iaoldef.F b/interpolation/iaoldef.F
deleted file mode 100644
index 2419457..0000000
--- a/interpolation/iaoldef.F
+++ /dev/null
@@ -1,471 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IAOLDEF (PWEST, PEAST, PNORTH, PSOUTH,
-     1   PNSINC, PWEINC, KAREA, OCHNG, OIWEGLOBE, OINPOLE, OISPOLE,
-     2   KIAREA, KPR, KERR)
-C
-C---->
-C**** *IAOLDEF*
-C
-C     PURPOSE
-C     _______
-C
-C     Set the output field definition variables for a regular
-C     latitude longitude field.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IAOLDEF (PWEST, PEAST, PNORTH, PSOUTH, PNSINC, PWEINC,
-C    1   KAREA, OCHNG, OIWEGLOBE, OINPOLE, OISPOLE, KIAREA, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PWEST      - The Western limit of the output field area.
-C
-C     PEAST      - The Eastern limit of the output field area.
-C
-C     PNORTH     - The Northern limit of the output field area.
-C
-C     PSOUTH     - The Southern limit of the output field area.
-C
-C     PNSINC     - The North-South stride for the output field.
-C
-C     PWEINC     - The West-East stride for the output field.
-C
-C     KAREA      - The previous output field area used for checking
-C                  for definition changes.
-C
-C     OIWEGLOBE  - Flag indicating whether the INPUT field spans the
-C                  globe in the West-East direction.
-C
-C     OINPOLE    - Flag indicating whether the INPUT field includes
-C                  the North polar line of latitude.
-C
-C     OISPOLE    - Flag indicating whether the INPUT field includes
-C                  the South polar line of latitude.
-C
-C     KIAREA     - The input field area which will be used for an
-C                  uninitialised output field area when the input
-C                  field is not global.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     KAREA      - The output field area if the definition has changed.
-C
-C     OCHNG      - A flag variable indicating whether the definition
-C                  has changed.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     None
-C
-C     Common block usage
-C     __________________
-C
-C     nofld.common - This file contains all the output field
-C                    definition variables.
-C
-C     NOGRID       - Output field grid definition (WE/NS) is set.
-C     NOREPR       - Output field representation is set.
-C     NOSCNM       - Output field scanning mode is set.
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     Check the output definition against the previous definition and
-C     update appropriate definition variables.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 3 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nofld.common"
-C
-C     Subroutine arguments
-      LOGICAL OCHNG, OIWEGLOBE, OINPOLE, OISPOLE
-      INTEGER KPR, KERR
-      INTEGER KAREA (4), KIAREA (4)
-      REAL PWEST, PEAST, PNORTH, PSOUTH, PNSINC, PWEINC
-C
-C     Local variables
-      LOGICAL GLOBE
-      INTEGER INORTH, ISOUTH, IWEST, IEAST, IWEINC, INSINC, IWETMP,
-     1   INSTMP, ITEMP
-      INTEGER IERR
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 21400)
-C
-C     External functions
-C
-C     Transform definition variables that must be preserved
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOLDEF: Section 1.',JPQUIET)
-C
-      IAOLDEF = 0
-C
-      IERR = 0
-C
-      OCHNG = .FALSE.
-C
-      GLOBE = OIWEGLOBE .AND. OINPOLE .AND. OISPOLE
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IAOLDEF: Input parameters.',JPQUIET)
-        CALL INTLOGR(JP_DEBUG,'IAOLDEF: W-E increment is ',PWEINC)
-        CALL INTLOGR(JP_DEBUG,'IAOLDEF: N-S increment is ',PNSINC)
-        CALL INTLOGR(JP_DEBUG,'IAOLDEF: AREA North ',PNORTH)
-        CALL INTLOGR(JP_DEBUG,'IAOLDEF: AREA West ',PWEST)
-        CALL INTLOGR(JP_DEBUG,'IAOLDEF: AREA South ',PSOUTH)
-        CALL INTLOGR(JP_DEBUG,'IAOLDEF: AREA East ',PEAST)
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 2. Convert parameters to integer
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOLDEF: Section 2.',JPQUIET)
-C
-C     Representation
-C
-      IF (NOREPR .NE. JPREGULAR) THEN
-         NOREPR = JPREGULAR
-         OCHNG = .TRUE.
-      ENDIF
-C
-      NOSCNM = 0
-C
-C     North, South, West and East limits
-C
-      INORTH = NINT (PNORTH * PPMULT)
-      ISOUTH = NINT (PSOUTH * PPMULT)
-      IWEST = NINT (PWEST * PPMULT)
-      IEAST = NINT (PEAST * PPMULT)
-C
-C     Direction increments for regular grids
-C
-      IWEINC = NINT (ABS (PWEINC) * PPMULT)
-      IWEINC = MAX (IWEINC, JPMIN)
-C
-      INSINC = NINT (ABS (PNSINC) * PPMULT)
-      INSINC = MAX (INSINC, JPMIN)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 3. Adjust grid stride and area
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOLDEF: Section 3.',JPQUIET)
-C
-C     Global field if all area limits are 0
-C
-      IF (INORTH .EQ. 0 .AND. ISOUTH .EQ. 0 .AND.
-     1   IWEST .EQ. 0 .AND. IEAST .EQ. 0) THEN
-C
-         IF (GLOBE) THEN
-C
-  310 CONTINUE
-            IF (MOD (JP90, IWEINC) .EQ. 0) GO TO 320
-               IWEINC = IWEINC - 1
-               GO TO 310
-  320 CONTINUE
-C
-            IF (MOD (JP90, INSINC) .EQ. 0) GO TO 330
-               INSINC = INSINC - 1
-               GO TO 320
-  330 CONTINUE
-C
-            INORTH = JP90
-            ISOUTH = - JP90
-            IWEST = 0
-            IEAST = JP360 - IWEINC
-C
-         ELSE
-C
-            IF (OINPOLE) THEN
-               INORTH = JP90
-            ELSE
-               INORTH = KIAREA (JPNORTH)
-            ENDIF
-C
-            IF (OISPOLE) THEN
-               ISOUTH = - JP90
-            ELSE
-               ISOUTH = KIAREA (JPSOUTH)
-            ENDIF
-C
-            IF (OIWEGLOBE) THEN
-C
-  340 CONTINUE
-               IF (MOD (JP90, IWEINC) .EQ. 0) GO TO 350
-                  IWEINC = IWEINC - 1
-                  GO TO 340
-  350 CONTINUE
-C
-               IWEST = 0
-               IEAST = JP360 - IWEINC
-            ELSE
-               IWEST = KIAREA (JPWEST)
-               IEAST = KIAREA (JPEAST)
-C
-  360 CONTINUE
-               IF (MOD (IEAST - IWEST, IWEINC) .EQ. 0) GO TO 370
-                  IWEINC = IWEINC - 1
-                  GO TO 360
-  370 CONTINUE
-C
-            ENDIF
-C
-  380 CONTINUE
-            IF (MOD (INORTH - ISOUTH, INSINC) .EQ. 0) GO TO 390
-               INSINC = INSINC - 1
-               GO TO 380
-  390 CONTINUE
-C
-         ENDIF
-      ELSE
-C
-C     Try to produce fields representable in GRIB for 0.5625 degree
-C     strides
-C
-         IF (IEAST .LT. IWEST) THEN
-            IF (IEAST .LE. 0) THEN
-               IEAST = IEAST + JP360
-            ELSE
-               IWEST = IWEST - JP360
-            ENDIF
-         ENDIF
-C
-         GLOBE = IEAST - IWEST + IWEINC .EQ. JP360 .OR.
-     1      IEAST - IWEST + IWEINC .EQ. 0
-C
-         IF (MOD (IWEINC, 10) .EQ. 5 .AND. .NOT. GLOBE) THEN
-            IWETMP = IWEINC * 2
-         ELSE
-            IWETMP = IWEINC
-         ENDIF
-C
-         IF (MOD (IEAST - IWEST, IWETMP) .NE. 0) THEN
-C
-            IF (MOD (IEAST, IWETMP) .NE. 0) THEN
-C
-               ITEMP = ABS (IEAST) / IWETMP
-C
-               IF (IEAST .GT. 0) THEN
-                  IEAST = (ITEMP + 1) * IWETMP
-                  IF (IEAST .GT. JP360) IEAST = IEAST - IWETMP
-               ELSE
-                  IEAST = - ITEMP * IWETMP
-               ENDIF
-            ENDIF
-C
-            IF (MOD (IWEST, IWETMP) .NE. 0) THEN
-C
-               ITEMP = ABS (IWEST) / IWETMP
-C
-               IF (IWEST .LT. 0) THEN
-                  IWEST = - (ITEMP + 1) * IWETMP
-                  IF (IWEST .LT. - JP360) IWEST = IWEST + IWETMP
-               ELSE
-                  IWEST = ITEMP * IWETMP
-               ENDIF
-            ENDIF
-         ENDIF
-C
-         IF (MOD (INSINC, 10) .EQ. 5) THEN
-            INSTMP = INSINC * 2
-         ELSE
-            INSTMP = INSINC
-         ENDIF
-C
-         IF (MOD (INORTH - ISOUTH, INSTMP) .NE. 0) THEN
-C
-            IF (MOD (INORTH, INSTMP) .NE. 0) THEN
-C
-               ITEMP = ABS (INORTH) / INSTMP
-C
-               IF (INORTH .GT. 0) THEN
-                  INORTH = (ITEMP + 1) * INSTMP
-                  IF (INORTH .GT. JP90) INORTH = INORTH - INSTMP
-               ELSE
-                  INORTH = - ITEMP * INSTMP
-               ENDIF
-            ENDIF
-C
-            IF (MOD (ISOUTH, INSTMP) .NE. 0) THEN
-C
-               ITEMP = ABS (ISOUTH) / INSTMP
-C
-               IF (ISOUTH .LT. 0) THEN
-                  ISOUTH = - (ITEMP + 1) * INSTMP
-                  IF (ISOUTH .LT. - JP90) ISOUTH = ISOUTH + INSTMP
-               ELSE
-                  ISOUTH = ITEMP * INSTMP
-               ENDIF
-            ENDIF
-         ENDIF
-C
-      ENDIF
-C
-      IF (NOGRID (JPWESTEP) .NE. IWEINC) THEN
-         NOGRID (JPWESTEP) = IWEINC
-         OCHNG = .TRUE.
-      ENDIF
-C
-      IF (NOGRID (JPNSSTEP) .NE. INSINC) THEN
-         NOGRID (JPNSSTEP) = INSINC
-         OCHNG = .TRUE.
-      ENDIF
-C
-      IF (KAREA (JPNORTH) .NE. INORTH) THEN
-         KAREA (JPNORTH) = INORTH
-         OCHNG = .TRUE.
-      ENDIF
-C
-      IF (KAREA (JPSOUTH) .NE. ISOUTH) THEN
-         KAREA (JPSOUTH) = ISOUTH
-         OCHNG = .TRUE.
-      ENDIF
-C
-      IF (IWEST .NE. KAREA (JPWEST) ) THEN
-         KAREA (JPWEST) = IWEST
-         OCHNG = .TRUE.
-      ENDIF
-C
-      IF (IEAST .NE. KAREA (JPEAST) ) THEN
-         KAREA (JPEAST) = IEAST
-         OCHNG = .TRUE.
-      ENDIF
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Output field definition parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Representation is ',NOREPR)
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Grid W-E is ', NOGRID(1))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Grid N-S is ', NOGRID(2))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Area North is ',KAREA(1))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Area West  is ',KAREA(2))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Area South is ',KAREA(3))
-        CALL INTLOG(JP_DEBUG,
-     X    'IAOLDEF: Area East  is ',KAREA(4))
-C
-        IF ( OCHNG ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      'IAOLDEF: Output field change is TRUE.',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      'IAOLDEF: Output field change is FALSE.',JPQUIET)
-        ENDIF
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IAOLDEF: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/iarcntl.F b/interpolation/iarcntl.F
index 9c2bfad..b64ebfa 100644
--- a/interpolation/iarcntl.F
+++ b/interpolation/iarcntl.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -282,7 +282,7 @@ C
       LOGICAL LFAIL, LERROR, LDEBUG, LREGOUT
       LOGICAL GINSPOLE, GIGLOBE, GISTAND, GONSPOLE, GOGLOBE, GOSTAND
       LOGICAL GPREC,LSM_VALUES
-      CHARACTER*120 YIFILE, YOFILE
+      CHARACTER*256 YIFILE, YOFILE
       CHARACTER*12 YFLAG
       INTEGER IIOFF, IINDEX, IOOFF
       INTEGER IIREC, IOREC, IERR
@@ -431,13 +431,7 @@ C       Is the output field global North South
 C
         GONSPOLE = OONPOLE.AND.OOSPOLE
         GOGLOBE  = OOWEGLOBE.AND.GONSPOLE
-
-        IF(GOGLOBE.AND.NOAREA(2).EQ.0) THEN
-            LGLOBL = .TRUE.
-        ELSE
-            LGLOBL = .FALSE.
-        ENDIF
-
+        LGLOBL   = (GOGLOBE.AND.NOAREA(2).EQ.0)
 C
         IF( NOREPR.EQ.JPGAUSSIAN ) THEN
 C
@@ -526,7 +520,8 @@ C
         IF( IARCNTL.GT.0 ) GOTO 900
 C
         IARCNTL = IRDIWE(MILLEN, NINS, MNSIND, NONS, MILONG, NIWE,
-     X                   MOLONG, NOWE, MWEIND, MWEDIST, KPR, KERR)
+     X                   MOLONG, NOWE, MWEIND, MWEDIST, NIAREA, NOAREA,
+     X                   KPR, KERR)
         IF( IARCNTL.GT.0 ) GOTO 900
 C
 C     The end of primary initialisation
diff --git a/interpolation/iareset.F b/interpolation/iareset.F
deleted file mode 100644
index 915a648..0000000
--- a/interpolation/iareset.F
+++ /dev/null
@@ -1,307 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IARESET (KSEC2, KSEC4, KVALUES, KPR, KERR)
-C
-C---->
-C**** *IARESET*
-C
-C     PURPOSE
-C     _______
-C
-C     Generate the output field definition.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IARESET (KSEC2, KSEC4, KVALUES, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     KSEC2      - The GRIB Section 2 array for the input field.
-C
-C     KSEC4      - The GRIB Section 4 array for the input field.
-C
-C     KVALUES    - The number of values in the output field.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     KSEC2      - The modified GRIB Section 2 array for the output
-C                  field.
-C
-C     KSEC4      - The modified GRIB Section 4 array for the output
-C                  field.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     None
-C
-C     Common block usage
-C     __________________
-C
-C     nofld.common - This file contains all the output field
-C                    definition variables.
-C
-C     NOACC        - Number of packing bits to be used for output
-C                    GRIB field is used.
-C     NOAREA       - Output field area definition (N/W/S/E) is used.
-C     NOGAUSS      - Output field Gaussian truncation is used.
-C     NOGRID       - Output field grid definition (WE/NS) is used.
-C     NONS         - Number of grid points in NS direction for output
-C                    field is used.
-C     NOREPR       - Output field representation is used.
-C     NOSCNM       - Output field scanning mode is used.
-C     NOWE         - Number of grid points in WE direction for output
-C                    field is used.
-C
-C     EXTERNALS
-C     _________
-C
-C     SETPAR       - Standard routine used to generate "missing" data
-C                    values for GRIB fields.
-C     INTLOG(R)    - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     This routine modifies sections 2 and 4 of the GRIB definition
-C     to match the output field.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 4 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nofld.common"
-C
-C     Dummy arguments
-      INTEGER KVALUES, KPR, KERR
-      INTEGER KSEC2 (JPGRIB_ISEC2), KSEC4 (JPGRIB_ISEC4)
-C
-C     Local variables
-      INTEGER IWEINC, ITEMP, IMISS, IERR
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 24200)
-C
-C     External functions
-C
-C     Transform definition variables that must be preserved
-C
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARESET: Section 1.',JPQUIET)
-C
-      IARESET = 0
-      IERR = 0
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IARESET: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'IARESET: No.bits for output field packing = ',NOACC)
-        CALL INTLOG(JP_DEBUG,
-     X    'IARESET: No.values to be packed = ',KVALUES)
-        IF (NOREPR .EQ. JPREGULAR) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      'IARESET: West-East stride = ', NOGRID (JPWESTEP))
-          CALL INTLOG(JP_DEBUG,
-     X      'IARESET: North-South stride = ', NOGRID (JPNSSTEP))
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      'IARESET: Gaussian truncation = ',NOGAUSS)
-        ENDIF
-      ENDIF
-C
-C     Get GRIB missing data value
-C
-      CALL SETPAR (ITEMP, IMISS, KPR)
-C
-C     Representation
-C
-      KSEC2 (JPSEC2_REP) = NOREPR
-      KSEC2 (JPSEC2_SCAN) = NOSCNM
-C
-C     _______________________________________________________
-C
-C*    Section 2. Set Grib Section 2 regular grid variables
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (NOREPR .EQ. JPREGULAR) THEN
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARESET: Section 2.',JPQUIET)
-C
-         KSEC2 (JPSEC2_QUASI) = 0
-C
-         KSEC2 (JPSEC2_NLONG) = NOWE
-         KSEC2 (JPSEC2_NLAT) = NONS
-C
-         KSEC2 (JPSEC2_NORTH) = NOAREA (JPNORTH) / 10
-         KSEC2 (JPSEC2_WEST) = NOAREA (JPWEST) / 10
-         KSEC2 (JPSEC2_SOUTH) = NOAREA (JPSOUTH) / 10
-C
-         IF (MOD (NOAREA (JPEAST), 10) .EQ. 5) THEN
-            KSEC2 (JPSEC2_EAST) = NOAREA (JPEAST) / 10 + 1
-         ELSE
-            KSEC2 (JPSEC2_EAST) = NOAREA (JPEAST) / 10
-         ENDIF
-C
-         IF (MOD (NOGRID (JPWESTEP), 10) .EQ. 5 .OR.
-     X      MOD (NOGRID (JPNSSTEP), 10) .EQ. 5) THEN
-C
-            KSEC2 (JPSEC2_RESOL) = 0
-            KSEC2 (JPSEC2_DLONG) = IMISS
-            KSEC2 (JPSEC2_DLAT) = IMISS
-C
-         ELSE
-C
-            KSEC2 (JPSEC2_RESOL) = 128
-            KSEC2 (JPSEC2_DLONG) = NOGRID (JPWESTEP) / 10
-            KSEC2 (JPSEC2_DLAT) = NOGRID (JPNSSTEP) / 10
-C
-         ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 3. Set Grib Section 2 Gaussian values
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      ELSE IF (NOREPR .EQ. JPGAUSSIAN) THEN
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARESET: Section 3.',JPQUIET)
-C
-         KSEC2 (JPSEC2_QUASI) = 0
-C
-         KSEC2 (JPSEC2_GTRUNC) = NOGAUSS
-         KSEC2 (JPSEC2_NLONG) = NOWE
-         KSEC2 (JPSEC2_NLAT) = NONS
-C
-         KSEC2 (JPSEC2_NORTH) = NOAREA (JPNORTH) / 10
-         KSEC2 (JPSEC2_WEST) = NOAREA (JPWEST) / 10
-         KSEC2 (JPSEC2_SOUTH) = NOAREA (JPSOUTH) / 10
-C
-         IF (MOD (NOAREA (JPEAST), 10) .EQ. 5) THEN
-            KSEC2 (JPSEC2_EAST) = NOAREA (JPEAST) / 10 + 1
-         ELSE
-            KSEC2 (JPSEC2_EAST) = NOAREA (JPEAST) / 10
-         ENDIF
-C
-         IWEINC = JP90 / NOGAUSS
-C
-         IF (MOD (IWEINC, 10) .EQ. 5) THEN
-C
-            KSEC2 (JPSEC2_RESOL) = 0
-            KSEC2 (JPSEC2_DLONG) = IMISS
-C
-         ELSE
-C
-            KSEC2 (JPSEC2_RESOL) = 128
-            KSEC2 (JPSEC2_DLONG) = IWEINC / 10
-C
-         ENDIF
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 4. Set Grib Section 4 values
-C     _______________________________________________________
-C
-  400 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARESET: Section 4.',JPQUIET)
-C
-      KSEC4 (JPSEC4_NVALUE) = KVALUES
-C
-      IF (NOACC .NE. 0) KSEC4 (JPSEC4_NBITS) = NOACC
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARESET: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/iarmem.F b/interpolation/iarmem.F
deleted file mode 100644
index 0451fea..0000000
--- a/interpolation/iarmem.F
+++ /dev/null
@@ -1,237 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IARMEM (KIMEM, KOMEM, KPR, KERR)
-C
-C---->
-C**** *IARMEM*
-C
-C     PURPOSE
-C     _______
-C
-C     This routine acquires heap space for expanded REAL fields.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IARMEM (KIMEM, KOMEM, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     KIMEM      - Space required for input field.
-C
-C     KOMEM      - Space required for output field.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     None
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     None
-C
-C     Common block usage
-C     __________________
-C
-C     nifld.common - This file contains all the input field
-C                    definition variables.
-C
-C     NINS         - Number of grid points in NS direction for input
-C                    field (used in ouspace.h).
-C     NIWE         - Number of grid points in WE direction for input
-C                    field (used in ouspace.h).
-C
-C     nofld.common - This file contains all the output field
-C                    definition variables.
-C
-C     NONS         - Number of grid points in NS direction for output
-C                    field (used in ouspace.h).
-C     NOWE         - Number of grid points in WE direction for output
-C                    field (used in ouspace.h).
-C
-C     ouspace.h    - This file contains the work space array
-C                    definitions for the arrays to hold the unpacked
-C                    real data from GRIB fields.
-C
-C     NIFELD       - POINTER to array RIFELD.
-C     NOFELD       - POINTER to array ROFELD.
-C
-C     RIFELD       - Dynamic array of length (NIWE * NINS)
-C                    (see nifld.common) which holds the expanded
-C                    input field.
-C     ROFELD       - Dynamic array of length (NOWE * NONS)
-C                    (see nofld.common) which holds the expanded
-C                    output field.
-C
-C     EXTERNALS
-C     _________
-C
-C     IGALLOC    - Get a heap allocation for array space.
-C     INTLOG(R)    - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     This routine calculates how much heap space is required. It
-C     then calls IGALLOC to acquire the required space. Finally the
-C     POINTERs to the arrays in ouspace.h are initialised to allow
-C     the use of the dynamic arrays.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 3 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "ouspace.h"
-C
-C     Dummy arguments
-      INTEGER KIMEM, KOMEM, KPR, KERR
-C
-C     Local variables
-      INTEGER IBASE, IERR
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 24100)
-C
-C     External functions
-      INTEGER IGALLOC
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARMEM: Section 1.',JPQUIET)
-C
-      IARMEM = 0
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IARMEM: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IARMEM: Input fld space = ',KIMEM)
-        CALL INTLOG(JP_DEBUG,'IARMEM: Output fld space = ',KOMEM)
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 2. Calculate memory required and get heap
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARMEM: Section 2.',JPQUIET)
-C
-C     Get the required memory
-C
-      IERR = IGALLOC (JPGRIB_SPACE, (KIMEM + KOMEM) * JPRLEN, IBASE,
-     1   KPR, KERR)
-C
-      IF (IERR .GT. 0) THEN
-         IARMEM = IERR
-         GO TO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 3. Initialise base addresses for POINTER arrays
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARMEM: Section 3.',JPQUIET)
-C
-      NIFELD = IBASE
-      NOFELD = NIFELD + KIMEM * JPRLEN
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IARMEM: Output base addresses.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IARMEM: Input fld base address = ',NIFELD)
-        CALL INTLOG(JP_DEBUG,'IARMEM: Output fld base address= ',NOFELD)
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IARMEM: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/ibasini.F b/interpolation/ibasini.F
index 3e121f6..cd3b2d7 100644
--- a/interpolation/ibasini.F
+++ b/interpolation/ibasini.F
@@ -64,7 +64,6 @@ C     Externals
 C     ---------
 C
 C     CLEAR_C - Clear common block variables
-C     RDDEFS  - Read interpolation handling default values
 C     GETENV  - Get value of an environment variable
 C     JINDEX  - Returns length of character string
 C  
@@ -100,7 +99,7 @@ C
 C
 C     Externals
 C
-      INTEGER RDDEFS, JINDEX
+      INTEGER JINDEX
 C
 C     -----------------------------------------------------------------|
 C     Section 1. Force initialisation if requested.
diff --git a/interpolation/igdiwe.F b/interpolation/igdiwe.F
index a19c500..c1f8b6f 100644
--- a/interpolation/igdiwe.F
+++ b/interpolation/igdiwe.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION IGDIWE (KILONG, KIWE, KOLONG, KOWE, OWEGLOBE,
-     1   KWEIND, KWEDIST, KPR, KERR)
+      INTEGER FUNCTION IGDIWE(KIWE,KOWE,KWEIND,KWEDIST,IAREA,OAREA,
+     .  KILONG,KOLONG,OWEGLOBE)  !FIXME: remove
 C
 C---->
 C**** *IGDIWE*
@@ -24,33 +24,27 @@ C
 C     INTERFACE
 C     _________
 C
-C     IERR = IGDIWE (KILONG, KIWE, KOLONG, KOWE, OWEGLOBE, KWEIND,
-C    1   KWEDIST, KPR, KERR)
+C     IERR = IGDIWE(KIWE,KOWE,KWEIND,KWEDIST,IAREA,OAREA)
 C
 C     Input parameters
 C     ________________
 C
-C     KILONG     - The array of input longitudes.
-C
 C     KIWE       - The number of points in the West-East direction in
 C                  the input field.
 C
-C     KOLONG     - The array of output longitudes.
-C
 C     KOWE       - The number of points in the West-East direction in
 C                  the output field.
 C
-C     OWEGLOBE   - This variable will be true if the input array of
-C                  longitudes spans the globe.
+C     IAREA      - Input field area definition (N/W/S/E).
 C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
+C     OAREA      - Input field area definition (N/W/S/E).
 C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
+CTEMP KILONG     - The array of input longitudes.
+CTEMP
+CTEMP KOLONG     - The array of output longitudes.
+CTEMP
+CTEMP OWEGLOBE   - This variable will be true if the input array of
+CTEMP              longitudes spans the globe.
 C
 C     Output parameters
 C     ________________
@@ -68,317 +62,217 @@ C     ____________
 C
 C     The error indicator (INTEGER).
 C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     24601 An output longitude was found that was outside the range
-C           spanned by the input longitudes.
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG(R)    - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     This routine will create the arrays of offsets and distance
-C     as two arrays of length (2, Number of output longitudes).
-C     This will be used for all latitude rows when both the input
-C     and output grids are regular.
-C
-C     This routine is used to provide the values for one line of
-C     latitude for quasi regular Gaussian input fields.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 2 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Oct 1993
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
 C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
+
       IMPLICIT NONE
-C
 #include "parim.h"
-C
-C     Dummy arguments
-      LOGICAL OWEGLOBE
-      INTEGER KIWE, KOWE, KPR, KERR
-      INTEGER KILONG (KIWE + 1), KOLONG (KOWE)
-      INTEGER KWEIND (2, KOWE), KWEDIST (2, KOWE)
-C
+#include "nofld.common"
+
+C     Arguments
+      INTEGER KIWE
+      INTEGER KOWE
+      INTEGER IAREA(4)
+      INTEGER OAREA(4)
+      INTEGER KWEIND (2,KOWE)
+      INTEGER KWEDIST(2,KOWE)
+
 C     Local variables
+      INTEGER I, J, IA, IB
+      LOGICAL LSTAGGL, LSUBAR  ! (to avoid globals)
+
+C     Arguments & local variables (FIXME: remove)
+      INTEGER KILONG(KIWE+1), KOLONG(KOWE)
+      LOGICAL OWEGLOBE
       INTEGER IBASE, ILOW, IUP
-      INTEGER JINP, JOUT
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 24600)
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGDIWE: Section 1.',JPQUIET)
-C
-      IGDIWE = 0
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IGDIWE: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IGDIWE: No.input fld pts = ',KIWE)
-        CALL INTLOG(JP_DEBUG,'IGDIWE: No.output fld pts = ',KOWE)
-        CALL INTLOG(JP_DEBUG,'IGDIWE: Input fld spread from ',KILONG(1))
-        CALL INTLOG(JP_DEBUG,'IGDIWE: to ',KILONG(KIWE))
-        CALL INTLOG(JP_DEBUG,'IGDIWE: Output spread from ',KOLONG(1))
-        CALL INTLOG(JP_DEBUG,'IGDIWE: to ',KOLONG(KOWE))
-        IF( OWEGLOBE ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      'IGDIWE: Input W-E fld is global',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      'IGDIWE: Input W-E fld is NOT global',JPQUIET)
-        ENDIF
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 2. Select points around a line of latitude.
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGDIWE: Section 2.',JPQUIET)
-C
-      IF (OWEGLOBE) THEN
-C
-        DO 230 JINP = 1, KIWE
-C
-C       NOTE that point number 1 is repeated as point KIWE + 1
-C       to simplify the wrap around case
-C
-          ILOW = KILONG (JINP)
-          IUP = KILONG (JINP + 1)
-C
-          IF (IUP .GT. ILOW) THEN
-C
-C           Normal case IUP > ILOW
-C
-            DO 210 JOUT = 1, KOWE
-C
-              IF (KOLONG(JOUT).GE.ILOW .AND.  KOLONG(JOUT).LT.IUP) THEN
-C
-C               Longitude point found
-C
-                KWEIND (JP_I_W, JOUT) = JINP
-C
-                IF (JINP .LT. KIWE) THEN
-                  KWEIND (JP_I_E, JOUT) = JINP + 1
-                ELSE
-                  KWEIND (JP_I_E, JOUT) = 1
+      REAL LO, LO1, LO2
+
+C     NOTE: subarea/staggered definition copied from areachk.F:218
+      LSUBAR  = (IAREA(1).NE.0) .AND. (IAREA(2).NE.0) .AND.
+     .          (IAREA(3).NE.0) .AND. (IAREA(4).NE.0)
+      LSTAGGL = (LSUBAR) .AND.
+     .          (IABS(JP360 - IAREA(4) - IAREA(2)).LT.1000)
+
+
+      IF( LSTAGGL .OR. LSUBAR .OR. .NOT. LGLOBL ) THEN
+
+!       CALL INTLOG(JP_DEBUG,
+!    .    'IGDIWE: Staggered grids not supported', JPQUIET )
+
+        CALL INTLOG(JP_DEBUG,'IGDIWE: algorithm: old :-(',JPQUIET)
+
+C       OLD METHOD:
+C       This sets the arrays of offsets and distance (of length
+C       (2, Number of output longitudes)), used for all latitude rows when
+C       both input & and output grids are regular. It is used to provide
+C       the values for one line of latitude for quasi regular Gaussian
+C       input fields.
+
+
+        IGDIWE = 0
+        IF (OWEGLOBE) THEN
+
+          DO I = 1, KIWE
+
+C           NOTE entry #1 is repeated as point KIWE + 1 to simplify the wrap around
+            ILOW = KILONG (I)
+            IUP  = KILONG (I + 1)
+            IF (IUP .GT. ILOW) THEN
+
+              DO J = 1, KOWE
+
+                IF (KOLONG(J).GE.ILOW .AND.  KOLONG(J).LT.IUP) THEN
+
+C                 Normal case IUP > ILOW: longitude point found
+                  KWEIND (JP_I_W, J) = I
+                  IF (I .LT. KIWE) THEN
+                    KWEIND (JP_I_E, J) = I + 1
+                  ELSE
+                    KWEIND (JP_I_E, J) = 1
+                  ENDIF
+                  KWEDIST (JP_I_W, J) = KOLONG (J) - ILOW
+                  KWEDIST (JP_I_E, J) = IUP - KOLONG (J)
+
                 ENDIF
-C
-                KWEDIST (JP_I_W, JOUT) = KOLONG (JOUT) - ILOW
-                KWEDIST (JP_I_E, JOUT) = IUP - KOLONG (JOUT)
-C
-              ENDIF
-C
-  210       CONTINUE
-C
-          ELSE
-C
-C           Wrap around case
-C
-            DO 220 JOUT = 1, KOWE
-C
-              IF (KOLONG (JOUT) .GE. ILOW) THEN
-C
-C               Longitude point found between ILOW and 3600000
-C
-                KWEIND (JP_I_W, JOUT) = JINP
-C
-                IF (JINP .LT. KIWE) THEN
-                  KWEIND (JP_I_E, JOUT) = JINP + 1
-                ELSE
-                  KWEIND (JP_I_E, JOUT) = 1
+
+              ENDDO
+
+            ELSE
+
+              DO J = 1, KOWE
+
+                IF (KOLONG (J) .GE. ILOW) THEN
+
+C                 Wrap around case: longitude point found between ILOW and 3600000
+                  KWEIND (JP_I_W, J) = I
+                  IF (I .LT. KIWE) THEN
+                    KWEIND (JP_I_E, J) = I + 1
+                  ELSE
+                    KWEIND (JP_I_E, J) = 1
+                  ENDIF
+                  KWEDIST (JP_I_W, J) = KOLONG (J) - ILOW
+                  KWEDIST (JP_I_E, J) = IUP + JP360 - KOLONG (J)
+
                 ENDIF
-C
-                KWEDIST (JP_I_W, JOUT) = KOLONG (JOUT) - ILOW
-                KWEDIST (JP_I_E, JOUT) = IUP + JP360 - KOLONG (JOUT)
-C
-              ENDIF
-C
-Cjdc          IF (KOLONG (JOUT) .LT. IUP) THEN
-              IF (KOLONG (JOUT) .LE. IUP) THEN
-C
-C               Longitude point found between 0 and IUP
-C
-                KWEIND (JP_I_W, JOUT) = JINP
-C
-                IF (JINP .LT. KIWE) THEN
-                  KWEIND (JP_I_E, JOUT) = JINP + 1
-                ELSE
-                  KWEIND (JP_I_E, JOUT) = 1
+
+                IF (KOLONG (J) .LE. IUP) THEN
+
+C                 Wrap around case: longitude point found between 0 and IUP
+                  KWEIND (JP_I_W, J) = I
+                  IF (I .LT. KIWE) THEN
+                    KWEIND (JP_I_E, J) = I + 1
+                  ELSE
+                    KWEIND (JP_I_E, J) = 1
+                  ENDIF
+                  KWEDIST (JP_I_W, J) = KOLONG (J) + JP360 - ILOW
+                  KWEDIST (JP_I_E, J) = IUP - KOLONG (J)
+
                 ENDIF
-C
-                KWEDIST (JP_I_W, JOUT) = KOLONG (JOUT) + JP360 - ILOW
-                KWEDIST (JP_I_E, JOUT) = IUP - KOLONG (JOUT)
-C
+
+              ENDDO
+
+            ENDIF
+
+          ENDDO
+
+        ELSE
+
+C         last point found for non-global input grids
+          IBASE = 1
+
+          DO J = 1, KOWE
+
+            DO I = IBASE, KIWE - 1
+
+              ILOW = KILONG (I)
+              IUP = KILONG (I + 1)
+
+              IF (KOLONG(J).GE.ILOW .AND. KOLONG(J).LE.IUP) THEN
+
+C               Normal case IUP > ILOW: longitude point found
+                KWEIND (JP_I_W, J) = I
+                KWEIND (JP_I_E, J) = I + 1
+                IBASE = I
+                KWEDIST (JP_I_W, J) = KOLONG (J) - ILOW
+                KWEDIST (JP_I_E, J) = IUP - KOLONG (J)
+                GOTO 250
+
+              ELSE IF (IUP .LT. ILOW) THEN
+
+                IF (KOLONG (J) .GE. ILOW) THEN
+
+C                 Wrap around case: longitude point found between ILOW and 3600000
+                  KWEIND (JP_I_W, J) = I
+                  KWEIND (JP_I_E, J) = I + 1
+                  IBASE = I
+                  KWEDIST (JP_I_W, J) = KOLONG (J) - ILOW
+                  KWEDIST (JP_I_E, J) = IUP + JP360 - KOLONG (J)
+                  GOTO 250
+
+                ENDIF
+
+                IF (KOLONG (J) .LE. IUP) THEN
+
+C                 Wrap around case: longitude point found between 0 and IUP
+                  KWEIND (JP_I_W, J) = I
+                  KWEIND (JP_I_E, J) = I + 1
+                  IBASE = I
+                  KWEDIST (JP_I_W, J) = KOLONG (J) + JP360 - ILOW
+                  KWEDIST (JP_I_E, J) = IUP - KOLONG (J)
+                  GOTO 250
+
+                ENDIF
+
               ENDIF
-C
-  220       CONTINUE
-C
-          ENDIF
-C
-  230   CONTINUE
-C
+
+            ENDDO
+
+C           This statement will be reached if the output grid does not
+C           fit within the input grid.
+            IGDIWE = 6
+            LO  = REAL(KOLONG(J))/PPMULT
+            LO1 = REAL(KILONG(1))/PPMULT
+            LO2 = REAL(KILONG(KIWE))/PPMULT
+      CALL INTLOG( JP_ERROR,'IGDIWE: Output long. value number = ',J)
+      CALL INTLOGR(JP_ERROR,'IGDIWE: Output long. value ',LO)
+      CALL INTLOGR(JP_ERROR,'IGDIWE: outside input range = ',LO1)
+      CALL INTLOGR(JP_ERROR,'IGDIWE: to ',LO2)
+      CALL INTLOG(JP_FATAL,'IGDIWE: Interpolation failing.',JPQUIET)
+            GOTO 900
+
+  250     CONTINUE
+          ENDDO
+
+        ENDIF
+  900   CONTINUE
+
       ELSE
-C
-C       Pointer to last point found if input grid is not global
-C
-        IBASE = 1
-C
-        DO 250 JOUT = 1, KOWE
-C
-          DO 240 JINP = IBASE, KIWE - 1
-C
-            ILOW = KILONG (JINP)
-            IUP = KILONG (JINP + 1)
-C
-C           Normal case IUP > ILOW
-C
-Cjdc        IF (KOLONG(JOUT).GE.ILOW .AND. KOLONG(JOUT).LT.IUP) THEN
-            IF (KOLONG(JOUT).GE.ILOW .AND. KOLONG(JOUT).LE.IUP) THEN
-C
-C             Longitude point found
-C
-              KWEIND (JP_I_W, JOUT) = JINP
-              KWEIND (JP_I_E, JOUT) = JINP + 1
-              IBASE = JINP
-C
-              KWEDIST (JP_I_W, JOUT) = KOLONG (JOUT) - ILOW
-              KWEDIST (JP_I_E, JOUT) = IUP - KOLONG (JOUT)
-C
-              GO TO 250
-C
-C           Wrap around case
-C
-            ELSE IF (IUP .LT. ILOW) THEN
-C
-              IF (KOLONG (JOUT) .GE. ILOW) THEN
-C
-C               Longitude point found between ILOW and 3600000
-C
-                KWEIND (JP_I_W, JOUT) = JINP
-                KWEIND (JP_I_E, JOUT) = JINP + 1
-                IBASE = JINP
-C
-                KWEDIST (JP_I_W, JOUT) = KOLONG (JOUT) - ILOW
-                KWEDIST (JP_I_E, JOUT) = IUP + JP360 - KOLONG (JOUT)
-C
-                GO TO 250
-C
-              ENDIF
-C
-Cjdc          IF (KOLONG (JOUT) .LT. IUP) THEN
-              IF (KOLONG (JOUT) .LE. IUP) THEN
-C
-C               Longitude point found between 0 and IUP
-C
-                KWEIND (JP_I_W, JOUT) = JINP
-                KWEIND (JP_I_E, JOUT) = JINP + 1
-                IBASE = JINP
-C
-                KWEDIST (JP_I_W, JOUT) = KOLONG (JOUT) + JP360 - ILOW
-                KWEDIST (JP_I_E, JOUT) = IUP - KOLONG (JOUT)
-C
-                GO TO 250
-C
-              ENDIF
-C
-            ENDIF
-C
-  240     CONTINUE
-C
-C         This statement will be reached if the output grid does not
-C         fit within the input grid.
-C
-          IGDIWE = JPROUTINE + 1
-          IF (KERR .GE. 0) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'IGDIWE: Output long. value number = ',JOUT)
-            CALL INTLOGR(JP_ERROR,
-     X        'IGDIWE: Output long. value ',REAL(KOLONG(JOUT))/PPMULT)
-            CALL INTLOGR(JP_ERROR,
-     X        'IGDIWE: outside input range = ',REAL(KILONG(1))/PPMULT)
-            CALL INTLOGR(JP_ERROR,
-     X        'IGDIWE: to ',REAL(KILONG(KIWE))/PPMULT)
-          ENDIF
-C
-          IF (KERR .EQ. 0) CALL INTLOGR(JP_FATAL,
-     X      'IGDIWE: Interpolation failing.',IGDIWE)
-C
-          GO TO 900
-C
-  250   CONTINUE
-C
+
+        CALL INTLOG(JP_DEBUG,'IGDIWE: algorithm: new :-)',JPQUIET)
+
+        DO J = 1, KOWE
+
+          I = FLOOR( REAL((J-1)*KIWE)/REAL(KOWE) ) + 1
+          KWEIND (JP_I_W,J) = I
+          KWEIND (JP_I_E,J) = MOD(I,KIWE)+1
+
+!C         original:
+!          IKIWE = JP360 / KIWE
+!          IKOWE = JP360 / KOWE
+!          IA = (J-1)*IKOWE - (I-1)*IKIWE
+!          IB = ( I )*IKIWE - (J-1)*IKOWE  ! (same as: IKIWE - A)
+
+          IA = (J-1)*KIWE - (I-1)*KOWE
+          IB = ( I )*KOWE - (J-1)*KIWE
+
+!C         adimensionalize from KIWE*KOWE space (optional):
+!          IA = INT( REAL(IA*JP360)*REAL(KIWE*KOWE) )
+!          IB = INT( REAL(IB*JP360)*REAL(KIWE*KOWE) )
+
+          KWEDIST(JP_I_W,J) = IA
+          KWEDIST(JP_I_E,J) = IB
+
+        ENDDO
+        IGDIWE = 0
+
       ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGDIWE: Section 9.',JPQUIET)
-C
-      RETURN
       END
diff --git a/interpolation/iggrid.F b/interpolation/iggrid.F
index a784cd5..f9e688d 100644
--- a/interpolation/iggrid.F
+++ b/interpolation/iggrid.F
@@ -159,7 +159,7 @@ C     Dummy arguments
 C
 C     Local variables
 C
-      INTEGER ILNSTR, IEAST, IWEST
+      INTEGER IEAST, IWEST
       INTEGER JLONG, JLAT
       REAL*8 RWEST, RKKK, RLNSTR
       INTEGER JPROUTINE
diff --git a/interpolation/iglrev.F b/interpolation/iglrev.F
deleted file mode 100644
index d3e4434..0000000
--- a/interpolation/iglrev.F
+++ /dev/null
@@ -1,242 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IGLREV (PMAT, KCOL, KROW, KDIR, KPR, KERR)
-C
-C---->
-C**** *IGLREV*
-C
-C     PURPOSE
-C     _______
-C
-C     This routine reverses either the rows or the columns of a
-C     rectangular matrix.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IGLREV (PMAT, KCOL, KROW, KDIR, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PMAT       - The input matrix of dimension (KCOL, KROW).
-C
-C     KCOL       - The length of the first dimension of PMAT.
-C
-C     KROW       - The length of the second dimension of PMAT.
-C
-C     KDIR       - 1    Reverses the order in each column.
-C                       West-East reversal for meteorological fields.
-C                  2    Reverses the order in each row.
-C                       North-South reversal for meteorological fields.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     PMAT       - The transformed matrix.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     None
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     KDIR = 1 is implemented by swapping elements within each column
-C              of the matrix.
-C
-C     KDIR = 2 is implemented by reversing the order of the columns.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 3 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Jan 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Dummy arguments
-C
-      INTEGER KCOL, KROW, KDIR, KPR, KERR
-C
-      REAL PMAT (KCOL, KROW)
-C
-C     Local variables
-C
-      INTEGER IHALF
-C
-      INTEGER JSTEP, JMOVE
-C
-      REAL ZTEMP
-C
-      INTEGER JPROUTINE
-C
-      PARAMETER (JPROUTINE = 7300)
-C
-C     External functions
-C
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGLREV: Section 1.',JPQUIET)
-C
-      IGLREV = 0
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IRSCAN: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IRSCAN: First matrix dimension is ',KCOL)
-        CALL INTLOG(JP_DEBUG,'IRSCAN: Second matrix dimension is ',KROW)
-        CALL INTLOG(JP_DEBUG,'IRSCAN: Direction value is ',KDIR)
-        CALL INTLOG(JP_DEBUG,'IRSCAN: Input parameters.',JPQUIET)
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 2. Matrix COLUMN reversal (Field row interchange - WE)
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGLREV: Section 2.',JPQUIET)
-C
-      IF (KDIR .EQ. 1) THEN
-C
-         IHALF = KCOL / 2
-C
-         DO 220 JMOVE = 1, IHALF
-C
-            DO 210 JSTEP = 1, KROW
-C
-               ZTEMP = PMAT (KCOL + 1 - JMOVE, JSTEP)
-               PMAT (KCOL + 1 - JMOVE, JSTEP) = PMAT (JMOVE, JSTEP)
-               PMAT (JMOVE, JSTEP) = ZTEMP
-C
-  210       CONTINUE
-C
-  220    CONTINUE
-C
-      ELSE
-C
-C     _______________________________________________________
-C
-C
-C*    Section 3. Matrix ROW reversal (Field column interchange - NS)
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGLREV: Section 3.',JPQUIET)
-C
-         IHALF = KROW / 2
-C
-         DO 320 JMOVE = 1, IHALF
-C
-            DO 310 JSTEP = 1, KCOL
-C
-               ZTEMP = PMAT (JSTEP, KROW + 1 - JMOVE)
-               PMAT (JSTEP, KROW + 1 - JMOVE) = PMAT (JSTEP, JMOVE)
-               PMAT (JSTEP, JMOVE) = ZTEMP
-C
-  310       CONTINUE
-C
-  320    CONTINUE
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGLREV: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/iglsmb.F b/interpolation/iglsmb.F
index 00c91ac..2207d77 100644
--- a/interpolation/iglsmb.F
+++ b/interpolation/iglsmb.F
@@ -8,8 +8,10 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION IGLSMB( OISTAND, HIFILE, KIREC, KIGRID, KILINE,
-     X   OOSTAND, HOFILE, KOREC, KOGRID, KOLINE, KPR, KERR)
+      INTEGER FUNCTION IGLSMB(
+     X  OISTAND, HIFILE, KIREC, KIGRID, KILINE,
+     X  OOSTAND, HOFILE, KOREC, KOGRID, KOLINE,
+     X  KPR, KERR )
 C
 C---->
 C**** *IGLSMB*
@@ -24,8 +26,10 @@ C
 C     INTERFACE
 C     ---------
 C
-C     IERR = IGLSMB( OISTAND, HIFILE, KIREC, KIGRID, KILINE, OOSTAND,
-C    X   HOFILE, KOREC, KOGRID, KOLINE, KPR, KERR)
+C     IERR = IGLSMB(
+C    X  OISTAND, HIFILE, KIREC, KIGRID, KILINE,
+C    X  OOSTAND, HOFILE, KOREC, KOGRID, KOLINE,
+C    X  KPR, KERR )
 C
 C
 C     Input parameters
@@ -134,17 +138,16 @@ C
 C     Externals
 C     ---------
 C
-C     ABORTX    - Standard routine to kill task.
 C     IGLSM01   - Read and process one latitude row from the 10
 C                 minute land sea mask.
-C     IGLSMR    - Calculate the effects of the land-sea masks for one
-C                 line of latitude on the unnormalised interpolation
-C                 weights.
+C     IGLSMR    - Calculate the effects of the land-sea masks for
+C                 one line of latitude on the unnormalised
+C                 interpolation weights.
 C     IGLSMST   - Read and process one line of latitude from a
 C                 standard land sea mask file.
 C     PBCLOSE   - Close a land sea mask file after processing.
 C     PBOPEN    - Open a land sea mask file for processing.
-C     INTLOG(R) - Logs messages.
+C     INTLOG(R) - Log messages.
 C     JINDEX    - Returns length of character string
 C
 C
@@ -164,11 +167,13 @@ C
 C
 C     Reference
 C     ---------
+C
 C     None
 C
 C
 C     Comments
 C     --------
+C
 C     None
 C
 C
@@ -197,27 +202,35 @@ C
 #include "nofld.common"
 #include "grspace.h"
 C
-C     Dummy arguments
-      LOGICAL OISTAND, OOSTAND
-      CHARACTER *(*) HIFILE, HOFILE
-      INTEGER KIREC, KOREC, KPR, KERR
-      INTEGER KIGRID(2), KILINE(2), KOGRID(2), KOLINE(2)
-C
-C     Local variables
-      INTEGER IIUNIT, IOUNIT, IIFILE, IOFILE
-      INTEGER ILATN, ILATS, IISTRIDE, IOSTRIDE, IOFF, IPR, IERR
-      INTEGER JOLAT
-      CHARACTER*256 XHIFILE, XHOFILE
-      CHARACTER*2 NEWFILE, MSKFILE
-      INTEGER XIIUNIT, XIOUNIT, II
-      DATA XIIUNIT/0/
-      DATA XIOUNIT/0/
-      SAVE  XHIFILE, XHOFILE, XIIUNIT, XIOUNIT
+C     Parameters
 C
       INTEGER JPROUTINE
       PARAMETER (JPROUTINE = 22400)
 C
+C     Function arguments
+C
+      LOGICAL       OISTAND,   OOSTAND
+      CHARACTER*256 HIFILE,    HOFILE
+      INTEGER       KIREC,     KOREC
+      INTEGER       KIGRID(2), KOGRID(2)
+      INTEGER       KILINE(2), KOLINE(2)
+      INTEGER KPR, KERR
+C
+C     Local variables
+C
+      INTEGER IIUNIT, IOUNIT, IIFILE, IOFILE, ILATN, ILATS
+      INTEGER IOFF, IPR, IERR, JOLAT, I
+      CHARACTER*2 NEWFILE, MSKFILE
+
+      CHARACTER*256 XHIFILE, XHOFILE
+      SAVE          XHIFILE, XHOFILE
+
+      INTEGER XIIUNIT,    XIOUNIT
+      DATA    XIIUNIT/0/, XIOUNIT/0/
+      SAVE    XIIUNIT,    XIOUNIT
+C
 C     External functions
+C
       INTEGER IGLSMR, IGLSMST, IGLSM01, JINDEX
 C
 C     -----------------------------------------------------------------|
@@ -234,45 +247,33 @@ C
       IOFILE = JINDEX(HOFILE)
 C
       IF( KPR.GE.1 ) THEN
-        CALL INTLOG(JP_DEBUG,'IGLSMB: Input parameters are:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IGLSMB: Land sea mask file name:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,HIFILE(1: IIFILE),JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Input parameters.',JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IGLSMB: LSM filename:',JPQUIET)
+        CALL INTLOG(JP_DEBUG,HIFILE(1:IIFILE),JPQUIET)
         IF( OISTAND ) THEN
-          CALL INTLOG(JP_DEBUG,'IGLSMB: Stnd fld flag = TRUE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IGLSMB: Standard fld: TRUE',JPQUIET)
         ELSE
-          CALL INTLOG(JP_DEBUG,'IGLSMB: Stnd fld flag = FALSE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IGLSMB: Standard fld: FALSE',JPQUIET)
         ENDIF
         CALL INTLOG(JP_DEBUG,'IGLSMB: LSM file rec len = ',KIREC)
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid stride WE = ',KIGRID(1))
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid stride NS = ',KIGRID(2))
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid start N = ',KILINE(1))
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid start W = ',KILINE(2))
-C
-        CALL INTLOG(JP_DEBUG,'IGLSMB: Output parameters are:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IGLSMB: Land sea mask file name:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,HOFILE(1: IIFILE),JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid stride WE = ',KIGRID(1))
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid stride NS = ',KIGRID(2))
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid start N = ',KILINE(1))
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid start W = ',KILINE(2))
+C
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Output parameters.',JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IGLSMB: LSM filename:',JPQUIET)
+        CALL INTLOG(JP_DEBUG,HOFILE(1:IOFILE),JPQUIET)
         IF( OOSTAND ) THEN
-          CALL INTLOG(JP_DEBUG,'IGLSMB: Stnd fld flag = TRUE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IGLSMB: Standard fld: TRUE',JPQUIET)
         ELSE
-          CALL INTLOG(JP_DEBUG,'IGLSMB: Stnd fld flag = FALSE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IGLSMB: Standard fld: FALSE',JPQUIET)
         ENDIF
         CALL INTLOG(JP_DEBUG,'IGLSMB: LSM file rec len = ',KOREC)
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid stride WE = ',KOGRID(1))
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid stride NS = ',KOGRID(2))
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid start N = ',KOLINE(1))
-        CALL INTLOG(JP_DEBUG,'IGLSMB: The grid start W = ',KOLINE(2))
-      ENDIF
-C
-      IF( MILONG(2).GE.MILONG(1) ) THEN
-        IISTRIDE = MILONG(2) - MILONG(1)
-      ELSE
-        IISTRIDE = MILONG(2) + JP360 - MILONG(1)
-      ENDIF
-C
-      IF( MOLONG(2).GE.MOLONG(1) ) THEN
-        IOSTRIDE = MOLONG(2) - MOLONG(1)
-      ELSE
-        IOSTRIDE = MOLONG(2) + JP360 - MOLONG(1)
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid stride WE = ',KOGRID(1))
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid stride NS = ',KOGRID(2))
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid start N = ',KOLINE(1))
+        CALL INTLOG(JP_DEBUG,'IGLSMB: Grid start W = ',KOLINE(2))
       ENDIF
 C
 C     -----------------------------------------------------------------|
@@ -286,28 +287,28 @@ C
 C     See if first time through or input land sea mask filename has
 C     changed since last access
 C
-      II = JINDEX(HIFILE)
-      IF( XHIFILE(1:II).NE.HIFILE(1:II) ) THEN
+      I = JINDEX(HIFILE)
+      IF( XHIFILE(1:I).NE.HIFILE(1:I) ) THEN
 C
 C       Open input land sea mask file
 C
-        IF( XIIUNIT.NE.0 ) CALL PBCLOSE(XIIUNIT,IERR)
+        IF(XIIUNIT.NE.0) CALL PBCLOSE(XIIUNIT,IERR)
         CALL PBOPEN(IIUNIT, HIFILE, 'r', IERR)
         IF( IERR.NE.0 ) THEN
           IGLSMB = JPROUTINE + 1
 C
           IF( KERR.GE.0 ) THEN
-            CALL INTLOG(JP_ERROR,'IGLSMB: PBOPEN error = ',IERR)
-            CALL INTLOG(JP_ERROR,'IGLSMB: trying to open file:',JPQUIET)
-            CALL INTLOG(JP_ERROR, HIFILE(1:IIFILE) ,JPQUIET)
-C
-            IF( KERR.EQ.0 ) CALL INTLOG(JP_FATAL,
-     X        'IGLSMB: Interpolation failed.',JPQUIET)
+            CALL INTLOG(JP_ERROR,'IGLSMB: PBOPEN return code = ',IERR)
+            CALL INTLOG(JP_ERROR,'IGLSMB: trying to open file',JPQUIET)
+            CALL INTLOG(JP_ERROR, HIFILE(1:IIFILE),JPQUIET)
           ENDIF
+C
+          IF( KERR.EQ.0 ) CALL INTLOG(JP_FATAL,
+     X      'IGLSMB: Interpolation failed.',JPQUIET)
           GOTO 900
         ENDIF
         XIIUNIT = IIUNIT
-        XHIFILE(1:II) = HIFILE(1:II)
+        XHIFILE(1:I) = HIFILE(1:I)
         NEWFILE(1:1) = 'Y'
 C
 C     Just rewind if same file still in use
@@ -320,28 +321,29 @@ C
 C     See if first time through or output land sea mask filename has
 C     changed since last access
 C
-      II = JINDEX(HOFILE)
-      IF( XHOFILE(1:II).NE.HOFILE(1:II) ) THEN
+      I = JINDEX(HOFILE)
+      IF( XHOFILE(1:I).NE.HOFILE(1:I) ) THEN
 C
 C       Open output land sea mask file
 C
-        IF( XIOUNIT.NE.0 ) CALL PBCLOSE(XIOUNIT,IERR)
+        IF(XIOUNIT.NE.0) CALL PBCLOSE(XIOUNIT,IERR)
         CALL PBOPEN(IOUNIT, HOFILE, 'r', IERR)
         IF( IERR.NE.0 ) THEN
           IGLSMB = JPROUTINE + 1
 C
           IF( KERR.GE.0 ) THEN
-            CALL INTLOG(JP_ERROR,'IGLSMB: PBOPEN error = ',IERR)
-            CALL INTLOG(JP_ERROR,'IGLSMB: trying to open file:',JPQUIET)
-            CALL INTLOG(JP_ERROR, HOFILE(1:IOFILE) ,JPQUIET)
+            CALL INTLOG(JP_ERROR,'IGLSMB: PBOPEN return code = ',IERR)
+            CALL INTLOG(JP_ERROR,'IGLSMB: trying to open file',JPQUIET)
+            CALL INTLOG(JP_ERROR, HOFILE(1:IOFILE),JPQUIET)
 C
-            IF( KERR.EQ.0 ) CALL INTLOG(JP_FATAL,
-     X        'IGLSMB: Interpolation failed.',JPQUIET)
-            GOTO 900
           ENDIF
+C
+          IF( KERR.EQ.0 ) CALL INTLOG(JP_FATAL,
+     X      'IGLSMB: Interpolation failed.',JPQUIET)
+          GOTO 900
         ENDIF
         XIOUNIT = IOUNIT
-        XHOFILE(1:II) = HOFILE(1:II)
+        XHOFILE(1:I) = HOFILE(1:I)
         NEWFILE(2:2) = 'Y'
 C
 C     Just rewind if same file still in use
@@ -350,6 +352,7 @@ C
         IOUNIT = XIOUNIT
         NEWFILE(2:2) = 'N'
       ENDIF
+C
 C     -----------------------------------------------------------------|
 C*    Section 3. Calculate arrays of weights
 C     -----------------------------------------------------------------|
@@ -372,12 +375,12 @@ C
           MSKFILE(2:2) = 'O'
           MSKFILE(1:1) = NEWFILE(2:2)
           IERR = IGLSMST(IOUNIT, IOFF, NOWE, KOLINE(JPWEST),
-     X                   KOGRID(JPWESTEP), KOREC, MOLSM, MSKFILE)
+     X         KOGRID(JPWESTEP), KOREC, MOLSM, MSKFILE)
           NEWFILE(2:2) = 'N'
 C
         ELSE
           IERR = IGLSM01(IOUNIT, NOWE, MOLONG, MOLATG(JOLAT),
-     X                   MEXPAND, KOREC, MOLSM)
+     X         MEXPAND, KOREC, MOLSM)
         ENDIF
 C
         IF( IERR.GT.0 ) THEN
@@ -398,7 +401,8 @@ C
           MSKFILE(2:2) = 'I'
           MSKFILE(1:1) = NEWFILE(1:1)
           IERR = IGLSMST(IIUNIT, IOFF, NIWE, KILINE(JPWEST),
-     X         KIGRID(JPWESTEP), KIREC, MILSM(1, JP_I_N), MSKFILE)
+     X         KIGRID(JPWESTEP), KIREC,
+     X         MILSM(1, JP_I_N), MSKFILE)
           NEWFILE(1:1) = 'N'
 C
           IF( IERR.GT.0 ) THEN
@@ -412,7 +416,8 @@ C
           MSKFILE(2:2) = 'I'
           MSKFILE(1:1) = NEWFILE(1:1)
           IERR = IGLSMST(IIUNIT, IOFF, NIWE, KILINE(JPWEST),
-     X         KIGRID(JPWESTEP), KIREC, MILSM(1, JP_I_S), MSKFILE)
+     X         KIGRID(JPWESTEP), KIREC,
+     X         MILSM(1, JP_I_S), MSKFILE)
           NEWFILE(1:1) = 'N'
 C
         ELSE
@@ -437,9 +442,9 @@ C
 C
 C       Now modify the unormalised weight for land-sea mask
 C
-        IERR = IGLSMR(MILSM(1, JP_I_N), MILSM(1, JP_I_S), MOLSM,
-     X      MWEIND, MWEIND, NOWE, WFACT(1,(JOLAT - 1) * NOWE + 1),
-     X      IPR, KERR)
+        IERR = IGLSMR(MILSM(1, JP_I_N), MILSM(1, JP_I_S),
+     X      MOLSM, MWEIND, MWEIND, NOWE,
+     X      WFACT(1,(JOLAT - 1) * NOWE + 1), IPR, KERR)
 C
         IF( IERR.GT.0 ) THEN
           IGLSMB = IERR
@@ -458,9 +463,5 @@ C
 C
       IF( KPR.GE.1 ) CALL INTLOG(JP_DEBUG,'IGLSMB: Section 9.',JPQUIET)
 C
- 9001 FORMAT(' IGLSMB ERROR', I6, ' - ', A, ' returned code', I6 /
-     1   21X, ' when ', A, 'ing file - ', A)
-C
-C
       RETURN
       END
diff --git a/interpolation/iglsmd.F b/interpolation/iglsmd.F
index 250089c..40bf329 100644
--- a/interpolation/iglsmd.F
+++ b/interpolation/iglsmd.F
@@ -74,19 +74,11 @@ C          = 0 if OK,
 C          = 25201 if data representation type is not valid.
 C          = 25202 if unable to locate lsm file for reduced gaussian
 C
-C     Common block usage
-C     __________________
-C
-C     None
-C
 C     EXTERNALS
 C     _________
 C
 C     GETENV     - Standard routine to get environmental variable.
-C     INDEX      - Intrinsic routine to find position of substring.
-C     LEN        - Intrinsic routine to find length of string.
 C     INTLOG(R)  - Logs messages.
-C     EMOSNUM    - Gives current EMOSLIB version number.
 C
 C     METHOD
 C     ______
@@ -103,16 +95,6 @@ C     arrays are set to appropriate values. If no match is found then
 C     the name of the basic 10 minute 0-1 land sea mask file is
 C     returned.
 C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 5 and 9
-C
 C     AUTHOR
 C     ______
 C
@@ -137,9 +119,9 @@ C
 C
 #include "parim.h"
 C
-C     Function arguments
+C     Arguments
 C
-      CHARACTER *(*) HFILE
+      CHARACTER*256 HFILE
       LOGICAL OSTAND
       INTEGER KDATE, KREPR, KGAUSS, KLN, KNREC, KPR, KERR
       INTEGER KGRID(2), KAREA(4), KOGRID(2), KOLINE(2)
@@ -158,10 +140,10 @@ C
 C
 C     Local variables
 C
-      CHARACTER*6 YEMOSNM,YFLAG,YFLAG1
-      INTEGER IEMOSNM
-      INTEGER ILSTRIDE, IRET, IOFFSET
+      CHARACTER*6 YFLAG
+      INTEGER IRET
       LOGICAL LDEBUG, L10MIN, L025
+      REAL RLSTRIDE
 C
       CHARACTER*256 YBASE
       CHARACTER*256 YENVBACK
@@ -176,8 +158,8 @@ C
 C
 C     External functions
 C
-      INTEGER EMOSNUM, LSM_RED, DPATH_TABLES_INTERPOL
-      EXTERNAL EMOSNUM, LSM_RED, DPATH_TABLES_INTERPOL
+      INTEGER LSM_RED, DPATH_TABLES_INTERPOL
+      EXTERNAL LSM_RED, DPATH_TABLES_INTERPOL
 C
       DATA YLSM10 / 'lsm_xx_lsm10m01' /
       DATA ILSM10LEN / 15 /
@@ -196,19 +178,15 @@ C     _______________________________________________________
 C
   100 CONTINUE
 C
-      L10MIN = .FALSE.
 C     Force processing with 10min lsm with env variable
-        CALL GETENV('LSM_10MIN', YFLAG)
-        IF( YFLAG(1:1).EQ.'1' ) L10MIN = .TRUE.
-
+      CALL GETENV('LSM_10MIN', YFLAG)
+      L10MIN = (YFLAG(1:1).EQ.'1')
       IF( L10MIN ) CALL INTLOG(JP_DEBUG,
      X  'IGLSMD: Forcing processing with 10 min',JPQUIET)
 
-      L025 = .FALSE.
 C     Processing with 0.25 Predefined lsm Enable
-        CALL GETENV('LSM_025', YFLAG1)
-        IF( YFLAG1(1:1).EQ.'1' ) L025 = .TRUE.
-
+      CALL GETENV('LSM_025', YFLAG)
+      L025 = (YFLAG(1:1).EQ.'1')
       IF( L025 ) CALL INTLOG(JP_DEBUG,
      X 'IGLSMD: Processing with 0.25 Predefined LSM Enabled',JPQUIET)
 
@@ -241,10 +219,6 @@ C
 C     _______________________________________________________
 C
 C*    Section 2. Check environment variable for path of land sea masks.
-C
-C                GETENV returns a blank value if the environmental
-C                variable is not set. This is true for C90, Sun and
-C                SGI.
 C     _______________________________________________________
 C
   200 CONTINUE
@@ -262,7 +236,7 @@ C
 C
 C     _______________________________________________________
 C
-C*    Section 3. Standard Gaussian grids - N80
+C*    Section 3. Standard Gaussian grids - F80
 C     _______________________________________________________
 C
   300 CONTINUE
@@ -271,10 +245,12 @@ C
      X    (KREPR.EQ.JPFGGROT) ) THEN
         IF( LDEBUG ) CALL INTLOG(JP_DEBUG,'IGLSMD: Section 3.',JPQUIET)
 C
-        ILSTRIDE = JP90 / KGAUSS
+c       ILSTRIDE = JP90 / KGAUSS
+        RLSTRIDE = 90./REAL(KGAUSS) * PPMULT
         KOGRID (JPWESTEP) = 1
         KOGRID (JPNSSTEP) = 1
-        KOLINE (JPWEST) = KAREA (JPWEST) / ILSTRIDE + 1
+c       KOLINE (JPWEST)  = KAREA (JPWEST) / ILSTRIDE + 1
+        KOLINE (JPWEST)  = REAL(KAREA(JPWEST))/RLSTRIDE + 1
         KOLINE (JPNORTH) = KLN
 C
         IF( KGAUSS.EQ.80 ) THEN
@@ -293,7 +269,7 @@ C
 C
 C     _______________________________________________________
 C
-C*    Section 4. Standard reduced Gaussian grids - R160
+C*    Section 4. Standard reduced Gaussian grids - N160
 C     _______________________________________________________
 C
   400 CONTINUE
@@ -396,7 +372,6 @@ C
 C
 C     _______________________________________________________
 C
-C
 C*    Section 9. Return to calling routine. Format statements
 C     _______________________________________________________
 C
diff --git a/interpolation/iglsmst.F b/interpolation/iglsmst.F
index 6522bcc..d7bc0f3 100644
--- a/interpolation/iglsmst.F
+++ b/interpolation/iglsmst.F
@@ -152,8 +152,7 @@ C
 C     Local variables
 C
       INTEGER JDCSIZE, JDCINDX, JDCPNT, JDCRET, JLSM
-      DIMENSION JLSM(1440)
-C                      `-------> good upto 0.25 degree latitude step
+      DIMENSION JLSM(1440)  ! good upto 0.25 degree latitude step
 C
       INTEGER IPOINT, IERR, ISIZE
       DATA ISIZE/0/
@@ -171,11 +170,6 @@ C
       POINTER (IRAWMSK, NRAWMSK )
       DATA IFILE/0,0/
       SAVE IFILE, LENRAW, IRAWMSK, ISIZE
-C
-C     Statement function
-C
-      INTEGER I, J
-C
 C     _______________________________________________________
 C
 C*    Section 1. Initialisation
diff --git a/interpolation/igscan.F b/interpolation/igscan.F
deleted file mode 100644
index 601dfe3..0000000
--- a/interpolation/igscan.F
+++ /dev/null
@@ -1,359 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IGSCAN (PMAT, KNWE, KNNS, KSCAN, OINFIELD,
-     1   KPR, KERR)
-C
-C---->
-C**** *IGSCAN*
-C
-C     PURPOSE
-C     _______
-C
-C     Transform a regular field between the specified external
-C     scanning mode and a standard internal scanning mode.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IGSCAN (PMAT, KNWE, KNNS, KSCAN, OINFIELD, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PMAT       - The input matrix of dimension (KNWE * KNNS).
-C
-C     KNWE       - The number of points in the West-East direction.
-C
-C     KNNS       - The number of points in the North-South direction.
-C
-C     KSCAN      - A standard GRIB byte variable with bits 1 to 3
-C                  separately significant. This means that the final
-C                  value is the sum of the bit settings.
-C
-C                  128 , Set if points scan East to West.
-C                   64 , Set if points scan South to North.
-C                   32 , Set if points in the North South direction
-C                        are consecutive.
-C
-C     OINFIELD   - Flag variable which is TRUE for an input field and
-C                  FALSE for an output field.
-C                  This determines the order in which the
-C                  transformations are applied.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     PMAT       - The transposed matrix.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     7101  The scanning mode was not in the range 0 to 255.
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C     EXTERNALS
-C     _________
-C
-C     ABORTX     - Standard routine to kill task.
-C     IGTRAN	 - Routine to transpose a rectangular matrix.
-C     IGLREV     - Routine to reverse the elements within each row or
-C                  each column of a rectangular matrix.
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     KSCAN = 128 is implemented by swapping elements within each
-C                 column of the matrix.
-C
-C     KSCAN = 64 is implemented by reversing the order of the columns.
-C
-C     KSCAN = 32 is implemented by transposing the matrix.
-C
-C     An input matrix is transposed before the two reversal stages
-C     are performed.
-C
-C     An output matrix has the matrix transposition as the final step.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 3 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Jan 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Dummy arguments
-C
-      LOGICAL OINFIELD
-C
-      INTEGER KNWE, KNNS, KSCAN, KPR, KERR
-C
-      REAL PMAT (KNWE * KNNS)
-C
-C     Local variables
-C
-      LOGICAL GNSMOD, GWEMOD, GTRMOD
-C
-      INTEGER ISCAN, IDIR, IERR
-C
-      INTEGER JPMOVE
-      PARAMETER (JPMOVE = (JPLAT + JPLONG) / 2)
-C
-      INTEGER IMOVE (JPMOVE)
-C
-      INTEGER JPROUTINE
-C
-      PARAMETER (JPROUTINE = 7100)
-C
-C     External functions
-C
-      INTEGER IGTRAN, IGLREV
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Initialisation - Evaluate scan modes
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGSCAN: Section 1.',JPQUIET)
-C
-      IGSCAN = 0
-C
-      IF (KPR .GE. 1) THEN
-         CALL INTLOG(JP_DEBUG,'IGSCAN: Input parameters',JPQUIET)
-         CALL INTLOG(JP_DEBUG,'IGSCAN: Longitude points are ',KNWE)
-         CALL INTLOG(JP_DEBUG,'IGSCAN: Latitude lines are ',KNNS)
-         CALL INTLOG(JP_DEBUG,'IGSCAN: Scan mode is ',KSCAN)
-         IF ( OINFIELD ) THEN
-           CALL INTLOG(JP_DEBUG,
-     X       'IGSCAN: Input field transformation is TRUE',JPQUIET)
-         ELSE
-           CALL INTLOG(JP_DEBUG,
-     X       'IGSCAN: Input field transformation is FALSE',JPQUIET)
-         ENDIF
-      ENDIF
-C
-      IF (KSCAN .LT. 0 .OR. KSCAN .GE. 256) THEN
-         IGSCAN = JPROUTINE + 1
-         IF (KERR .GE. 0) CALL INTLOG(JP_ERROR,
-     X    'IGSCAN: Scan mode is not in range 0 to 255 = ',KSCAN)
-         IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X    'IGSCAN: Interpolation fails.',IGSCAN)
-         GO TO 900
-      ENDIF
-C
-C     Zero KSCAN means no transformation
-C
-      IF (KSCAN .EQ. 0) GO TO 900
-C
-      ISCAN = KSCAN
-      GWEMOD = .FALSE.
-      GNSMOD = .FALSE.
-C
-      IF (ISCAN .GE. 128) THEN
-         ISCAN = ISCAN - 128
-         GWEMOD = .TRUE.
-      ENDIF
-C
-      IF (ISCAN .GE. 64) THEN
-         ISCAN = ISCAN - 64
-         GNSMOD = .TRUE.
-      ENDIF
-C
-      GTRMOD = ISCAN .GE. 32
-C
-C     _______________________________________________________
-C
-C*    Section 2. Input field
-C
-C                Potential operations in order are
-C
-C                1 Transpose matrix
-C                2 Modify West East mode
-C                3 Modify North South mode
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGSCAN: Section 2.',JPQUIET)
-C
-      IF (OINFIELD) THEN
-C
-         IF (GTRMOD) THEN
-C
-            IERR = IGTRAN (PMAT, KNNS, KNWE, IMOVE, JPMOVE, KPR, KERR)
-C
-            IF (IERR .NE. 0) THEN
-               IGSCAN = IERR
-               GO TO 900
-            ENDIF
-C
-         ENDIF
-C
-         IF (GWEMOD) THEN
-C
-            IDIR = 1
-C
-            IERR = IGLREV (PMAT, KNWE, KNNS, IDIR, KPR, KERR)
-C
-            IF (IERR .NE. 0) THEN
-               IGSCAN = IERR
-               GO TO 900
-            ENDIF
-C
-         ENDIF
-C
-         IF (GNSMOD) THEN
-C
-            IDIR = 2
-C
-            IERR = IGLREV (PMAT, KNWE, KNNS, IDIR, KPR, KERR)
-C
-            IF (IERR .NE. 0) THEN
-               IGSCAN = IERR
-               GO TO 900
-            ENDIF
-C
-         ENDIF
-C
-      ELSE
-C
-C     _______________________________________________________
-C
-C*    Section 3. Output field
-C
-C                Potential operations in order are
-C
-C                1 Modify West East mode
-C                2 Modify North South mode
-C                3 Transpose matrix
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGSCAN: Section 3.',JPQUIET)
-C
-         IF (GWEMOD) THEN
-C
-            IDIR = 1
-C
-            IERR = IGLREV (PMAT, KNWE, KNNS, IDIR, KPR, KERR)
-C
-            IF (IERR .NE. 0) THEN
-               IGSCAN = IERR
-               GO TO 900
-            ENDIF
-C
-         ENDIF
-C
-         IF (GNSMOD) THEN
-C
-            IDIR = 2
-C
-            IERR = IGLREV (PMAT, KNWE, KNNS, IDIR, KPR, KERR)
-C
-            IF (IERR .NE. 0) THEN
-               IGSCAN = IERR
-               GO TO 900
-            ENDIF
-C
-         ENDIF
-C
-         IF (GTRMOD) THEN
-C
-            IERR = IGTRAN (PMAT, KNWE, KNNS, IMOVE, JPMOVE, KPR, KERR)
-C
-            IF (IERR .NE. 0) THEN
-               IGSCAN = IERR
-               GO TO 900
-            ENDIF
-C
-         ENDIF
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGSCAN: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/igsetup.F b/interpolation/igsetup.F
index 5be9b6a..9b48888 100644
--- a/interpolation/igsetup.F
+++ b/interpolation/igsetup.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION IGSETUP( KSEC1, KSEC2, KSEC4)
+      INTEGER FUNCTION IGSETUP(KSEC1,KSEC2,KSEC3,KSEC4)
 C
 C---->
 C**** IGSETUP
@@ -16,27 +16,29 @@ C
 C     Purpose
 C     -------
 C
-C     Setup GRIB sections 1, 2 and 4 for the new interpolation product.
-C
+C     Setup GRIB sections 1, 2, 3 & 4 for the new interpolation product.
+C     For GRIBex.
 C
 C     Interface
 C     ---------
 C
-C     IRET IGSETUP( KSEC1, KSEC2, KSEC4)
+C     IRET IGSETUP(KSEC1,KSEC2,KSEC3,KSEC4)
 C
 C     Input
 C     -----
 C
-C     KSEC1   - Section 1 values (for GRIBEX)
-C     KSEC2   - Section 2 values (for GRIBEX)
-C     KSEC3   - Section 4 values (for GRIBEX)
+C     KSEC1   - Section 1 values
+C     KSEC2   - Section 2 values
+C     KSEC3   - Section 3 values
+C     KSEC4   - Section 4 values
 C
 C     Output
 C     ------
 C
-C     KSEC1   - Modified section 1 values (for GRIBEX)
-C     KSEC2   - Modified section 2 values (for GRIBEX)
-C     KSEC3   - Modified section 4 values (for GRIBEX)
+C     KSEC1   - Section 1 values (modified)
+C     KSEC2   - Section 2 values (modified)
+C     KSEC3   - Section 3 values (modified)
+C     KSEC4   - Section 4 values (modified)
 C
 C     Method
 C     ------
@@ -71,13 +73,13 @@ C
 C
 C     Function arguments
 C
-      INTEGER KSEC1, KSEC2, KSEC4
-      DIMENSION KSEC1(*), KSEC2(*), KSEC4(*)
+      INTEGER KSEC1(*), KSEC2(*), KSEC3(*), KSEC4(*)
 C
 C     Local variables
 C
       LOGICAL LIROTAT, LOROTAT
       INTEGER ILOOP, ITEMP
+      REAL RSEC2(JPGRIB_ISEC2)  ! (not an argument, not necessary ouside)
 C
 C***********************************************************************
 C     Section 1.   Startup.
@@ -166,9 +168,7 @@ C
 C
 C       Lots of zeroes
 C
-        DO 210 ILOOP = 22, 36
-          KSEC1(ILOOP) = 0
-  210   CONTINUE
+        KSEC1(22:36) = 0
 C
 C     Allow for user specified output field values when input is packed
 C
@@ -245,7 +245,6 @@ cs            IGSETUP = JPROUTINE + 2
 cs            GOTO 900
 cs          ENDIF
 cs        ENDIF
-
 C
 C       Number of points along a parallel
 C
@@ -300,12 +299,16 @@ C
         ELSE
           KSEC2(11) = NOSCNM
         ENDIF
-C
+
+
 C       i and j  direction increments
-C
-        KSEC2(9)  = (NOGRID(1) + (JPMICRO/2)) / JPMICRO
+C       EMOS-214: store REAL values in parallel data structure (real precision), for values that requiring sub-millidegree precision
+        KSEC2( 9) = (NOGRID(1) + (JPMICRO/2)) / JPMICRO
         KSEC2(10) = (NOGRID(2) + (JPMICRO/2)) / JPMICRO
-C
+        RSEC2( 9) =  NOGRID(1)/JPMULT
+        RSEC2(10) =  NOGRID(2)/JPMULT
+
+
 C       Following left same as for input product
 C       - no.of vertical coordinate parameters,
 C       - lat/long of southern pole of rotation
@@ -399,7 +402,7 @@ C
 C
 C       i direction increment
 C
-C       For a regular gaussian grid, only 
+C       For a regular gaussian grid, only
 C
         IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPFGGROT) ) THEN
           KSEC2(9) = (((JP90)/NOGAUSS)+(JPMICRO/2)) / JPMICRO
@@ -452,9 +455,9 @@ C       For reduced grid, move in number of points along each parallel
 C
           IF( (NOREPR.EQ.JPQUASI) .OR.
      X        (NOREPR.EQ.JPQGGROT) ) THEN
-          DO 325 ILOOP = 1, KSEC2(3)
+          DO ILOOP = 1, KSEC2(3)
             KSEC2(22+ILOOP) = NOLPTS(ILOOP+NO1NS-1)
- 325      CONTINUE
+          ENDDO
         ENDIF
 C
       ENDIF
@@ -568,7 +571,7 @@ C
       KSEC4(9)  = 0
       KSEC4(10) = 0
       KSEC4(11) = 0
-C     
+C
 C     Reserved words, set to 0
 C
       KSEC4(12) = 0
@@ -590,16 +593,12 @@ C       KSEC4(20), pentagonal resolution parameter M for packing of subset,
 C                  unchanged from input
 C
       ELSE
-        DO 410 ILOOP = 16, 20
-          KSEC4(ILOOP) = 0
- 410    CONTINUE
+        KSEC4(16:20) = 0
       ENDIF
 C
 C     Words 21-33 reserved, set to zero.
 C
-      DO 420 ILOOP = 21, 33
-        KSEC4(ILOOP) = 0
- 420  CONTINUE
+      KSEC4(21:33) = 0
 C
 C***********************************************************************
 C     Section 9.   Closedown
diff --git a/interpolation/igsize.F b/interpolation/igsize.F
index 9700e00..d3424e7 100644
--- a/interpolation/igsize.F
+++ b/interpolation/igsize.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -245,6 +245,7 @@ C
 C       Number of points along line is
 C
         KNWE = NINT( FLOAT(IREACH) / FLOAT(ILNSTR) )
+        IF( OWEGLOBE ) KNWE = 4*KGTRUNC
 C
       ELSE
 C
diff --git a/interpolation/igtog.F b/interpolation/igtog.F
index be66a0d..4ae3301 100644
--- a/interpolation/igtog.F
+++ b/interpolation/igtog.F
@@ -144,7 +144,6 @@ C
 C     Externals
 C
       LOGICAL FORCED_NEAREST_NEIGHBOUR
-      INTEGER IGTOGR
 C
 C     Statement function
 C
diff --git a/interpolation/igtogr.F b/interpolation/igtogr.F
deleted file mode 100644
index f400002..0000000
--- a/interpolation/igtogr.F
+++ /dev/null
@@ -1,253 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities
-C granted to it by virtue of its status as an intergovernmental organisation
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IGTOGR (PIFELDN, PIFELDS, KNINDEX, KSINDEX,
-     1   PWFACT, KOWE, POFELD, KPR, KERR)
-C
-C---->
-C**** *IGTOGR*
-C
-C     Purpose
-C     -------
-C
-C     Perform basic interpolation for one line of latitude of the
-C     output field using its two neighbouring input field lines of
-C     latitude.
-C
-C     Interface
-C     ---------
-C
-C     IERR = IGTOGR (PIFELDN, PIFELDS, KNINDEX, KSINDEX, PWFACT,
-C    1   KOWE, POFELD, KPR, KERR)
-C
-C     Input parameters
-C     ----------------
-C
-C     PIFELDN    - The line of latitude of the input field North of
-C                  the output row.
-C
-C     PIFELDS    - The line of latitude of the input field South of
-C                  the output row.
-C
-C     KNINDEX    - This array contains the array offsets of the West
-C                  and East points in the input array North of the
-C                  output row.
-C
-C     KSINDEX    - This array contains the array offsets of the West
-C                  and East points in the input array South of the
-C                  output row.
-C
-C     PWFACT     - The array of interpolating weights to the four
-C                  neighbouring points for every output point of this
-C                  line of latitude.
-C
-C     KOWE       - The number of points in the West-East direction in
-C                  the output field.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     -----------------
-C
-C     POFELD     - The interpolated output field line of latitude
-C                  returned to the calling routine.
-C
-C     Return value
-C     ------------
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     -------------------------------
-C
-C     None
-C
-C     Common block usage
-C     ------------------
-C
-C     None
-C
-C     Externals
-C     ---------
-C
-C     INTLOG - Logs messages
-C     FORCED_NEAREST_NEIGHBOUR - check forced interpolation method
-C
-C
-C     Method
-C     ------
-C
-C     This routine performs basic linear interpolation using the four
-C     neighbouring points in the input array to generate the output
-C     array.
-C
-C     The parameter list is designed to allow for quasi regular input
-C     fields with different grid spacing in the Northern and Southern
-C     lines of latitude.
-C
-C     Reference
-C     ---------
-C
-C     None
-C
-C     Comments
-C     --------
-C
-C     Program contains sections 0 to 2 and 9
-C
-C     Author
-C     ------
-C
-C     K. Fielding      *ECMWF*      Oct 1993
-C
-C     Modifications
-C     -------------
-C
-C     Allow for missing data values
-C     J.D.Chambers      ECMWF       August 2000
-C
-C     Force nearest neighbour processing with env variable or
-C     INTOUT parameter
-C     S.Curic           ECMWF       September 2005
-C
-C----<
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-C
-C     Function arguments
-C
-      INTEGER KOWE, KPR, KERR
-      INTEGER KNINDEX (2, KOWE), KSINDEX (2, KOWE)
-      REAL PIFELDN (*), PIFELDS (*), POFELD (KOWE)
-      REAL PWFACT (4, KOWE)
-C
-C     Local variables
-C
-      INTEGER JOLON, COUNT
-      REAL NEAREST
-      LOGICAL LVEGGY
-C
-C     Externals
-C
-      LOGICAL FORCED_NEAREST_NEIGHBOUR
-C
-C     Statement function
-C
-      REAL A, B
-      LOGICAL NOTEQ
-      NOTEQ(A,B) = (ABS((A)-(B)).GT.(ABS(A)*1E-3))
-C
-C     -----------------------------------------------------------------|
-C*    Section 1. Initialisation
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      IGTOGR = 0
-C
-      IF( KPR.GE.1 ) THEN
-         CALL INTLOG(JP_DEBUG,'IGTOGR: Section 1.',JPQUIET)
-         CALL INTLOG(JP_DEBUG,'IGTOGR: Input parameters.',JPQUIET)
-         CALL INTLOG(JP_DEBUG,
-     X     'IGTOGR:  Number of output field longitudes is -',KOWE)
-      ENDIF
-C
-C     Use nearest neighbour if required
-      LVEGGY = FORCED_NEAREST_NEIGHBOUR(LMETHOD,NITABLE,NIPARAM)
-      IF( LVEGGY ) CALL INTLOG(JP_DEBUG,
-     X  'IGTOGR: nearest neighbour processing',JPQUIET)
-C
-C     -----------------------------------------------------------------|
-C*    Section 2. Basic interpolation
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-      IF( KPR.GE.1 ) CALL INTLOG(JP_DEBUG,'IGTOGR: Section 2.',JPQUIET)
-C
-      DO JOLON = 1, KOWE
-C
-C       Count non-missing data values
-C
-        IF( LIMISSV ) THEN
-          COUNT = 0
-          IF( NOTEQ(PIFELDN(KNINDEX(JP_I_W,JOLON)),RMISSGV) )
-     X      COUNT = COUNT + 1
-          IF( NOTEQ(PIFELDN(KNINDEX(JP_I_E,JOLON)),RMISSGV) )
-     X      COUNT = COUNT + 1
-          IF( NOTEQ(PIFELDN(KSINDEX(JP_I_W,JOLON)),RMISSGV) )
-     X      COUNT = COUNT + 1
-          IF( NOTEQ(PIFELDN(KSINDEX(JP_I_E,JOLON)),RMISSGV) )
-     X      COUNT = COUNT + 1
-        ELSE
-          COUNT = 4
-        ENDIF
-C
-C       Interpolate using four neighbours if none are missing
-C
-        IF( (COUNT.EQ.4).AND.(.NOT.LVEGGY) ) THEN
-          POFELD(JOLON) =
-     X      PIFELDN(KNINDEX(JP_I_W,JOLON)) * PWFACT(JP_I_NW,JOLON) +
-     X      PIFELDN(KNINDEX(JP_I_E,JOLON)) * PWFACT(JP_I_NE,JOLON) +
-     X      PIFELDS(KSINDEX(JP_I_W,JOLON)) * PWFACT(JP_I_SW,JOLON) +
-     X      PIFELDS(KSINDEX(JP_I_E,JOLON)) * PWFACT(JP_I_SE,JOLON)
-C
-C       Set missing if all neighbours are missing
-C
-        ELSE IF( COUNT.EQ.0 ) THEN
-          POFELD(JOLON) = RMISSGV
-C
-C       Otherwise, use the nearest neighbour
-C
-        ELSE
-          NEAREST = PWFACT(JP_I_NW,JOLON)
-          POFELD(JOLON) = PIFELDN(KNINDEX(JP_I_W,JOLON))
-C
-          IF( PWFACT(JP_I_NE,JOLON).GT.NEAREST ) THEN
-            NEAREST = PWFACT(JP_I_NE,JOLON)
-            POFELD(JOLON) = PIFELDN(KNINDEX(JP_I_E,JOLON))
-          ENDIF
-C
-          IF( PWFACT(JP_I_SW,JOLON).GT.NEAREST ) THEN
-            NEAREST = PWFACT(JP_I_SW,JOLON)
-            POFELD(JOLON) = PIFELDS(KSINDEX(JP_I_W,JOLON))
-          ENDIF
-C
-          IF( PWFACT(JP_I_SE,JOLON).GT.NEAREST ) THEN
-            NEAREST = PWFACT(JP_I_SE,JOLON)
-            POFELD(JOLON) = PIFELDS(KSINDEX(JP_I_E,JOLON))
-          ENDIF
-        ENDIF
-C
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C*    Section 9. Return to calling routine. Format statements
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      IF( KPR.GE.1 ) CALL INTLOG(JP_DEBUG,'IGTOGR: Section 9.',JPQUIET)
-C
-      RETURN
-      END
-
diff --git a/interpolation/igtran.F b/interpolation/igtran.F
deleted file mode 100644
index db76b98..0000000
--- a/interpolation/igtran.F
+++ /dev/null
@@ -1,345 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IGTRAN (PMAT, KINCOL, KINROW, KMOVE, KLEN,
-     1   KPR, KERR)
-C
-C---->
-C**** *IGTRAN*
-C
-C     PURPOSE
-C     _______
-C
-C     This routine transposes a rectangular matrix.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IGTRAN (PMAT, KINCOL, KINROW, KMOVE, KLEN, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PMAT       - The input matrix of length KINCOL * KINROW.
-C
-C     KINCOL     - The length of the first dimension on entry and
-C                  second dimension on exit.
-C
-C     KINROW     - The length of the second dimension on entry and
-C                  first dimension on exit.
-C
-C     KMOVE      - Work array used to store information to speed up
-C                  the process.
-C
-C     KLEN       - Length of array KMOVE. The recommended length is
-C                  (KINCOL + KINROW) / 2.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  (No longer used, kept for backward compatibility.
-C                   Used to be used as follows:
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.)
-C
-C     Output parameters
-C     ________________
-C
-C     PMAT       - The transposed matrix.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     7401  KLEN was less than 1.
-C     7402  A failure during transposition (should never happen).
-C
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG     - Generate log messages.
-C
-C
-C     METHOD
-C     ______
-C
-C     This algorithm uses the cyclic structure of transposition to
-C     perform a transposition in place with a minimum amount of work
-C     storage.
-C
-C     REFERENCE
-C     _________
-C
-C     Esko G. Cate and David W. Twigg      Analysis of In-Situ
-C                                          Transposition
-C     CACM Algorithm 513
-C
-C
-C     COMMENTS
-C     ________
-C
-C     None.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Jan 1994
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers      ECMWF       Sept 1995
-C
-C----<
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Function arguments
-C
-      INTEGER KINCOL, KINROW, KLEN, KPR, KERR
-      INTEGER KMOVE(KLEN)
-      REAL PMAT (KINCOL * KINROW)
-C
-C     Local variables
-      INTEGER ICOUNT, IRMULC, IR0, IR1, IR2, IPOINT, IKMI, IP1, IP2,
-     X   IRMCM1, IP1C, IP2C, IROWP1, ICOLM1, ISTART
-      INTEGER JST, JINROW, JINCOL
-      REAL ZMIP1, ZMIP1C, ZTEMP
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 7400)
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGTRAN: Section 1.',JPQUIET)
-C
-      IGTRAN = 0
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IGTRAN: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IGTRAN: 1st matrix dimension = ',KINCOL)
-        CALL INTLOG(JP_DEBUG,'IGTRAN: 2nd matrix dimension = ',KINROW)
-        CALL INTLOG(JP_DEBUG,'IGTRAN: Work array length = ',KLEN)
-        CALL INTLOG(JP_DEBUG,
-     X    'IGTRAN: Recommended length = ',(KINCOL + KINROW) / 2)
-      ENDIF
-C
-      IF (KINCOL .LE. 1 .OR. KINROW .LE. 1) GO TO 900
-C
-C     _______________________________________________________
-C
-C*    Section 2. Rectangular transposition setup
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGTRAN: Section 2.',JPQUIET)
-C
-      IF (KINCOL .NE. KINROW) THEN
-C
-        IF (KLEN .LT. 1) THEN
-          IGTRAN = JPROUTINE + 1
-          CALL INTLOG(JP_ERROR,'IGTRAN: Work array size = ',KLEN)
-          CALL INTLOG(JP_ERROR,'IGTRAN: Must be at least 1.',JPQUIET)
-          GO TO 900
-        ENDIF
-C
-        ICOUNT = 2
-        IRMULC = KINCOL * KINROW
-        IRMCM1 = IRMULC - 1
-C
-        DO 210 JST = 1, KLEN
-          KMOVE (JST) = 0
-  210   CONTINUE
-C
-        IF (KINCOL .GT. 2 .AND. KINROW .GT. 2) THEN
-C
-C         Calculate the number of fixed points, Euclids algorithm
-C         for GCD (m - 1, n - 1)
-C
-          IR2 = KINCOL - 1
-          IR1 = KINROW - 1
-C
-  220     CONTINUE
-          IR0 = MOD (IR2, IR1)
-          IR2 = IR1
-          IR1 = IR0
-          IF (IR0 .NE. 0) GO TO 220
-C
-          ICOUNT = ICOUNT + IR2 - 1
-C
-        ENDIF
-C
-C       Set initial values for search
-C
-        ISTART = 1
-        IPOINT = KINCOL
-C
-C       At least one loop must be rearranged so branch into loop
-C
-        GO TO 330
-C
-C     _______________________________________________________
-C
-C*    Section 3. Rectangular transposition main loop
-C     _______________________________________________________
-C
-  310   CONTINUE
-C
-C       Search for loops to rearrange
-C
-        IKMI = IRMCM1 - ISTART
-        ISTART = ISTART + 1
-C
-        IF (ISTART .GT. IKMI) THEN
-          IGTRAN = JPROUTINE + 2
-          CALL INTLOG(JP_ERROR,
-     X        'IGTRAN: Fail during transposition.',JPQUIET)
-          GO TO 900
-        ENDIF
-C
-        IPOINT = IPOINT + KINCOL
-C
-        IF (IPOINT .GT. IRMCM1) IPOINT = IPOINT - IRMCM1
-C
-        IP2 = IPOINT
-C
-        IF (ISTART .EQ. IP2) GO TO 310
-C
-        IF (ISTART .GT. KLEN) THEN
-C
-  320     CONTINUE
-C
-C         Loop exit condition
-C
-          IF (IP2 .LE. ISTART .OR. IP2 .GE. IKMI)  THEN
-            IF (IP2 .NE. ISTART) THEN
-              GO TO 310
-            ELSE
-              GO TO 330
-            ENDIF
-          ENDIF
-          IP1 = IP2
-          IP2 = KINCOL * IP1 - IRMCM1 * (IP1 / KINROW)
-          GO TO 320
-        ENDIF
-C
-        IF (KMOVE (ISTART) .NE. 0) GO TO 310
-C
-C       Rearrange the elements of a loop and its companion loop
-C
-C       Entry into loop on first pass
-C
-  330   CONTINUE
-C
-        IP1 = ISTART
-        IKMI = IRMCM1 - ISTART
-        ZMIP1 = PMAT (IP1 + 1)
-        IP1C = IKMI
-        ZMIP1C = PMAT (IP1C + 1)
-C
-  340   CONTINUE
-        IP2 = KINCOL * IP1 - IRMCM1 * (IP1 / KINROW)
-        IP2C = IRMCM1 - IP2
-C
-        IF (IP1 .LE. KLEN) KMOVE (IP1) = 2
-        IF (IP1C .LE. KLEN) KMOVE (IP1C) = 2
-C
-        ICOUNT = ICOUNT + 2
-C
-C       Loop exit conditions
-C
-        IF (IP2 .EQ. ISTART) GO TO 360
-        IF (IP2 .EQ. IKMI) GO TO 350
-C
-        PMAT (IP1 + 1) = PMAT(IP2 + 1)
-        PMAT (IP1C + 1) = PMAT(IP2C + 1)
-        IP1 = IP2
-        IP1C = IP2C
-C
-        GO TO 340
-C
-  350   CONTINUE
-C
-        ZTEMP = ZMIP1
-        ZMIP1 = ZMIP1C
-        ZMIP1C = ZTEMP
-C
-  360   CONTINUE
-C
-        PMAT (IP1 + 1) = ZMIP1
-        PMAT (IP1C + 1) = ZMIP1C
-C
-        IF (ICOUNT .LT. IRMULC) GO TO 310
-C
-      ELSE
-C
-C     _______________________________________________________
-C
-C*    Section 4. Square transposition
-C     _______________________________________________________
-C
-  400 CONTINUE
-C
-        IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGTRAN: Section 4.',JPQUIET)
-C
-C       Square matrix so exchange elements a(i,j) and a(j,i)
-C
-        ICOLM1 = KINCOL - 1
-C
-        DO 420 JINCOL = 1, ICOLM1
-C
-          IROWP1 = JINCOL + 1
-C
-          DO 410 JINROW = IROWP1, KINROW
-C
-            IP1 = JINCOL + (JINROW - 1) * KINCOL
-            IP2 = JINROW + (JINCOL - 1) * KINROW
-C
-            ZTEMP = PMAT (IP1)
-            PMAT (IP1) = PMAT (IP2)
-            PMAT (IP2) = ZTEMP
-C
-  410     CONTINUE
-  420   CONTINUE
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IGTRAN: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/init_cm.F b/interpolation/init_cm.F
deleted file mode 100644
index bff9b77..0000000
--- a/interpolation/init_cm.F
+++ /dev/null
@@ -1,309 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INIT_CM( KPARAM, KVAL )
-C---->
-C**** INIT_CM
-C
-C     Purpose
-C     -------
-C
-C     Initialise common block values used by interpolation.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INIT_CM( KPARAM, KVAL )
-C
-C     Input
-C     -----
-C
-C     KPARAM - Flag indicating common block element to update.
-C     KVAL   - Value for element.
-C
-C
-C     Output
-C     ------
-C
-C     Common block entry updated.
-C
-C
-C     Method
-C     ------
-C
-C     1      NIFORM
-C     2      NOFORM
-C     3      NITABLE
-C     4      NIPARAM
-C     5      NIRESO
-C     6      NORESO
-C     7      NOACC
-C     8      NIGRID(1)
-C     9      NIGRID(2)
-C     10     NOGRID(1)
-C     11     NOGRID(2)
-C     12     NIGAUSS, RIGAUSS, MILLEN, NINS, NIGAUSO, HIGAUST
-C     13     NOGAUSS, ROGAUSS, NOLPTS, NONS, NOGAUSO, HOGAUST
-C     14     NIAREA(1)
-C     15     NIAREA(2)
-C     16     NIAREA(3)
-C     17     NIAREA(4)
-C     18     NOAREA(1)
-C     19     NOAREA(2)
-C     20     NOAREA(3)
-C     21     NOAREA(4)
-C     22     NISCNM
-C     23     NOSCNM
-C     24     LSM
-C     25     LWIND
-C     26     LPREC
-C     27     RIGAUSS, MILLEN, NINS, NIGAUSO, HIGAUST
-C     28     ROGAUSS, NOLPTS, NONS, NOGAUSO, HOGAUST
-C     29     LSMPAR
-C
-C     99     Display current values in common block.
-C
-C
-C     Externals
-C     ---------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-C
-      INTEGER KPARAM, KVAL
-C
-C     Local variables
-C
-      INTEGER IRET, LOOP
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "current.h"
-C
-      INIT_CM = 0
-C
-      IF ( KPARAM .EQ.1 ) NIFORM = KVAL
-C
-      IF ( KPARAM .EQ.2 ) NOFORM = KVAL
-C
-      IF ( KPARAM .EQ.3 ) NITABLE = KVAL
-C
-      IF ( KPARAM .EQ.4 ) NIPARAM = KVAL
-C
-      IF ( KPARAM .EQ.5 ) NIRESO = KVAL
-C
-      IF ( KPARAM .EQ.6 ) NORESO = KVAL
-C
-      IF ( KPARAM .EQ.7 ) NOACC = KVAL
-C
-      IF ( KPARAM .EQ.8 ) NIGRID(1) = KVAL
-C
-      IF ( KPARAM .EQ.9 ) NIGRID(2) = KVAL
-C
-      IF ( KPARAM .EQ.10) NOGRID(1) = KVAL
-C
-      IF ( KPARAM .EQ.11) NOGRID(2) = KVAL
-C
-      IF ( KPARAM .EQ.12) THEN
-        NIGAUSS = KVAL
-        IF( (NIGAUSO.NE.NIGAUSS).OR.(HIGAUST.NE.'F') ) THEN
-          CALL JGETGG( NIGAUSS, 'F', RIGAUSS, MILLEN, IRET)
-          IF ( IRET .NE. 0 ) THEN
-            WRITE(*,*) 'INIT_CM: JGETGG failed for NIGAUSS'
-            INIT_CM = IRET
-            GOTO 900
-          ENDIF
-          NINS = 2*NIGAUSS
-          NIGAUSO = NIGAUSS
-          HIGAUST = 'F'
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.13) THEN
-        NOGAUSS = KVAL
-        IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-          CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
-          IF ( IRET .NE. 0 ) THEN
-            WRITE(*,*) 'INIT_CM: JGETGG failed for NOGAUSS'
-            INIT_CM = IRET
-            GOTO 900
-          ENDIF
-          NONS = 2*NOGAUSS
-          NOGAUSO = NOGAUSS
-          HOGAUST = 'F'
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.14) NIAREA(1) = KVAL
-C
-      IF ( KPARAM .EQ.15) NIAREA(2) = KVAL
-C
-      IF ( KPARAM .EQ.16) NIAREA(3) = KVAL
-C
-      IF ( KPARAM .EQ.17) NIAREA(4) = KVAL
-C
-      IF ( KPARAM .EQ.18) NOAREA(1) = KVAL
-C
-      IF ( KPARAM .EQ.19) NOAREA(2) = KVAL
-C
-      IF ( KPARAM .EQ.20) NOAREA(3) = KVAL
-C
-      IF ( KPARAM .EQ.21) NOAREA(4) = KVAL
-C
-      IF ( KPARAM .EQ.22) NISCNM    = KVAL
-C
-      IF ( KPARAM .EQ.23) NOSCNM    = KVAL
-C
-      IF ( KPARAM .EQ.24) THEN
-        IF ( KVAL .EQ. 1) THEN
-          LSM       = .TRUE.
-        ELSE
-          LSM       = .FALSE.
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.25) THEN
-        IF ( KVAL .EQ. 1) THEN
-          LWIND     = .TRUE.
-        ELSE
-          LWIND     = .FALSE.
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.26) THEN
-        IF ( KVAL .EQ. 1) THEN
-          LPREC     = .TRUE.
-        ELSE
-          LPREC     = .FALSE.
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.27) THEN
-        IF ( KVAL .EQ. 1) THEN
-          IF( (NIGAUSO.NE.NIGAUSS).OR.(HIGAUST.NE.'R') ) THEN
-            CALL JGETGG( NIGAUSS, 'R', RIGAUSS, MILLEN, IRET)
-            IF ( IRET .NE. 0 ) THEN
-              WRITE(*,*) 'INIT_CM: JGETGG failed for NIGAUSS'
-              INIT_CM = IRET
-              GOTO 900
-            ENDIF
-            NINS = 2*NIGAUSS
-            NIGAUSO = NIGAUSS
-            HIGAUST = 'R'
-          ENDIF
-        ELSE
-          WRITE(*,*) 'No user input supported for reduced gaussian grid'
-          INIT_CM = 999
-          GOTO 900
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.28) THEN
-        IF ( KVAL .EQ. 1) THEN
-          IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'R') ) THEN
-            CALL JGETGG( NOGAUSS, 'R', ROGAUSS, NOLPTS, IRET)
-            IF ( IRET .NE. 0 ) THEN
-              WRITE(*,*) 'INIT_CM: JGETGG failed for NIGAUSS'
-              INIT_CM = IRET
-              GOTO 900
-            ENDIF
-            NONS = 2*NOGAUSS
-            NOGAUSO = NOGAUSS
-            HOGAUST = 'R'
-          ENDIF
-        ELSE
-          WRITE(*,*) 'No user input supported for reduced gaussian grid'
-          INIT_CM = 999
-          GOTO 900
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.29) THEN
-        IF ( KVAL .EQ. 1) THEN
-          LSMPAR    = .TRUE.
-        ELSE
-          LSMPAR    = .FALSE.
-        ENDIF
-      ENDIF
-C
-      IF ( KPARAM .EQ.99) THEN
-        WRITE(*,*) ' LCHANGE   = ', LCHANGE
-        WRITE(*,*) ' LSMCHNG   = ', LSMCHNG
-        WRITE(*,*) ' LSMSET    = ', LSMSET
-        WRITE(*,*) ' LSMPARSET = ', LSMPARSET
-        WRITE(*,*) ' LPRECSET  = ', LPRECSET
-        WRITE(*,*) ' LWINDSET  = ', LWINDSET
-        WRITE(*,*) ' NINS      = ', NINS
-        WRITE(*,*) ' NIWE      = ', NIWE
-        WRITE(*,*) ' NO1NS     = ', NO1NS
-        WRITE(*,*) ' NO1WE     = ', NO1WE
-        WRITE(*,*) ' NONS      = ', NONS
-        WRITE(*,*) ' NOWE      = ', NOWE
-C
-        WRITE(*,*) ' NIFORM    = ', NIFORM
-        WRITE(*,*) ' NOFORM    = ', NOFORM
-        WRITE(*,*) ' NITABLE   = ', NITABLE
-        WRITE(*,*) ' NIPARAM   = ', NIPARAM
-        WRITE(*,*) ' NIRESO    = ', NIRESO
-        WRITE(*,*) ' NORESO    = ', NORESO
-        WRITE(*,*) ' LNORESO   = ', LNORESO
-        WRITE(*,*) ' NOACC     = ', NOACC 
-        WRITE(*,*) ' LNOACC    = ', LNOACC 
-        WRITE(*,*) ' NIGRID(1) = ', NIGRID(1)
-        WRITE(*,*) ' NIGRID(2) = ', NIGRID(2)
-        WRITE(*,*) ' NOGRID(1) = ', NOGRID(1)
-        WRITE(*,*) ' NOGRID(2) = ', NOGRID(2)
-        WRITE(*,*) ' NIGAUSS   = ', NIGAUSS
-        WRITE(*,*) ' NOGAUSS   = ', NOGAUSS
-        WRITE(*,*) ' LNOGAUS   = ', LNOGAUS
-        WRITE(*,*) ' NIAREA(1) = ', NIAREA(1)
-        WRITE(*,*) ' NIAREA(2) = ', NIAREA(2)
-        WRITE(*,*) ' NIAREA(3) = ', NIAREA(3)
-        WRITE(*,*) ' NIAREA(4) = ', NIAREA(4)
-        WRITE(*,*) ' NOAREA(1) = ', NOAREA(1)
-        WRITE(*,*) ' NOAREA(2) = ', NOAREA(2)
-        WRITE(*,*) ' NOAREA(3) = ', NOAREA(3)
-        WRITE(*,*) ' NOAREA(4) = ', NOAREA(4)
-        WRITE(*,*) ' NISCNM    = ', NISCNM   
-        WRITE(*,*) ' NOSCNM    = ', NOSCNM   
-        WRITE(*,*) ' LSM       = ', LSM      
-        WRITE(*,*) ' LWIND     = ', LWIND    
-        WRITE(*,*) ' LPREC     = ', LPREC    
-        WRITE(*,*) ' LSMPAR    = ', LSMPAR   
-      ENDIF
-C
-      IF ( KPARAM .GT.99) THEN
-        DO 110 LOOP = 1, NINS
-          WRITE(*,*) ' RIGAUSS(',LOOP,'), MILLEN(',LOOP,')=',
-     X                 RIGAUSS(LOOP), MILLEN(LOOP)
-  110   CONTINUE
-        DO 120 LOOP = 1, NONS
-          WRITE(*,*) ' ROGAUSS(',LOOP,'), NOLPTS(',LOOP,')=',
-     X                 ROGAUSS(LOOP), NOLPTS(LOOP)
-  120   CONTINUE
-      ENDIF
-C
- 900  CONTINUE
-      RETURN
-      END
diff --git a/interpolation/insane.F b/interpolation/insane.F
index 501a402..36cc812 100644
--- a/interpolation/insane.F
+++ b/interpolation/insane.F
@@ -246,7 +246,7 @@ C
 C
 C         Not too small
 C
-C if env variable 1 no check of incterval
+C if env variable 1 no check of interval
       LNLIMIT = .TRUE.
       CALL GETENV('INCREMENT_NO_LIMIT', YFLAG)
       IF(YFLAG1(1:1).EQ.'1' ) LNLIMIT = .FALSE.
@@ -421,6 +421,19 @@ C
         GOTO 900
       ENDIF
 C
+C     Subarea not supported for reduced lat/lon to reduced lat/lon
+C
+      IF( LNOAREA.AND.
+     X    ((NIREPR.EQ.JPREDLL).AND.(NOREPR.EQ.JPREDLL)) ) THEN
+        IERR   = JPROUTINE + 46
+        CALL INTLOG(JP_ERROR,
+     X    'Sorry!: Subarea not supported for reduced lat/lon '//
+     X    'to reduced lat/lon grids',
+     X    JPQUIET)
+        INSANE = IERR
+        GOTO 900
+      ENDIF
+C
 C     -----------------------------------------------------------------|
 C*    Section 5.   Check legal gaussian grid definition.
 C     -----------------------------------------------------------------|
@@ -477,14 +490,6 @@ C
      X      ((NIREPR.NE.JPSPHERE)  .AND.
      X       (NIREPR.NE.JPGAUSSIAN).AND.
      X       (NIREPR.NE.JPQUASI)) ) THEN
-Cjdc      CALL INTLOG(JP_ERROR,
-Cjdc X      'Sorry!: Only allowed rotations are:',JPQUIET)
-Cjdc      CALL INTLOG(JP_ERROR,
-Cjdc X      '        spectral to regular lat/long, or',JPQUIET)
-Cjdc      CALL INTLOG(JP_ERROR,
-Cjdc X      '        regular gaussian to regular lat/long',JPQUIET)
-Cjdc      CALL INTLOG(JP_ERROR,
-Cjdc X      '        reduced gaussian to regular lat/long',JPQUIET)
           INSANE = JPROUTINE + 61
           GOTO 900
         ENDIF
diff --git a/interpolation/intf.F b/interpolation/intf.F
index 000cdd6..a67a852 100644
--- a/interpolation/intf.F
+++ b/interpolation/intf.F
@@ -101,24 +101,14 @@ C
       DIMENSION IIHOLD(4), IOHOLD(4)
       INTEGER NUMTABL, NUMPROD
       LOGICAL L98WAVE, LUNROT
-      LOGICAL LIQUASI
-      CHARACTER*6 YFLAG
-      INTEGER IOS
-      INTEGER LENMED, ISIZE
+      CHARACTER*1 HTYPE
 C
 C     Externals
 C
       INTEGER IBASINI, PDDEFS, INSANE
       INTEGER INTFAU, INTFAP, INTFB, HNTFAU, HNTFAP
-      INTEGER INTWAVE2,INTWAVE,INTWAVU, OCEANP, OCEANU, RESET_C
-      INTEGER FIXAREA
+      INTEGER INTWAVE2, INTWAVU, OCEANP, OCEANU, RESET_C !, INTWAVE
       LOGICAL PRECIP
-
-#ifdef POINTER_64
-      INTEGER*8 JMALLOC
-#else
-      INTEGER JMALLOC
-#endif
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -222,7 +212,8 @@ cs    this is for merging with grib_api
         LUVCOMP = .FALSE.
         IF( NOREPR.EQ.JPNOTYPE ) THEN
          IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-            CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
+            HTYPE = 'F'
+            CALL JGETGG(NOGAUSS,HTYPE,ROGAUSS,NOLPTS,IRET)
             IF( IRET.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,
      X          'INTF: JGETGG failed, NOGAUSS = ',NOGAUSS)
@@ -230,7 +221,7 @@ cs    this is for merging with grib_api
               GOTO 900
             ENDIF
             NOGAUSO = NOGAUSS
-            HOGAUST = 'F'
+            HOGAUST = HTYPE
           ENDIF
           NOREPR = JPGAUSSIAN
         ENDIF
diff --git a/interpolation/intf2.c b/interpolation/intf2.c
new file mode 100644
index 0000000..53f6951
--- /dev/null
+++ b/interpolation/intf2.c
@@ -0,0 +1,321 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+
+
+#include "grib_api.h"
+#include "emos.h"
+
+fortint intf2_(char* grib_in, fortint* length_in, char* grib_out, fortint* length_out)
+{
+    fortint isec1[ISECTION_1] = {0,};
+    fortint isec2[ISECTION_2] = {0,};
+    fortint isec3[ISECTION_3] = {0,};
+    fortint isec4[ISECTION_4] = {0,};
+
+    static double *values_in = NULL;
+    static double *values_out = NULL;
+    static size_t values_in_len = 0;
+    static size_t values_out_len = 0;
+    double *values =NULL;
+
+    static float *values_in1 = NULL;
+    static float *values_out1 = NULL;
+    static size_t values_in_len1 = 0;
+    static size_t values_out_len1 = 0;
+
+    size_t ii = 0;
+    size_t inlen;
+    size_t len=0;
+    size_t outlen = *length_out;
+    size_t outlen_grib_message = 0;
+
+    fortint out_length = 0;
+
+    long long_length_in = *length_in;
+    fortint fortint_inlen = *length_in;
+    fortint fortint_outlen = outlen;
+
+    grib_handle *handle = 0;
+    grib_handle *outh   = 0;
+    grib_handle *finalh = 0;
+
+    fortint err1 = 0, mars_interpolation = 0;
+    int err = 0 , what = 0;
+    int  resetOutput = 0;
+    long nins, niwe;
+    long acc = 0;
+    long bitmapPresent = 0;
+
+    size_t size;
+
+    const void* temp;
+    char *intf2_debug = getenv("INTF2_DEBUG");
+    char *intf2_write = getenv("INTF2_WRITE_TO_FILE");
+    int jpeg = 0;
+    int set_spec_flags=0;
+    grib_util_grid_spec     spec={0,};
+    grib_util_packing_spec packing_spec={0,};
+
+    mars_interpolation = int2_chkout();
+
+    if(!mars_interpolation)
+    {
+        *length_out = 0;
+        if(intf2_debug){
+            printf("INTF2: There is NOT users settings \n");
+            printf("INTF2: No Interpolation carried out \n");
+        }
+        return err;
+    }
+
+    fortint outputRepresentation = int2_outrep();
+
+    if(intf2_debug)
+    {
+        if(outputRepresentation)
+            printf("INTF2:  Output Representation is NOT set by user\n");
+    }
+
+    handle = grib_handle_new_from_message(0,grib_in,long_length_in);
+    if(handle == 0) {
+        err = -1;
+        fprintf(stdout,"INTF2: Cannot create Handle %ld\n",err);
+        /* intlog2("INTF2: Cannot create Handle"); */
+        goto cleanup;
+    }
+
+    if( err = grib_get_size(handle,"values",&inlen))
+    {
+        fprintf(stdout,"INTF2: Cannot get size %s\n",grib_get_error_message(err));
+        return err;
+    }
+
+    if(inlen > values_in_len)
+    {
+        if(values_in) free(values_in);
+        values_in = (double*)malloc(sizeof(double)*inlen);
+        values_in_len = inlen;
+
+        if(!values_in)
+        {
+            err = -1;
+            fprintf(stdout,"INTF2: Cannot allocate %ld\n",inlen);
+            goto cleanup;
+        }
+    }
+
+   /* If bitmap Present  */
+    if((err = grib_get_long(handle,"bitmapPresent",&bitmapPresent))!= GRIB_SUCCESS)
+     {
+        fprintf(stderr,"Cannot get bitmapPresent  %s\n",grib_get_error_message(err));
+        return err;
+     }
+
+    /* if bitmap present Set missing value which correspond WAVE in Emos  */
+    if(bitmapPresent)
+    {
+        /* if(err = grib_set_double(handle,"missingValue",12345.0)) */
+        if(err = grib_set_double(handle,"missingValue",-9999999.0))
+        {
+            fprintf(stdout,"INTF2: Cannot set Missing Value %s\n",grib_get_error_message(err));
+            goto cleanup;
+        }
+    }
+
+    /* Get decoded values */
+    if(err = grib_get_double_array(handle,"values",values_in,&inlen))
+    {
+        fprintf(stdout,"INTF2: Cannot get decoded values %s\n",grib_get_error_message(err));
+        goto cleanup;
+    }
+
+
+    /* Descibe input field and initial settings for output field */
+    if(err = describe_input_field(handle,outputRepresentation))
+    {
+        fprintf(stdout,"INTF2 describe_input_field failed : %d\n",err);
+        goto cleanup;
+    }
+
+
+    /*=============  INTF ====================================*/
+
+    if(outputRepresentation){
+        out_length = inlen;
+    }
+    else{
+        out_length = int2_estima();
+        if(!out_length){
+            fprintf(stdout,"INTF2: Estimate for length of output array is 0 \n");
+            err = -1;
+            goto cleanup;
+        }
+    }
+    if(out_length > values_out_len)
+    {
+        if(values_out) free(values_out);
+        values_out = (double*)malloc(sizeof(double)*out_length);
+        values_out_len = out_length;
+
+        if(!values_out)
+        {
+            fprintf(stdout,"INTF2: Cannot allocate values_out %ld\n",out_length);
+            err = -1;
+            goto cleanup;
+        }
+    }
+
+    fortint_inlen = inlen;
+    fortint_outlen = outlen;
+
+
+#ifdef REAL_8
+    if(err = int2_intf(values_in,fortint_inlen,values_out,&fortint_outlen))
+    {
+        fprintf(stdout,"INTF failed %d\n",err);
+        goto cleanup;
+    }
+#else
+    if(inlen > values_in_len1)
+    {
+        if(values_in1) free(values_in1);
+        values_in1 = (float*)malloc(sizeof(float)*inlen);
+        values_in_len1 = inlen;
+
+        if(!values_in1)
+        {
+            err = -1;
+            fprintf(stdout,"INTF2: Cannot allocate values_in1 %ld\n",inlen);
+            goto cleanup;
+        }
+    }
+    if(out_length > values_out_len1)
+    {
+        if(values_out1) free(values_out1);
+        values_out1 = (float*)malloc(sizeof(float)*out_length);
+        values_out_len1 = out_length;
+
+        if(!values_out1)
+        {
+            fprintf(stdout,"INTF2: Cannot allocate values_out1 %ld\n",out_length);
+            err = -1;
+            goto cleanup;
+        }
+    }
+    for( ii = 0 ; ii < fortint_inlen; ii++){
+        values_in1[ii] = values_in[ii];
+    }
+    if(err = int2_intf(values_in1,fortint_inlen,values_out1,&fortint_outlen))
+    {
+        fprintf(stdout,"INTF failed %d\n",err);
+        goto cleanup;
+    }
+    for( ii = 0 ; ii < fortint_outlen; ii++){
+        values_out[ii] = values_out1[ii];
+    }
+#endif
+    outlen = fortint_outlen;
+
+    if(intf2_debug) {
+        printf("INTF2: Outlen: %d  \n",outlen);
+    }
+
+    err=copy_spec_from_ksec(&spec,&packing_spec);
+    if (err) {
+        fprintf(stdout,"INTF2: ERROR - copy_grid_spec_from_ksec unable to copy spec: %d\n", err);
+        goto cleanup;
+    }
+
+    packing_spec.accuracy=GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
+    packing_spec.packing=GRIB_UTIL_PACKING_USE_PROVIDED;
+
+    if(outlen == 0) {
+        set_spec_flags |= GRIB_UTIL_SET_SPEC_FLAGS_ONLY_PACKING;
+        /* Sinisa and Enrico 7/3/11 comments this line */
+        /* packing_spec.packing=0; */
+        len=inlen;
+        values=values_in;
+        if(intf2_debug )
+            printf("INTF2: Outlen = 0 No Interpolation carried out \n");
+    } else {
+        len=outlen;
+        values=values_out;
+    }
+#ifdef DUMPING_GRIB_HANDLE
+{
+    const int dump_flags = GRIB_DUMP_FLAG_VALUES
+                |  GRIB_DUMP_FLAG_READ_ONLY
+                |  GRIB_DUMP_FLAG_ALIASES
+                |  GRIB_DUMP_FLAG_TYPE;
+    printf("intf2_ start dump...................\n");
+    grib_dump_content(handle, stdout,"debug", dump_flags, NULL);
+    printf("intf2_ end dump.....................\n");
+}
+#endif
+    finalh = grib_util_set_spec(handle,&spec, &packing_spec, set_spec_flags,values, len, &err);
+    if(!finalh)  {
+        fprintf(stdout,"INTF2: ERROR - grib_util_set_spec: %d\n", err);
+        if(!err) err = 1;
+        goto cleanup;
+    }
+
+    /* deallocate pl array, if it has been passed into spec */
+    if (spec.pl!=NULL) {
+        free((long*) spec.pl);
+        spec.pl = NULL;
+    }
+
+    if (outlen == 0){
+        if(err == -1) {
+            /* -1 coming from grib_util when there is not packing */
+            err = 0;
+            *length_out = 0;
+            if(intf2_debug)
+                printf("INTF2: No Interpolation carried out, nothing repacked \n");
+            goto cleanup;
+        }
+    }
+
+    err = grib_get_message(finalh,&temp,&outlen_grib_message);
+    if(err!=0) {
+        fprintf(stdout,"INTF2: ERROR - grib_get_message unable to generate message: %d\n", err);
+        goto cleanup;
+    }
+
+    if(outlen_grib_message > *length_out) {
+        fprintf(stdout,"INTF2: ERROR - INTF2  OUTLEN is too large: %ld > %ld\n", outlen_grib_message, *length_out);
+        err = 1;
+        goto cleanup;
+    }
+
+    memcpy(grib_out,temp,outlen_grib_message);
+
+    *length_out = outlen_grib_message;
+
+    /* goto cleanup; */
+    if(intf2_debug && (set_spec_flags & GRIB_UTIL_SET_SPEC_FLAGS_ONLY_PACKING)){
+        printf("INTF2: No Interpolation carried out but data repacked \n");
+    }
+
+
+cleanup:
+    if(resetOutput = int2_setrep(outputRepresentation)) printf("INTF2: Output Representation reset failed:  %d \n",resetOutput);
+    if(handle)     {grib_handle_delete(handle);handle=NULL;}
+    if(outh)       {grib_handle_delete(outh);outh=NULL;}
+    if(outlen!=0 && finalh)     grib_handle_delete(finalh);
+
+    return err;
+}
+
+fortint intf2(char* grib_in, fortint* length_in, char* grib_out, fortint* length_out)
+{
+    return intf2_(grib_in,length_in,grib_out,length_out);
+}
diff --git a/interpolation/intfa.F b/interpolation/intfa.F
deleted file mode 100644
index 562774d..0000000
--- a/interpolation/intfa.F
+++ /dev/null
@@ -1,182 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTFA( INGRIB,INLEN,FLDIN,OUTGRIB,OUTLEN,FLDOUT)
-C
-C---->
-C**** INTFA
-C
-C     Purpose
-C     -------
-C
-C     Prepare to interpolate input field...
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INTFA( INGRIB,INLEN,FLDIN,OUTGRIB,OUTLEN,FLDOUT)
-C
-C     Input
-C     -----
-C
-C     INGRIB - Input field (packed).
-C     INLEN  - Input field length (words).
-C     FLDIN  - Input field (unpacked).
-C
-C
-C     Output
-C     ------
-C
-C     OUTGRIB - Output field (packed).
-C     OUTLEN  - Output field length (words).
-C     FLDOUT  - Output field (unpacked).
-C
-C
-C     Method
-C     ------
-C
-C     Unpack field if GRIB).
-C
-C
-C     Externals
-C     ---------
-C
-C     IBASINI - Ensure basic interpolation setup is done.
-C     GRIBEX  - Decode/encode GRIB product.
-C     GRSVCK  - Turn off GRIB checking
-C     RESET_C - Reset interpolation handling options using GRIB product.
-C     PDDEFS  - Setup interpolation using parameter dependent options.
-C     INTLOG  - Log error message.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Jan 1995
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-      INTEGER INGRIB(*),OUTGRIB(*),INLEN,OUTLEN
-      REAL FLDIN(*),FLDOUT(*)
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "intf.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 26100 )
-C
-C     Local variables
-C
-      INTEGER IWORD, IERR
-      INTEGER KPR
-      INTEGER LOOP
-C
-C     Externals
-      INTEGER IBASINI, RESET_C, PDDEFS
-C
-C ------------------------------------------------------------------
-C*    Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-      INTFA = 0
-      IERR = 0
-      KPR = 0
-C
-C     Check that basic initialisation has been done
-      IERR = IBASINI(0)
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTFA: basic initialisation fail',JPQUIET)
-        INTFA = IERR
-        GOTO 900
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 2.   Decode data from the GRIB code
-C ------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-C     Allocate work array ZNFELDI if not already done.
-C
-      IF( IZNJDCI.NE.1952999238 ) THEN
-        CALL JMEMHAN( 19, IZNFLDI, JPEXPAND, 1, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_WARN,'INTFA: ZNFELDI allocation fail',JPQUIET)
-          INTFA = IERR
-          GOTO 900
-        ENDIF
-        IZNJDCI = 1952999238
-      ENDIF
-C
-C     If input is a GRIB product
-      If (NIFORM .EQ. 1) THEN
-C
-C       Decode data from GRIB code (no checking)
-C
-        IWORD = INLEN
-        IERR  =  0
-        CALL GRSVCK(0)
-        IERR = 1
-        ISEC3(2) = NINT(RMISSGV)
-        ZSEC3(2) = RMISSGV
-        CALL GRIBEX(ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X              ZNFELDI, JPEXPAND, INGRIB, INLEN, IWORD, 'D',IERR)
-        IF ( IERR .NE. 0) THEN
-          CALL INTLOG(JP_ERROR, 'INTFA: GRIBEX decoding failed.',IERR)
-          INTFA = IERR
-          GOTO 900
-        ENDIF
-C
-C       Setup interpolation options from GRIB product characteristics
-        IERR = RESET_C( ISEC1, ISEC2, ZSEC2, ISEC4)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTFA: Setup interp. options from GRIB failed.',JPQUIET)
-          INTFA = IERR
-          GOTO 900
-        ENDIF
-C
-C     Otherwise, move unpacked values in from user array
-      ELSE
-        DO 210 LOOP = 1, INLEN
-          ZNFELDI( LOOP ) = FLDIN( LOOP )
- 210    CONTINUE
-C
-      ENDIF
-C
-C     Setup interpolation options based on parameter in field.
-      IERR = PDDEFS()
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTFA: Setup interp. options from parameter failed.',JPQUIET)
-        INTFA = IERR
-        GOTO 900
-      ENDIF
-C
-C
-C ------------------------------------------------------------------
-C*    Section 9.   Closedown.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing
-C
-      RETURN
-      END
diff --git a/interpolation/intfap.F b/interpolation/intfap.F
index 731fdce..d12e5b7 100644
--- a/interpolation/intfap.F
+++ b/interpolation/intfap.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -114,7 +114,7 @@ C
 C     Local variables
 C
       REAL POLELAT, POLELON
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
       INTEGER NUMPTS, NGAUSS
       INTEGER IWORD, IERR, KPR, NBYTES, ITRUNC, LOOP, IRET
       INTEGER ISIZE
@@ -430,11 +430,11 @@ C
         POLELON = REAL(NOROTA(2))/JPMULT
         NGAUSS = ISEC2(3)/2
         IF( NIREPR.EQ.JPGAUSSIAN ) THEN
-          TYPE = 'F'
+          HTYPE = 'F'
         ELSE
-          TYPE = 'R'
+          HTYPE = 'R'
         ENDIF
-        IRET = NGROTAT(ZNFELDI,SWORK,NUMPTS,POLELAT,POLELON,TYPE,NGAUSS)
+        IRET =NGROTAT(ZNFELDI,SWORK,NUMPTS,POLELAT,POLELON,HTYPE,NGAUSS)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFAP: Gaussian rotation fail',JPQUIET)
           INTFAP = JPROUTINE + 5
diff --git a/interpolation/intfau.F b/interpolation/intfau.F
index 13b8c80..d26a4e4 100644
--- a/interpolation/intfau.F
+++ b/interpolation/intfau.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -80,7 +80,7 @@ C
 C     Local variables
 C
       REAL POLELAT, POLELON
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
       INTEGER NUMPTS, NGAUSS
       INTEGER ISIZE, NBYTES, ITRUNC
       DATA ISIZE/0/
@@ -282,11 +282,11 @@ C
         POLELON = REAL(NOROTA(2))/JPMULT
         NGAUSS = NIGAUSS
         IF( NIREPR.EQ.JPGAUSSIAN ) THEN
-          TYPE = 'F'
+          HTYPE = 'F'
         ELSE
-          TYPE = 'R'
+          HTYPE = 'R'
         ENDIF
-        IRET = GGROTAT(ZNFELDI,SWORK,NUMPTS,POLELAT,POLELON,TYPE,NGAUSS)
+        IRET=GGROTAT(ZNFELDI,SWORK,NUMPTS,POLELAT,POLELON,HTYPE,NGAUSS)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFAU: Gaussian rotation fail',JPQUIET)
           INTFAU = JPROUTINE + 5
diff --git a/interpolation/intfb.F b/interpolation/intfb.F
index f9e756e..b378feb 100644
--- a/interpolation/intfb.F
+++ b/interpolation/intfb.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION INTFB( INGRIB,INLEN,OUTGRIB,OUTLEN,FLDOUT)
+      INTEGER FUNCTION INTFB(INGRIB,INLEN,OUTGRIB,OUTLEN,FLDOUT)
 C
 C---->
 C**** INTFB
@@ -113,20 +113,12 @@ C
 C     Parameters
 C
       INTEGER JPROUTINE
-      INTEGER JUNPACK, JPREALB
+      INTEGER JUNPACK
       PARAMETER (JPROUTINE = 26400 )
-      INTEGER JPIMISS,CLASMISS,KNEWMISS
-      PARAMETER (JPIMISS = -2147483647)
-      PARAMETER (CLASMISS = 9999)
-      REAL JPZMISS,NEWMISS
-      PARAMETER (JPZMISS = -2.1474836E+09)
       PARAMETER (JUNPACK = 3000000)
-      PARAMETER (JPREALB = 8)
 C
 C     Local variables
 C
-      INTEGER NWEPTS, NNSPTS
-      REAL OLDS, OLDE
       REAL EW, NS, NORTH, SOUTH, WEST, EAST, RTEMP
       INTEGER IWORD, IERR, ILENF, ISIZE, IUV, IDISTEP
       REAL PNORTH, PSOUTH, PWEST, PEAST, PLATINC, PLONINC
@@ -134,20 +126,18 @@ C
       LOGICAL OOWEGLOBE, OONPOLE, OOSPOLE
       LOGICAL LBITMP,LFRAME,LSTYLE,LGLOBAL,LSAMERS,LIQUASI
       LOGICAL LOLDLSP, LOLDLSM
-      INTEGER INORTH, ISOUTH, IEAST, IWEST
+      INTEGER INORTH, ISOUTH, IEAST
       INTEGER HOLDEW, HOLDNS, N_NOWE, N_NONS
       INTEGER KILN, KITOTAL, KOLN, KOTOTAL, KPR, KERR
       INTEGER LOOP, LOOPI, NEXT, ISWAP, NTRUNC, NTROLD, NTROLD2
       INTEGER LENMED
-      INTEGER IOS, ILENS
+      INTEGER ILENS
       REAL*8 DISSRES
-      REAL TEMP(2048)
 C
       DATA NTROLD/-1/, NTROLD2/-1/
       SAVE NTROLD, NTROLD2
       CHARACTER*1 HTYPE
       CHARACTER*1 HFUNC
-      CHARACTER*6 YFLAG
 #ifndef _CRAYFTN
 #ifdef POINTER_64
 #ifndef FUJITSU
@@ -169,13 +159,10 @@ C
 C     Externals
 C
       INTEGER IGLSIZE, IGSIZE, IRSIZE, IARCNTL, IAGCNTL, DSSAREA
-      INTEGER IGSETUP, FIXAREA, ISCRSZ, OCEANP, AURESOL, MKBITMP
+      INTEGER IGSETUP, FIXAREA, ISCRSZ, AURESOL, MKBITMP !, OCEANP
       INTEGER INTISL, KRG2RG, KRG2RGU,KRG2RGZ, KRG2RGD, KRG2RGY
-#ifdef POINTER_64
-      INTEGER*8 JMALLOC
-#else
-      INTEGER JMALLOC
-#endif
+      CHARACTER*1 GGHTYPE
+      EXTERNAL GGHTYPE
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -501,7 +488,7 @@ C       Get scratch space for interpolation
 C       If dissemination style, space has to be for a 0.5x0.5 grid
 C
         IF( LSTYLE ) THEN
-c to be consistant with product generation 
+c to be consistant with product generation
            IF(NIRESO.EQ.1279) THEN
               DISSRES = 0.125
            ELSEIF(NIRESO.EQ.799) THEN
@@ -532,14 +519,14 @@ C
         ISIZE = ISCRSZ()
         IF( ISIZE.LE.0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFB: Get scratch space failed.',ISIZE)
-          INTFB = JPROUTINE + 2
+          INTFB = JPROUTINE + 4
           GOTO 900
         ENDIF
 C
         CALL JMEMHAN( 3, IZNFLDO, ISIZE, 1, IERR)
         IF( IERR.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFB: Get scratch space fail.',JPQUIET)
-          INTFB = JPROUTINE + 2
+          INTFB = JPROUTINE + 4
           GOTO 900
         ENDIF
         IF( LSTYLE ) THEN
@@ -587,7 +574,7 @@ C
           IF( IERR.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTFB: Interpolation to lat/long field failed.',JPQUIET)
-            INTFB = JPROUTINE + 3
+            INTFB = JPROUTINE + 4
             GOTO 900
           ENDIF
 C
@@ -601,28 +588,31 @@ C
         ENDIF
 C
 C
-        IF( NOREPR.EQ.JPGAUSSIAN ) THEN
+        IF ((NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPQUASI)) THEN
 C
-C         -> regular gaussian grid
+C         -> regular/reduced gaussian grid
 C
-          CALL INTLOG(JP_DEBUG,'INTFB: SH -> regular gaussian.',JPQUIET)
-C
-C         Is it a user_regular_gaussian (or standard regular gaussian)..
-C
-          IF( LOGIVEL ) THEN
-            HTYPE = 'U'
-          ELSE
+          HTYPE = ''
+          IF (NOREPR.EQ.JPGAUSSIAN) THEN
+          CALL INTLOG(JP_DEBUG,'INTFB: SH -> regular gaussian',JPQUIET)
+C           Is it a user_regular_gaussian (or standard regular gaussian)..
             HTYPE = 'F'
+            IF (LOGIVEL) HTYPE = 'U'
+          ELSE
+          CALL INTLOG(JP_DEBUG,'INTFB: SH -> reduced gaussian',JPQUIET)
+            HTYPE = 'R'
+            IF (LOCTAHEDRAL) HTYPE = 'O'
+            IF (LOGIVEP)     HTYPE = 'U'
           ENDIF
 C
 C         Special handling for stretched fields
 C
           IF( RISTRET.NE.0 ) THEN
-            CALL JSGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
+            CALL JSGGGP(ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
+     X                  NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
           ELSE
-            CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
+            CALL JAGGGP(ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
+     X                  NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
 C
           ENDIF
           IF( IERR .NE. 0 ) THEN
@@ -637,43 +627,9 @@ C
         ENDIF
 C
 C
-        IF( NOREPR.EQ.JPQUASI ) THEN
-C
-C         -> reduced gaussian grid
-C
-          CALL INTLOG(JP_DEBUG,'INTFB: SH -> quasi gaussian.',JPQUIET)
-C
-C         Is it a user_reduced_gaussian (or standard reduced gaussian)?
-C
-          IF( LOGIVEP ) THEN
-            HTYPE = 'U'
-          ELSE
-            HTYPE = 'R'
-          ENDIF
-C
-C         Special handling for stretched fields
-C
-          IF( RISTRET.NE.0 ) THEN
-            CALL JSGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
-          ELSE
-            CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
-          ENDIF
-          IF( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'INTFB: Interpolation to quasi GG field failed.',JPQUIET)
-            INTFB = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
 C       Dropthrough => unrecognized output field type
 C
-        IERR  = JPROUTINE + 1
+        IERR  = JPROUTINE + 4
         CALL INTLOG(JP_ERROR,
      X    'INTFB: Unrecognized output field type.',NOREPR)
         INTFB = IERR
@@ -914,7 +870,7 @@ C        Sinisa - if double interpolation involved
           CALL INTLOG(JP_DEBUG,
      X    'INTFB: Double interpolation is not performed',JPQUIET)
          ELSE
-	        IF(NIFORM.EQ.1)  THEN
+           IF(NIFORM.EQ.1)  THEN
              CALL INTLOG(JP_DEBUG,
      X      'INTFB: RG2RG to unpacked - double interpolation',JPQUIET)
                IERR = KRG2RGY(INGRIB,RWORK,NOMEGA)
@@ -939,7 +895,7 @@ C        Sinisa - if double interpolation involved
                  LENMED = IERR
                ENDIF
             ENDIF
- 
+
                DO LOOP = 1, LENMED
                  ZNFELDI(LOOP) = RWORK(LOOP)
                ENDDO
@@ -951,14 +907,15 @@ C        Sinisa - if double interpolation involved
               GOTO 900
             ENDIF
             CALL INTLOG(JP_DEBUG,
-     X           'INTFB: quasi input double interolation ',NIGAUSS)
-             CALL JGETGG( NIGAUSS, 'R', RIGAUSS, MILLEN, IERR)
-             IF ( IERR .NE. 0 ) THEN
-               CALL INTLOG(JP_ERROR,
-     X           'INTFB: JGETGG fail - double interpolation ',JPQUIET)
-                INTFB = JPROUTINE + 10
-               GOTO 900
-             ENDIF
+     X        'INTFB: quasi input double interolation ',NIGAUSS)
+            HTYPE = GGHTYPE(NIREPR,NIGAUSS,MILLEN)
+            CALL JGETGG(NIGAUSS,HTYPE,RIGAUSS,MILLEN,IERR)
+            IF ( IERR .NE. 0 ) THEN
+              CALL INTLOG(JP_ERROR,
+     X          'INTFB: JGETGG fail - double interpolation ',JPQUIET)
+               INTFB = JPROUTINE + 10
+              GOTO 900
+            ENDIF
 
             IERR = IRSIZE( NIGAUSS, NIAREA, MILLEN, NIWE, NINS, KILN,
      X                 KITOTAL, RIGAUSS, OIWEGLOBE, OINPOLE, OISPOLE,
@@ -1075,7 +1032,7 @@ C
 C
 C       Setup GRIB sections for the output product
 C
-        IERR = IGSETUP( ISEC1, ISEC2, ISEC4 )
+        IERR = IGSETUP(ISEC1,ISEC2,ISEC3,ISEC4)
         IF( IERR.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFB: Setup GRIB section fail',JPQUIET)
           INTFB = IERR
@@ -1141,14 +1098,15 @@ C             Complex packing does not support sub-areas of reduced
 C             gaussian grids. If output is reduced gaussian, check if
 C             it is global to within a tolerance of 0.1 degrees.
 C
-              LGLOBAL = .TRUE.
-              INORTH    = NINT( ROGAUSS(1) * PPMULT )
-              IF( IABS(NOAREA(1)-INORTH).GT.1000) LGLOBAL = .FALSE.
-              ISOUTH    = - INORTH
-              IF( IABS(NOAREA(3)-ISOUTH).GT.1000) LGLOBAL = .FALSE.
-              IF( NOAREA(2).NE.0 ) LGLOBAL = .FALSE.
-              IEAST = JP360 - (JP90/NOGAUSS)
-              IF( IABS(NOAREA(4)-IEAST).GT.1000) LGLOBAL = .FALSE.
+              INORTH = NINT( ROGAUSS(1) * PPMULT )
+              ISOUTH = -INORTH
+c             EMOS-199: adjusted for reduced_gg/octahedral
+c             IEAST  = JP360 - (JP360/NOLPTS(NOGAUSS))
+              IEAST  = JP360 - (JP90/NOGAUSS)
+              LGLOBAL = (NOAREA(2).EQ.0)
+     X          .AND. (IABS(NOAREA(1)-INORTH).LE.1000)
+     X          .AND. (IABS(NOAREA(3)-ISOUTH).LE.1000)
+     X          .AND. (IABS(NOAREA(4)-IEAST ).LE.1000)
 C
 C             Use simple packing if not global.
 C
diff --git a/interpolation/intfbp.F b/interpolation/intfbp.F
deleted file mode 100644
index dbae5f8..0000000
--- a/interpolation/intfbp.F
+++ /dev/null
@@ -1,469 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTFBP( INGRIB,INLEN,OUTGRIB,OUTLEN)
-C
-C---->
-C**** INTFBP
-C
-C     Purpose
-C     -------
-C
-C     Interpolate input field...
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INTFBP( INGRIB,INLEN,OUTGRIB,OUTLEN)
-C
-C     Input
-C     -----
-C
-C     INGRIB - Input field (packed).
-C     INLEN  - Input field length (words).
-C
-C
-C     Output
-C     ------
-C
-C     OUTGRIB - Output field (packed).
-C     OUTLEN  - Output field length (words).
-C
-C
-C     Method
-C     ------
-C
-C     Call interpolation routines; then repack if GRIB output.
-C
-C     Currently, subareas are not supported for reduced gaussian fields.
-C     (Works OK; but need to setup values in GRIB product for number of
-C      points in each latitude row)
-C
-C
-C     Externals
-C     ---------
-C
-C     IARCNTL - Control interp. quasi reg.Gauss -> Gaussian or lat/long
-C     IAGCNTL - Control interpolation reg.Gaussian or lat/long fields.
-C     JSH2SH  - Changes resolution of a field of spectral coefficients.
-C     JALLGP  - Converts spectral input fields to lat/long grid fields.
-C     JALLWN  - Converts spectral input wind fields to lat/long grids.
-C     JAGGGP  - Converts spectral input fields to a gaussian grid field.
-C     IBASINI - Ensure basic interpolation setup is done.
-C     GRIBEX  - Decode/encode GRIB product.
-C     GRSVCK  - Turn off GRIB checking
-C     RESET_C - Reset interpolation handling options using GRIB product.
-C     IGSETUP - Setup GRIB sections for the output product.
-C     JMEMHAN - Handles memory allocation.
-C     IGLSIZE - Evaluate array sizes for reg. lat/long and area.
-C     IGSIZE  - Evaluate array sizes for a regular Gaussian.
-C     IRSIZE  - Evaluate array sizes for a quasi reg Gaussian.
-C     FIXAREA - Fixup area definition to correspond to grid definitions
-C     ISCRSZ  - Calculate number of values in generated field.
-C     INTLOG  - Log error message.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Aug 1994
-C
-C     J.D.Chambers     ECMWF        Feb 1997
-C     Allow for 64-bit pointers
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-      INTEGER INGRIB(*),OUTGRIB(*),INLEN,OUTLEN
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "intf.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 26500 )
-C
-C     Local variables
-C
-      CHARACTER*1 HFUNC
-      INTEGER IWORD, IERR, ILENF, ISIZE, IUV
-      REAL PNORTH, PSOUTH, PWEST, PEAST, PLATINC, PLONINC
-      LOGICAL OIWEGLOBE, OINPOLE, OISPOLE
-      LOGICAL OOWEGLOBE, OONPOLE, OOSPOLE
-      INTEGER KILN, KITOTAL, KOLN, KOTOTAL, KPR, KERR
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IZNFLDO
-#endif
-#endif
-      REAL ZNFLDO
-      POINTER ( IZNFLDO, ZNFLDO )
-      DIMENSION ZNFLDO( 1 )
-C
-C     Externals
-C
-      INTEGER IGLSIZE, IGSIZE, IRSIZE, IARCNTL, IAGCNTL
-      INTEGER IGSETUP, FIXAREA, ISCRSZ
-C
-C ------------------------------------------------------------------
-C*    Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-      INTFBP = 0
-      IERR = 0
-      KPR = 0
-C
-C     Allocate work array ZNFELDI if not already done.
-C
-      IF( IZNJDCI.NE.1952999238 ) THEN
-        CALL JMEMHAN( 19, IZNFLDI, JPEXPAND, 1, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_WARN,'INTFBP: ZNFELDI allocation fail',JPQUIET)
-          INTFBP = IERR
-          GOTO 900
-        ENDIF
-        IZNJDCI = 1952999238
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 3.   Interpolation spherical harmonics to spherical
-C                  harmonics
-C ------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-      IF ( ((NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT)) .AND.
-     X     ((NOREPR.EQ.JPSPHERE).OR.(NOREPR.EQ.JPSPHROT)) ) THEN
-C
-C       Get scratch space for interpolation
-        ISIZE = ISCRSZ()
-        IF ( ISIZE .LE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTFBP: Get scratch space failed',ISIZE)
-          INTFBP = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-        CALL JMEMHAN( 3, IZNFLDO, ISIZE, 1, IERR)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTFBP: Get scratch space fail',JPQUIET)
-          INTFBP = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-C
-        CALL SH2SH( ZNFELDI, NIRESO, ZNFLDO, NORESO )
-C
-        GOTO 700
-C
-C     If not spectral -> spectral transformation, make sure the input
-C     and output area definitions have been setup.
-C
-      ELSE
-C
-C       Fixup area definition to correspond to grid definitions
-        IERR = FIXAREA()
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTFBP: Fixup area definition failed.',JPQUIET)
-          INTFBP = JPROUTINE + 9
-          GOTO 900
-        ENDIF
-C
-C       Setup geographical limits
-        PNORTH = FLOAT( NOAREA(1) ) / PPMULT
-        PWEST  = FLOAT( NOAREA(2) ) / PPMULT
-        PSOUTH = FLOAT( NOAREA(3) ) / PPMULT
-        PEAST  = FLOAT( NOAREA(4) ) / PPMULT
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 4.   Interpolation spherical harmonics to grid point.
-C ------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-      IF ( (NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT) ) THEN
-C
-C       Get scratch space for interpolation
-C
-        ISIZE = ISCRSZ()
-        IF ( ISIZE .LE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTFBP: Get scratch space failed',ISIZE)
-          INTFBP = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-C
-        CALL JMEMHAN( 3, IZNFLDO, ISIZE, 1, IERR)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTFBP: Get scratch space fail',JPQUIET)
-          INTFBP = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-C
-C       Setup wind flag
-C
-        IF( .NOT.LWINDSET ) THEN
-          LWIND = ( ( NOTABLE.EQ.128 ).AND.
-     X            ((NOPARAM.EQ.131).OR.(NOPARAM.EQ.132)) )
-        ENDIF
-        CALL INTLOG(JP_DEBUG,'INTFBP: Wind flag = ', LWIND)
-        IF ( LWIND ) THEN
-          IUV = 1
-        ELSE
-          IUV = 0
-        ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 4.1  Interpolation spherical harmonics to grid point.
-C ------------------------------------------------------------------
-C
-  410 CONTINUE
-C
-        IF ( (NOREPR.EQ.JPREGULAR).OR.(NOREPR.EQ.JPREGROT) ) THEN
-C
-C         -> latitude/longitude grid
-C
-          PLONINC = FLOAT( NOGRID(1) ) / PPMULT
-          PLATINC = FLOAT( NOGRID(2) ) / PPMULT
-          IF ( LWIND ) THEN
-            CALL JALLWN( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   PLATINC, PLONINC, ZNFLDO, IERR)
-          ELSE
-            CALL JALLGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                   PLATINC, PLONINC, ZNFLDO, IERR)
-          ENDIF
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'INTFBP: Interpolation of gaussian field failed.',JPQUIET)
-            INTFBP = JPROUTINE + 3
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C
-        IF ( NOREPR .EQ. JPGAUSSIAN) THEN
-C
-C         -> regular gaussian grid
-C
-          CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                 NOGAUSS, 'U', NOLPTS, ZNFLDO, IUV, IERR)
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'INTFBP: Interpolation of gaussian field failed.',JPQUIET)
-            INTFBP = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C
-        IF ( NOREPR .EQ. JPQUASI) THEN
-C
-C         -> reduced gaussian grid
-          CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                 NOGAUSS, 'U', NOLPTS, ZNFLDO, IUV, IERR)
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'INTFBP: Interpolation of gaussian field failed.',JPQUIET)
-            INTFBP = JPROUTINE + 4
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C       Dropthrough => unrecognized output field type
-        IERR   = JPROUTINE + 1
-        CALL INTLOG(JP_ERROR,
-     X    'INTFBP: Unrecognized output field type.',NOREPR)
-        INTFBP = IERR
-        GOTO 900
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 5.   Interpolate Gaussian grid to grid point.
-C ------------------------------------------------------------------
-C
-  500 CONTINUE
-C
-C     Setup flags for input and output fields
-      KERR = 1
-      IF (NIREPR .EQ. JPQUASI) THEN
-        IERR = IRSIZE( NIGAUSS, NIAREA, MILLEN, NIWE, NINS, KILN,
-     X                 KITOTAL, RIGAUSS, OIWEGLOBE, OINPOLE, OISPOLE,
-     X                 KPR, KERR)
-      ELSE IF ( NIREPR .EQ. JPGAUSSIAN ) THEN
-          IERR = IGSIZE( NIGAUSS, NIAREA, NIWE, NINS, KILN, RIGAUSS,
-     X                    OIWEGLOBE, OINPOLE, OISPOLE, KPR, KERR)
-      ELSE
-        IERR = IGLSIZE( NIGRID, NIAREA, NIWE, NINS, KILN, OIWEGLOBE,
-     X                  OINPOLE, OISPOLE, KPR, KERR)
-      ENDIF
-C
-      NONS = 0
-      NOWE = 0
-      IF (NOREPR .EQ. JPQUASI) THEN
-        IERR = IRSIZE( NOGAUSS, NOAREA, NOLPTS, NOWE, NONS, KOLN,
-     X                 KOTOTAL, ROGAUSS, OOWEGLOBE, OONPOLE, OOSPOLE,
-     X                 KPR, KERR)
-      ELSE IF ( NOREPR .EQ. JPGAUSSIAN ) THEN
-          IERR = IGSIZE( NOGAUSS, NOAREA, NOWE, NONS, KOLN, ROGAUSS,
-     X                    OOWEGLOBE, OONPOLE, OOSPOLE, KPR, KERR)
-      ELSE
-        IERR = IGLSIZE( NOGRID, NOAREA, NOWE, NONS, KOLN, OOWEGLOBE,
-     X                  OONPOLE, OOSPOLE, KPR, KERR)
-      ENDIF
-C
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTFBP: Setup of gaussian field flags failed.',IERR)
-        INTFBP = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-C
-C
-C ------------------------------------------------------------------
-C     Section 5.1  Interpolate reduced Gaussian grid to grid point.
-C ------------------------------------------------------------------
-C
-  510 CONTINUE
-C
-C
-      ISIZE = ISCRSZ()
-      IF ( ISIZE .LE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTFBP: Get scratch space failed.',ISIZE)
-        INTFBP = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-      CALL JMEMHAN( 3, IZNFLDO, ISIZE, 1, IERR)
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTFBP: Get scratch space fail.',JPQUIET)
-        INTFBP = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-      IF (NIREPR .EQ. JPQUASI) THEN
-        IERR = IARCNTL( ZNFELDI, JPEXPAND, ZNFLDO, ISIZE, KILN,
-     X                  OIWEGLOBE, OINPOLE, OISPOLE, KOLN, OOWEGLOBE,
-     X                  OONPOLE, OOSPOLE, KPR ,KERR)
-        IF ( IERR .NE. 0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTFBP: Interpolation of gaussian field failed.',IERR)
-          INTFBP = JPROUTINE + 7
-          GOTO 900
-        ENDIF
-C
-        GOTO 700
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 6.   Interpolate regular grid point to grid point.
-C ------------------------------------------------------------------
-C
-  600 CONTINUE
-C
-      IERR = IAGCNTL( ZNFELDI, JPEXPAND, ZNFLDO, ISIZE, KILN,
-     X                OIWEGLOBE, OINPOLE, OISPOLE, KOLN, OOWEGLOBE,
-     X                OONPOLE, OOSPOLE, KPR, KERR)
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTFBP: Interpolation of gaussian field failed.',IERR)
-        INTFBP = JPROUTINE + 8
-        GOTO 900
-      ENDIF
-C
-C ------------------------------------------------------------------
-C*    Section 7.   Pack field into GRIB if necessary.
-C ------------------------------------------------------------------
-C
-  700 CONTINUE
-C
-C     Setup GRIB sections for the output product
-      IERR = IGSETUP( ISEC1, ISEC2, ISEC4 )
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTFBP: Setup GRIB sections failed.',IERR)
-        INTFBP = IERR
-        GOTO 900
-      ENDIF
-C
-C     Code data into GRIB
-C
-      ILENF = ISIZE
-      IERR = 1
-C
-C     If grid-point output, setup for 2nd order packing if requested.
-C
-      IF( (NOREPR.NE.JPSPHERE) .AND. (NOREPR.NE.JPSPHROT) ) THEN
-        HFUNC = 'C'
-        IF( NOHFUNC.EQ.'K' ) THEN
-          HFUNC = 'K'
-          ISEC4(4)  = 64
-          ISEC4(6)  = 16
-          ISEC4(9)  = 32
-          ISEC4(10) = 16
-          ISEC4(12) = 8
-          ISEC4(13) = 4
-          ISEC4(14) = 0
-          ISEC4(15) = -1
-        ELSE IF( NOHFUNC.EQ.'S' ) THEN
-          ISEC4(4)  = 0
-          ISEC4(6)  = 0
-        ENDIF
-      ELSE
-        HFUNC = 'C'
-        IF( NOHFUNC.EQ.'C' ) THEN
-          ISEC2(6) = 2
-          ISEC4(4) = 64
-        ELSE IF( NOHFUNC.EQ.'S' ) THEN
-          ISEC2(6) = 1
-          ISEC4(4) = 0
-        ENDIF
-      ENDIF
-C
-      IF( LIMISSV ) THEN
-        ISEC1(5) = 192
-        ISEC3(2) = NINT(RMISSGV)
-        ZSEC3(2) = RMISSGV
-      ENDIF
-      CALL GRIBEX( ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X             ZNFLDO,ILENF,OUTGRIB,OUTLEN,IWORD,HFUNC,IERR)
-      IF ( IERR .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTFBP: GRIBEX encoding failed.',IERR)
-        INTFBP = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-      OUTLEN = IWORD
-C
-C ------------------------------------------------------------------
-C*    Section 9.   Closedown.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing
-      LCHANGE = .FALSE.
-      LSMCHNG = .FALSE.
-C
-      RETURN
-      END
diff --git a/interpolation/intfbu.F b/interpolation/intfbu.F
index 7a67f28..0152333 100644
--- a/interpolation/intfbu.F
+++ b/interpolation/intfbu.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -63,7 +63,6 @@ C     JMEMHAN - Handles memory allocation.
 C     IGLSIZE - Evaluate array sizes for reg. lat/long and area.
 C     IGSIZE  - Evaluate array sizes for a regular Gaussian.
 C     IRSIZE  - Evaluate array sizes for a quasi reg Gaussian.
-C     FIXAREA - Fixup area definition to correspond to grid definitions
 C     ISCRSZ  - Calculate number of values in generated field.
 C     INTLOG  - Log error message.
 C
@@ -101,8 +100,6 @@ C     Local variables
 C
       INTEGER IERR, ISIZE, IUV
       REAL PNORTH, PSOUTH, PWEST, PEAST, PLATINC, PLONINC
-      REAL EW, NS, NORTH, SOUTH, WEST, EAST
-      REAL HNORTH, HSOUTH, HWEST, HEAST
       LOGICAL OIWEGLOBE, OINPOLE, OISPOLE
       LOGICAL OOWEGLOBE, OONPOLE, OOSPOLE
       LOGICAL LSTYLE
@@ -110,6 +107,7 @@ C
       INTEGER LOOP
       INTEGER HOLDEW, HOLDNS, N_NOWE, N_NONS, IDISTEP
       REAL*8 DISSRES
+      CHARACTER*1 HTYPE
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 IZNFLDO
@@ -121,7 +119,7 @@ C
 C
 C     Externals
       INTEGER IGLSIZE, IGSIZE, IRSIZE, IARCNTL, IAGCNTL
-      INTEGER FIXAREA, ISCRSZ
+      INTEGER ISCRSZ
 C
 C ------------------------------------------------------------------
 C*    Section 1.   Initialise
@@ -230,14 +228,14 @@ C
         ISIZE = ISCRSZ()
         IF ( ISIZE .LE. 0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFBU: Get scratch space failed',ISIZE)
-          INTFBU = JPROUTINE + 2
+          INTFBU = JPROUTINE + 4
           GOTO 900
         ENDIF
 C
         CALL JMEMHAN( JPSCR16, IZNFLDO, ISIZE, JPALLOC, IERR)
         IF ( IERR .NE. 0 ) THEN
           CALL INTLOG(JP_ERROR,'INTFBU: Get scratch space fail',JPQUIET)
-          INTFBU = JPROUTINE + 2
+          INTFBU = JPROUTINE + 4
           GOTO 900
         ENDIF
 C
@@ -261,6 +259,7 @@ C
   410 CONTINUE
 C
         IF ( (NOREPR.EQ.JPREGULAR).OR.(NOREPR.EQ.JPREGROT) ) THEN
+          CALL INTLOG(JP_DEBUG,'INTFBU: SH -> lat/long',JPQUIET)
 C
 C         -> latitude/longitude grid
 C
@@ -276,25 +275,6 @@ C
           IF ( IERR .NE. 0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTFBU: Interpolation of gaussian field failed.',JPQUIET)
-            INTFBU = JPROUTINE + 3
-            GOTO 900
-          ENDIF
-C
-          GOTO 700
-C
-        ENDIF
-C
-C
-        IF ( NOREPR .EQ. JPGAUSSIAN) THEN
-C
-C         -> regular gaussian grid
-C
-          CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                 NOGAUSS, 'F', NOLPTS, ZNFLDO, IUV, IERR)
-cs     X                 NOGAUSS, 'U', NOLPTS, ZNFLDO, IUV, IERR)
-          IF ( IERR .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,
-     X        'INTFBU: Interpolation of gaussian field failed.',JPQUIET)
             INTFBU = JPROUTINE + 4
             GOTO 900
           ENDIF
@@ -304,26 +284,35 @@ C
         ENDIF
 C
 C
-        IF ( NOREPR .EQ. JPQUASI) THEN
+        IF ((NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPQUASI)) THEN
 C
-C         -> reduced gaussian grid
+C         -> regular/reduced gaussian grid
 C
-          CALL JAGGGP( ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
-     X                 NOGAUSS, 'U', NOLPTS, ZNFLDO, IUV, IERR)
+          HTYPE = ''
+          IF (NOREPR.EQ.JPGAUSSIAN) THEN
+          CALL INTLOG(JP_DEBUG,'INTFBU: SH -> regular gaussian',JPQUIET)
+cs          HTYPE = 'U'
+            HTYPE = 'F'
+          ELSE
+          CALL INTLOG(JP_DEBUG,'INTFBU: SH -> reduced gaussian',JPQUIET)
+            HTYPE = 'U'
+          ENDIF
+
+          CALL JAGGGP(ZNFELDI, NIRESO, PNORTH, PSOUTH, PWEST, PEAST,
+     X                NOGAUSS, HTYPE, NOLPTS, ZNFLDO, IUV, IERR)
           IF ( IERR .NE. 0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTFBU: Interpolation of gaussian field failed.',JPQUIET)
             INTFBU = JPROUTINE + 4
             GOTO 900
           ENDIF
-C
           GOTO 700
-C
+
         ENDIF
 C
 C       Dropthrough => unrecognized output field type
 C
-        IERR   = JPROUTINE + 1
+        IERR   = JPROUTINE + 4
         CALL INTLOG(JP_ERROR,
      X    'INTFBU: Unrecognized output field type.',NOREPR)
         INTFBU = IERR
diff --git a/interpolation/intfc.F b/interpolation/intfc.F
deleted file mode 100644
index b460331..0000000
--- a/interpolation/intfc.F
+++ /dev/null
@@ -1,125 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTFC( INGRIB,INLEN,FLDIN,OUTGRIB,OUTLEN,FLDOUT)
-C
-C---->
-C**** INTFC
-C
-C     Purpose
-C     -------
-C
-C     Move input field to output field.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INTFC( INGRIB,INLEN,FLDIN,OUTGRIB,OUTLEN,FLDOUT)
-C
-C     Input
-C     -----
-C
-C     INGRIB - Input field (packed).
-C     INLEN  - Input field length (words).
-C     FLDIN  - Input field (unpacked).
-C
-C
-C     Output
-C     ------
-C
-C     OUTGRIB - Output field (packed).
-C     OUTLEN  - Output field length (words).
-C     FLDOUT  - Output field (unpacked).
-C
-C
-C     Method
-C     ------
-C
-C     Move data (packed or unpacked) without special processing.
-C
-C
-C     Externals
-C     ---------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Jan 1995
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-      INTEGER INGRIB(*),OUTGRIB(*),INLEN,OUTLEN
-      REAL FLDIN(*),FLDOUT(*)
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 26700 )
-C
-C     Local variables
-C
-      INTEGER LOOP
-C
-C ------------------------------------------------------------------
-C*    Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-      INTFC = 0
-C
-C ------------------------------------------------------------------
-C*    Section 2.   Move data from input to output.
-C ------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-C     If input is a GRIB product
-      If (NIFORM .EQ. 1) THEN
-C
-C       Move packed values to user array
-        DO 210 LOOP = 1, INLEN
-          OUTGRIB( LOOP ) = INGRIB( LOOP )
- 210    CONTINUE
-C
-      ELSE
-C
-C       Otherwise, move unpacked values to user array
-        DO 220 LOOP = 1, INLEN
-          FLDOUT( LOOP ) = FLDIN( LOOP )
- 220    CONTINUE
-C
-      ENDIF
-C
-C     Return the number of values, the unpacked array length
-      OUTLEN = INLEN
-C
-C ------------------------------------------------------------------
-C*    Section 9.   Closedown.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing
-      LCHANGE = .FALSE.
-      LSMCHNG = .FALSE.
-C
-      RETURN
-      END
diff --git a/interpolation/intin.F b/interpolation/intin.F
index 30ce2f8..b1b255b 100644
--- a/interpolation/intin.F
+++ b/interpolation/intin.F
@@ -1,23 +1,23 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION INTIN( HPARN, INTV, REALV, CHARV)
-C  
+C
 C---->
 C**** INTIN
-C  
+C
 C     Purpose
 C     -------
 C
 C     Change input field parameters in common block.
-C  
+C
 C     Interface
 C     ---------
 C
@@ -28,36 +28,32 @@ C     HPARN - MARS parameter name.
 C     INTV  - MARS parameter value(s) (Integer).
 C     REALV - MARS parameter value(s) (Real).
 C     CHARV - MARS parameter value(s) (Character).
-C  
-C  
+C
+C
 C     Method
 C     ------
 C
 C     Recognise MARS paramter and reset appropriate common
 C     variable value(s).
 C
-C     Uses environment variable ISLSCP_OLD_LSM to locate old
-C     land-sea mask GRIB product file. If the variable is not set,
-C     uses /home/ma/emos/data/islscp_old_lsm.
-C  
 C
 C     Externals
 C     ---------
 C
 C     JDEBUG   - Check if debug switched on.
-C     IBASINI  - Check basic initialisation of common blocks is done
+C     IBASINI  - Check basic initialisation of common blocks is done.
 C     CHEQUAL  - Compare two ASCII strings without regard to case.
 C     INTLOG   - Log error message.
 C     JMALLOC  - Dynamically allocate memory
 C     JFREE    - Free dynamically allocated memory
 C     GETENV   - Get value of an environment variable
-C  
-C  
+C
+C
 C     Author
 C     ------
 C
 C     J.D.Chambers       ECMWF        August 1994.
-C  
+C
 C----<
 C
 C     IMPLICIT NONE
@@ -84,13 +80,14 @@ C
 C
 C     Local variables
 C
-      INTEGER ITEMP, I, IRET, ILOOP, ILAST, IGSIZE, IASIZE, IBLANK
+      INTEGER ITEMP, I, IRET, IGSIZE, IASIZE, IBLANK
       INTEGER NEWGRIB(1), OLDGRIB(1)
       POINTER( NIPNGRB, NEWGRIB )
       POINTER( NIPOGRB, OLDGRIB )
       LOGICAL LFOUND
       CHARACTER*256 OLDLSM, ISLDEFL
-      CHARACTER*3 NUMBER
+      CHARACTER*1 CTEMP
+      CHARACTER*8 CTEMP8
 C
 C     Externals
 C
@@ -99,14 +96,14 @@ C
 #else
       INTEGER JMALLOC
 #endif
-      LOGICAL CHEQUAL
-      EXTERNAL CHEQUAL, JMALLOC
+      LOGICAL CHEQUAL, ISGGVALID
+      EXTERNAL CHEQUAL, ISGGVALID, JMALLOC
 C
       DATA ISLDEFL/'/home/ma/emos/data/islscp_old_lsm'/
       SAVE ISLDEFL
 C
 C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
+C     Section 1.   Initialise
 C     -----------------------------------------------------------------|
 C
   100 CONTINUE
@@ -123,11 +120,111 @@ C
       CALL INTLOG(JP_DEBUG, 'INTIN: option = ' // HPARN ,JPQUIET)
 C
 C     -----------------------------------------------------------------|
-C*    Section 2.   Decode request
+C     Section 2.   Decode request
 C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
+C     Input grid name.
+C     Note: compared to INTIN('gridname'), no rotation is supported
+C
+      IF( CHEQUAL( HPARN, 1, 8, 'gridname') ) THEN
+        CALL INTLOG(JP_DEBUG, 'INTIN: gridname = '//CHARV,JPQUIET)
+        LFOUND = .TRUE.
+C
+C       Make sure we read a grid type and grid number from input
+        I = MIN(8,LEN(CHARV))
+        IF( 0.LT.INDEX(CHARV,CHAR(0)) ) I=MIN(I,INDEX(CHARV,CHAR(0))-1)
+        IF( 0.LT.INDEX(CHARV,' '    ) ) I=MIN(I,INDEX(CHARV,' '    )-1)
+        CTEMP8(1:8) = ' '
+        CTEMP8 = CHARV(1:I)
+        CTEMP = ' '
+        ITEMP = 0
+        IF(   .TRUE.   ) READ(CTEMP8,'(A1,I4)',ERR=203) CTEMP, ITEMP
+  203   IF( ITEMP.EQ.0 ) READ(CTEMP8,'(A1,I3)',ERR=204) CTEMP, ITEMP
+  204   IF( ITEMP.EQ.0 ) READ(CTEMP8,'(A1,I2)',ERR=205) CTEMP, ITEMP
+  205   IF( ITEMP.EQ.0 ) READ(CTEMP8,'(A1,I1)',ERR=206) CTEMP, ITEMP
+        IF( ITEMP.EQ.0 ) THEN
+  206     CONTINUE
+          PRINT *, "INTIN: Invalid gridname (interpreting CHARV)"
+          PRINT *, "  CHARV='"//CHARV//"'"
+          PRINT *, "  CTEMP8='"//CTEMP8//"'"
+          PRINT *, "  CTEMP='"//CTEMP//"'"
+          PRINT *, "  ITEMP=", ITEMP
+          IRET   = JPROUTINE + 1
+          INTIN  = IRET
+          CALL INTLOG(JP_ERROR,
+     X      'INTIN: Invalid gridname: '//TRIM(CTEMP8), JPQUIET)
+          GOTO 900
+        ENDIF
+C
+C       Make sure we have a valid grid type, following JGETGG
+C       (possible results are [ROF], uppercase)
+        IF(     CHEQUAL(CTEMP,1,1,'N') ) THEN
+          CTEMP = 'R'
+        ELSEIF( CHEQUAL(CTEMP,1,1,'O') ) THEN
+          CTEMP = 'O'
+        ELSEIF( CHEQUAL(CTEMP,1,1,'F') ) THEN
+          CTEMP = 'F'
+        ELSE
+          IRET   = JPROUTINE + 2
+          INTIN  = IRET
+          CALL INTLOG(JP_ERROR,
+     X      'INTIN: Invalid gridname: '//TRIM(CTEMP8)//
+     X      ' (type "'//TRIM(CTEMP)//'" not recognized)', JPQUIET)
+          GOTO 900
+        ENDIF
+C
+C       Make sure we have a valid grid number
+        IF( .NOT.ISGGVALID(CTEMP,ITEMP) ) THEN
+          IRET   = JPROUTINE + 2
+          INTIN  = IRET
+          CALL INTLOG(JP_ERROR,
+     X      'INTIN: Invalid grid: '//TRIM(CTEMP8)//
+     X      ' (number not recognized)', JPQUIET)
+          GOTO 900
+        ENDIF
+C
+C       Generate output grid structure if necessary
+        I = JPQUASI
+        IF( CTEMP.EQ.'F' ) I = JPGAUSSIAN
+        LCHANGE = (NIREPR .EQ.JPNOTYPE) .OR.
+     X            (NIREPR .NE.I)        .OR.
+     X            (NIGAUSO.NE.ITEMP)    .OR.
+     X            (NIGAUSS.NE.ITEMP)    .OR.
+     X            (HIGAUST.NE.CTEMP)
+        IF( LCHANGE ) THEN
+          CALL JGETGG( ITEMP, CTEMP, RIGAUSS, MILLEN, IRET)
+          IF( IRET .NE. 0 ) THEN
+            CALL INTLOG(JP_ERROR,
+     X        'INTIN: JGETGG fail for NIGAUSS = ',ITEMP)
+            INTIN = IRET
+            GOTO 900
+          ENDIF
+        ENDIF
+        NIGAUSO = ITEMP
+        NIGAUSS = ITEMP
+        HIGAUST = CTEMP
+C
+C       Compute first and last latlon grid points
+        NIAREA(1) = INT( RIGAUSS(1) * PPMULT )
+        NIAREA(2) = 0
+        NIAREA(3) = INT( RIGAUSS(NIGAUSS*2) * PPMULT )
+        NIAREA(4) = JP360 - JP360/MILLEN(NIGAUSS)
+        NINS = NIGAUSS*2
+        NIPCNT = 0
+        DO I= 1, NIGAUSS*2
+          NIPCNT = NIPCNT + MILLEN(I)
+        ENDDO
+C
+C       Additional global state variables changes
+        NIREPR = JPQUASI
+        IF( CTEMP.EQ.'F' ) NIREPR = JPGAUSSIAN
+        NIGRID(1:2) = 0
+C
+        GOTO 900
+      ENDIF
+C
 C     Request ISLSCP processing
 C
       IF( CHEQUAL( HPARN, 1, 6, 'islscp') ) THEN
@@ -137,7 +234,7 @@ C
         IF( CHEQUAL( CHARV, 1, 3, 'off' ) ) THEN
           IF( LNIISCL ) THEN
             CALL JFREE(NIPOGRB)
-            CALL JFREE(NIPNGRB) 
+            CALL JFREE(NIPNGRB)
             NIPOGRS = 0
             NIPNGRS = 0
           ENDIF
@@ -156,8 +253,8 @@ C
           OLDLSM(1:IBLANK) = ISLDEFL(1:IBLANK)
           IF( INTV(1).GT.0 ) THEN
             OLDLSM(IBLANK+1:IBLANK+2) = '_n'
-            WRITE(NUMBER,'(I3.3)') INTV(1)
-            OLDLSM(IBLANK+3:IBLANK+5) = NUMBER(1:3)
+            WRITE(CTEMP8,'(I3.3)') INTV(1)
+            OLDLSM(IBLANK+3:IBLANK+5) = CTEMP8(1:3)
             IBLANK = IBLANK + 5
           ENDIF
         ENDIF
@@ -188,7 +285,7 @@ C
 C
         IF( NIPOGRS.LT.IGSIZE ) THEN
           IF( NIPOGRB.NE.0 ) CALL JFREE(NIPOGRB)
-          NIPOGRS = IGSIZE 
+          NIPOGRS = IGSIZE
           NIPOGRB = JMALLOC(NIPOGRS)
 #ifdef hpR64
           NIPOGRB = NIPOGRB/(1024*1024*1024*4)
@@ -198,7 +295,7 @@ C
      X        'INTIN: Problem processing islscp option',JPQUIET)
             CALL INTLOG(JP_ERROR,
      X        'INTIN: JMALLOC fail old land-sea mask GRIB',JPQUIET)
-            INTIN = JPROUTINE + 3
+            INTIN = JPROUTINE + 2
             GOTO 900
           ENDIF
         ENDIF
@@ -255,7 +352,7 @@ C
      X        'INTIN: Problem processing islscp option',JPQUIET)
             CALL INTLOG(JP_ERROR,
      X        'INTIN: JMALLOC fail new land-sea mask GRIB',JPQUIET)
-            INTIN = JPROUTINE + 3
+            INTIN = JPROUTINE + 2
             GOTO 900
           ENDIF
         ENDIF
@@ -293,7 +390,7 @@ C
         GOTO 900
       ENDIF
 
-C     missingval because can not be applied in Emos lib everywhere... 
+C     missingval because can not be applied in Emos lib everywhere...
 C
       IF( CHEQUAL( HPARN, 1, 10, 'missingval') ) THEN
         LFOUND = .TRUE.
@@ -400,10 +497,13 @@ C
 C
 C     Input reduced.
 C
-      IF ( CHEQUAL( HPARN, 1, 7, 'reduced') ) THEN
+      IF( CHEQUAL( HPARN, 1,  7, 'reduced') ) THEN
         LFOUND = .TRUE.
-        CALL INTLOG(JP_DEBUG, 'INTIN: reduced = ',INTV(1))
-        IF ( NIGAUSS .NE. INTV(1) ) LCHANGE = .TRUE.
+C
+C       (Check for changes to internal interp. request)
+        LCHANGE = (NIGAUSS.NE.INTV(1))
+C
+        CALL INTLOG(JP_DEBUG, 'INTIN: '//TRIM(HPARN)//' = ',INTV(1))
         NIGAUSS = INTV(1)
         LNIGAUS = .TRUE.
         IF ( NIREPR .NE. JPQUASI ) THEN
@@ -413,28 +513,31 @@ C
           NIGRID(2) = 0
         ENDIF
         NIREPR = JPQUASI
-        IF( (NIGAUSO.NE.NIGAUSS).OR.(HIGAUST.NE.'R') ) THEN
-          CALL JGETGG( NIGAUSS, 'R', RIGAUSS, MILLEN, IRET)
+        IF( (NIGAUSO.NE.NIGAUSS) .OR. (HIGAUST.EQ.'O')
+     X      .OR. ((HIGAUST.NE.'R') .AND. (HIGAUST.NE.'O')) ) THEN
+          CTEMP = 'R'
+          CALL JGETGG( NIGAUSS, CTEMP, RIGAUSS, MILLEN, IRET)
           IF ( IRET .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,'INTIN: JGETGG fail - NIGAUSS',JPQUIET)
+            CALL INTLOG(JP_ERROR,
+     X        'INTIN: JGETGG fail for NIGAUSS = ',NIGAUSS)
             INTIN = IRET
             GOTO 900
           ENDIF
           NIGAUSO = NIGAUSS
-          HIGAUST = 'R'
+          HIGAUST = CTEMP
         ENDIF
 C
         NIAREA(1) = INT( RIGAUSS(1) * PPMULT )
         NIAREA(2) = 0
         NIAREA(3) = INT( RIGAUSS(NIGAUSS*2) * PPMULT )
-c this gives differnt result from one in the grib header
+c this gives different result from one in the grib header
         NIAREA(4) = JP360 - JP360/MILLEN(NIGAUSS)
 C
+        NINS = NIGAUSS*2 ! Added by D. Jokic Mar-2005;
         NIPCNT = 0
-        Nins = NIGAUSS*2 ! Added by D. Jokic Mar-2005;
-        DO 230 ILOOP = 1, NIGAUSS*2
-          NIPCNT = NIPCNT + MILLEN(ILOOP)
- 230    CONTINUE
+        DO I= 1, NIGAUSS*2
+          NIPCNT = NIPCNT + MILLEN(I)
+        ENDDO
         GOTO 900
       ENDIF
 C
@@ -450,11 +553,11 @@ C
           NIRESO = 0
         ENDIF
         NIREPR = JPREGULAR
-        DO 210 I = 1, 2
+        DO I = 1, 2
           ITEMP = INT( REALV(I)*PPMULT)
           IF ( NIGRID(I) .NE. ITEMP ) LCHANGE = .TRUE.
           NIGRID(I) = ITEMP
- 210    CONTINUE
+        ENDDO
         GOTO 900
       ENDIF
 C
@@ -471,11 +574,11 @@ cs        CALL INTLOGR(JP_DEBUG, 'INTIN: reduced_ll e-w = ',REALV(1))
         ENDIF
         NIREPR = JPREDLL
         NINS = INTV(1)
-        DO 217 I = 1, 2
+        DO I = 1, 2
           ITEMP = INT( REALV(I)*PPMULT)
           IF ( NIGRID(I) .NE. ITEMP ) LCHANGE = .TRUE.
           NIGRID(I) = ITEMP
- 217    CONTINUE
+        ENDDO
         GOTO 900
       ENDIF
 C
@@ -505,7 +608,7 @@ C
         CALL INTLOGR(JP_DEBUG, 'INTIN: Local settings',NILOCAL)
         GOTO 900
       ENDIF
-c	  
+c
       IF ( CHEQUAL( HPARN, 1, 6, 'matrix') ) THEN
         LFOUND = .TRUE.
         NIMATR = INTV(1)
@@ -517,18 +620,14 @@ C
         LFOUND = .TRUE.
         CALL INTLOGR(JP_DEBUG, 'INTIN: Ocean field grid Coordinate'
      X     ,JPQUIET)
-        DO 249 ILOOP = 1, NICOORN
-          OCCOOR(ILOOP) = INTV(ILOOP)
- 249    CONTINUE
+        OCCOOR(1:NICOORN) = INTV(1:NICOORN)
         GOTO 900
       ENDIF
 C
       IF ( CHEQUAL( HPARN, 1, 6, 'l_npts') ) THEN
         LFOUND = .TRUE.
-C
-        DO 247 ILOOP = 1, NINS
-          MILLEN(ILOOP) = INTV(ILOOP)
- 247    CONTINUE
+        MILLEN(1:NINS) = INTV(1:NINS)
+        CALL INTLOG(JP_DEBUG, 'INTIN: l_npts (#) = ',NINS)
         GOTO 900
       ENDIF
 C
@@ -622,14 +721,16 @@ C
         ENDIF
         NIREPR = JPGAUSSIAN
         IF( (NIGAUSO.NE.NIGAUSS).OR.(HIGAUST.NE.'F') ) THEN
-          CALL JGETGG( NIGAUSS, 'F', RIGAUSS, MILLEN, IRET)
+          CTEMP = 'F'
+          CALL JGETGG(NIGAUSS,CTEMP,RIGAUSS,MILLEN,IRET)
           IF ( IRET .NE. 0 ) THEN
-            CALL INTLOG(JP_ERROR,'INTIN: JGETGG fail - NIGAUSS',JPQUIET)
+            CALL INTLOG(JP_ERROR,
+     X        'INTIN: JGETGG fail for NIGAUSS',NIGAUSS)
             INTIN = IRET
             GOTO 900
           ENDIF
           NIGAUSO = NIGAUSS
-          HIGAUST = 'F'
+          HIGAUST = CTEMP
         ENDIF
 C
         NIAREA(1) = INT( RIGAUSS(1) * PPMULT )
@@ -638,8 +739,8 @@ C
         NIAREA(4) = JP360 - JP360/MILLEN(NIGAUSS)
 C
         NIPCNT = 0
-        DO ILOOP = 1, NIGAUSS*2
-          NIPCNT = NIPCNT + MILLEN(ILOOP)
+        DO I= 1, NIGAUSS*2
+          NIPCNT = NIPCNT + MILLEN(I)
         ENDDO
         GOTO 900
       ENDIF
@@ -652,11 +753,11 @@ C
         CALL INTLOGR(JP_DEBUG, 'INTIN: west  = ',REALV(2))
         CALL INTLOGR(JP_DEBUG, 'INTIN: south = ',REALV(3))
         CALL INTLOGR(JP_DEBUG, 'INTIN: east  = ',REALV(4))
-        DO 220 I = 1, 4
+        DO I = 1, 4
           ITEMP = INT( REALV(I)*PPMULT)
           IF ( NIAREA(I) .NE. ITEMP ) LCHANGE = .TRUE.
           NIAREA(I) = ITEMP
- 220    CONTINUE
+        ENDDO
         GOTO 900
       ENDIF
 C
@@ -725,13 +826,10 @@ C     (Ignore the call if the user_regular_gaussian value = 0.)
         NIGAUSS = INTV(1)
         NIREPR  = JPGAUSSIAN
 C
-        ILAST = NIGAUSS*2
-        DO 235 ILOOP = 1, ILAST
-          MILLEN(ILOOP) = NOGAUSS*4
- 235    CONTINUE
+        MILLEN(1:NIGAUSS*2) = NOGAUSS*4
         NIGAUSO = NIGAUSS
         HIGAUST = 'U'
-        LIGIVEP   = .TRUE.
+        LIGIVEP = .TRUE.
 C
         GOTO 900
       ENDIF
@@ -762,7 +860,7 @@ C
       IF ( CHEQUAL( HPARN, 1, 7, 'ga_pnts') ) THEN
         LFOUND = .TRUE.
         IF ( NIGAUSS .LE. 0 ) THEN
-          IRET = JPROUTINE + 1
+          IRET = JPROUTINE + 2
           CALL INTLOG(JP_ERROR,
      X      'INTIN: Impossible number of gaussian latitudes.',NIGAUSS)
           INTIN = IRET
@@ -772,17 +870,14 @@ C
      X      'INTIN: Reduced Gaussian - grib_api ',NIGAUSS)
 C
 cs        ILAST = NIGAUSS*2 + 1
-        ILAST = NIGAUSS*2
-        DO 241 ILOOP = 1, ILAST
-          MILLEN(ILOOP) = INTV(ILOOP)
- 241    CONTINUE
+        MILLEN(1:NIGAUSS*2) = INTV(1:NIGAUSS*2)
 C
         NIAREA(4) = JP360 - INT( JP360/MILLEN(NIGAUSS) )
 C
         NIPCNT = 0
-        DO 251 ILOOP = 1, ILAST
-          NIPCNT = NIPCNT + MILLEN(ILOOP)
- 251    CONTINUE
+        DO I= 1, NIGAUSS*2
+          NIPCNT = NIPCNT + MILLEN(I)
+        ENDDO
         NIGAUSO = NIGAUSS
         HIGAUST = 'U'
         LIGIVEP = .TRUE.
@@ -793,26 +888,24 @@ cs end ga
       IF ( CHEQUAL( HPARN, 1, 6, 'g_pnts') ) THEN
         LFOUND = .TRUE.
         IF ( NIGAUSS .LE. 0 ) THEN
-          IRET = JPROUTINE + 1
+          IRET = JPROUTINE + 2
           CALL INTLOG(JP_ERROR,
      X      'INTIN: Impossible number of gaussian latitudes.',NIGAUSS)
           INTIN = IRET
           GOTO 900
         ENDIF
 C
-        ILAST = NIGAUSS*2 + 1
-        DO 240 ILOOP = 1, NIGAUSS
-          MILLEN(ILOOP) = INTV(ILOOP)
-          ILAST = ILAST - 1
-          MILLEN(ILAST) = INTV(ILOOP)
- 240    CONTINUE
+        DO I = 1, NIGAUSS
+          MILLEN(I)                 = INTV(I)
+          MILLEN(NIGAUSS*2 + 1 - I) = INTV(I)
+        ENDDO
 C
         NIAREA(4) = JP360 - INT( JP360/MILLEN(NIGAUSS) )
 C
         NIPCNT = 0
-        DO 250 ILOOP = 1, NIGAUSS*2
-          NIPCNT = NIPCNT + MILLEN(ILOOP)
- 250    CONTINUE
+        DO I = 1, NIGAUSS*2
+          NIPCNT = NIPCNT + MILLEN(I)
+        ENDDO
         NIGAUSO = NIGAUSS
         HIGAUST = 'U'
         LIGIVEP = .TRUE.
@@ -824,19 +917,17 @@ C
       IF ( CHEQUAL( HPARN, 1, 6, 'g_lats') ) THEN
         LFOUND = .TRUE.
         IF ( NIGAUSS .LE. 0 ) THEN
-          IRET  = JPROUTINE + 1
+          IRET  = JPROUTINE + 2
           CALL INTLOG(JP_ERROR,
      X      'INTIN: Impossible number of gaussian latitudes.',NIGAUSS)
           INTIN = IRET
           GOTO 900
         ENDIF
 C
-        ILAST = NIGAUSS*2 + 1
-        DO 260 ILOOP = 1, NIGAUSS
-          RIGAUSS(ILOOP) = REALV(ILOOP)
-          ILAST = ILAST - 1
-          RIGAUSS(ILAST) = -REALV(ILOOP)
- 260    CONTINUE
+        DO I = 1, NIGAUSS
+          RIGAUSS(I)                 =  REALV(I)
+          RIGAUSS(NIGAUSS*2 + 1 - I) = -REALV(I)
+        ENDDO
 C
         NIAREA(1) = INT( RIGAUSS(1) * PPMULT )
         NIAREA(2) = 0
@@ -848,15 +939,15 @@ C
         GOTO 900
       ENDIF
 C
-C     ------------------------------------------------------------------
-C*     Section 9.   Closedown.
-C     ------------------------------------------------------------------
+C     -----------------------------------------------------------------|
+C     Section 9.   Closedown.
+C     -----------------------------------------------------------------|
 C
   900 CONTINUE
       IF( .NOT. LFOUND ) THEN
         CALL INTLOG(JP_ERROR, 'INTIN: Unknown keyword used:', JPQUIET)
         CALL INTLOG(JP_ERROR, HPARN, JPQUIET)
-        INTIN = JPROUTINE + 2
+        INTIN = JPROUTINE + 9
       ENDIF
       RETURN
       END
diff --git a/interpolation/intisl.F b/interpolation/intisl.F
index d1889a7..eb8644e 100644
--- a/interpolation/intisl.F
+++ b/interpolation/intisl.F
@@ -73,7 +73,6 @@ C
       INTEGER OLDLSM(*), OLDFLD(*), NEWLSM(*), NEWFLD(*)
 C
 #include "parim.h"
-#include "intisl.h"
 #include "nifld.common"
 #include "nofld.common"
 C
@@ -93,7 +92,8 @@ C
       INTEGER ILSEC0(2),ILSEC1(1024),ILSEC2(1024),ILSEC3(2),ILSEC4(512)
       INTEGER IFSEC0(2),IFSEC1(1024),IFSEC2(1024),IFSEC3(2),IFSEC4(512)
       INTEGER IMSEC0(2),IMSEC1(1024),IMSEC2(1024),IMSEC3(2),IMSEC4(512)
-      INTEGER NFSEC0(2),NFSEC1(1024),NFSEC2(1024),NFSEC3(2),NFSEC4(512)
+      INTEGER                                     NFSEC3(2)
+C     INTEGER NFSEC0(2),NFSEC1(1024),NFSEC2(1024),          NFSEC4(512)
       INTEGER KLSEC4, KFSEC4, KMSEC4, KPSEC4, NEWTYPE
 #ifndef _CRAYFTN
 #if (!defined sgi)
@@ -109,7 +109,7 @@ C
       REAL ZLSEC2(1500), ZLSEC3(2), ZLSEC4(1)
       REAL ZFSEC2(1500), ZFSEC3(2), ZFSEC4(1)
       REAL ZMSEC2(1500), ZMSEC3(2), ZMSEC4(1)
-      REAL PFSEC2(1500), PFSEC3(2), PFSEC4(1)
+      REAL               PFSEC3(2), PFSEC4(1)  !PFSEC2(1500)
 C
       POINTER( IZLSEC4, ZLSEC4 )
       POINTER( IZFSEC4, ZFSEC4 )
diff --git a/interpolation/intlog.F b/interpolation/intlog.F
index 3b17025..e2f81fa 100644
--- a/interpolation/intlog.F
+++ b/interpolation/intlog.F
@@ -114,7 +114,7 @@ C
      X           'WARN ',
      X           'ERROR',
      X           'FATAL'/
-      INTEGER IRET, ILEN
+      INTEGER ILEN
 
 #ifdef MPI_DEBUG
       INTEGER my_id, ierr
diff --git a/interpolation/intlogr.F b/interpolation/intlogr.F
index 4a025e3..3998892 100644
--- a/interpolation/intlogr.F
+++ b/interpolation/intlogr.F
@@ -96,8 +96,6 @@ C
       INTEGER KLEVEL
       REAL PNUM
       CHARACTER *(*) MESSAGE
-C
-#include "intlog.h"
 
 #ifdef MPI_DEBUG
 #include "mpif.h"
@@ -114,7 +112,7 @@ C
      X           'WARN ',
      X           'ERROR',
      X           'FATAL'/
-      INTEGER IRET, ILEN
+      INTEGER ILEN
 
 #ifdef MPI_DEBUG
       INTEGER my_id, ierr
diff --git a/interpolation/intout.F b/interpolation/intout.F
index de5feb1..49112db 100644
--- a/interpolation/intout.F
+++ b/interpolation/intout.F
@@ -43,7 +43,7 @@ C
 C     JDEBUG   - Check if debug switched on.
 C     IBASINI  - Check basic initialisation of common blocks is done.
 C     CHEQUAL  - Compare two ASCII strings without regard to case.
-C     INTLOG(R)- Log error message.
+C     INTLOG   - Log error message.
 C     IGGLAT   - Compute gaussian latitudes for given truncation.
 C
 C
@@ -62,6 +62,11 @@ C----<
 C
       IMPLICIT NONE
 C
+C     Parameters
+C
+      INTEGER JPROUTINE
+      PARAMETER (JPROUTINE = 28200)
+C
 C     Function arguments
 C
       CHARACTER*(*) HPARN
@@ -69,11 +74,6 @@ C
       REAL REALV(*)
       INTEGER INTV(*)
 C
-C     Parameters
-C
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 28200 )
-C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
@@ -82,16 +82,17 @@ C
 C
 C     Local variables
 C
-      INTEGER ITEMP, I, IRET, ILOOP, ILAST, IFILE1
+      INTEGER ITEMP, I, IRET, IFILE1
       LOGICAL LFOUND
+      CHARACTER*1 CTEMP
+      CHARACTER*8 CTEMP8
 C
 C     Externals
 C
-      LOGICAL CHEQUAL
-      EXTERNAL CHEQUAL
+      LOGICAL CHEQUAL, ISOCTAHEDRAL, ISGGVALID
       INTEGER IGGLAT, JINDEX
+      EXTERNAL CHEQUAL, ISOCTAHEDRAL, ISGGVALID
       EXTERNAL IGGLAT, JINDEX
-      LOGICAL LOCTAHEDRAL_REQ
 C
 C     -----------------------------------------------------------------|
 C     Section 1.   Initialise
@@ -99,7 +100,7 @@ C     -----------------------------------------------------------------|
 C
   100 CONTINUE
 C
-      INTOUT  = 0
+      INTOUT = 0
       LFOUND = .FALSE.
 C
 C     Check if debug turned on
@@ -116,6 +117,117 @@ C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
+C     Output grid name.
+C     Note: compared to INTOUT('gridname'), rotation is supported
+C
+      IF( CHEQUAL( HPARN, 1, 8, 'gridname') ) THEN
+        CALL INTLOG(JP_DEBUG, 'INTOUT: gridname = '//CHARV,JPQUIET)
+        LFOUND = .TRUE.
+C
+C       Make sure we read a grid type and grid number from input
+        I = MIN(8,LEN(CHARV))
+        IF( 0.LT.INDEX(CHARV,CHAR(0)) ) I=MIN(I,INDEX(CHARV,CHAR(0))-1)
+        IF( 0.LT.INDEX(CHARV,' '    ) ) I=MIN(I,INDEX(CHARV,' '    )-1)
+        CTEMP8(1:8) = ' '
+        CTEMP8 = CHARV(1:I)
+        CTEMP = ' '
+        ITEMP = 0
+        IF(   .TRUE.   ) READ(CTEMP8,'(A1,I4)',ERR=203) CTEMP, ITEMP
+  203   IF( ITEMP.EQ.0 ) READ(CTEMP8,'(A1,I3)',ERR=204) CTEMP, ITEMP
+  204   IF( ITEMP.EQ.0 ) READ(CTEMP8,'(A1,I2)',ERR=205) CTEMP, ITEMP
+  205   IF( ITEMP.EQ.0 ) READ(CTEMP8,'(A1,I1)',ERR=206) CTEMP, ITEMP
+        IF( ITEMP.EQ.0 ) THEN
+  206     CONTINUE
+          PRINT *, "INTOUT: Invalid gridname (interpreting CHARV)"
+          PRINT *, "  CHARV='"//CHARV//"'"
+          PRINT *, "  CTEMP8='"//CTEMP8//"'"
+          PRINT *, "  CTEMP='"//CTEMP//"'"
+          PRINT *, "  ITEMP=", ITEMP
+          IRET   = JPROUTINE + 1
+          INTOUT = IRET
+          CALL INTLOG(JP_ERROR,
+     X      'INTOUT: Invalid gridname: '//TRIM(CTEMP8), JPQUIET)
+          GOTO 900
+        ENDIF
+C
+C       Make sure we have a valid grid type, following JGETGG
+C       (possible results are [ROF], uppercase)
+        IF(     CHEQUAL(CTEMP,1,1,'N') ) THEN
+          CTEMP = 'R'
+        ELSEIF( CHEQUAL(CTEMP,1,1,'O') ) THEN
+          CTEMP = 'O'
+        ELSEIF( CHEQUAL(CTEMP,1,1,'F') ) THEN
+          CTEMP = 'F'
+        ELSE
+          IRET   = JPROUTINE + 2
+          INTOUT = IRET
+          CALL INTLOG(JP_ERROR,
+     X      'INTOUT: Invalid gridname: '//TRIM(CTEMP8)//
+     X      ' (type "'//TRIM(CTEMP)//'" not recognized)', JPQUIET)
+          GOTO 900
+        ENDIF
+C
+C       Make sure we have a valid grid number
+        IF( .NOT.ISGGVALID(CTEMP,ITEMP) ) THEN
+          IRET   = JPROUTINE + 2
+          INTOUT = IRET
+          CALL INTLOG(JP_ERROR,
+     X      'INTOUT: Invalid grid: '//TRIM(CTEMP8)//
+     X      ' (number not recognized)', JPQUIET)
+          GOTO 900
+        ENDIF
+C
+C       Generate output grid structure if necessary
+        I = JPNOTYPE
+        IF( CTEMP.EQ.'F' .AND. .NOT. LNOROTA ) I = JPGAUSSIAN
+        IF( CTEMP.EQ.'F' .AND.       LNOROTA ) I = JPFGGROT
+        IF( CTEMP.NE.'F' .AND. .NOT. LNOROTA ) I = JPQUASI
+        IF( CTEMP.NE.'F' .AND.       LNOROTA ) I = JPQGGROT
+        LCHANGE = (NOREPR .EQ.JPNOTYPE) .OR.
+     X            (NOREPR .NE.I)        .OR.
+     X            (NOGAUSO.NE.ITEMP)    .OR.
+     X            (NOGAUSS.NE.ITEMP)    .OR.
+     X            (HOGAUST.NE.CTEMP)
+        IF( LCHANGE ) THEN
+          CALL JGETGG( ITEMP, CTEMP, ROGAUSS, NOLPTS, IRET)
+          IF( IRET .NE. 0 ) THEN
+            CALL INTLOG(JP_ERROR,
+     X        'INTOUT: JGETGG fail for NOGAUSS = ',ITEMP)
+            INTOUT = IRET
+            GOTO 900
+          ENDIF
+        ENDIF
+        NOGAUSO = ITEMP
+        NOGAUSS = ITEMP
+        HOGAUST = CTEMP
+C
+C       Compute first and last latlon grid points
+        NOAREA(1) = INT( ROGAUSS(1) * PPMULT )
+        NOAREA(2) = 0
+        NOAREA(3) = INT( ROGAUSS(NOGAUSS*2) * PPMULT )
+        NOAREA(4) = JP360 - JP360/NOLPTS(NOGAUSS)
+        NOPCNT = 0
+        DO I = 1, NOGAUSS*2
+          NOPCNT = NOPCNT + NOLPTS(I)
+        ENDDO
+C
+C       Additional global state variables changes
+        LOCTAHEDRAL = CTEMP.EQ.'O'
+        IF( CTEMP.EQ.'F' ) THEN
+          NOREPR = JPGAUSSIAN
+          IF( LNOROTA ) NOREPR = JPFGGROT
+        ELSE
+          NOREPR = JPQUASI
+          IF( LNOROTA ) NOREPR = JPQGGROT
+        ENDIF
+        LNOREPR = .TRUE.
+        LNOGRID = .FALSE.
+        NOGRID(1) = 0
+        NOGRID(2) = 0
+C
+        GOTO 900
+      ENDIF
+C
 C     Output grid.
 C
       IF( CHEQUAL( HPARN, 1, 4, 'grid') ) THEN
@@ -166,7 +278,8 @@ C       (Ignore the call if the gaussian value = 0.)
         NOGAUSS = INTV(1)
         LNOGAUS = .TRUE.
         IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-          CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
+          CTEMP = 'F'
+          CALL JGETGG(NOGAUSS,CTEMP,ROGAUSS,NOLPTS,IRET)
           IF( IRET .NE. 0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTOUT: JGETGG fail for NOGAUSS = ',NOGAUSS)
@@ -174,10 +287,10 @@ C       (Ignore the call if the gaussian value = 0.)
             GOTO 900
           ENDIF
           NOGAUSO = NOGAUSS
-          HOGAUST = 'F'
+          HOGAUST = CTEMP
         ENDIF
 C
-        NONS = 2*NOGAUSS
+        NONS = NOGAUSS*2
         GOTO 900
       ENDIF
 C
@@ -212,7 +325,7 @@ C       (Ignore the call if the gaussian value = 0.)
         LDOUBLE = .TRUE.
 c        NOREPR = JPNOTYPE
 c        LNOREPR = .TRUE.
-c        NONS = 2*NOGAUSS
+c        NONS = NOGAUSS*2
         GOTO 900
       ENDIF
 C
@@ -343,7 +456,7 @@ C       (Ignore the call if the gaussian value = 0.)
         LNOGAUS = .TRUE.
         NOREPR = JPNOTYPE
         LNOREPR = .TRUE.
-        NONS = 2*NOGAUSS
+        NONS = NOGAUSS*2
         GOTO 900
       ENDIF
 C
@@ -411,13 +524,17 @@ C
 C
 C     Output reduced.
 C
-      IF( CHEQUAL( HPARN, 1,  7, 'reduced') .OR.
-     X    CHEQUAL( HPARN, 1, 10, 'octahedral') ) THEN
+      IF( CHEQUAL( HPARN, 1,  7, 'reduced') ) THEN
         LFOUND = .TRUE.
+C
 C       (Ignore the call if the reduced value = 0.)
         IF( INTV(1) .EQ. 0 ) GOTO 900
-        IF( NOGAUSS .NE. INTV(1) ) LCHANGE = .TRUE.
-        CALL INTLOG(JP_DEBUG, 'INTOUT: reduced = ',INTV(1))
+C
+C       (Check for changes to internal interp. request)
+        LCHANGE = ((NOGAUSS.NE.INTV(1)) .OR. LOCTAHEDRAL )
+        LOCTAHEDRAL = .FALSE.
+C
+        CALL INTLOG(JP_DEBUG, 'INTOUT: '//TRIM(HPARN)//' = ',INTV(1))
         NOGAUSS = INTV(1)
         LNOGAUS = .TRUE.
         IF( NOREPR .NE. JPQUASI ) THEN
@@ -432,8 +549,10 @@ C       (Ignore the call if the reduced value = 0.)
           NOREPR  = JPQUASI
         ENDIF
         LNOREPR = .TRUE.
-        IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'R') ) THEN
-          CALL JGETGG( NOGAUSS, 'R', ROGAUSS, NOLPTS, IRET)
+        IF( (NOGAUSO.NE.NOGAUSS) .OR. (HOGAUST.EQ.'O')
+     X      .OR. ((HOGAUST.NE.'R') .AND. (HOGAUST.NE.'O')) ) THEN
+          CTEMP = 'R'
+          CALL JGETGG(NOGAUSS,CTEMP,ROGAUSS,NOLPTS,IRET)
           IF( IRET .NE. 0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTOUT: JGETGG fail for NOGAUSS = ',NOGAUSS)
@@ -441,27 +560,19 @@ C       (Ignore the call if the reduced value = 0.)
             GOTO 900
           ENDIF
           NOGAUSO = NOGAUSS
-          HOGAUST = 'R'
+          HOGAUST = CTEMP
         ENDIF
 C
         NOAREA(1) = INT( ROGAUSS(1) * PPMULT )
         NOAREA(2) = 0
         NOAREA(3) = INT( ROGAUSS(NOGAUSS*2) * PPMULT )
         NOAREA(4) = JP360 - JP360/NOLPTS(NOGAUSS)
+C
         NOPCNT = 0
-        DO ILOOP = 1, NOGAUSS*2
-          NOPCNT = NOPCNT + NOLPTS(ILOOP)
+        DO I = 1, NOGAUSS*2
+          NOPCNT = NOPCNT + NOLPTS(I)
         ENDDO
 C
-C       Check octahedral request
-C
-        LOCTAHEDRAL_REQ = CHEQUAL(HPARN,1,10,'octahedral') .AND.
-     X                    (INTV(1) .NE. 0)
-        IF ((LOCTAHEDRAL_REQ .AND. .NOT. LOCTAHEDRAL) .OR.
-     X      (.NOT. LOCTAHEDRAL_REQ .AND. LOCTAHEDRAL)) THEN
-          LCHANGE = .TRUE.
-        ENDIF
-        LOCTAHEDRAL = LOCTAHEDRAL_REQ
         GOTO 900
       ENDIF
 C
@@ -488,13 +599,12 @@ C       (Ignore the call if the user_regular_gaussian value = 0.)
         ENDIF
         LNOREPR = .TRUE.
 C
-        ILAST = NOGAUSS*2
-        DO ILOOP = 1, ILAST
-          NOLPTS(ILOOP) = NOGAUSS*4
-        ENDDO
+        NONS = NOGAUSS*2
+        NOLPTS(1:NOGAUSS*2) = NOGAUSS*4
         NOGAUSO = NOGAUSS
         HOGAUST = 'U'
-        LOGIVEP   = .TRUE.
+        LOGIVEP = .TRUE.
+        LOCTAHEDRAL = .FALSE.
 C
         GOTO 900
       ENDIF
@@ -536,20 +646,19 @@ C
           GOTO 900
         ENDIF
 C
-        ILAST = NOGAUSS*2 + 1
-        DO ILOOP = 1, NOGAUSS
-          NOLPTS(ILOOP) = INTV(ILOOP)
-          ILAST = ILAST - 1
-          NOLPTS(ILAST) = INTV(ILOOP)
+        DO I = 1, NOGAUSS
+          NOLPTS(I)                 = INTV(I)
+          NOLPTS(NOGAUSS*2 + 1 - I) = INTV(I)
         ENDDO
 C
         NOPCNT = 0
-        DO ILOOP = 1, NOGAUSS*2
-          NOPCNT = NOPCNT + NOLPTS(ILOOP)
+        DO I = 1, NOGAUSS*2
+          NOPCNT = NOPCNT + NOLPTS(I)
         ENDDO
         NOGAUSO = NOGAUSS
         HOGAUST = 'U'
         LOGIVEP = .TRUE.
+        LOCTAHEDRAL = ISOCTAHEDRAL(NOGAUSS,NOLPTS)
         GOTO 900
       ENDIF
 C
@@ -565,11 +674,9 @@ C
           GOTO 900
         ENDIF
 C
-        ILAST = NOGAUSS*2 + 1
-        DO ILOOP = 1, NOGAUSS
-          ROGAUSS(ILOOP) = REALV(ILOOP)
-          ILAST = ILAST - 1
-          ROGAUSS(ILAST) = -REALV(ILOOP)
+        DO I = 1, NOGAUSS
+          ROGAUSS(I)                 =  REALV(I)
+          ROGAUSS(NOGAUSS*2 + 1 - I) = -REALV(I)
         ENDDO
 C
         NOAREA(1) = INT( ROGAUSS(1) * PPMULT )
@@ -578,7 +685,7 @@ C
         NOAREA(4) = JP360 - JP360/NOLPTS(NOGAUSS)
         NOGAUSO = NOGAUSS
         HOGAUST = 'U'
-        LOGIVEL   = .TRUE.
+        LOGIVEL = .TRUE.
         GOTO 900
       ENDIF
 C
@@ -687,14 +794,11 @@ C
           GOTO 900
         ENDIF
 C
-        ILAST = NOREDLL
-        DO ILOOP = 1, NOREDLL
-          NOLPTS(ILOOP) = INTV(ILOOP)
-        ENDDO
+        NOLPTS(1:NOREDLL) = INTV(1:NOREDLL)
 C
         NOPCNT = 0
-        DO ILOOP = 1, NOREDLL-1
-          NOPCNT = NOPCNT + NOLPTS(ILOOP)
+        DO I = 1, NOREDLL-1
+          NOPCNT = NOPCNT + NOLPTS(I)
         ENDDO
         LOGIVEP = .TRUE.
         GOTO 900
@@ -712,9 +816,7 @@ C
           GOTO 900
         ENDIF
 C
-        DO ILOOP = 1, NOREDLL
-          ROREDLL(ILOOP) = REALV(ILOOP)
-        ENDDO
+        ROREDLL(1:NOREDLL) = REALV(1:NOREDLL)
 C
         NOAREA(1) = INT( ROREDLL(1) * PPMULT )
         NOAREA(2) = 0
@@ -772,20 +874,19 @@ C
 C
         CALL PBCLOSE(IFILE1, IRET)
 C
-        ILAST = NOGAUSS*2 + 1
-        DO ILOOP = 1, NOGAUSS
-          ILAST = ILAST - 1
-          NOLPTS(ILAST) = NOLPTS(ILOOP)
+        DO I = 1, NOGAUSS
+          NOLPTS(NOGAUSS*2 + 1 - I) = NOLPTS(I)
         ENDDO
 C
         NOPCNT = 0
-        DO ILOOP = 1, NOGAUSS*2
-          NOPCNT = NOPCNT + NOLPTS(ILOOP)
+        DO I = 1, NOGAUSS*2
+          NOPCNT = NOPCNT + NOLPTS(I)
         ENDDO
         NOGAUSO = NOGAUSS
         HOGAUST = 'U'
         LOGIVEP = .TRUE.
         LOGIVEL = .TRUE.
+        LOCTAHEDRAL = ISOCTAHEDRAL(NOGAUSS,NOLPTS)
 C
         IRET = IGGLAT(NOGAUSS*2, ROGAUSS, 0, 1)
         IF( IRET.NE.0 ) THEN
@@ -873,7 +974,8 @@ C
         IF( LNOGAUS ) THEN
           CALL INTLOG(JP_DEBUG,
      X      'INTOUT: replace gaussian specification = ', NOGAUSS)
-          CALL JGETGG( NOGAUSS, 'R', ROGAUSS, NOLPTS, IRET)
+          CTEMP = 'R'
+          CALL JGETGG(NOGAUSS,CTEMP,ROGAUSS,NOLPTS,IRET)
           IF( IRET .NE. 0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTOUT: JGETGG fail for NOGAUSS = ',NOGAUSS)
@@ -881,7 +983,7 @@ C
             GOTO 900
           ENDIF
           NOGAUSO = NOGAUSS
-          HOGAUST = 'R'
+          HOGAUST = CTEMP
 C
           IF( .NOT.LNOAREA ) THEN
             CALL INTLOG(JP_DEBUG,
@@ -891,8 +993,8 @@ C
             NOAREA(3) = INT( ROGAUSS(NOGAUSS*2) * PPMULT )
             NOAREA(4) = JP360 - JP360/NOLPTS(NOGAUSS)
             NOPCNT = 0
-            DO ILOOP = 1, NOGAUSS*2
-              NOPCNT = NOPCNT + NOLPTS(ILOOP)
+            DO I = 1, NOGAUSS*2
+              NOPCNT = NOPCNT + NOLPTS(I)
             ENDDO
             GOTO 900
           ENDIF
@@ -901,7 +1003,7 @@ C
       ENDIF
 C
 C     -----------------------------------------------------------------|
-C      Section 9.   Closedown.
+C     Section 9.   Closedown.
 C     -----------------------------------------------------------------|
 C
   900 CONTINUE
diff --git a/interpolation/intpnum.F b/interpolation/intpnum.F
index 7cc0544..a4b0c5b 100644
--- a/interpolation/intpnum.F
+++ b/interpolation/intpnum.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -39,7 +39,7 @@ C     Returns a 6-digit version number, aaabbc, where:
 C       aaa = 3-digit major number
 C       bb  = 2-digit minor number
 C       c   = 1-digit spare number (normally 0)
-C     
+C
 C
 C     Method
 C     ------
@@ -53,13 +53,13 @@ C
 C       **************************************
 C       * INTP_CYCLE version number = aaabbc *
 C       **************************************
-C     
+C
 C
 C     Externals
 C     ---------
 C
 C     None.
-C     
+C
 C
 C     Author
 C     ------
@@ -75,7 +75,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/interpolation/intuvdh.F b/interpolation/intuvdh.F
index dc80f35..1cdeb6d 100644
--- a/interpolation/intuvdh.F
+++ b/interpolation/intuvdh.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -91,6 +91,7 @@ C
 C     Externals
 C
       INTEGER IGSETUP
+      EXTERNAL IGSETUP
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise.
@@ -128,7 +129,7 @@ C
 C
 C     Setup GRIB sections for the output product
 C
-      IERR = IGSETUP( ISEC1, ISEC2, ISEC4 )
+      IERR = IGSETUP(ISEC1,ISEC2,ISEC3,ISEC4)
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,'INTUVDH: GRIB section setup fail',JPQUIET)
         INTUVDH = IERR
diff --git a/interpolation/intuvf.F b/interpolation/intuvf.F
deleted file mode 100644
index 2a9fcd8..0000000
--- a/interpolation/intuvf.F
+++ /dev/null
@@ -1,324 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities
-C granted to it by virtue of its status as an intergovernmental organisation
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTUVF( KVGRIB, KDGRIB, INLEN,
-     X                         KUGRIBO, KVGRIBO, OUTLEN)
-C
-C---->
-C**** INTUVF
-C
-C     Purpose
-C     -------
-C
-C     Interpolate input vorticity and divergence field to
-C     U and V fields.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INTUVF( KVGRIB, KDGRIB, INLEN, KUGRIBO,KVGRIBO,OUTLEN)
-C
-C     Input
-C     -----
-C
-C     KVGRIB - Input vorticity field  (spectral, GRIB format).
-C     KDGRIB - Input divergence field (spectral, GRIB format).
-C     INLEN  - Input field length (words).
-C
-C
-C     Output
-C     ------
-C
-C     KUGRIBO - Output U field (GRIB format).
-C     KVGRIBO - Output V field (GRIB format).
-C     OUTLEN  - Output field length (words).
-C
-C
-C     Method
-C     ------
-C
-C     Convert spectral vorticity/divergence to spectral U/V and then
-C     interpolate U and V to output fields.
-C
-C
-C     Externals
-C     ---------
-C
-C     IBASINI - Ensure basic interpolation setup is done.
-C     JVOD2UV - Converts spectral vorticity/divergence to spectral U/V.
-C     JMEMHAN - Allocate/deallocate scratch memory.
-C     INTFAU  - Prepare to interpolate unpacked input field.
-C     INTFBU  - Interpolate unpacked input field.
-C     INTLOG  - Log error message.
-C     RESET_C - Reset interpolation handling options using GRIB product.
-C     INSANE  - Ensure no outrageous values given for interpolation.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Jan 1995
-C
-C     J.D.Chambers     ECMWF        Feb 1997
-C     Allow for 64-bit pointers
-C
-C----<
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-C
-      INTEGER KVGRIB(*), KDGRIB(*), INLEN
-      INTEGER KUGRIBO(*), KVGRIBO(*), OUTLEN
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "intf.h"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPALLOC, JPDEALL, JPSCR3, JPSCR4
-      PARAMETER (JPROUTINE = 26800 )
-      PARAMETER (JPALLOC = 1)
-      PARAMETER (JPDEALL = 0)
-      PARAMETER (JPSCR3 = 3)
-      PARAMETER (JPSCR4 = 4)
-C
-C     Local variables
-C
-      INTEGER IERR, KPR, ISZVD, ISZUV, IWORD, ISAME
-      INTEGER IPVORT, IPDIV, IP_U, IP_V
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IUV
-      INTEGER*8 IVD
-#endif
-#endif
-      REAL UV, VD
-      POINTER ( IUV, UV )
-      POINTER ( IVD, VD )
-      DIMENSION UV( 1 ), VD( 1 )
-C
-C     Externals
-C
-      INTEGER INTFAU, INTFBU, RESET_C
-      INTEGER IBASINI, INSANE
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-      INTUVF = 0
-      IERR   = 0
-      KPR    = 0
-      IPVORT = 1
-C
-C     Ensure that basic initialisation has been done
-C
-      IERR = IBASINI(0)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: basic initialise failed',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.   Unpack the vorticity/divergence fields.
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-C     Get scratch memory for vorticity/divergence unpacked fields.
-C     Vorticity/divergence memory areas are adjacent.
-C
-C     Need to establish input truncation, so unpack GRIB sections 1
-C     and 2.
-C
-      IERR = 1
-      CALL GRIBEX(ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X            VD(IPVORT), ISZVD, KVGRIB, INLEN, IWORD, 'I',IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: GRIBEX decoding failed.',IERR)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-      NIRESO = ISEC2(2)
-      ISZVD = (NIRESO+1)*(NIRESO+2)
-      IPDIV  = 1 + ISZVD
-      CALL JMEMHAN( JPSCR4, IVD, ISZVD*2, JPALLOC, IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: Memory allocation fail.',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Decode data from GRIB code (no checking)
-C     Vorticity ...
-C
-      IWORD = INLEN
-      IERR  =  0
-      CALL GRSVCK(0)
-      IERR = 1
-      ISEC3(2) = NINT(RMISSGV)
-      ZSEC3(2) = RMISSGV
-      CALL GRIBEX(ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X            VD(IPVORT), ISZVD, KVGRIB, INLEN, IWORD, 'D',IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: GRIBEX decoding failed.',IERR)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Divergence ...
-C
-      IERR = 1
-      ISEC3(2) = NINT(RMISSGV)
-      ZSEC3(2) = RMISSGV
-      CALL GRIBEX(ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X            VD(IPDIV), ISZVD, KDGRIB, INLEN, IWORD, 'D',IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: GRIBEX decoding failed.',IERR)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Setup interpolation options from input GRIB characteristics.
-C
-      IERR = RESET_C( ISEC1, ISEC2, ZSEC2, ISEC4)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVF: Setup interp. options from GRIB failed.',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Check that no outrageous values given for interpolation
-C
-      ISAME = INSANE()
-      IF( ISAME.GT.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVF: Interpolation cannot use given values.',JPQUIET)
-        INTUVF = ISAME
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 3.   Convert spectral vorticity/divergence
-C                  to spectral U/V
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-C     Get scratch memory for U and V spectral fields.
-C     U and V memory areas are adjacent.
-C
-      ISZUV = (NIRESO+1)*(NIRESO+4)
-      IP_U = 1
-      IP_V = 1 + ISZUV
-      CALL JMEMHAN( JPSCR3, IUV, ISZUV*2, JPALLOC, IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: Memory allocation fail.',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Generate U and V with same truncation as input fields.
-C
-      CALL JVOD2UV( VD(IPVORT), VD(IPDIV), NIRESO,
-     X              UV(IP_U), UV(IP_V), NIRESO)
-C
-C     -----------------------------------------------------------------|
-C*    Section 4.   Interpolate U field.
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-C     Prepare to interpolate U field.
-C
-      NIFORM = 0
-      IERR = INTFAU( UV(IP_U), ISZUV, KUGRIBO, OUTLEN)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVF: Prepare to interpolate failed.',IERR)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Interpolate U field.
-C
-      IERR = INTFBU( UV(IP_U), ISZUV, KUGRIBO, OUTLEN)
-C
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: Interpolation failed.',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 5.   Interpolate V field.
-C     -----------------------------------------------------------------|
-C
-  500 CONTINUE
-C
-C     Prepare to interpolate V field.
-C
-      IERR = INTFAU( UV(IP_V), ISZUV, KVGRIBO, OUTLEN)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVF: Prepare to interpolate failed.',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     Interpolate V field.
-C
-      IERR = INTFBU( UV(IP_V), ISZUV, KVGRIBO, OUTLEN)
-C
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVF: Prepare to interpolate failed.',JPQUIET)
-        INTUVF = IERR
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 9.   Closedown.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing
-C
-      LCHANGE = .FALSE.
-      LSMCHNG = .FALSE.
-C
-C     Return the scratch memory.
-C
-      CALL JMEMHAN( JPSCR3, IUV, ISZUV*2, JPDEALL, IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: Memory deallocation fail',JPQUIET)
-        INTUVF = IERR
-      ENDIF
-C
-      CALL JMEMHAN( JPSCR4, IVD, ISZVD*2, JPDEALL, IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVF: Memory deallocation fail',JPQUIET)
-        INTUVF = IERR
-      ENDIF
-C
-      RETURN
-      END
-
diff --git a/interpolation/intuvgh.F b/interpolation/intuvgh.F
index 36e9228..39ce12a 100644
--- a/interpolation/intuvgh.F
+++ b/interpolation/intuvgh.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -59,7 +59,6 @@ C     IBASINI - Ensure basic interpolation setup is done.
 C     INTUVDH - Encodes/decodes data into/from GRIB code.
 C     JMEMHAN - Allocate scratch memory.
 C     GRIBEX  - GRIB decoding/encoding.
-C     ISCRSZ  - Calculate number of values in generated field.
 C     FIXAREA - Fixup area definition to correspond to grid definitions
 C     INTLOG  - Log error message.
 C     MKFRAME - Create a 'frame' from a rectangular field.
@@ -88,32 +87,27 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grfixed.h"
 #include "intf.h"
 #include "intlog.h"
 #include "current.h"
 C
 C     Parameters
 C
-      INTEGER JPROUTINE, JPALLOC, JPDEALL, JPSCR3, JPSCR4,JPSCR5
+      INTEGER JPROUTINE, JPALLOC, JPSCR4
       PARAMETER (JPROUTINE = 40170 )
-      PARAMETER (JPALLOC = 1) 
-      PARAMETER (JPDEALL = 0) 
-      PARAMETER (JPSCR3 = 3) 
-      PARAMETER (JPSCR4 = 4) 
-      PARAMETER (JPSCR5 = 5) 
+      PARAMETER (JPALLOC = 1)
+      PARAMETER (JPSCR4 = 4)
 C
 C     Local variables
 C
-      CHARACTER*1 HFUNC
       REAL OLDGRID(2), AREA(4), GRID(2), POLE(2)
       LOGICAL LOLDWIND, LFRAME
-      INTEGER IRET,KPR,ISZOUV,ISIZE,ISAME,IPARAM
+      INTEGER IRET, KPR, ISZOUV, ISIZE, ISAME, IPARAM
       INTEGER LOOP, NGAUSS
       INTEGER IPINU, IPINV, NUMPTS, NLON, NLAT, IN_U, IN_V
 #ifndef _CRAYFTN
 #ifdef POINTER_64
-      INTEGER*8 IOLDUV, ISWORK
+      INTEGER*8 IOUV, ISWORK
 #endif
 #endif
       REAL OLDUV, SWORK
@@ -122,8 +116,10 @@ C
 C
 C     Externals
 C
-      INTEGER RESET_C,ISCRSZ,FIXAREA,IBASINI,INSANE,INTUVDH,HIRLAMW
+      INTEGER RESET_C, FIXAREA, IBASINI, INSANE, INTUVDH, HIRLAMW
       INTEGER HRG2GGW, HLL2LLW
+      EXTERNAL RESET_C, FIXAREA, IBASINI, INSANE, INTUVDH, HIRLAMW
+      EXTERNAL HRG2GGW, HLL2LLW
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -339,8 +335,11 @@ C
 C
 C       Dynamically allocate memory for rotated gaussian grids
 C
-        NUMPTS = NOGAUSS * NOGAUSS
-        ISIZE = 2 * NUMPTS * 8 
+        NUMPTS = 0
+        DO LOOP = 1, NOGAUSS*2
+          NUMPTS = NUMPTS + NOLPTS(LOOP)
+        ENDDO
+        ISIZE = 2 * NUMPTS
         CALL JMEMHAN( 11, ISWORK, ISIZE, 1, IRET)
         IF( IRET.NE.0 ) THEN
           IF( LDEBUG ) CALL INTLOG(JP_ERROR,
diff --git a/interpolation/intuvp.F b/interpolation/intuvp.F
index 99a7d10..0bc32da 100644
--- a/interpolation/intuvp.F
+++ b/interpolation/intuvp.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -87,29 +87,26 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grfixed.h"
 #include "intf.h"
 C
 C     Parameters
 C
-      INTEGER JPROUTINE, JPALLOC, JPDEALL, JPSCR3, JPSCR4,JPSCR5
+      INTEGER JPROUTINE, JPALLOC, JPSCR3, JPSCR4, JPSCR5
       INTEGER JPVORT, JPDIVE
       PARAMETER (JPROUTINE = 26900 )
-      PARAMETER (JPALLOC = 1) 
-      PARAMETER (JPDEALL = 0) 
-      PARAMETER (JPSCR3 = 3) 
-      PARAMETER (JPSCR4 = 4) 
-      PARAMETER (JPSCR5 = 5) 
-      PARAMETER (JPVORT = 138) 
-      PARAMETER (JPDIVE = 155) 
+      PARAMETER (JPALLOC = 1)
+      PARAMETER (JPSCR3 = 3)
+      PARAMETER (JPSCR4 = 4)
+      PARAMETER (JPSCR5 = 5)
+      PARAMETER (JPVORT = 138)
+      PARAMETER (JPDIVE = 155)
 C
 C     Local variables
 C
-      CHARACTER*1 HFUNC
       REAL EW, NS, DUMMY
       LOGICAL LOLDWIND, LSPECUV
-      INTEGER IERR,KPR,ISZVD,ISZUV,IWORD,ISIZE,ILENF,ISAME,IDIVOFF
-      INTEGER NEXT, LOOP, MTRUNC, NTRUNC, NTROLD, NTROLD2, NPARAM
+      INTEGER IERR, KPR, ISZVD, ISZUV, ISIZE, ISAME, IDIVOFF
+      INTEGER LOOP, MTRUNC, NTRUNC, NTROLD, NTROLD2, NPARAM
       INTEGER NOLD, NLEN, NLENU, NLENV, HNORESO
       INTEGER INRESO, IHOLD
       LOGICAL LSTYLE
@@ -143,9 +140,12 @@ C
 C
 C     Externals
 C
-      INTEGER RESET_C,ISCRSZ,FIXAREA,AURESOL,DSSAREA
+      INTEGER RESET_C, ISCRSZ, FIXAREA, AURESOL, DSSAREA
       INTEGER IBASINI, INSANE, INTUVDH, INTUVXH
-      INTEGER INTUVPH, INTUVGH
+      INTEGER INTUVGH !, INTUVPH
+      EXTERNAL RESET_C, ISCRSZ, FIXAREA, AURESOL, DSSAREA
+      EXTERNAL IBASINI, INSANE, INTUVDH, INTUVXH
+      EXTERNAL INTUVGH !, INTUVPH
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -153,8 +153,8 @@ C     -----------------------------------------------------------------|
 C
   100 CONTINUE
       INTUVP = 0
-      IERR    = 0
-      KPR     = 0
+      IERR   = 0
+      KPR    = 0
 C
       IF( LFIRST ) THEN
         CALL GETENV('IGNORE_UV_EXTRA_MODE', EXTRA)
@@ -257,7 +257,7 @@ C
         GOTO 990
       ENDIF
 C
-C     Decode vorticity and divegence.
+C     Decode vorticity and divergence.
 C
       NPARAM = JPVORT
       NLEN = INLEN
diff --git a/interpolation/intuvp2.c b/interpolation/intuvp2.c
new file mode 100644
index 0000000..771d95b
--- /dev/null
+++ b/interpolation/intuvp2.c
@@ -0,0 +1,445 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+
+
+#include "grib_api.h"
+#include "emos.h"
+
+
+fortint intuvp2_(char* vort_grib_in, char* div_grib_in, fortint* length_in, char* vort_grib_out, char* div_grib_out, fortint* length_out)
+{
+
+    static double *vort_values_in = NULL;
+    static double *div_values_in  = NULL;
+    static double *vort_values_out = NULL;
+    static double *div_values_out  = NULL;
+    static size_t values_in_len = 0;
+    static size_t values_out_len = 0;
+
+
+    static float *vort_values_in1 = NULL;
+    static float *div_values_in1  = NULL;
+    static float *vort_values_out1 = NULL;
+    static float *div_values_out1  = NULL;
+    static size_t values_in_len1 = 0;
+    static size_t values_out_len1 = 0;
+
+    grib_handle* hu = NULL;
+    grib_handle* hv = NULL;
+
+    size_t inlen;
+    size_t outlen  = *length_out;
+    size_t outlen1  = *length_out;
+
+    long long_inlen  = *length_in;
+    fortint fortint_inlen  = *length_in;
+    fortint fortint_outlen = outlen;
+
+    int jpeg = 0, resetOutput = 0, what = 0;
+    long ii = 0;
+
+    char *text = "";
+    fortint   intv[4];
+    fortfloat realv[4];
+    long truncation;
+    grib_handle *handle1 = NULL, *handle2 = NULL;
+    grib_handle *outh_u = NULL, *outh_v = NULL;
+    int err = 0;
+    int grib_err = 0;
+    long accuracy = 0;
+
+    fortint out_length = 0;
+
+    const void* temp1;
+    const void* temp2;
+    char *intf2_debug ;
+    char *intf2_write ;
+    fortint outputRepresentation;
+    int gribex_compatibility;
+    grib_util_grid_spec spec={0,};
+    grib_util_packing_spec packing_spec={0,};
+
+    gribex_compatibility=grib_get_gribex_mode(0);
+
+    intf2_debug = getenv("INTF2_DEBUG");
+    intf2_write = getenv("INTF2_WRITE_TO_FILE");
+
+    outputRepresentation = int2_outrep();
+
+    if(outputRepresentation)
+        if(intf2_debug) {
+            printf("INTUVP2: Output Representation is Not set by user\n");
+        }
+
+    handle1 = grib_handle_new_from_message_copy(0,vort_grib_in,long_inlen);
+    if(!handle1) {
+        err = -1;
+        goto cleanup;
+    }
+
+    handle2 = grib_handle_new_from_message_copy(0,div_grib_in,long_inlen);
+    if(!handle2) {
+        err = -1;
+        goto cleanup;
+    }
+
+    /*----------------------------------*/
+    if( err = grib_get_size(handle1,"values",&inlen))
+    {
+        fprintf(stderr,"INTUVP2: Cannot get size for vorticity %s\n",grib_get_error_message(err));
+        goto cleanup;
+    }
+
+    if(intf2_debug) { printf("INTUVP2: inlen for vorticity: %d  \n",inlen); }
+
+    if(inlen > values_in_len)
+    {
+        if(vort_values_in) free(vort_values_in);
+        vort_values_in = (double*)malloc(sizeof(double)*inlen);
+        values_in_len = inlen;
+
+        if(!vort_values_in)
+        {
+            err = -1;
+            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_in %ld\n",inlen);
+            goto cleanup;
+        }
+
+        if(div_values_in) free(div_values_in);
+        div_values_in = (double*)malloc(sizeof(double)*inlen);
+        if(!div_values_in)
+        {
+            err = -1;
+            fprintf(stderr,"INTUVP2: Cannot allocate input array for divergency %d\n",inlen);
+            goto cleanup;
+        }
+    }
+
+/*
+    if( err = grib_get_size(handle2,"values",&inlen))
+    {
+        fprintf(stderr,"INTUVP2: Cannot get size for divergency %s\n",grib_get_error_message(err));
+        goto cleanup;
+    }
+*/
+    if(intf2_debug) { printf("INTUVP2: inlen for divergency: %d  \n",inlen); }
+
+
+    /* Default Accuracy */
+    if((err = grib_get_long(handle1,"bitsPerValue",&accuracy))!= GRIB_SUCCESS)
+    {
+        fprintf(stderr,"INTUVP2: Cannot get accuracy %s\n",grib_get_error_message(err));
+        return err;
+    }
+    intv[0] = accuracy;
+    if(err = int2_intin("accuracy",intv,realv,text))
+    {
+        fprintf(stderr,"INTUVP2: Accuracy setup INTIN failed %d\n",err);
+    }
+    if(intf2_debug)
+    {
+        printf("INTUVP2: Input Accuracy  %d  \n",accuracy);
+    }
+
+    /*----------------------------------*/
+
+    /* Get decoded values vorticity */
+    if(err = grib_get_double_array(handle1,"values",vort_values_in,&inlen))
+    {
+        fprintf(stderr,"INTUVP2: Cannot get decoded values %s\n",grib_get_error_message(err));
+        goto cleanup;
+    }
+
+    /* Get decoded values divergency */
+    if(err = grib_get_double_array(handle2,"values",div_values_in,&inlen))
+    {
+        fprintf(stderr,"INTUVP2: Cannot get decoded values %s\n",grib_get_error_message(err));
+        goto cleanup;
+    }
+    /*----------------------------------*/
+
+    /* get Truncation */
+    if(err = grib_get_long(handle1,"J", &truncation))
+    {
+        fprintf(stderr,"INTUVP2: Cannot get Truncation %s\n",grib_get_error_message(err));
+        goto cleanup;
+    }
+    intv[0] = truncation;
+    if(err = int2_intin("truncation",intv,realv,text))
+    {
+        fprintf(stderr,"INTUVP2: Truncation  setup INTIN failed %d\n",err);
+        goto cleanup;
+    }
+    if(outputRepresentation)
+    {
+        if(err = int2_intout("truncation",intv,realv,text))
+        {
+            fprintf(stderr,"INTUVP2: Truncation  setup INTOUT failed %d\n",err);
+            goto cleanup;
+        }
+    }
+
+    /*=============  INTUVY ====================================*/
+   if(outputRepresentation){
+        out_length = inlen;
+    }
+    else{
+        out_length = int2_estima();
+        if(!out_length){
+            fprintf(stdout,"INTUVP2: Estimate for length of output array is 0 \n");
+            err = -1;
+            goto cleanup;
+        }
+    }
+
+    if(out_length > values_out_len)
+    {
+        if(vort_values_out) free(vort_values_out);
+        vort_values_out = (double*)malloc(sizeof(double)*out_length);
+        values_out_len = out_length;
+
+        if(!vort_values_out)
+        {
+            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_out %ld\n",out_length);
+            err = -1;
+            goto cleanup;
+        }
+        if(div_values_out) free(div_values_out);
+        div_values_out = (double*)malloc(sizeof(double)*out_length);
+
+        if(!div_values_out)
+        {
+            fprintf(stdout,"INTUVP2: Cannot allocate div_values_out %ld\n",out_length);
+            err = -1;
+            goto cleanup;
+        }
+    }
+
+
+    fortint_inlen = inlen;
+    fortint_outlen = outlen;
+#ifdef REAL_8
+    if(err = int2_intuvu(vort_values_in, div_values_in, fortint_inlen, vort_values_out, div_values_out, &fortint_outlen))
+    {
+        fprintf(stderr,"INTUVP2 failed %d\n",err);
+        goto cleanup;
+    }
+#else
+    if(inlen > values_in_len1)
+    {
+        if(vort_values_in1) free(vort_values_in1);
+        vort_values_in1 = (float*)malloc(sizeof(float)*inlen);
+        values_in_len1 = inlen;
+
+        if(!vort_values_in1)
+        {
+            err = -1;
+            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_in %ld\n",inlen);
+            goto cleanup;
+        }
+
+        if(div_values_in1) free(div_values_in1);
+        div_values_in1 = (float*)malloc(sizeof(float)*inlen);
+        if(!div_values_in1)
+        {
+            err = -1;
+            fprintf(stderr,"INTUVP2: Cannot allocate input array for divergency %d\n",inlen);
+            goto cleanup;
+        }
+    }
+    if(out_length > values_out_len1)
+    {
+        if(vort_values_out1) free(vort_values_out1);
+        vort_values_out1 = (float*)malloc(sizeof(float)*out_length);
+        values_out_len1 = out_length;
+
+        if(!vort_values_out1)
+        {
+            fprintf(stdout,"INTUVP2: Cannot allocate vort_values_out %ld\n",out_length);
+            err = -1;
+            goto cleanup;
+        }
+        if(div_values_out1) free(div_values_out1);
+        div_values_out1 = (float*)malloc(sizeof(float)*out_length);
+
+        if(!div_values_out1)
+        {
+            fprintf(stdout,"INTUVP2: Cannot allocate div_values_out %ld\n",out_length);
+            err = -1;
+            goto cleanup;
+        }
+    }
+    for( ii = 0 ; ii < fortint_inlen; ii++){
+            vort_values_in1[ii] = vort_values_in[ii];
+   }
+    for( ii = 0 ; ii < fortint_inlen; ii++){
+            div_values_in1[ii] = div_values_in[ii];
+   }
+    if(err = int2_intuvu(vort_values_in1, div_values_in1, fortint_inlen, vort_values_out1, div_values_out1, &fortint_outlen))
+    {
+        fprintf(stderr,"INTUVP2 failed %d\n",err);
+        goto cleanup;
+    }
+    for( ii = 0 ; ii < fortint_outlen; ii++){
+            vort_values_in[ii] = vort_values_in1[ii];
+   }
+    for( ii = 0 ; ii < fortint_outlen; ii++){
+            div_values_in[ii] = div_values_in1[ii];
+   }
+#endif
+
+    *length_out = fortint_outlen;
+    outlen     = fortint_outlen;
+
+    if(intf2_debug)
+    {
+        int i;
+        printf("INTUVP2: outlen: %d  \n",outlen);
+        for(i=0; i<10 ; i++)
+        {
+            printf("INTUVP2: output data values U -  %d -  %f \n",i,vort_values_out[i]);
+            printf("INTUVP2: output data values V -  %d -  %f \n",i,div_values_out[i]);
+        }
+    }
+
+    if(outlen)
+    {
+        err=copy_spec_from_ksec(&spec,&packing_spec);
+
+        packing_spec.accuracy=GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
+        packing_spec.packing=GRIB_UTIL_PACKING_USE_PROVIDED;
+
+        if (err) {
+                  fprintf(stdout,"INTUVP2: ERROR - copy_grid_spec_from_ksec unable to copy spec: %d\n", err);
+                  goto cleanup;
+        }
+        if (spec.grid_type==GRIB_UTIL_GRID_SPEC_SH) {
+            if (0 && gribex_compatibility) {
+                double laplacianOperator=0;
+                long P=0;
+                grib_get_long(handle2,"P",&P);
+                if(err = grib_get_double(handle2,"laplacianOperator",&laplacianOperator))
+                {
+                    fprintf(stderr,"INTUVP2: Cannot Get P %s\n",grib_get_error_message(err));
+                    goto cleanup;
+                }
+                /*
+                if(err = grib_set_long(handle2,"computeLaplacianOperator",0))
+                {
+                    fprintf(stderr,"INTUVP2: Cannot Set computeLaplacianOperator %s\n",grib_get_error_message(err));
+                    goto cleanup;
+                }
+                if(err = grib_set_long(handle1,"computeLaplacianOperator",0))
+                {
+                    fprintf(stderr,"INTUVP2: Cannot Set computeLaplacianOperator %s\n",grib_get_error_message(err));
+                    goto cleanup;
+                }
+                if(err = grib_set_long(handle1,"P",P))
+                {
+                    fprintf(stderr,"INTUVP2: Cannot Set P %s\n",grib_get_error_message(err));
+                    goto cleanup;
+                }
+                if(err = grib_set_long(handle2,"P",P))
+                {
+                    fprintf(stderr,"INTUVP2: Cannot Set P %s\n",grib_get_error_message(err));
+                    goto cleanup;
+                }
+                */
+                packing_spec.computeLaplacianOperator=0;
+                packing_spec.truncateLaplacian=1;
+                packing_spec.laplacianOperator=laplacianOperator;
+            } else {
+                packing_spec.computeLaplacianOperator=1;
+            }
+        }
+
+        hu = grib_util_set_spec(handle1,&spec, &packing_spec, 0,vort_values_out, outlen, &err);
+        if(!hu)  {
+                   fprintf(stdout,"INTUVP2: ERROR - grib_util_set_spec: %d\n", err);
+                   if(!err) err = 1;
+                   goto cleanup;
+        }
+
+        hv = grib_util_set_spec(handle2,&spec, &packing_spec, 0,div_values_out, outlen, &err);
+        if(!hv)  {
+                   fprintf(stdout,"INTUVP2: ERROR - grib_util_set_spec: %d\n", err);
+                   if(!err) err = 1;
+                   goto cleanup;
+        }
+
+        /* U velocity*/
+        if(err = grib_set_long(hu,"paramId",131))
+        {
+            fprintf(stderr,"INTUVP2: Cannot Set V %s\n",grib_get_error_message(err));
+            goto cleanup;
+        }
+
+        err = grib_get_message(hu,&temp1,&outlen);
+        if(err!=0)
+        {
+            fprintf(stderr,"INTUVP2: ERROR - grib_get_message unable to generate message (U): %d\n",err);
+            goto cleanup;
+        }
+        if(temp1) {
+            if(intf2_debug) {
+                printf("INTUVP2: outlen u-comp -> %d \n", outlen);
+            }
+            memcpy(vort_grib_out,temp1,outlen);
+        }
+        else
+            fprintf(stderr,"INTUVP2: Error u-comp \n");
+        outlen = *length_out;
+
+        /* V velocity*/
+        if(err = grib_set_long(hv,"paramId",132))
+        {
+            fprintf(stderr,"INTUVP2: Cannot Set V %s\n",grib_get_error_message(err));
+            goto cleanup;
+        }
+        grib_get_message(hv,&temp2,&outlen);
+        if(err!=0)
+        {
+            fprintf(stderr,"INTUVP2: ERROR - grib_get_message unable to generate message (V): %d\n",err);
+            goto cleanup;
+        }
+        if(temp2) {
+            if(intf2_debug) {
+                printf("INTUVP2: outlen v-comp -> %d \n", outlen);
+            }
+            memcpy(div_grib_out,temp2,outlen);
+        }
+        else
+            fprintf(stderr,"INTUVP2: Error v-comp \n");
+        *length_out = outlen;
+
+        goto cleanup;
+
+    }
+    else {
+        fprintf(stderr,"INTUVP2: ERROR - INTUVP2  OUTLEN is: %d\n", outlen);
+        err = 1;
+    }
+
+cleanup:
+
+    if(resetOutput = int2_setrep(outputRepresentation)) printf("INTUVP2: Output Representation reset failed:  %d \n",resetOutput);
+    if(hu && (hu != handle1))     grib_handle_delete(hu);
+    if(hv && (hv != handle2))     grib_handle_delete(hv);
+    if(handle1)     {grib_handle_delete(handle1);handle1=0;};
+    if(handle2)     {grib_handle_delete(handle2);handle2=0;};
+
+    return err;
+}
+
+fortint intuvp2(char* vort_grib_in, char* div_grib_in, fortint* length_in, char* vort_grib_out, char* div_grib_out, fortint* length_out)
+{
+    return intuvp2_(vort_grib_in,div_grib_in,length_in,vort_grib_out,div_grib_out,length_out);
+}
diff --git a/interpolation/intuvph.F b/interpolation/intuvph.F
deleted file mode 100644
index 8b16789..0000000
--- a/interpolation/intuvph.F
+++ /dev/null
@@ -1,552 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities
-C granted to it by virtue of its status as an intergovernmental organisation
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTUVPH( KFIELD1, KFIELD2, INLEN,
-     X                          KUGRIBO, KVGRIBO,
-     X                          OUTLENU, OUTLENV)
-C
-C---->
-C**** INTUVPH
-C
-C     Purpose
-C     -------
-C
-C     Interpolate GRIB format input spectral vorticity and divergence,
-C     or spectral U and V, fields to GRIB format U and V fields.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INTUVPH(KFIELD1,KFIELD2,INLEN,
-C                    KUGRIBO,KVGRIBO,OUTLENU,OUTLENV)
-C
-C     Input
-C     -----
-C
-C     KFIELD1 - Input vorticity or U field  (spectral, GRIB format).
-C     KFIELD2 - Input divergence or V field (spectral, GRIB format).
-C     INLEN  - Input field length (words).
-C
-C
-C     Output
-C     ------
-C
-C     KUGRIBO - Output U field (GRIB format).
-C     KVGRIBO - Output V field (GRIB format).
-C     OUTLENU - Output U field length (words).
-C     OUTLENV - Output V field length (words).
-C
-C
-C     Method
-C     ------
-C
-C     Convert spectral vorticity/divergence to spectral U/V and then
-C     interpolate U and V to output fields.
-C
-C     Note that a common block is used in intf.h to hold the U/V
-C     fields before interpolation.
-C
-C     Externals
-C     ---------
-C
-C     IBASINI - Ensure basic interpolation setup is done.
-C     INTUVDH - Encodes/decodes data into/from GRIB code.
-C     INTUVXH - Interpolate U or V component spectral field to grid point.
-C     JVOD2UV - Converts spectral vorticity/divergence to spectral U/V.
-C     JMEMHAN - Allocate scratch memory.
-C     GRIBEX  - GRIB decoding/encoding.
-C     ISCRSZ  - Calculate number of values in generated field.
-C     FIXAREA - Fixup area definition to correspond to grid definitions
-C     INTLOG  - Log error message.
-C     RESET_C - Reset interpolation handling options using GRIB product.
-C     INSANE  - Ensure no outrageous values given for interpolation.
-C     GRSMKP  - P factor calculation switch for routine GRIBEX.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     February 2001
-C
-C
-C----<
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-C
-      INTEGER KFIELD1(*), KFIELD2(*), INLEN
-      INTEGER KUGRIBO(*), KVGRIBO(*), OUTLENU, OUTLENV
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grfixed.h"
-#include "intf.h"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPALLOC, JPDEALL, JPSCR3, JPSCR4,JPSCR5
-      PARAMETER (JPROUTINE = 40160 )
-      PARAMETER (JPALLOC = 1)
-      PARAMETER (JPDEALL = 0)
-      PARAMETER (JPSCR3 = 3)
-      PARAMETER (JPSCR4 = 4)
-      PARAMETER (JPSCR5 = 5)
-C
-C     Local variables
-C
-      CHARACTER*1 HFUNC
-      REAL EW, NS
-      LOGICAL LOLDWIND, LSPECUV
-      INTEGER IERR,KPR,ISZVD,ISZUV,IWORD,ISIZE,ILENF,ISAME,IPARAM
-      INTEGER NEXT, LOOP, MTRUNC, NTRUNC, NTROLD, NTROLD2, NPARAM
-      INTEGER MIRESO, MORESO, NOLD, NLEN
-C
-      LOGICAL LFIRST, LNEWUV
-      CHARACTER*3 EXTRA
-      DATA LFIRST/.TRUE./, LNEWUV/.TRUE./, EXTRA/'NO '/
-      SAVE LFIRST, LNEWUV
-C
-      DATA NTROLD/-1/, NTROLD2/-1/
-      SAVE NTROLD, NTROLD2
-      INTEGER IPVORT, IPDIV, IP_U, IP_V, IDIVOFF
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IZNFLDO
-#endif
-#endif
-      REAL ZNFLDO
-      POINTER ( IZNFLDO, ZNFLDO )
-      DIMENSION ZNFLDO( 1 )
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IUV, IVD
-#endif
-#endif
-      REAL UV, VD
-      POINTER ( IUV, UV )
-      POINTER ( IVD, VD )
-      DIMENSION UV( 1 ), VD( 1 )
-C
-C     Externals
-C
-      INTEGER RESET_C,ISCRSZ,FIXAREA,AURESOL
-      INTEGER IBASINI, INSANE, INTUVDH, INTUVXH
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      INTUVPH = 0
-      IERR    = 0
-      KPR     = 0
-      IPVORT  = 1
-C
-      IF( LFIRST ) THEN
-        CALL GETENV('IGNORE_UV_EXTRA_MODE', EXTRA)
-        IF((EXTRA(1:1).EQ.'Y').OR.(EXTRA(1:1).EQ.'y')) LNEWUV = .FALSE.
-        IF( LNEWUV ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      'INTUVPH: IGNORE_UV_EXTRA_MODE not turned on',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      'INTUVPH: IGNORE_UV_EXTRA_MODE turned on',JPQUIET)
-        ENDIF
-        LFIRST = .FALSE.
-      ENDIF
-C
-      MIRESO = NIRESO
-      MORESO = NORESO
-C
-      LOLDWIND = LWINDSET
-C
-C     Ensure that basic initialisation has been done
-C
-      IERR = IBASINI(0)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVPH: basic initialise failed',JPQUIET)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.   Unpack the input fields.
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-C     Need to establish input truncation, so unpack GRIB sections 1
-C     and 2.
-C
-      IPARAM = 0
-      ISZVD = 1
-      IERR = INTUVDH(VD(IPVORT),ISZVD,KFIELD1,INLEN,'I',IPARAM)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVPH: GRIB header decode failed',IERR)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-C     Check that the input is an ECMWF spectral field
-C
-      IF( (ISEC1(1).NE.128).OR.(ISEC2(1).NE.50) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVPH: Input is not ECMWF spectral field.',JPQUIET)
-        INTUVPH = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-C     Get scratch memory for input unpacked fields.
-C     Unpacked field memory areas are adjacent.
-C
-      NIRESO = ISEC2(2)
-      ISZVD  = (NIRESO+1)*(NIRESO+2)
-      IPDIV  = 1 + ISZVD
-      CALL JMEMHAN( JPSCR4, IVD, ISZVD*2, JPALLOC, IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVPH: Scratch memory type 4 allocation failed.',JPQUIET)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-C     Decode input fields..
-C
-      IERR = INTUVDH(VD(IPVORT),ISZVD,KFIELD1,INLEN,'D',IPARAM)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVPH: Vorticity decoding failed',IERR)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-      IERR = INTUVDH(VD(IPDIV),ISZVD,KFIELD2,INLEN,'D',IPARAM)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVPH: Divergence decoding failed',IERR)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-C     Setup interpolation options from input GRIB characteristics.
-C
-      IERR = RESET_C( ISEC1, ISEC2, ZSEC2, ISEC4)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVPH: Setup interp. options from GRIB failed.',JPQUIET)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-C     Check that no outrageous values given for interpolation
-C
-      ISAME = INSANE()
-      IF( (ISAME.GT.0).AND.(ISAME.NE.27261) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVPH: Interpolation cannot use given values.',JPQUIET)
-        INTUVPH = ISAME
-        GOTO 900
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 3.   Convert spectral vorticity/divergence
-C                  to spectral U/V
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-C     Spectral U and V for Tn are to be generated from vorticity
-C     and divergence spectral T(n-1)
-C
-C     Get scratch memory for U and V spectral fields.
-C     The memory areas are adjacent.
-C
-      IF( ISEC1(6).EQ.155 ) THEN
-C
-C       Truncate vorticity and divergence to correspond to U/V
-C
-C
-        IF( LARESOL.AND.LNEWUV ) THEN
-          IF( (NOGRID(1).NE.0).AND.(NOGRID(2).NE.0) ) THEN
-            EW = FLOAT(NOGRID(1))/PPMULT
-            NS = FLOAT(NOGRID(2))/PPMULT
-            NTRUNC = AURESOL(NS,EW) - 1
-          ELSE IF( NOGAUSS.NE.0 ) THEN
-            EW = 90.0/FLOAT(NOGAUSS)
-            NS = EW
-            NTRUNC = AURESOL(NS,EW) - 1
-          ELSE IF( LNORESO ) THEN
-            NTRUNC = NORESO - 1
-          ELSE
-            NTRUNC = NIRESO - 1
-          ENDIF
-          IF( NTRUNC.GT.(NIRESO-1) ) NTRUNC = NIRESO - 1
-C
-        ELSE IF( LNORESO ) THEN
-          NTRUNC = NORESO - 1
-        ELSE
-          NTRUNC = NIRESO - 1
-        ENDIF
-C
-        IF( LNEWUV ) THEN
-          MTRUNC = NTRUNC + 1
-        ELSE
-          NTRUNC = NTRUNC + 1
-          MTRUNC = NTRUNC
-        ENDIF
-
-C
-C       Check whether the output resolution is greater than the input
-C
-        IF( NTRUNC.GT.NIRESO ) THEN
-C
-C         Issue warning if the output resolution was user-supplied
-C
-          IF( .NOT.LARESOL ) THEN
-C
-C           Revert to the input truncation
-C
-            IF( NIRESO.NE.NTROLD2 ) THEN
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: spectral -> grid point interpolation',JPQUIET)
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: User supplied resolution = ',NTRUNC)
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: Input field resolution   = ',NIRESO)
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: User supplied resolution ignored',JPQUIET)
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: Input field resolution has been used',JPQUIET)
-              NTROLD2 = NIRESO
-            ENDIF
-            NTRUNC = NIRESO
-C
-          ELSE
-C
-C           Revert to the input truncation
-C
-            NTRUNC = NIRESO
-            IF( NTRUNC.NE.NTROLD2 ) THEN
-              NTROLD2 = NTRUNC
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: Auto-resolution selection too high',JPQUIET)
-              CALL INTLOG(JP_WARN,
-     X          'INTUVPH: Resolution set to input resolution: ',NTRUNC)
-            ENDIF
-          ENDIF
-        ENDIF
-C
-C
-        CALL INTLOG(JP_DEBUG,'INTUVPH: vo/div truncation = ', NTRUNC)
-        CALL INTLOG(JP_DEBUG,'INTUVPH: U/V truncation    = ', MTRUNC)
-C
-        ISIZE =  (NTRUNC+1)*(NTRUNC+2)
-        CALL JMEMHAN( JPSCR5, IZNFLDO, ISIZE*2, JPALLOC, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTUVP: Scratch memory type 5 allocation failed.',JPQUIET)
-          INTUVPH = JPROUTINE + 4
-          GOTO 900
-        ENDIF
-C
-        CALL SH2SH( VD(IPVORT), NIRESO, ZNFLDO, NTRUNC )
-C
-        IDIVOFF = IPVORT + (NTRUNC+1)*(NTRUNC+2)
-        CALL SH2SH( VD(IPDIV), NIRESO, ZNFLDO(IDIVOFF), NTRUNC )
-C
-        NEXT = 0
-        DO LOOP = NTRUNC, 0, -1
-          NEXT = NEXT + LOOP + 1
-          ZNFLDO(IDIVOFF+NEXT*2-2) = 0
-          ZNFLDO(IDIVOFF+NEXT*2-1) = 0
-          ZNFLDO(IPVORT +NEXT*2-2) = 0
-          ZNFLDO(IPVORT +NEXT*2-1) = 0
-        ENDDO
-C
-        ISZUV = (MTRUNC+1)*(MTRUNC+2)
-        IP_U  = 1
-        IP_V  = 1 + ISZUV
-        CALL JMEMHAN( JPSCR3, IUV, ISZUV*2, JPALLOC, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTUVPH: Scratch memory type 3 allocation failed.',JPQUIET)
-            INTUVPH = IERR
-          GOTO 900
-        ENDIF
-C
-C       Generate U and V from vorticity and divergence,
-C
-        CALL JVOD2UV(ZNFLDO(IPVORT),ZNFLDO(IDIVOFF),NTRUNC,
-     X               UV(IP_U),UV(IP_V),MTRUNC)
-C
-      ELSE
-C
-C       Get scratch memory for U and V spectral fields.
-C       The memory areas are adjacent.
-C
-        NTRUNC = NIRESO
-        ISZUV = (NIRESO+1)*(NIRESO+2)
-        IP_U  = 1
-        IP_V  = 1 + ISZUV
-        CALL JMEMHAN( JPSCR3, IUV, ISZUV*2, JPALLOC, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTUVPH: Scratch memory type 3 allocation failed.',JPQUIET)
-          INTUVPH = IERR
-          GOTO 900
-        ENDIF
-C
-C       Transfer input spectral U and V to the memory areas.
-C
-        DO LOOP = 0, ISZUV-1
-          UV(IP_U + LOOP) = VD(IPVORT + LOOP)
-          UV(IP_V + LOOP) = VD(IPDIV  + LOOP)
-        ENDDO
-C
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 4. Handle spectral output.
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-      IF( (LNORESO)            .AND.
-     X    ((NOREPR.EQ.JPSPHERE).OR.(NOREPR.EQ.JPSPHROT)) ) THEN
-C
-        CALL INTLOG(JP_DEBUG,
-     X    'INTUVPH: Produce spectral output with truncation',NORESO)
-C
-C       Set GRIBEX flag to force recalculation of complex packing factor
-C
-        CALL GRSMKP(1)
-C
-        ISIZE =  (NORESO+1)*(NORESO+2)
-        CALL JMEMHAN( JPSCR5, IZNFLDO, ISIZE*2, JPALLOC, IERR)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTUVPH: Scratch memory type 5 allocation failed.',JPQUIET)
-          INTUVPH = JPROUTINE + 4
-          GOTO 900
-        ENDIF
-C
-        IP_U = 1
-        CALL SH2SH( UV(1), NIRESO, ZNFLDO(IP_U), NORESO )
-C
-        IP_V = 1 + (NORESO+1)*(NORESO+2)
-        CALL SH2SH( UV(1+ISZUV), NIRESO, ZNFLDO(IP_V), NORESO )
-C
-        NIRESO = NORESO
-C
-      ENDIF
-C
-C     Has all processing been done (ie is the output spectral)?
-C
-      IF( (NOREPR.EQ.JPSPHERE).OR.(NOREPR.EQ.JPSPHROT) ) THEN
-C
-C       Code U into GRIB
-C
-        IERR = INTUVDH(ZNFLDO(IP_U),ISZUV,KUGRIBO,OUTLENU,'C',JP_U)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTUVPH: U encoding into GRIB failed.',IERR)
-          INTUVPH = JPROUTINE + 4
-          GOTO 900
-        ENDIF
-C
-C       Code V into GRIB
-C
-        IERR = INTUVDH(ZNFLDO(IP_V),ISZUV,KVGRIBO,OUTLENV,'C',JP_V)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTUVPH: V encoding into GRIB failed.',IERR)
-          INTUVPH = JPROUTINE + 4
-          GOTO 490
-        ENDIF
-C
-  490   CONTINUE
-C
-C       Turn off GRIBEX flag which forces recalculation of complex
-C       packing factor
-C
-        CALL GRSMKP(0)
-C
-        GOTO 900
-C
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 6.   Generate interpolated GRIB format U and V fields.
-C     -----------------------------------------------------------------|
-C
-  600 CONTINUE
-C
-C     Get scratch space for interpolation
-C
-      IERR = FIXAREA()
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVPH: Fixarea failed.',JPQUIET)
-        INTUVPH = IERR
-        GOTO 900
-      ENDIF
-C
-      ISIZE = ISCRSZ()*2
-      IF( ISIZE.LE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTUVPH: Get scratch space failed.',ISIZE)
-        INTUVPH = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-      CALL JMEMHAN( JPSCR5, IZNFLDO, ISIZE, JPALLOC, IERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVPH: Scratch memory(5) allocation failed.',JPQUIET)
-        INTUVPH = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-C
-      LWIND = .TRUE.
-      LWINDSET = .TRUE.
-C
-C     Interpolate U and V
-C
-      NOLD = NIRESO
-      NIRESO = MTRUNC
-      IERR = INTUVXH(UV,ISZUV,ZNFLDO,KUGRIBO,KVGRIBO,OUTLENU,OUTLENV)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTUVPH: U/V interpolation failed.',JPQUIET)
-        INTUVPH = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-C
-      NIRESO = NOLD
-C
-C     -----------------------------------------------------------------|
-C*    Section 9.   Return
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing and reset wind flag
-C
-      LCHANGE = .FALSE.
-      LSMCHNG = .FALSE.
-      LWINDSET  = LOLDWIND
-      LWIND = .FALSE.
-C
-      NIRESO = MIRESO
-      NORESO = MORESO
-C
-      RETURN
-      END
-
diff --git a/grib_api_merging/intuvs2.c b/interpolation/intuvs2.c
old mode 100755
new mode 100644
similarity index 100%
rename from grib_api_merging/intuvs2.c
rename to interpolation/intuvs2.c
diff --git a/interpolation/intuvu.F b/interpolation/intuvu.F
index 76e104e..11536dc 100644
--- a/interpolation/intuvu.F
+++ b/interpolation/intuvu.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -71,46 +71,68 @@ C----<
 C
       IMPLICIT NONE
 C
-C     Function arguments
-C
-      INTEGER INLEN, OUTLEN
-      REAL PVYIN(INLEN), PDVIN(INLEN), PUOUT(*), PVOUT(*)
-C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
 #include "grfixed.h"
 #include "intf.h"
 #include "current.h"
-#include "intlog.h"
 C
 C     Parameters
 C
-      INTEGER JPROUTINE, JPALLOC, JPDEALL, JPSCR3, JPSCR4, JPSCR5
-      PARAMETER (JPROUTINE = 27000 )
-      PARAMETER (JPALLOC = 1) 
-      PARAMETER (JPDEALL = 0) 
-      PARAMETER (JPSCR3 = 3) 
-      PARAMETER (JPSCR4 = 4) 
-      PARAMETER (JPSCR5 = 5) 
+      INTEGER JPROUTINE, JPALLOC, JPSCR3, JPSCR5
+      PARAMETER (JPROUTINE = 27000)
+      PARAMETER (JPALLOC = 1)
+      PARAMETER (JPSCR3 = 3)
+      PARAMETER (JPSCR5 = 5)
+C
+C     Function arguments
+C
+      INTEGER INLEN, OUTLEN
+      REAL PVYIN(INLEN), PDVIN(INLEN), PUOUT(*), PVOUT(*)
 C
 C     Local variables
 C
-      INTEGER IIHOLD, IOHOLD
-      DIMENSION IIHOLD(4), IOHOLD(4)
       CHARACTER*1 HOLDTYP
-      REAL EW, NS
-      LOGICAL LOLDWIND, LSPECUV, LSPCUVI, LSFCUVI
-      INTEGER IERR, KPR, ISZUV, ISIZE, NOLD, IDIVOFF
-      INTEGER NEXT, LOOP, MTRUNC, NTRUNC, NTROLD, NTROLD2, IPVORT
-      INTEGER KK, ISAME
-      INTEGER NLON, NLAT, NUMPTS, NGAUSS, NCOUNT, NUVFLAG
-      LOGICAL LSTYLE, LFRAME
-      REAL NORTH, SOUTH, WEST, EAST
-      REAL AREA(4), POLE(2), GRID(2)
+      CHARACTER*1 HTYPE
+      INTEGER IDIVOFF
+      INTEGER IERR
+      INTEGER IOHOLD(4)
+      INTEGER IPVORT
+      INTEGER ISIZE
+      INTEGER ISZUV
+      INTEGER KK
+      INTEGER KPR
       INTEGER KPTS(JPGTRUNC*2)
+      INTEGER LOOP
+      INTEGER MTRUNC
+      INTEGER NCOUNT
+      INTEGER NGAUSS
+      INTEGER NLAT
+      INTEGER NLON
+      INTEGER NOLD
+      INTEGER NTROLD
+      INTEGER NTROLD2
+      INTEGER NTRUNC
+      INTEGER NUMPTS
+      INTEGER NUVFLAG
+      LOGICAL LFRAME
+      LOGICAL LOLDWIND
+      LOGICAL LSFCUVI
+      LOGICAL LSPCUVI
+      LOGICAL LSPECUV
+      LOGICAL LSTYLE
+      REAL AREA(4)
+      REAL EAST
+      REAL EW
       REAL GLATS(JPGTRUNC*2)
+      REAL GRID(2)
+      REAL NORTH
+      REAL NS
       REAL OLDGRID(2)
+      REAL POLE(2)
+      REAL SOUTH
+      REAL WEST
 C
       LOGICAL LFIRST, LNEWUV
       CHARACTER*3 EXTRA
@@ -143,10 +165,12 @@ C
 C
 C     Externals
 C
-      INTEGER INTFAU,INTFBU,AURESOL,DSSAREA,FIXAREA
-      INTEGER HIRLAMW,HSP2GG
-      INTEGER INSANE
+      INTEGER INTFAU, INTFBU, AURESOL, DSSAREA, FIXAREA
+      INTEGER HIRLAMW, HSH2GG
       INTEGER HRG2GGW, HLL2LLW
+      EXTERNAL INTFAU, INTFBU, AURESOL, DSSAREA, FIXAREA
+      EXTERNAL HIRLAMW, HSH2GG
+      EXTERNAL HRG2GGW, HLL2LLW
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -189,21 +213,22 @@ C
 
 C
 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
-cs   Regular Gaussian has to be set here
-        IF( NOREPR.EQ.JPNOTYPE ) THEN
-         IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-            CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IERR)
-            IF( IERR.NE.0 ) THEN
-              CALL INTLOG(JP_ERROR,
-     X          'INTUVU: JGETGG failed, NOGAUSS = ',NOGAUSS)
-              INTUVU = IERR
-              GOTO 900
-            ENDIF
-            NOGAUSO = NOGAUSS
-            HOGAUST = 'F'
+cs    Regular Gaussian has to be set here
+      IF( NOREPR.EQ.JPNOTYPE ) THEN
+        IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
+          HTYPE = 'F'
+          CALL JGETGG(NOGAUSS,HTYPE,ROGAUSS,NOLPTS,IERR)
+          IF( IERR.NE.0 ) THEN
+            CALL INTLOG(JP_ERROR,
+     X        'INTUVU: JGETGG failed, NOGAUSS = ',NOGAUSS)
+            INTUVU = IERR
+            GOTO 900
           ENDIF
-          NOREPR = JPGAUSSIAN
+          NOGAUSO = NOGAUSS
+          HOGAUST = HTYPE
         ENDIF
+        NOREPR = JPGAUSSIAN
+      ENDIF
 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
 C
 C     -----------------------------------------------------------------|
@@ -323,7 +348,7 @@ C
           IF( IERR.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTUVU: Scratch memory type 5 allocn failed.',JPQUIET)
-            INTUVU = JPROUTINE + 4
+            INTUVU = JPROUTINE + 2
             GOTO 900
           ENDIF
 C
@@ -458,7 +483,7 @@ C
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_FATAL,
      X    'INTUVU: Get scratch space failed',JPQUIET)
-        INTUVU = JPROUTINE + 2
+        INTUVU = JPROUTINE + 3
         GOTO 900
       ENDIF
 C
@@ -511,7 +536,7 @@ C
             IERR = DSSAREA( EW, NS, NORTH, WEST, SOUTH, EAST)
             IF( IERR.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,'INTUVU: DSSAREA failed:',IERR)
-              INTUVU = JPROUTINE + 9
+              INTUVU = JPROUTINE + 3
               GOTO 900
             ENDIF
 C
@@ -586,29 +611,29 @@ C
      X    'INTUVU: INTFBU interpolate failed.',JPQUIET)
         INTUVU = IERR
         GOTO 900
-      ENDIF 
+      ENDIF
 
 cs      GOTO 900
        GOTO 890
 C
 C     -----------------------------------------------------------------|
-C*    Section 6.  Initialise spectral to grid-point with rotation 
+C*    Section 6.  Initialise spectral to grid-point with rotation
 C     -----------------------------------------------------------------|
 C
   700 CONTINUE
       IF( .NOT.LUSEHIR ) THEN
         CALL INTLOG(JP_ERROR,
-     X    'INTUVU : Unable to rotate spectral U or V:',JPQUIET)
-        INTUVU  = JPROUTINE + 3
+     X    'INTUVU: Unable to rotate spectral U or V:',JPQUIET)
+        INTUVU  = JPROUTINE + 6
         GOTO 900
       ENDIF
 C
       IF( (NOREPR.NE.JPREGROT).AND.(NOREPR.NE.JPREGULAR) ) THEN
         CALL INTLOG(JP_ERROR,
-     X    'INTUVU : For U/V, only regular lat/long',JPQUIET)
+     X    'INTUVU: For U/V, only regular lat/long',JPQUIET)
         CALL INTLOG(JP_ERROR,
-     X    'INTUVU : output rotated grids allowed',JPQUIET)
-        INTUVU  = JPROUTINE + 3
+     X    'INTUVU: output rotated grids allowed',JPQUIET)
+        INTUVU  = JPROUTINE + 6
         GOTO 900
       ENDIF
 C
@@ -624,7 +649,7 @@ cssssssssss
 cs      IERR = FIXAREA()
 cs      IF( IERR.NE.0 ) THEN
 cs        CALL INTLOG(JP_ERROR,'INTUVU: area fixup failed',JPQUIET)
-cs        INTUVU = JPROUTINE + 3
+cs        INTUVU = JPROUTINE + 6
 cs        GOTO 900
 cs      ENDIF
 C
@@ -646,11 +671,15 @@ C
   800 CONTINUE
 C
       NTRUNC = NIRESO
-      IERR = HSP2GG(NTRUNC,NGAUSS,KPTS,GLATS,ISIZE)
+      NGAUSS = 0
+      HTYPE  = ''
+      NS = 0.
+      EW = 0.
+      IERR = HSH2GG(NS,EW,NTRUNC,NGAUSS,HTYPE,KPTS,GLATS,ISIZE)
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVU: problem getting data for reduced grid',NTRUNC)
-        INTUVU = JPROUTINE + 4
+        INTUVU = JPROUTINE + 7
         GOTO 900
       ENDIF
       NCOUNT = ISIZE
@@ -661,7 +690,7 @@ C
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVU: memory alloc for reduced grid fail',JPQUIET)
-        INTUVU = JPROUTINE + 4
+        INTUVU = JPROUTINE + 7
         GOTO 900
       ENDIF
 C
@@ -673,16 +702,16 @@ C     Create the reduced gaussian grid
 C
       HOLDTYP = HOGAUST
       WEST = 0.0
-      EAST = 360.0 - (360.0/(NGAUSS*4))
+      EAST = 360.0 - (360.0/FLOAT(KPTS(NGAUSS)))
 C
 C     U component
 C
       CALL JAGGGP(UV(IP_U),NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID,NUVFLAG,IERR)
+     X            EAST,NGAUSS,HTYPE,KPTS,RGGRID,NUVFLAG,IERR)
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVU: spectral to reduced gaussian failed',JPQUIET)
-        INTUVU = JPROUTINE + 4
+        INTUVU = JPROUTINE + 7
         GOTO 900
       ENDIF
 C
@@ -691,11 +720,11 @@ C
 C     V component
 C
       CALL JAGGGP(UV(IP_V),NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID(1+NCOUNT),NUVFLAG,IERR)
+     X            EAST,NGAUSS,HTYPE,KPTS,RGGRID(1+NCOUNT),NUVFLAG,IERR)
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVU: spectral to reduced gaussian failed',JPQUIET)
-        INTUVU = JPROUTINE + 4
+        INTUVU = JPROUTINE + 7
         GOTO 900
       ENDIF
 
@@ -721,17 +750,17 @@ C
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVU: memory alloc for lat/long grid fail',JPQUIET)
-        INTUVU = JPROUTINE + 5
+        INTUVU = JPROUTINE + 8
         GOTO 900
       ENDIF
 C
-      IERR = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,AREA,
-     X               POLE,GRID,SWORK,SWORK(1+NUMPTS),NUMPTS,NLON,NLAT)
+      IERR = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,HTYPE,
+     X  AREA,POLE,GRID,SWORK,SWORK(1+NUMPTS),NUMPTS,NLON,NLAT)
 C
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVU: HIRLAMW rotation failed',JPQUIET)
-        INTUVU = JPROUTINE + 5
+        INTUVU = JPROUTINE + 8
         GOTO 900
       ENDIF
 c
@@ -770,23 +799,23 @@ C
 C       Rotate reduced gaussian to lat/long
 C
         IF( (NIREPR.EQ.JPGAUSSIAN).OR.(NIREPR.EQ.JPQUASI) ) THEN
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'INTUVU: Rotate reduced gaussian to lat/long',JPQUIET)
           IERR = HIRLAMW(LO12PT,
      X                   PVYIN,PDVIN,INLEN,
-     X                   NOGAUSS,AREA,POLE,GRID,
+     X                   NOGAUSS,HTYPE,AREA,POLE,GRID,
      X                   PUOUT,PVOUT,OUTLEN,NLON,NLAT)
           IF( IERR.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTUVU: HIRLAMW rotation failed',JPQUIET)
-            INTUVU = JPROUTINE + 3
+            INTUVU = JPROUTINE + 8
             GOTO 900
           ENDIF
 C
 C       Rotate lat/long to lat/long
 C
         ELSE
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'INTUVU: Rotate lat/long to lat/long',JPQUIET)
           OLDGRID(1) = REAL(NIGRID(1)) / PPMULT
           OLDGRID(2) = REAL(NIGRID(2)) / PPMULT
@@ -796,7 +825,7 @@ C
           IF( IERR.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'INTUVU: HLL2LLW rotation failed',JPQUIET)
-            INTUVU = JPROUTINE + 3
+            INTUVU = JPROUTINE + 8
             GOTO 900
           ENDIF
         ENDIF
@@ -807,7 +836,7 @@ C
 C     -----------------------------------------------------------------|
 C
 C
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'INTUVU: Rotate gaussian to gaussian',JPQUIET)
 C
 C       Dynamically allocate memory for rotated gaussian grids
@@ -821,9 +850,9 @@ cs        NGAUSS = ISEC2(10)
      X                 NIGAUSS,AREA,POLE,NOGAUSS,HOGAUST,
      X                 PUOUT,PVOUT,OUTLEN,NUMPTS)
         IF( IERR.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X        'INTUVU: HRG2GGW rotation failed',JPQUIET)
-            INTUVU = JPROUTINE + 4
+            INTUVU = JPROUTINE + 8
             GOTO 900
           ENDIF
 C
diff --git a/interpolation/intuvxh.F b/interpolation/intuvxh.F
index bd0fdc2..1e1b36e 100644
--- a/interpolation/intuvxh.F
+++ b/interpolation/intuvxh.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -82,17 +82,32 @@ C
 C
 C     Function arguments
 C
-      INTEGER KPARAM, KNVALS, KUGRIB(*), KVGRIB(*), OUTLENU, OUTLENV
+      INTEGER KNVALS, KUGRIB(*), KVGRIB(*), OUTLENU, OUTLENV
       REAL PUVSH(KNVALS*2), ZNFLDO(*)
 C
 C     Local variables
 C
-      LOGICAL LFRAME, LOLDWIND
-      INTEGER NPARAM, IRET, ILENF, NTRUNC, NGAUSS, ISIZE, NCOUNT
-      INTEGER NUVFLAG, NLON, NLAT, NUMPTS, NBYTES
-      REAL AREA(4), GRID(2), POLE(2), EAST, WEST
       CHARACTER*1 HOLDTYP
-      INTEGER LOOP
+      CHARACTER*1 HTYPE
+      INTEGER ILENF
+      INTEGER IRET
+      INTEGER ISIZE
+      INTEGER NCOUNT
+      INTEGER NGAUSS
+      INTEGER NLAT
+      INTEGER NLON
+      INTEGER NTRUNC
+      INTEGER NUMPTS
+      INTEGER NUVFLAG
+      LOGICAL LFRAME
+      LOGICAL LOLDWIND
+      REAL AREA(4)
+      REAL EAST
+      REAL EW
+      REAL GRID(2)
+      REAL NS
+      REAL POLE(2)
+      REAL WEST
 C
       REAL RGGRID, SWORK
       POINTER (IRGGRID, RGGRID(1) )
@@ -101,14 +116,14 @@ C
       INTEGER KPTS(JPGTRUNC*2)
       REAL GLATS(JPGTRUNC*2)
 C
-C     Externals
-C
-      INTEGER FIXAREA, INTFAU, INTFBU, INTUVDH, HSP2GG
-      INTEGER HIRLAMW, JMALLOC
-C
       DATA IRGGRID/0/, ISWORK/0/
       SAVE IRGGRID, ISWORK
 C
+C     Externals
+C
+      INTEGER INTFAU, INTFBU, INTUVDH, HSH2GG !, FIXAREA
+      INTEGER HIRLAMW
+C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise.
 C     -----------------------------------------------------------------|
@@ -282,7 +297,11 @@ C
   400 CONTINUE
 C
       NTRUNC = NIRESO
-      IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,GLATS,ISIZE)
+      NGAUSS = 0
+      HTYPE  = ''
+      NS = 0.
+      EW = 0.
+      IRET = HSH2GG(NTRUNC,NGAUSS,HTYPE,KPTS,GLATS,ISIZE)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVXH: problem getting data for reduced grid',NTRUNC)
@@ -309,12 +328,12 @@ C     Create the reduced gaussian grid
 C
       HOLDTYP = HOGAUST
       WEST = 0.0
-      EAST = 360.0 - (360.0/(NGAUSS*4))
+      EAST = 360.0 - (360.0/FLOAT(KPTS(NGAUSS)))
 C
 C     U component
 C
       CALL JAGGGP(PUVSH,NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID,NUVFLAG,IRET)
+     X            EAST,NGAUSS,HTYPE,KPTS,RGGRID,NUVFLAG,IRET)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVXH: spectral to reduced gaussian failed',JPQUIET)
@@ -327,7 +346,7 @@ C
 C     V component
 C
       CALL JAGGGP(PUVSH(1+KNVALS),NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID(1+NCOUNT),NUVFLAG,IRET)
+     X            EAST,NGAUSS,HTYPE,KPTS,RGGRID(1+NCOUNT),NUVFLAG,IRET)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTUVXH: spectral to reduced gaussian failed',JPQUIET)
@@ -360,8 +379,9 @@ C
         GOTO 900
       ENDIF
 C
-      IRET = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,AREA,
-     X               POLE,GRID,SWORK,SWORK(1+NUMPTS),NUMPTS,NLON,NLAT)
+      IRET = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,HTYPE,
+     X               AREA,POLE,GRID,SWORK,SWORK(1+NUMPTS),NUMPTS,NLON,
+     X               NLAT)
 C
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
diff --git a/interpolation/intvect.F b/interpolation/intvect.F
deleted file mode 100644
index 9210f55..0000000
--- a/interpolation/intvect.F
+++ /dev/null
@@ -1,511 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTVECT(PUFIELD,PVFIELD,KASIZE,
-     X                         KUGRIB,KVGRIB,OUTLEN)
-C
-C---->
-C**** INTVECT
-C
-C     Purpose
-C     -------
-C     Interpolate U or V component fields to grid point.
-C
-C
-C     Interface
-C     ---------
-C     IRET = INTVECT(PUFIELD,PVFIELD,KASIZE,
-C    X               KUGRIB,KVGRIB,OUTLEN)
-C
-C     Input
-C     -----
-C     PUFIELD - U values.
-C     PVFIELD - V values.
-C     KASIZE  - Size of input arrays
-C
-C
-C     Output
-C     ------
-C     KUGRIB - Output wind U component field (GRIB format).
-C     KVGRIB - Output wind V component field (GRIB format).
-C     OUTLEN - Output U field length (words).
-C
-C
-C     Method
-C     ------
-C     None.
-C
-C
-C     Externals
-C     ---------
-C     RESET_C - Reset interpolation handling options using GRIB product.
-C     IBASINI - Ensure basic interpolation setup is done.
-C     ISCRSZ  - Calculate number of values in generated field.
-C     INTUVDH - Encode/decode data into/from GRIB code.
-C     INTFAU  - Prepare to interpolate unpacked input field.
-C     INTFBU  - Interpolate unpacked input field.
-C     INTLOG  - Log error message.
-C     MKFRAME - Create a 'frame' from a rectangular field.
-C     INTUVGH - Interpolate GRIB U and V reduced gaussian to rotated GRIB
-C               U and V.
-C
-C
-C     Author
-C     ------
-C     J.D.Chambers     ECMWF     September 2004
-C
-C
-C----<
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "intf.h"
-#include "current.h"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 40170 )
-C
-C     Function arguments
-C
-      INTEGER KPARAM, KASIZE, KUGRIB(*), KVGRIB(*), OUTLEN
-      REAL PUFIELD(KASIZE), PVFIELD(KASIZE)
-C
-C     Local variables
-C
-      LOGICAL LFRAME, LOLDWIND, LOMISSV
-      INTEGER NPARAM, IRET, ILENF, NTRUNC, NGAUSS, ISIZE, NCOUNT
-      INTEGER NUVFLAG, NLON, NLAT, NBYTES, NSIZE
-      INTEGER ISZVD, IHOLD, ISAME
-      INTEGER IN_U, IN_V
-      REAL DUMMY
-      REAL AREA(4), GRID(2), POLE(2), EAST, WEST
-      CHARACTER*1 HOLDTYP
-      INTEGER LOOP
-      INTEGER OUTLENO
-C
-      REAL RGGRID, SWORK, TWORK
-      POINTER (IRGGRID, RGGRID(1) )
-      POINTER (ISWORK, SWORK(1) )
-      POINTER (ITWORK, TWORK(1) )
-C
-      INTEGER KPTS(JPGTRUNC*2)
-      REAL GLATS(JPGTRUNC*2)
-
-      LOGICAL LFIRST, LNEWUV, LSPECUV
-      CHARACTER*3 EXTRA
-C
-C     Externals
-C
-      INTEGER FIXAREA, INTFAU, INTFBU, INTUVDH, HSP2GG, IBASINI
-      INTEGER HIRLAMW, ISCRSZ, RESET_C, INSANE, INTUVGH
-C
-      DATA IRGGRID/0/, ISWORK/0/, ITWORK/0/
-      SAVE IRGGRID, ISWORK, ITWORK
-      DATA LFIRST/.TRUE./, LNEWUV/.TRUE./, EXTRA/'NO '/
-      SAVE LFIRST, LNEWUV
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      INTVECT = 0
-
-
-      IF( LFIRST ) THEN
-        CALL GETENV('IGNORE_UV_EXTRA_MODE', EXTRA)
-        IF((EXTRA(1:1).EQ.'Y').OR.(EXTRA(1:1).EQ.'y')) LNEWUV = .FALSE.
-        IF( LNEWUV ) THEN
-          CALL INTLOG(JP_DEBUG,
-     X      'INTVECT: IGNORE_UV_EXTRA_MODE not turned on',JPQUIET)
-        ELSE
-          CALL INTLOG(JP_DEBUG,
-     X      'INTVECT: IGNORE_UV_EXTRA_MODE turned on',JPQUIET)
-        ENDIF
-        LFIRST = .FALSE.
-      ENDIF
-C
-      LOLDWIND = LWINDSET
-C
-C     Ensure that basic initialisation has been done
-C
-      IRET = IBASINI(0)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: basic initialise failed',JPQUIET)
-        INTVECT = IRET
-        GOTO 900
-      ENDIF
-C
-C     Unpack GRIB sections 1 and 2.
-C
-      ISZVD = 1
-      IRET = INTUVDH(DUMMY,ISZVD,PUFIELD,KASIZE,'J',IN_U)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: GRIB header decode failed',IRET)
-        INTVECT = IRET
-        GOTO 900
-      ENDIF
-      NSIZE = ISEC4(1)
-      NIREPR = ISEC2(1)
-      LSPECUV = (NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT)
-      IF( LSPECUV ) NIRESO = ISEC2(2)
-C
-C     Setup interpolation options from input GRIB characteristics.
-C
-      IRET = RESET_C(ISEC1, ISEC2, ZSEC2, ISEC4)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: Setup interp. options from GRIB failed.',JPQUIET)
-        INTVECT = IRET
-        GOTO 900
-      ENDIF
-
-      IF(NIREPR.EQ.JPREGROT) THEN
-        OUTLEN = 0
-        IRET   = 0
-        CALL INTLOG(JP_DEBUG,
-     X    'INTF: Input U and V rotated lat/long fields ...',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'INTF: ... no interpolation has been done',JPQUIET)
-        GOTO 900
-      ENDIF
-C
-C       Only allowed rotations are:
-C        - spectral to regular lat/long
-C        - reduced gaussian to regular lat/long
-C
-      IF( LNOROTA ) THEN
-        IF( ((NOREPR.NE.JPREGROT).AND.(NOREPR.NE.JPREGULAR)).OR.
-     X      ((NIREPR.NE.JPSPHERE).AND.(NIREPR.NE.JPQUASI)) ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'INTVECT: For vector fields, only allowed rotations are:',
-     X      JPQUIET)
-          CALL INTLOG(JP_ERROR,
-     X      'INTVECT: spectral to regular lat/long, or',JPQUIET)
-          CALL INTLOG(JP_ERROR,
-     X      'INTVECT: reduced gaussian to regular lat/long',JPQUIET)
-          INTVECT = JPROUTINE + 1
-          GOTO 900
-        ENDIF
-      ENDIF
-C
-C     Check that no outrageous values given for interpolation
-C
-      ISAME = INSANE()
-      IF( (ISAME.GT.0).AND.(ISAME.NE.27261) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: Interpolation cannot use given values.',JPQUIET)
-        INTVECT = ISAME
-        GOTO 900
-      ENDIF
-C
-      LFRAME = LNOFRAME.AND.
-     X         ((NOREPR.EQ.JPREGULAR).OR.(NOREPR.EQ.JPGAUSSIAN).OR.
-     X          (NOREPR.EQ.JPREGROT ).OR.(NOREPR.EQ.JPFGGROT  ) )
-C
-C     Fill area limits (handles case when default 0/0/0/0 given)
-C
-      IRET = FIXAREA()
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: area fixup failed',JPQUIET)
-        INTVECT = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-C
-      AREA(1) = REAL(NOAREA(1))/PPMULT
-      AREA(2) = REAL(NOAREA(2))/PPMULT
-      AREA(3) = REAL(NOAREA(3))/PPMULT
-      AREA(4) = REAL(NOAREA(4))/PPMULT
-C
-      GRID(1) = REAL(NOGRID(1))/PPMULT
-      GRID(2) = REAL(NOGRID(2))/PPMULT
-C
-      IF( LNOROTA ) THEN
-        POLE(1) = REAL(NOROTA(1))/PPMULT
-        POLE(2) = REAL(NOROTA(2))/PPMULT
-        CALL INTLOG(JP_DEBUG,'INTVECT: Rotate the U & V fields',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'INTVECT: South pole lat  ',NOROTA(1))
-        CALL INTLOG(JP_DEBUG,'INTVECT: South pole long ',NOROTA(2))
-      ELSE
-        NOROTA(1) = -9000000
-        NOROTA(2) = 0
-      ENDIF
-C
-      IF( .NOT. LSPECUV ) GOTO 500
-C
-C     Get some scratch memory for the U and V fields
-C
-      ILENF = NSIZE
-      ISIZE = ILENF * 2
-      CALL JMEMHAN( 11, ISWORK, NSIZE*2, 1, IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: memory alloc for scratch memory failed',JPQUIET)
-        INTVECT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-C     Unpack U field
-C
-      NIFORM = 0
-      NIPARAM = IN_U
-      LWIND = .TRUE.
-      LOLDWIND = LWINDSET
-      LWINDSET = .TRUE.
-C
-      IRET = INTUVDH(SWORK,NSIZE,PUFIELD,KASIZE,'D',NIPARAM)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: Vorticity decoding failed',IRET)
-        INTVECT = IRET
-        GOTO 900
-      ENDIF
-      IN_U = ISEC1(6)
-C
-C     Unpack V field
-C
-      NIPARAM = IN_V
-C
-      IRET = INTUVDH(SWORK(1+NSIZE),NSIZE,PVFIELD,KASIZE,'D',NIPARAM)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: Vorticity decoding failed',IRET)
-        INTVECT = IRET
-        GOTO 900
-      ENDIF
-      IN_V = ISEC1(6)
-C
-      IF( LNOROTA ) GOTO 300
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.   Spectral to grid-point with no rotation
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-      CALL INTLOG(JP_DEBUG,
-     X  'INTVECT: Interpolate U & V fields with no rotation',JPQUIET)
-C
-      CALL JMEMHAN( 18, ITWORK, ISIZE, 1, IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: memory alloc for scratch memory failed',JPQUIET)
-        INTVECT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-C     Interpolate U field
-C
-      IRET = INTFAU(SWORK, NSIZE)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: Prepare to interpolate failed.',JPQUIET)
-        INTVECT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-      IRET = INTFBU(SWORK, NSIZE, TWORK, ILENF)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: Interpolation failed.',JPQUIET)
-        INTVECT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-C     Interpolate V field
-C
-      IRET = INTFAU(SWORK(1+NSIZE),NSIZE)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: Prepare to interpolate failed.',JPQUIET)
-        INTVECT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-      IRET = INTFBU(SWORK(1+NSIZE),NSIZE, TWORK(1+ILENF), ILENF)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTVECT: Interpolation failed.',JPQUIET)
-        INTVECT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-      GOTO 700
-C
-C     -----------------------------------------------------------------|
-C*    Section 3.   Spectral to grid-point with rotation
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-      IF( .NOT.LUSEHIR ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT : Unable to rotate spectral U or V:',JPQUIET)
-        INTVECT  = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-C
-C     Convert spectral to suitable global reduced gaussian
-C
-      NTRUNC = NIRESO
-      IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,GLATS,ISIZE)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: problem getting data for reduced grid',NTRUNC)
-        INTVECT = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-      NCOUNT = ISIZE
-C
-C     Dynamically allocate memory for global reduced gaussian grid
-C
-      CALL JMEMHAN( 18, IRGGRID, (NCOUNT*2), 1, IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: memory alloc for reduced grid fail',JPQUIET)
-        INTVECT = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-C     Set flag to show field is a wind component
-C
-      NUVFLAG = 1
-C
-C     Create the reduced gaussian grid
-C
-      HOLDTYP = HOGAUST
-      WEST = 0.0
-      EAST = 360.0 - (360.0/(NGAUSS*4))
-C
-C     U component spectral -> reduced gaussian
-C
-      CALL JAGGGP(SWORK,NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID,NUVFLAG,IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: spectral to reduced gaussian failed',JPQUIET)
-        INTVECT = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-      HOGAUST = HOLDTYP
-C
-C     V component spectral -> reduced gaussian
-C
-      CALL JAGGGP(SWORK(1+NSIZE),NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID(1+NCOUNT),NUVFLAG,IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: spectral to reduced gaussian failed',JPQUIET)
-        INTVECT = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-      HOGAUST = HOLDTYP
-C
-C     Rotate using 12-point horizontal interpolation
-C
-C     Dynamically allocate memory for rotated lat/long grid
-C
-      NLON = 1 + NINT((AREA(JPEAST)  - AREA(JPWEST)) /
-     X       GRID(JPWESTEP))                  ! SC
-      NLAT = 1 + NINT((AREA(JPNORTH) - AREA(JPSOUTH)) /
-     X       GRID(JPNSSTEP))                  ! SC
-C
-      ILENF = NLON * NLAT
-      ISIZE  = ILENF * 2
-      CALL JMEMHAN( 17, ITWORK, ISIZE, 1, IRET)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: memory alloc for lat/long grid fail',JPQUIET)
-        INTVECT = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-C
-      IRET = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,AREA,
-     X               POLE,GRID,TWORK,TWORK(1+ILENF),ILENF,NLON,NLAT)
-C
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: HIRLAMW rotation failed',JPQUIET)
-        INTVECT = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-C
-C     Set the components flag for rotated U and V coefficients
-C
-      ISEC2(19) = 8
-      NOWE = NLON
-      NONS = NLAT
-C
-      GOTO 700
-C
-C     -----------------------------------------------------------------|
-C*    Section 5.   Reduced gaussian to grid-point
-C     -----------------------------------------------------------------|
-C
-  500 CONTINUE
-C
-      INTVECT =
-     X       INTUVGH(PUFIELD,PVFIELD,KASIZE,KUGRIB,KVGRIB,OUTLEN,OUTLEN)
-C
-      GOTO 900
-C
-C     -----------------------------------------------------------------|
-C*    Section 7.   Pack the fields into GRIB format
-C     -----------------------------------------------------------------|
-C
-  700 CONTINUE
-C
-C     Reset the input format flag
-C
-      NIFORM = 1
-C
-C     If a 'frame' has been specified, build the frame
-C
-      IF( LFRAME ) THEN
-        LOMISSV = LIMISSV
-        LIMISSV = .TRUE.
-        CALL MKFRAME(NLON,NLAT,TWORK,RMISSGV,NOFRAME)
-        CALL MKFRAME(NLON,NLAT,TWORK(1+ILENF),RMISSGV,NOFRAME)
-      ENDIF
-C
-      OUTLENO = OUTLEN
-      IRET = INTUVDH(TWORK,ILENF,KUGRIB,OUTLEN,'C',IN_U)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: Wind component into GRIB encoding fail',IRET)
-        INTVECT = JPROUTINE + 7
-        GOTO 900
-      ENDIF
-
-C
-      OUTLEN = OUTLENO
-      IRET = INTUVDH(TWORK(1+ILENF),ILENF,KVGRIB,OUTLEN,'C',IN_V)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTVECT: Wind component into GRIB encoding fail',IRET)
-        INTVECT = JPROUTINE + 7
-        GOTO 900
-      ENDIF
-C
-      IF( LFRAME ) LIMISSV = LOMISSV
-C
-C     -----------------------------------------------------------------|
-C*    Section 9.   Return
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/grib_api_merging/intvect2.c b/interpolation/intvect2.c
old mode 100755
new mode 100644
similarity index 100%
rename from grib_api_merging/intvect2.c
rename to interpolation/intvect2.c
diff --git a/interpolation/intvecy.F b/interpolation/intvecy.F
index 347a6ac..43754fc 100644
--- a/interpolation/intvecy.F
+++ b/interpolation/intvecy.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -47,7 +47,6 @@ C     Externals
 C     ---------
 C     RESET_C - Reset interpolation handling options using GRIB product.
 C     IBASINI - Ensure basic interpolation setup is done.
-C     ISCRSZ  - Calculate number of values in generated field.
 C     INTFAU  - Prepare to interpolate unpacked input field.
 C     INTFBU  - Interpolate unpacked input field.
 C     INTLOG  - Log error message.
@@ -71,48 +70,68 @@ C
 #include "nofld.common"
 #include "intf.h"
 #include "current.h"
-#include "intlog.h"
+#include "grfixed.h"
 C
 C     Parameters
 C
       INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 40170 )
+      PARAMETER (JPROUTINE = 40170)
 C
 C     Function arguments
 C
-      INTEGER KPARAM, KASIZE, OUTLEN
+      INTEGER KASIZE, OUTLEN
       REAL PUFIELD(KASIZE), PVFIELD(KASIZE), PUOUT(*), PVOUT(*)
 C
 C     Local variables
 C
-      LOGICAL LFRAME, LOLDWIND, LOMISSV
-      INTEGER NPARAM, IRET, ILENF, NTRUNC, NGAUSS, ISIZE, NCOUNT
-      INTEGER NUVFLAG, NLON, NLAT, NBYTES, NSIZE
-      INTEGER IHOLD, ISAME
-      INTEGER IN_U, IN_V
-      INTEGER NUMPTS
-      REAL DUMMY
-      REAL AREA(4), GRID(2), POLE(2), EAST, WEST
-      REAL OLDGRID(2)
       CHARACTER*1 HOLDTYP
-      INTEGER LOOP
-C
-      REAL RGGRID, SWORK, TWORK
-      POINTER (IRGGRID, RGGRID(1) )
-      POINTER (ISWORK, SWORK(1) )
-      POINTER (ITWORK, TWORK(1) )
-C
+      CHARACTER*1 HTYPE
+      CHARACTER*3 EXTRA
+      INTEGER IRET
+      INTEGER ISAME
+      INTEGER ISIZE
       INTEGER KPTS(JPGTRUNC*2)
+      INTEGER LOOP
+      INTEGER NCOUNT
+      INTEGER NGAUSS
+      INTEGER NLAT
+      INTEGER NLON
+      INTEGER NSIZE
+      INTEGER NTRUNC
+      INTEGER NUMPTS
+      INTEGER NUVFLAG
+      LOGICAL LFIRST
+      LOGICAL LFRAME
+      LOGICAL LNEWUV
+      LOGICAL LOLDWIND
+      LOGICAL LOMISSV
+      LOGICAL LSPECUV
+      REAL AREA(4)
+      REAL EAST
       REAL GLATS(JPGTRUNC*2)
-
-      LOGICAL LFIRST, LNEWUV, LSPECUV
-      CHARACTER*3 EXTRA
+      REAL GRID(2)
+      REAL OLDGRID(2)
+      REAL POLE(2)
+      REAL RGGRID
+      REAL SWORK
+      REAL TWORK
+      REAL WEST
+cc    INTEGER IN_U
+cc    INTEGER IN_V
+      POINTER (IRGGRID,RGGRID(1))
+      POINTER (ISWORK,SWORK(1))
+      POINTER (ITWORK,TWORK(1))
 C
 C     Externals
 C
-      INTEGER FIXAREA, INTFAU, INTFBU, INTUVDH, HSP2GG, IBASINI
-      INTEGER HIRLAMW, ISCRSZ, RESET_C, INSANE, INTUVGH
+      CHARACTER*1 GGHTYPE
+      INTEGER FIXAREA, INTFAU, INTFBU, HSH2GG, IBASINI
+      INTEGER HIRLAMW, INSANE, INTUVGH !, RESET_C
       INTEGER HRG2GGW, HLL2LLW
+      EXTERNAL GGHTYPE
+      EXTERNAL FIXAREA, INTFAU, INTFBU, HSH2GG, IBASINI
+      EXTERNAL HIRLAMW, INSANE, INTUVGH !, RESET_C
+      EXTERNAL HRG2GGW, HLL2LLW
 C
       DATA IRGGRID/0/, ISWORK/0/, ITWORK/0/
       SAVE IRGGRID, ISWORK, ITWORK
@@ -304,7 +323,7 @@ C
 C
       IF( .NOT.LUSEHIR ) THEN
         CALL INTLOG(JP_ERROR,
-     X    'INTVECY : Unable to rotate spectral U or V:',JPQUIET)
+     X    'INTVECY: Unable to rotate spectral U or V:',JPQUIET)
         INTVECY  = JPROUTINE + 3
         GOTO 900
       ENDIF
@@ -312,7 +331,9 @@ C
 C     Convert spectral to suitable global reduced gaussian
 C
       NTRUNC = NIRESO
-      IRET = HSP2GG(NTRUNC,NGAUSS,KPTS,GLATS,ISIZE)
+      NGAUSS = 0
+      HTYPE  = ''
+      IRET = HSH2GG(NTRUNC,NGAUSS,HTYPE,KPTS,GLATS,ISIZE)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTVECY: problem getting data for reduced grid',NTRUNC)
@@ -340,12 +361,12 @@ C     Create the reduced gaussian grid
 C
       HOLDTYP = HOGAUST
       WEST = 0.0
-      EAST = 360.0 - (360.0/(NGAUSS*4))
+      EAST = 360.0 - (360.0/FLOAT(KPTS(NGAUSS)))
 C
 C     U component spectral -> reduced gaussian
 C
       CALL JAGGGP(PUFIELD,NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID,NUVFLAG,IRET)
+     X            EAST,NGAUSS,HTYPE,KPTS,RGGRID,NUVFLAG,IRET)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTVECY: spectral to reduced gaussian failed',JPQUIET)
@@ -358,7 +379,7 @@ C
 C     V component spectral -> reduced gaussian
 C
       CALL JAGGGP(PVFIELD,NTRUNC,GLATS(1),GLATS(NGAUSS*2),WEST,
-     X            EAST,NGAUSS,'R',KPTS,RGGRID(1+NCOUNT),NUVFLAG,IRET)
+     X            EAST,NGAUSS,HTYPE,KPTS,RGGRID(1+NCOUNT),NUVFLAG,IRET)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'INTVECY: spectral to reduced gaussian failed',JPQUIET)
@@ -379,8 +400,8 @@ C
 C
       OUTLEN = NLON * NLAT
 C
-      IRET = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,AREA,
-     X               POLE,GRID,PUOUT,PVOUT,OUTLEN,NLON,NLAT)
+      IRET = HIRLAMW(LO12PT,RGGRID,RGGRID(1+NCOUNT),NCOUNT,NGAUSS,HTYPE,
+     X  AREA,POLE,GRID,PUOUT,PVOUT,OUTLEN,NLON,NLAT)
 C
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
@@ -424,23 +445,24 @@ C
 C       Rotate reduced gaussian to lat/long
 C
         IF( (NIREPR.EQ.JPGAUSSIAN).OR.(NIREPR.EQ.JPQUASI) ) THEN
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'INTVECY: Rotate reduced gaussian to lat/long',JPQUIET)
+          HTYPE = GGHTYPE(NIREPR,NIGAUSS,MILLEN)
           IRET = HIRLAMW(LO12PT,
      X                   PUFIELD,PVFIELD,KASIZE,
-     X                   NIGAUSS,AREA,POLE,GRID,
+     X                   NIGAUSS,HTYPE,AREA,POLE,GRID,
      X                   PUOUT,PVOUT,OUTLEN,NLON,NLAT)
           IF( IRET.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
-     X        'INTUVGH: HIRLAMW rotation failed',JPQUIET)
-            INTUVGH = JPROUTINE + 3
+     X        'INTVECY: HIRLAMW rotation failed',JPQUIET)
+            INTVECY = JPROUTINE + 3
             GOTO 900
           ENDIF
 C
 C       Rotate lat/long to lat/long
 C
         ELSE
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'INTVECY: Rotate lat/long to lat/long',JPQUIET)
           OLDGRID(1) = REAL(NIGRID(1)) / PPMULT
           OLDGRID(2) = REAL(NIGRID(2)) / PPMULT
@@ -462,13 +484,13 @@ C     -----------------------------------------------------------------|
 C
   400   CONTINUE
 C
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+        CALL INTLOG(JP_DEBUG,
      X    'INTVECY: Rotate gaussian to gaussian',JPQUIET)
 C
 C       Dynamically allocate memory for rotated gaussian grids
 C
         NUMPTS = NOGAUSS * NOGAUSS
-        OUTLEN = 2 * NUMPTS * 8 
+        OUTLEN = 2 * NUMPTS * 8
 C
 cs        NGAUSS = ISEC2(10)
         IRET = HRG2GGW(LO12PT,
@@ -476,9 +498,9 @@ cs        NGAUSS = ISEC2(10)
      X                 NIGAUSS,AREA,POLE,NOGAUSS,HOGAUST,
      X                 PUOUT,PVOUT,OUTLEN,NUMPTS)
         IF( IRET.NE.0 ) THEN
-          IF( LDEBUG ) CALL INTLOG(JP_ERROR,
+          CALL INTLOG(JP_ERROR,
      X        'INTVECY: HRG2GGW rotation failed',JPQUIET)
-            INTUVGH = JPROUTINE + 4
+            INTVECY = JPROUTINE + 4
             GOTO 900
           ENDIF
 C
diff --git a/interpolation/intwave.F b/interpolation/intwave.F
deleted file mode 100644
index 3609df6..0000000
--- a/interpolation/intwave.F
+++ /dev/null
@@ -1,544 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION INTWAVE(INGRIB,INLEN,OUTGRIB,OUTLEN)
-C
-C---->
-C**** INTWAVE
-C
-C     Purpose
-C     -------
-C
-C     Interpolate an ECMWF wave field wave field or a reduced
-C     latitude-longitude field
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = INTWAVE(INGRIB,INLEN,OUTGRIB,OUTLEN)
-C
-C     Input
-C     -----
-C
-C     INGRIB - Input field (packed).
-C     INLEN  - Input field length (words).
-C
-C
-C     Output
-C     ------
-C
-C     OUTGRIB - Output field (packed).
-C     OUTLEN  - Output field length (words).
-C
-C
-C     Method
-C     ------
-C
-C     Call interpolation routine; then repack into GRIB format.
-C
-C
-C     Externals
-C     ---------
-C
-C     FIXAREA - Fixup area definition to correspond to grid definitions
-C     GRIBEX  - Decode/encode GRIB product.
-C     JMEMHAN - Handles memory allocation.
-C     JDEBUG  - Checks environment to switch on/off debug
-C     INTLOG  - Log error message.
-C     WAVEXXX - Interpolate wave fields (except 2D spectra)
-C     WV2DXXX - Interpolate wave 2D spectra fields
-C     MKFRAME - Create a 'frame' from a rectangular field
-C     MKBITMP - Apply a bitmap to a rectangular field
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Sep 1996
-C
-C
-C     Modifications
-C     -------------
-C
-C     J.D.Chambers     ECMWF     Nov 1966
-C     Add interpolation of 2D spectra.
-C
-C     J.D.Chambers     ECMWF        Feb 1997
-C     Allow for 64-bit pointers
-C
-C     J.D.Chambers     ECMWF        April 2004
-C     Handle reduced lat-long fields
-C
-C     S.Curic     ECMWF        April 2005
-C     Add support for frame and bitmap
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-      INTEGER INGRIB(*),OUTGRIB(*),INLEN,OUTLEN
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "intf.h"
-#include "grfixed.h"
-#include "jparams.h"
-C
-C     Parameters
-      INTEGER JPROUTINE, JP2DSP, JP2DSPQ, JPMAXLT
-
-      PARAMETER (JPROUTINE = 40200 )
-      PARAMETER (JP2DSP  = 250 )
-C                           ^---- parameter number for 2D wave spectra (whole)
-      PARAMETER (JP2DSPQ = 251 )
-C                           ^---- parameter number for 2D wave spectra (single)
-      PARAMETER (JPMAXLT = 361 )
-C
-C     Local variables
-C
-      CHARACTER*1 HFUNC
-
-      REAL ZMISS
-      DATA ZMISS/-9999999.0/
-      INTEGER IWORD, IRET, ISIZE, NSPEC, LAT1, LOOP, IERR
-      INTEGER KNUM, NUM_E_W, NUM_N_S, NFULLNS, NFULLEW
-      REAL GRIDWE, GRIDNS, NORTH, SOUTH, WEST, EAST
-      INTEGER NUMPTS
-      DIMENSION NUMPTS(JPMAXLT)
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 INEWAVE, IDISTNW, IZ2DSP, INEWIDX
-#endif
-#endif
-      REAL NEWAVE
-      POINTER ( INEWAVE, NEWAVE )
-      DIMENSION NEWAVE( 1 )
-      REAL*4 DISTNEW
-      POINTER ( IDISTNW, DISTNEW )
-      DIMENSION DISTNEW( 1 )
-      REAL Z2DSP
-      POINTER ( IZ2DSP, Z2DSP )
-      DIMENSION Z2DSP( 1 )
-      INTEGER NEWIDX
-      POINTER ( INEWIDX, NEWIDX )
-      DIMENSION NEWIDX( 1 )
-      REAL RNLAT, RSLAT, STEP
-      INTEGER NUMTABL, NUMPROD
-      LOGICAL LCOEFFS, L98WAVE, LFRAME, LBITMP
-      LOGICAL LDEBUG
-C
-C     Externals
-      INTEGER WAVEXXX, WV2DXXX, AREACHK, FIXAREA
-      INTEGER NUMPTNS, NUMPTWE, JNORSGG, MKBITMP
-C
-C ------------------------------------------------------------------
-C     Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      INTWAVE = 0
-C
-      LCOEFFS = .FALSE.
-C
-C     Check if debug option turned on
-      CALL JDEBUG()
-      LDEBUG = NDBG.GT.0
-C
-C     Allocate work array ZNFELDI if not already done.
-C
-      IF( IZNJDCI.NE.1952999238 ) THEN
-        CALL JMEMHAN( 19, IZNFLDI, JPEXPAND, 1, IRET)
-        IF( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_WARN,'INTWAVE: ZNFELDI allocate fail',JPQUIET)
-          INTWAVE= IRET
-          GOTO 900
-        ENDIF
-        IZNJDCI = 1952999238
-      ENDIF
-C
-C     Unpack GRIB message headers (using ZMISS as missing data value).
-C
-      IRET = 1
-      ISEC3(2) = NINT(ZMISS)
-      ZSEC3(2) = ZMISS
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZNFELDI,JPEXPAND,INGRIB,INLEN,IWORD,'J',IRET)
-      IF( (IRET.NE.0).AND.(IRET.NE.811) ) THEN
-        CALL INTLOG(JP_ERROR,'INTWAVE: GRIBEX decoding failed.',JPQUIET)
-        INTWAVE = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-C     Check that the field can be handled
-C
-      NUMTABL = ISEC1(2)*1000 + ISEC1(1)
-      NUMPROD = NUMTABL*1000 + ISEC1(6)
-      L98WAVE = (NUMTABL.EQ.98140).OR.
-     X          (NUMPROD.EQ.98131229).OR.
-     X          (NUMPROD.EQ.98131232).OR.
-     X          (NIREPR.EQ.26)
-      IF( .NOT.L98WAVE ) THEN
-        CALL INTLOG(JP_WARN,'INTWAVE: Not an ECMWF wave field',JPQUIET)
-        INTWAVE = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-      IF( ISEC2(1).NE.0 ) THEN
-        CALL INTLOG(JP_WARN,
-     X    'INTWAVE: Not a lat/long field',JPQUIET)
-        INTWAVE = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-      IF( (ISEC2(6).NE.128) .OR. (ISEC2(10).LT.10) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'INTWAVE: Cannot handle longitude increment',ISEC2(10))
-        INTWAVE = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 2.   Sort out interpolation area.
-C ------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      NSPEC = 1
-      KNUM  = ISEC2(3)
-C
-C     Adjust (sub-)area limits to suit the grid
-C
-      IRET = FIXAREA()
-      IF ( IRET .NE. 0 ) THEN
-        CALL INTLOG(JP_ERROR, 'INTWAVE: FIXAREA failed.',JPQUIET)
-        INTWAVE = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-      NORTH = FLOAT(NOAREA(1))/PPMULT
-      WEST  = FLOAT(NOAREA(2))/PPMULT
-      SOUTH = FLOAT(NOAREA(3))/PPMULT
-      EAST  = FLOAT(NOAREA(4))/PPMULT
-C
-C     Calculate the number of points E-W and N-S in new grid area
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN)) THEN
-        GRIDWE  = NOGAUSS
-        GRIDNS  = 0
-      ELSE IF( NOREPR.EQ.JPREDLL ) THEN
-        GRIDWE  = 360.0/NOLPTS((NOREDLL/2)+1)
-        GRIDNS  = FLOAT(NOGRID(2))/PPMULT
-      ELSE
-        GRIDWE  = FLOAT(NOGRID(1))/PPMULT
-        GRIDNS  = FLOAT(NOGRID(2))/PPMULT
-      ENDIF
-C
-      IRET = AREACHK(GRIDWE,GRIDNS,NORTH,WEST,SOUTH,EAST)
-      IF( IRET.NE.0 ) THEN
-        INTWAVE = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-      NOAREA(1) = NINT(NORTH*PPMULT)
-      NOAREA(2) = NINT(WEST*PPMULT)
-      NOAREA(3) = NINT(SOUTH*PPMULT)
-      NOAREA(4) = NINT(EAST*PPMULT)
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN)) THEN
-        GRIDWE  = 360.0/NOLPTS(NOGAUSS)
-        NUM_E_W = NUMPTWE(WEST,EAST,GRIDWE)
-        NFULLEW = NUMPTWE(0.0,360.0,GRIDWE) - 1
-        NUM_N_S = JNORSGG(SOUTH,ROGAUSS,NOGAUSS,1) - 
-     X            JNORSGG(NORTH,ROGAUSS,NOGAUSS,0) + 1
-        NFULLNS = NOGAUSS*2
-      ELSE IF( NOREPR.EQ.JPREDLL ) THEN
-        NUM_E_W = NUMPTWE(WEST,EAST,GRIDWE)
-        NFULLEW = NUMPTWE(0.0,360.0,GRIDWE) - 1
-        NUM_N_S = NUMPTNS(NORTH,SOUTH,GRIDNS)
-        NFULLNS = NOREDLL
-      ELSE
-        NUM_E_W = NUMPTWE(WEST,EAST,GRIDWE)
-        NFULLEW = NUMPTWE(0.0,360.0,GRIDWE) - 1
-        NUM_N_S = NUMPTNS(NORTH,SOUTH,GRIDNS)
-        NFULLNS = NUM_N_S
-      ENDIF
-C
-C
-C ------------------------------------------------------------------
-C     Section 3.   Interpolate wave fields other than 2D spectra.
-C ------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Handle if not 2D spectra ..
-C
-      IF( (ISEC1(6).NE.JP2DSP).AND.(ISEC1(6).NE.JP2DSPQ) ) THEN
-       IF( LDEBUG ) THEN
-       CALL INTLOG(JP_DEBUG,
-     X 'INTWAVE: Interpolate wave fields other than 2D spectra',JPQUIET)
-       ENDIF
-C
-C       Get some scratch space for the interpolated field.
-C
-        ISIZE = NFULLEW * NUM_N_S
-        CALL JMEMHAN( 3, INEWAVE, ISIZE, 1, IRET)
-        IF ( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Get work space fail.',JPQUIET)
-          INTWAVE = JPROUTINE + 7
-          GOTO 900
-        ENDIF
-C
-        ISIZE = NFULLEW * NFULLNS * 4
-        CALL JMEMHAN( 4, INEWIDX, ISIZE, 1, IRET)
-        IF ( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Get work space fail.',JPQUIET)
-          INTWAVE = JPROUTINE + 8
-          GOTO 900
-        ENDIF
-C
-        ISIZE = NFULLEW * NFULLNS * 10
-        CALL JMEMHAN( 5, IDISTNW, ISIZE, 1, IRET)
-        IF ( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Get work space fail.',JPQUIET)
-          INTWAVE = JPROUTINE + 9
-          GOTO 900
-        ENDIF
-
-C       Interpolate the field
-C
-        IRET = WAVEXXX(ISEC2,ISEC4,NUM_N_S,GRIDNS,GRIDWE,INGRIB,NEWIDX,
-     X                 DISTNEW,NEWAVE,NORTH,WEST,ZMISS)
-        IF( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Interpolation failed.',JPQUIET)
-          INTWAVE = JPROUTINE + 10
-          GOTO 900
-        ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 4.   Interpolate wave 2D spectra field.
-C ------------------------------------------------------------------
-C
-      ELSE
-C
-  400   CONTINUE
-
-      IF( LDEBUG ) THEN
-      CALL INTLOG(JP_DEBUG,
-     X 'INTWAVE: Interpolate wave 2D spectra field',JPQUIET)
-      ENDIF
-C
-C       Find number of 2D spectra values at each point
-C
-        IF( ISEC4(8).NE.0 ) LCOEFFS = .TRUE.
-        IF( (ISEC4(8).NE.0).AND.(ISEC1(6).NE.JP2DSPQ) ) THEN
-          NSPEC = ISEC4(50) * ISEC4(51)
-        ELSE
-          NSPEC = 1
-        ENDIF
-C
-C       Get some scratch space for the interpolated field.
-C
-        ISIZE = NSPEC * NFULLEW * NUM_N_S
-        CALL JMEMHAN( 3, INEWAVE, ISIZE, 1, IRET)
-        IF ( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Get work space fail.',JPQUIET)
-          INTWAVE = JPROUTINE + 11
-          GOTO 900
-        ENDIF
-C
-        ISIZE = NFULLEW * NFULLNS
-        CALL JMEMHAN( 4, INEWIDX, ISIZE, 1, IRET)
-        IF ( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Get work space fail.',JPQUIET)
-          INTWAVE = JPROUTINE + 12
-          GOTO 900
-        ENDIF
-C
-C       Interpolate the field
-C
-        IRET = WV2DXXX(ISEC2,ISEC4,NUM_N_S,GRIDNS,GRIDWE,
-     X                 INGRIB,NEWIDX,NEWAVE,NORTH,WEST,ZMISS)
-        IF( IRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTWAVE: Interpolation failed.',JPQUIET)
-          INTWAVE = JPROUTINE + 13
-          GOTO 900
-        ENDIF
-C
-      ENDIF
-C
-C ------------------------------------------------------------------
-C     Section 5.   Pack the interpolated field into GRIB.
-C ------------------------------------------------------------------
-C
-  500   CONTINUE
-
-C     If a 'bitmap' has been specified, build the bitmap
-C
-      LBITMP = LNOBITMP.AND.
-     X         ((NOREPR.EQ.JPREGROT).OR.(NOREPR.EQ.JPREGULAR).OR.
-     X          (NOREPR.EQ.JPGAUSSIAN))
-
-      IF( LBITMP ) THEN
-        CALL INTLOG(JP_DEBUG,'INTWAVE: MKBITMP is enabled',JPQUIET)
-        IERR = MKBITMP(NUM_E_W,NUM_N_S,NEWAVE,ZMISS)
-        IF( IERR.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,'INTFB: Problem applying bitmap',JPQUIET)
-          GOTO 900
-        ENDIF
-      ENDIF
-C     If a 'frame' has been specified, build the frame
-C
-       LFRAME = LNOFRAME.AND.
-     X         ((NOREPR.EQ.JPREGULAR).OR.(NOREPR.EQ.JPGAUSSIAN).OR.
-     X          (NOREPR.EQ.JPREGROT ).OR.(NOREPR.EQ.JPFGGROT  ) )
-
-         CALL INTLOG(JP_DEBUG,'INTWAVE: NUM_E_W ',NUM_E_W)
-         CALL INTLOG(JP_DEBUG,'INTWAVE: NUM_N_S ',NUM_N_S)
-      IF( LFRAME ) THEN
-           CALL INTLOG(JP_DEBUG,'INTWAVE: MKFRAME is enabled',JPQUIET)
-           CALL INTLOG(JP_DEBUG,'INTWAVE: NOFRAME ',NOFRAME)
-         CALL MKFRAME(NUM_E_W,NUM_N_S,NEWAVE,ZMISS,NOFRAME) 
-      ENDIF
-C
-C     GRIB sections 2 and 3 (bitmap) included
-C
-      ISEC1(5) = 192
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPREDLL) ) THEN
-C
-C       Reduced gaussian or reduced lat/long with (possible) subarea
-C
-        IF( NOREPR.EQ.JPQUASI ) THEN
-          ISEC2(1) = JPGAUSSIAN
-          ISEC2(10)= NOGAUSS
-        ELSE
-          ISEC2(1) = JPREGULAR
-          ISEC2(10)= NINT(GRIDNS*1000.0)
-        ENDIF
-        ISEC2(2) = 255
-        ISEC2(3) = NUM_N_S
-        ISEC2(5) = NINT(WEST*1000.0)
-        ISEC2(6) = 0
-        ISEC2(8) = NINT(EAST*1000.0)
-        ISEC2(17)= 1
-        ISEC4(1) = 0
-C
-        LAT1 = 0
- 510    CONTINUE
-        LAT1 = LAT1 + 1
-        IF( NOREPR.EQ.JPQUASI ) THEN
-          RNLAT = ROGAUSS(LAT1)
-          RSLAT = ROGAUSS(LAT1+NUM_N_S-1)
-        ELSE
-          RNLAT = 90.0 - (LAT1-1)*GRIDNS
-          RSLAT = 90.0 - (LAT1+NUM_N_S-2)*GRIDNS
-        ENDIF
-        IF( RNLAT.GT.NORTH ) GOTO 510
-C
-        ISEC2(4) = NINT(RNLAT*1000.0)
-        ISEC2(7) = NINT(RSLAT*1000.0)
-C
-        DO LOOP = LAT1, (NUM_N_S+LAT1-1)
-          ISEC2(23+LOOP-LAT1) = NOLPTS(LOOP)
-          ISEC4(1) = ISEC4(1) + ISEC2(23+LOOP-LAT1)
-        ENDDO
-C
-      ELSE
-C
-C       Regular gaussian or lat/long with (possible) subarea
-C
-        IF( NOREPR.EQ.JPGAUSSIAN ) THEN
-          ISEC2(1) = JPGAUSSIAN
-        ELSE
-          ISEC2(1) = JPREGULAR
-        ENDIF
-        ISEC2(2) = NUM_E_W
-        ISEC2(3) = NUM_N_S
-        ISEC2(4) = NINT(NORTH*1000.0)
-        ISEC2(5) = NINT(WEST*1000.0)
-        ISEC2(6) = 128
-        ISEC2(7) = NINT(SOUTH*1000.0)
-        ISEC2(8) = NINT(EAST*1000.0)
-        ISEC2(9) = NINT(GRIDWE*1000.0)
-        IF( NOREPR.EQ.JPGAUSSIAN ) THEN
-          ISEC2(10) = NOGAUSS
-        ELSE
-          ISEC2(10) = NINT(GRIDNS*1000.0)
-        ENDIF
-        ISEC2(17)= 0
-        ISEC4(1) = NUM_E_W * NUM_N_S
-      ENDIF
-C
-C     Use -9999999 as missing data value.
-C
-      ISEC3(2) = NINT(ZMISS)
-      ZSEC3(2) = ZMISS
-C
-      ISEC4(1) = ISEC4(1) * NSPEC
-      ISEC4(2) = NOACC
-      IF( LCOEFFS ) ISEC4(6)  = 16
-C            `-----> wave fields have additional flags for
-C                    NC1 and NC2 coefficients (floats stored
-C                    in integer array isec4)
-      IRET = 1
-C
-C     If grid-point output, setup for 2nd order packing if requested.
-C
-      IF( (NOREPR.NE.JPSPHERE) .AND. (NOREPR.NE.JPSPHROT) ) THEN
-        HFUNC = 'C'
-        IF( NOHFUNC.EQ.'K' ) THEN
-          HFUNC = 'K'
-          ISEC4(4)  = 64
-          ISEC4(6)  = 16
-          ISEC4(9)  = 32
-          ISEC4(10) = 16
-          ISEC4(12) = 8
-          ISEC4(13) = 4
-          ISEC4(14) = 0
-          ISEC4(15) = -1
-        ELSE
-          ISEC4(4)  = 0
-        ENDIF
-      ELSE
-        HFUNC = 'C'
-        IF( NOHFUNC.EQ.'C' ) THEN
-          ISEC2(6) = 2
-          ISEC4(4) = 64
-        ELSE IF( NOHFUNC.EQ.'S' ) THEN
-          ISEC2(6) = 1
-          ISEC4(4) = 0
-        ENDIF
-
-      ENDIF
-
-C
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             NEWAVE,ISEC4(1),OUTGRIB,OUTLEN,IWORD,HFUNC,IRET)
-C
-      IF ( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,'INTWAVE: GRIBEX encoding failed.',IRET)
-        INTWAVE = JPROUTINE + 14
-        GOTO 900
-      ENDIF
-      OUTLEN = IWORD
-C
-C ------------------------------------------------------------------
-C*    Section 9.   Closedown.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-C     Clear change flags for next product processing
-C
-      LCHANGE = .FALSE.
-      LSMCHNG = .FALSE.
-C
-      RETURN
-      END
diff --git a/interpolation/intwave2.F b/interpolation/intwave2.F
index fed71bc..ca75620 100644
--- a/interpolation/intwave2.F
+++ b/interpolation/intwave2.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -70,7 +70,8 @@ C
       IMPLICIT NONE
 C
 C     Function arguments
-      INTEGER INGRIB(*),OUTGRIB(*),INLEN,OUTLEN
+      INTEGER INLEN,OUTLEN
+      INTEGER INGRIB(*),OUTGRIB(*)
 C
 #include "parim.h"
 #include "nifld.common"
@@ -83,10 +84,8 @@ C     Parameters
       INTEGER JPROUTINE, JP2DSP, JP2DSPQ, JPMAXLT
 
       PARAMETER (JPROUTINE = 40200 )
-      PARAMETER (JP2DSP  = 250 )
-C                           ^---- parameter number for 2D wave spectra (whole)
-      PARAMETER (JP2DSPQ = 251 )
-C                           ^---- parameter number for 2D wave spectra (single)
+      PARAMETER (JP2DSP  = 250 )  ! for 2D wave spectra (whole)
+      PARAMETER (JP2DSPQ = 251 )  ! for 2D wave spectra (single)
       PARAMETER (JPMAXLT = 1801 )
 C
 C     Local variables
@@ -117,7 +116,7 @@ C
       INTEGER NEWIDX
       POINTER ( INEWIDX, NEWIDX )
       DIMENSION NEWIDX( 1 )
-      REAL RNLAT, RSLAT, STEP
+      REAL RNLAT, RSLAT
       INTEGER NUMTABL, NUMPROD
       LOGICAL LCOEFFS, L98WAVE, LFRAME, LBITMP
       LOGICAL LDEBUG
@@ -246,7 +245,7 @@ C
         GRIDWE  = 360.0/NOLPTS(NOGAUSS)
         NUM_E_W = NUMPTWE(WEST,EAST,GRIDWE)
         NFULLEW = NUMPTWE(0.0,360.0,GRIDWE) - 1
-        NUM_N_S = JNORSGG(SOUTH,ROGAUSS,NOGAUSS,1) - 
+        NUM_N_S = JNORSGG(SOUTH,ROGAUSS,NOGAUSS,1) -
      X            JNORSGG(NORTH,ROGAUSS,NOGAUSS,0) + 1
         NFULLNS = NOGAUSS*2
       ELSE IF( NOREPR.EQ.JPREDLL ) THEN
@@ -294,7 +293,8 @@ C
           ENDDO
         ENDIF
       ENDIF
-C--------------------------------------------------------------------
+C
+C
 C ------------------------------------------------------------------
 C     Section 3.   Interpolate wave fields other than 2D spectra.
 C ------------------------------------------------------------------
@@ -430,7 +430,7 @@ C
       IF( LFRAME ) THEN
            CALL INTLOG(JP_DEBUG,'INTWAVE2: MKFRAME is enabled',JPQUIET)
            CALL INTLOG(JP_DEBUG,'INTWAVE2: NOFRAME ',NOFRAME)
-         CALL MKFRAME(NUM_E_W,NUM_N_S,NEWAVE,ZMISS,NOFRAME) 
+         CALL MKFRAME(NUM_E_W,NUM_N_S,NEWAVE,ZMISS,NOFRAME)
       ENDIF
 C
 C     GRIB sections 2 and 3 (bitmap) included
diff --git a/interpolation/intwavu.F b/interpolation/intwavu.F
index 9131503..f4a6d96 100644
--- a/interpolation/intwavu.F
+++ b/interpolation/intwavu.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -70,8 +70,7 @@ C
 C
 C     Function arguments
       INTEGER INLEN,OUTLEN
-      REAL INFLD, OUTFLD
-      DIMENSION INFLD(*),OUTFLD(*)
+      REAL INFLD(*), OUTFLD(*)
 C
 #include "parim.h"
 #include "nifld.common"
@@ -84,32 +83,27 @@ C     Parameters
       INTEGER JPROUTINE, JP2DSP, JP2DSPQ, JPMAXLT
 
       PARAMETER (JPROUTINE = 40200 )
-      PARAMETER (JP2DSP  = 250 )
-C                           ^---- parameter number for 2D wave spectra (whole)
-      PARAMETER (JP2DSPQ = 251 )
-C                           ^---- parameter number for 2D wave spectra (single)
+      PARAMETER (JP2DSP  = 250 )  ! for 2D wave spectra (whole)
+      PARAMETER (JP2DSPQ = 251 )  ! for 2D wave spectra (single)
       PARAMETER (JPMAXLT = 1801 )
 C
 C     Local variables
 C
-      CHARACTER*1 HFUNC
-
       REAL ZMISS
 cs      DATA ZMISS/-9999999.0/
       REAL RLATINC, ONORTH, OSOUTH
-      INTEGER IWORD, IRET, ISIZE, NSPEC, LAT1, LOOP, IERR
+      INTEGER IRET, NSPEC, LOOP, IERR
       INTEGER KNUM, NUM_E_W, NUM_N_S, NFULLNS, NFULLEW
       REAL GRIDWE, GRIDNS, NORTH, SOUTH, WEST, EAST
       REAL INORTH, ISOUTH, IWEST, IEAST, RNS
       INTEGER NUMPTS,MISSLAT,KOLDNUM
       DIMENSION NUMPTS(JPMAXLT)
-      INTEGER NUMTABL, NUMPROD
       INTEGER KNEWNUM
-      LOGICAL LCOEFFS, L98WAVE, LFRAME, LBITMP
+      LOGICAL LCOEFFS, LFRAME, LBITMP
       LOGICAL LDEBUG
 C
 C     Externals
-      INTEGER AREACHK, FIXAREA, WAVEXX2, WV2DXX2
+      INTEGER WAVEXX2, WV2DXX2, AREACHK, FIXAREA
       INTEGER NUMPTNS, NUMPTWE, JNORSGG, MKBITMP
 C
 C ------------------------------------------------------------------
@@ -188,27 +182,24 @@ C
       NOAREA(4) = NINT(EAST*PPMULT)
 C
       IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN)) THEN
-         IF(NOREPR.EQ.JPQUASI) THEN
-            GRIDWE  = 360.0/NOLPTS(NOGAUSS)
-         ELSE
-            GRIDWE  = 360.0/(NOGAUSS*4)
-         ENDIF
+        GRIDWE  = 360.0/NOLPTS(NOGAUSS)
         NUM_E_W = NUMPTWE(WEST,EAST,GRIDWE)
         NFULLEW = NUMPTWE(0.0,360.0,GRIDWE) - 1
-        NUM_N_S = JNORSGG(SOUTH,ROGAUSS,NOGAUSS,1) - 
+        NUM_N_S = JNORSGG(SOUTH,ROGAUSS,NOGAUSS,1) -
      X            JNORSGG(NORTH,ROGAUSS,NOGAUSS,0) + 1
         NFULLNS = NOGAUSS*2
+C
         NONS    = NFULLNS
-         IF(NOREPR.EQ.JPQUASI) THEN
-           KNEWNUM = NOGAUSS*2
-           DO LOOP = 1, KNEWNUM
-             OUTLEN  = OUTLEN + NOLPTS(LOOP)
-           ENDDO
-           NOWE = 0
-         ELSE
-            NOWE    = NUM_E_W
-            OUTLEN  = NOWE*NONS
-         ENDIF
+        IF(NOREPR.EQ.JPQUASI) THEN
+          KNEWNUM = NOGAUSS*2
+          DO LOOP = 1, KNEWNUM
+            OUTLEN  = OUTLEN + NOLPTS(LOOP)
+          ENDDO
+          NOWE = 0
+        ELSE
+          NOWE    = NUM_E_W
+          OUTLEN  = NOWE*NONS
+        ENDIF
       ELSE IF( NOREPR.EQ.JPREDLL ) THEN
         NUM_E_W = NUMPTWE(WEST,EAST,GRIDWE)
         NFULLEW = NUMPTWE(0.0,360.0,GRIDWE) - 1
@@ -299,11 +290,12 @@ C ------------------------------------------------------------------
 C
       ELSE
 C
+  400   CONTINUE
+
       IF( LDEBUG ) THEN
       CALL INTLOG(JP_DEBUG,
      X 'INTWAVU: Interpolate wave 2D spectra field',JPQUIET)
       ENDIF
-  400   CONTINUE
 C
         IRET = WV2DXX2(NIMATR,KNUM,MILLEN,NUM_N_S,GRIDNS,GRIDWE,INFLD,
      X               OUTFLD,NORTH,WEST,ZMISS)
@@ -346,7 +338,7 @@ C
       IF( LFRAME ) THEN
            CALL INTLOG(JP_DEBUG,'INTWAVU: MKFRAME is enabled',JPQUIET)
            CALL INTLOG(JP_DEBUG,'INTWAVU: NOFRAME ',NOFRAME)
-         CALL MKFRAME(NUM_E_W,NUM_N_S,OUTFLD,ZMISS,NOFRAME) 
+         CALL MKFRAME(NUM_E_W,NUM_N_S,OUTFLD,ZMISS,NOFRAME)
       ENDIF
 C
 C
diff --git a/interpolation/irdiwe.F b/interpolation/irdiwe.F
index 144ec43..4bfae45 100644
--- a/interpolation/irdiwe.F
+++ b/interpolation/irdiwe.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION IRDIWE (KLLEN, KINS, KNSIND, KONS, KILONG,
-     1   KIWE, KOLONG, KOWE, KWEIND, KWEDIST, KPR, KERR)
+      INTEGER FUNCTION IRDIWE(KLLEN,KINS,KNSIND,KONS,KILONG,KIWEMAX,
+     1  KOLONG,KOWE,KWEIND,KWEDIST,IAREA,OAREA,KPR,KERR)
 C
 C---->
 C**** *IRDIWE*
@@ -24,8 +24,8 @@ C
 C     INTERFACE
 C     _________
 C
-C     IERR = IRDIWE (KLLEN, KINS, KNSIND, KONS, KILONG, KIWE, KOLONG,
-C    1   KOWE, KWEIND, KWEDIST, KPR, KERR)
+C     IERR = IRDIWE(KLLEN,KINS,KNSIND,KONS,KILONG,KIWEMAX,
+C    1  KOLONG,KOWE,KWEIND,KWEDIST,IAREA,OAREA,KPR,KERR)
 C
 C     Input parameters
 C     ________________
@@ -45,7 +45,7 @@ C                  in the output field.
 C
 C     KILONG     - The array of input longitudes.
 C
-C     KIWE       - The maximum number of points in the West-East
+C     KIWEMAX    - The maximum number of points in the West-East
 C                  direction for this quasi regular Gaussian grid.
 C
 C     KOLONG     - The array of output longitudes.
@@ -53,6 +53,10 @@ C
 C     KOWE       - The number of points in the West-East direction in
 C                  the output field.
 C
+C     IAREA      - Input field area definition (N/W/S/E).
+C
+C     OAREA      - output field area definition (N/W/S/E).
+C
 C     KPR        - The debug print switch.
 C                  0  , No debugging output.
 C                  1  , Produce debugging output.
@@ -97,7 +101,7 @@ C     IGDIWE     - Calculate the distances between points in an
 C                  output longitude array and its West and East
 C                  neighbours in the input longitude array for one
 C                  line of latitude.
-C     INTLOG(R)    - Logs messages.
+C     INTLOG(R)  - Logs messages.
 C
 C     METHOD
 C     ______
@@ -111,187 +115,124 @@ C     number of points in the quasi regular lines of latitude does
 C     not change. When the definition changes IGDIWE is used to
 C     generate the offsets and distances for the new line definition.
 C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 2 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Nov 1993
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
 C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
+
+C     ------------------------------------------------------------------
+C*    Section 0. Definition of variables
+C     ------------------------------------------------------------------
       IMPLICIT NONE
-C
+
 #include "parim.h"
-C
-C     Dummy arguments
-      INTEGER KINS, KONS, KIWE, KOWE, KPR, KERR
+
+C     Arguments
+      INTEGER IAREA(4)
+      INTEGER OAREA(4)
+      INTEGER KINS
+      INTEGER KONS
+      INTEGER KIWEMAX
+      INTEGER KOWE
+      INTEGER KPR
+      INTEGER KERR
       INTEGER KLLEN (KINS)
-      INTEGER KNSIND (2, KONS)
-      INTEGER KILONG (KIWE + 1), KOLONG (KOWE)
-      INTEGER KWEIND (2, KOWE, 2, KONS),
-     1   KWEDIST (2, KOWE, 2, KONS)
-C
+      INTEGER KNSIND (2,KONS)
+      INTEGER KILONG (KIWEMAX+1)
+      INTEGER KOLONG (KOWE)
+      INTEGER KWEIND (2,KOWE,2,KONS)
+      INTEGER KWEDIST(2,KOWE,2,KONS)
+
 C     Local variables
       LOGICAL GWEGLOBE
-      INTEGER IIPLAT, IILON, ISTRIDE, IPR, IERR
-      INTEGER IBLON, IBNS, IBLAT
-      INTEGER JLAT, JLON, JNS, JWE
+      INTEGER KIWE
+      INTEGER ISTRIDE
+      INTEGER IERR
+      INTEGER IBLON
+      INTEGER IBNS
+      INTEGER IBLAT
+      INTEGER JLAT
+      INTEGER JLON
+      INTEGER JNS
       INTEGER JPROUTINE
       PARAMETER (JPROUTINE = 23900)
-C
+
 C     External functions
       INTEGER IGDIWE
-C
-C     _______________________________________________________
-C
+      EXTERNAL IGDIWE
+
+C     ------------------------------------------------------------------
 C*    Section 1. Initialisation
-C     _______________________________________________________
-C
+C     ------------------------------------------------------------------
   100 CONTINUE
-C
+
       IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRDIWE: Section 1.',JPQUIET)
-C
+
       IRDIWE = 0
-C
+
       IF (KPR .GE. 1) THEN
         CALL INTLOG(JP_DEBUG,'IRDIWE: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IRDIWE: Max no.input longs = ',KIWE)
-        CALL INTLOG(JP_DEBUG,'IRDIWE: No.input lats = ',KINS)
-        CALL INTLOG(JP_DEBUG,'IRDIWE: No.output longs = ',KOWE)
-        CALL INTLOG(JP_DEBUG,'IRDIWE: No.output lats = ',KONS)
+        CALL INTLOG(JP_DEBUG,'IRDIWE: Max no.input longs  = ',KIWEMAX)
+        CALL INTLOG(JP_DEBUG,'IRDIWE: No.input lats       = ',KINS)
+        CALL INTLOG(JP_DEBUG,'IRDIWE: No.output longs     = ',KOWE)
+        CALL INTLOG(JP_DEBUG,'IRDIWE: No.output lats      = ',KONS)
         CALL INTLOG(JP_DEBUG,'IRDIWE: Output field spread = ',KOLONG(1))
         CALL INTLOG(JP_DEBUG,'IRDIWE: to ',KOLONG(KOWE))
       ENDIF
-C
+
       GWEGLOBE = .TRUE.
-C
       IBLON = 0
-C
       IERR = 0
-C
-C     _______________________________________________________
-C
-C*    Section 2. Generate distances and points for all lines
-C                of latitude
-C     _______________________________________________________
-C
+
+C     ------------------------------------------------------------------
+C*    Section 2. Generate distances and points for all lines of latitude
+C     ------------------------------------------------------------------
   200 CONTINUE
-C
+
       IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRDIWE: Section 2.',JPQUIET)
-C
-      IPR = KPR
+
       IBLAT = 1
       IBNS  = 1
-C
-      DO 250 JLAT = 1, KONS
-C
-         DO 240 JNS = 1, 2
-C
-            IIPLAT = KNSIND (JNS, JLAT)
-            IILON = KLLEN (IIPLAT)
-C
-            IF (IILON .EQ. IBLON) THEN
-C
-C     Same line definition as last one calculated
-C
-               DO 220 JWE = 1, 2
-                  DO 210 JLON = 1, KOWE
-C
-                     KWEIND (JWE, JLON, JNS, JLAT) =
-     1                  KWEIND (JWE, JLON, IBNS, IBLAT)
-                     KWEDIST (JWE, JLON, JNS, JLAT) =
-     1                  KWEDIST (JWE, JLON, IBNS, IBLAT)
-C
-  210             CONTINUE
-  220          CONTINUE
-C
-            ELSE
-C
-               IBLON = IILON
-               IBNS = JNS
-               IBLAT = JLAT
-C
-               ISTRIDE = JP360 / IILON
-C
-C     Generate longitude values for this line
-C
-               DO 230 JLON = 1, IILON
-C
-                  KILONG (JLON) = (JLON - 1) * ISTRIDE
-C
-  230          CONTINUE
-C
-C     Wrap around input grid to simplify routine IGDIWE
-C
-               KILONG (IILON + 1) = KILONG (1)
-C
-               IERR = IGDIWE (KILONG, IILON, KOLONG, KOWE, GWEGLOBE,
-     1            KWEIND (1, 1, JNS, JLAT), KWEDIST (1, 1, JNS, JLAT),
-     2            IPR, KERR)
-C
-               IF (IERR .GT. 0) THEN
-                  IRDIWE = IERR
-                  GO TO 900
-               ENDIF
-C
-               IPR = KPR - 1
-C
-            ENDIF
-C
-  240    CONTINUE
-C
-  250 CONTINUE
-C
-C
-C     _______________________________________________________
-C
+
+      DO JLAT = 1, KONS
+        DO JNS = 1, 2
+
+          KIWE = KLLEN(KNSIND(JNS,JLAT))
+
+          IF (KIWE .EQ. IBLON) THEN
+
+C          Same line definition as last one calculated
+           KWEIND (1:2,1:KOWE,JNS,JLAT) = KWEIND (1:2,1:KOWE,IBNS,IBLAT)
+           KWEDIST(1:2,1:KOWE,JNS,JLAT) = KWEDIST(1:2,1:KOWE,IBNS,IBLAT)
+
+          ELSE
+
+            IBLON = KIWE
+            IBNS  = JNS
+            IBLAT = JLAT
+
+C           Generate longitude values for this line            ! FIXME: remove
+C           (wrap around input grid to simplify IGDIWE)        ! ...
+            ISTRIDE = JP360 / KIWE                             ! ...
+            DO JLON = 1, KIWE                                  ! ...
+              KILONG (JLON) = (JLON - 1) * ISTRIDE             ! ...
+            ENDDO                                              ! ...
+            KILONG(KIWE + 1) = KILONG (1)                      ! ...
+
+            IRDIWE = IGDIWE( KIWE, KOWE,
+     1        KWEIND  (1,1,JNS,JLAT),
+     2        KWEDIST (1,1,JNS,JLAT),
+     3        IAREA, OAREA,
+     4        KILONG, KOLONG, GWEGLOBE )   ! FIXME: remove
+            IF (IRDIWE.NE.0) GO TO 900
+
+          ENDIF
+
+        ENDDO
+      ENDDO
+
+C     ------------------------------------------------------------------
 C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
+C     ------------------------------------------------------------------
   900 CONTINUE
-C
+
       IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRDIWE: Section 9.',JPQUIET)
-C
-C
-      RETURN
       END
+
diff --git a/interpolation/irgmem.F b/interpolation/irgmem.F
index f5710fc..c379236 100644
--- a/interpolation/irgmem.F
+++ b/interpolation/irgmem.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -195,7 +195,6 @@ C
 C
 C     Dummy arguments
 C
-      INTEGER*8 WORK
       INTEGER*8 DELTA
       INTEGER*8 OFFSET
 
@@ -209,8 +208,6 @@ C
       INTEGER IBASE
 #endif
       INTEGER IREQUEST, IERR
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 23100)
 C
 C     External functions
 C
@@ -249,7 +246,10 @@ C
 C
 C     Reduced Gaussian input fields (These change for regular fields)
 C
-      IREQUEST = IREQUEST + (8 * NOWE * NONS + NINS) * JPILEN
+c     IREQUEST = IREQUEST + (8 * NOWE * NONS + NINS) * JPILEN
+      IREQUEST = IREQUEST
+     1  + JPILEN * (2 * NONS) * (4 * NOWE + 20)  ! account for RGG/octahedral
+     2  + JPILEN * NINS
 C
 C     Fields for LSM calculations
 C
@@ -280,7 +280,7 @@ C     Precipitation REAL arrays
 C
 C     We are having trouble when using POINTER values in arithmetic
 C     where we get overflow when we don't expect it. Like the POINTER
-C     is interpreted as a 32-bit length value. For that reason we 
+C     is interpreted as a 32-bit length value. For that reason we
 C     calculate an OFFSET and add DELTA values to it before reading
 C     its value out into the various base addresses which are then not
 C     used again in further calculations.
@@ -300,7 +300,7 @@ C     This offset may change if DOUBLE PRECISION
 C
       DELTA = NOWE * JPRLEN
       OFFSET = OFFSET + DELTA
-      NILONGP = OFFSET      
+      NILONGP = OFFSET
 C      NILONGP = NINPNTP + NOWE * JPRLEN
 
 C
@@ -321,7 +321,7 @@ C      NOLATGP  = NOLONGP + NOWE * JPILEN
 
       DELTA = NONS * JPILEN
       OFFSET = OFFSET + DELTA
-      NNSINDP = OFFSET      
+      NNSINDP = OFFSET
 C      NNSINDP = NOLATGP + NONS * JPILEN
 
       DELTA = 2 * NONS * JPILEN
@@ -339,7 +339,7 @@ C      NWEINDP = NNSDISTP  + 2 * NONS * JPILEN
       OFFSET = OFFSET + DELTA
       NWEDISTP = OFFSET
 C      NWEDISTP = NWEINDP + 4 * NOWE * NONS * JPILEN
-      
+
       DELTA = 4 * NOWE * NONS * JPILEN
       OFFSET = OFFSET + DELTA
       NISTRTP = OFFSET
@@ -357,7 +357,7 @@ c      NILSMP = NISTRTP + NINS * JPILEN
       OFFSET = OFFSET + DELTA
       NOLSMP = OFFSET
 c      NOLSMP = NILSMP + 2 * NIWE * JPILEN
-         
+
 C
       IF( KPR.GE.1 ) THEN
         CALL INTLOG(JP_DEBUG,'IRGMEM: ************************',JPQUIET)
@@ -380,7 +380,7 @@ C
         CALL INTLOG(JP_DEBUG,'IRGMEM: Line start array addr.= ',NISTRTP)
         CALL INTLOG(JP_DEBUG,'IRGMEM: Input LSM address = ',NILSMP)
         CALL INTLOG(JP_DEBUG,'IRGMEM: Output LSM address = ',NOLSMP)
-        
+
       ENDIF
 C
 
diff --git a/interpolation/irlrev.F b/interpolation/irlrev.F
deleted file mode 100644
index b7fc29e..0000000
--- a/interpolation/irlrev.F
+++ /dev/null
@@ -1,244 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IRLREV (PMAT, KLEN, KLLEN, KCOL, KDIR, KPR,
-     1   KERR)
-C
-C---->
-C**** *IRLREV*
-C
-C     PURPOSE
-C     _______
-C
-C     This routine reverses either the rows or the columns of a quasi
-C     regular matrix.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IRLREV (PMAT, KLEN, KLLEN, KCOL, KDIR, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PMAT       - The input matrix of dimension (KLEN).
-C
-C     KLEN       - The length of the array PMAT.
-C
-C     KLLEN      - The lengths of each column within PMAT.
-C
-C     KCOL       - The number of entries in KLLEN and columns in PMAT.
-C
-C     KDIR       - 1   Reverses the order of the rows.
-C                      West-East reversal for meteorological fields.
-C                  2   Reverses the order of the columns.
-C                      North-South reversal for meteorological fields.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  (No longer used, kept for backward compatibility.
-C                   Used to be used as follows:
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.)
-C
-C
-C     Output parameters
-C     ________________
-C
-C     PMAT       - The transformed matrix.
-C
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     7501  A column swap has been attempted where the lengths in the
-C           array KLLEN are not symmetric about the middle value.
-C
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG     - Generate log messages.
-C
-C
-C     METHOD
-C     ______
-C
-C     KDIR = 1 is implemented by swapping corresponding columns of
-C              the matrix.
-C
-C     KDIR = 2 is implemented by reversing the elements within each
-C              column.
-C
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C
-C     COMMENTS
-C     ________
-C
-C     None.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Jan 1994
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers      ECMWF        Sept 1995
-C
-C----<
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Function arguments
-      INTEGER KLEN, KCOL, KDIR, KPR, KERR
-      INTEGER KLLEN (KCOL)
-      REAL PMAT (KLEN)
-C
-C     Local variables
-      INTEGER IHALF, ISTARTL, ISTARTU, ILINE
-      INTEGER JSTEP, JMOVE
-      REAL ZTEMP
-C
-C     Parameters.
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 7500)
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialisation
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRLREV: Section 1.',JPQUIET)
-C
-      IRLREV = 0
-C
-      IF (KPR .GE. 1) THEN
-        CALL INTLOG(JP_DEBUG,'IRLREV: Input parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IRLREV: Matrix length = ',KLEN)
-        CALL INTLOG(JP_DEBUG,'IRLREV: Number of rows = ',KCOL)
-        CALL INTLOG(JP_DEBUG,'IRLREV: Direction value = ',KDIR)
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 2. Matrix COLUMN reversal (Field row interchange - WE)
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRLREV: Section 2.',JPQUIET)
-C
-      IF (KDIR .EQ. 1) THEN
-C
-        ISTARTL = 0
-C
-        DO 220 JSTEP = 1, KCOL
-C
-          ILINE = KLLEN (JSTEP)
-          IHALF = ILINE / 2
-C
-          DO 210 JMOVE = 1, IHALF
-            ZTEMP = PMAT(ISTARTL + ILINE + 1 - JMOVE)
-            PMAT(ISTARTL + ILINE + 1 - JMOVE) = PMAT(ISTARTL + JMOVE)
-            PMAT(ISTARTL + JMOVE) = ZTEMP
-  210     CONTINUE
-C
-          ISTARTL = ISTARTL + ILINE
-C
-  220   CONTINUE
-C
-      ELSE
-C
-C     _______________________________________________________
-C
-C*    Section 3. Matrix ROW reversal (Field column interchange - NS)
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-        IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRLREV: Section 3.',JPQUIET)
-C
-        IHALF = KCOL / 2
-C
-        ISTARTL = 0
-        ISTARTU = KLEN - KLLEN (KCOL)
-C
-        DO 320 JMOVE = 1, IHALF
-C
-C         The quasi regular line lengths must be symmetric for this
-C         operation.
-C
-          IF (KLLEN (JMOVE) .NE. KLLEN (KCOL + 1 - JMOVE) ) THEN
-            IRLREV = JPROUTINE + 1
-C
-            CALL INTLOG(JP_ERROR,
-     X        'IRLREV: Line of latitude reversal failed', JPQUIET)
-            CALL INTLOG(JP_ERROR,'IRLREV: at lat.lines = ',JMOVE)
-            CALL INTLOG(JP_ERROR,'IRLREV: and = ',(KCOL+1-JMOVE))
-            CALL INTLOG(JP_ERROR,
-     X        'IRLREV: Lengths are not the same.', JPQUIET)
-            CALL INTLOG(JP_ERROR,'IRLREV: 1st length = ', KLLEN (JMOVE))
-            CALL INTLOG(JP_ERROR,
-     X        'IRLREV: 2nd length = ',KLLEN(KCOL+1-JMOVE))
-C
-          ENDIF
-C
-          DO 310 JSTEP = 1, KLLEN (JMOVE)
-C
-            ZTEMP = PMAT (ISTARTU + JSTEP)
-            PMAT (ISTARTU + JSTEP) = PMAT (ISTARTL + JSTEP)
-            PMAT (ISTARTL + JSTEP) = ZTEMP
-C
-  310     CONTINUE
-C
-          ISTARTL = ISTARTL + KLLEN (JMOVE)
-          ISTARTU = ISTARTU - KLLEN (KCOL - JMOVE)
-C
-  320   CONTINUE
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRLREV: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/irlsmb.F b/interpolation/irlsmb.F
index dcd847d..b627beb 100644
--- a/interpolation/irlsmb.F
+++ b/interpolation/irlsmb.F
@@ -8,13 +8,15 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION IRLSMB (OISTAND, HIFILE, KIREC, KIGRID, KILINE,
-     X   OOSTAND, HOFILE, KOREC, KOGRID, KOLINE, KPR, KERR)
+      INTEGER FUNCTION IRLSMB(
+     X  OISTAND, HIFILE, KIREC, KIGRID, KILINE,
+     X  OOSTAND, HOFILE, KOREC, KOGRID, KOLINE,
+     X  KPR, KERR )
 C
 C---->
 C**** *IRLSMB*
 C
-C     Purpose
+C     PURPOSE
 C     -------
 C
 C     Calculate the effects of the land-sea masks on the unnormalised
@@ -22,11 +24,13 @@ C     interpolation weights for a quasi regular input field and a
 C     regular output field.
 C
 C
-C     Interface
+C     INTERFACE
 C     ---------
 C
-C     IERR = IRLSMB (OISTAND, HIFILE, KIREC, KIGRID, KILINE,
-C    X   OOSTAND, HOFILE, KOREC, KOGRID, KOLINE, KPR, KERR)
+C     IERR = IRLSMB(
+C    X  OISTAND, HIFILE, KIREC, KIGRID, KILINE,
+C    X  OOSTAND, HOFILE, KOREC, KOGRID, KOLINE,
+C    X  KPR, KERR )
 C
 C
 C     Input parameters
@@ -106,13 +110,15 @@ C     grspace.h    - This file contains all the work space array
 C                    definitions for grid point to grid point
 C                    interpolation.
 C
-C     MEXPAND      - Array used to expand one latitude line of the
-C                    10 minute land sea mask file to have one word
-C                    per bit for improved efficiency.
+C     MEXPAND      - Array used to
+C                    expand one latitude line of the 10 minute land
+C                    sea mask file to have one word per bit for
+C                    improved efficiency.
 C     MILLEN       - Array containing a quasi regular line length
 C                    definition.
-C     MWORK        - Array used to read one latitude line of a
-C                    standard land sea mask file.
+C     MWORK        - Array used to
+C                    read one latitude line of a standard land sea
+C                    mask file.
 C
 C     MILATG       - The input field latitudes.
 C     MILONG       - The input field longitudes.
@@ -176,10 +182,11 @@ C
 C     None
 C
 C
-C     Author
+C     AUTHOR
 C     ------
 C     K. Fielding      *ECMWF*      Nov 1993
 C
+C
 C     Modifications
 C     -------------
 C
@@ -187,10 +194,12 @@ C     J.D.Chambers      ECMWF       Oct 1996
 C     Reduced number of parameters in call to IGLSMST and IGLSM01
 C
 C----<
+C
 C     -----------------------------------------------------------------|
 C*    Section 0. Definition of variables.
 C     -----------------------------------------------------------------|
 C
+C
       IMPLICIT NONE
 C
 #include "parim.h"
@@ -198,28 +207,35 @@ C
 #include "nofld.common"
 #include "grspace.h"
 C
+C     Parameters
+C
+      INTEGER JPROUTINE
+      PARAMETER (JPROUTINE = 23400)
+C
 C     Function arguments
 C
-      LOGICAL OISTAND, OOSTAND
-      CHARACTER *(*) HIFILE, HOFILE
-      INTEGER KIREC, KOREC, KPR, KERR
-      INTEGER KIGRID (2), KILINE (2), KOGRID (2), KOLINE (2)
+      LOGICAL       OISTAND,   OOSTAND
+      CHARACTER*256 HIFILE,    HOFILE
+      INTEGER       KIREC,     KOREC
+      INTEGER       KIGRID(2), KOGRID(2)
+      INTEGER       KILINE(2), KOLINE(2)
+      INTEGER KPR, KERR
 C
 C     Local variables
 C
-      INTEGER IIUNIT, IOUNIT, IIFILE, IOFILE
-      INTEGER ILATN, ILATS, ILINEN, ILINES, ISTRIDEN, ISTRIDES
-      INTEGER IOSTRIDE, INDEXN, INDEXS, IZERO, IOFF, IPR, IERR
-      INTEGER JLON, JOLAT
-      CHARACTER*256 XHIFILE, XHOFILE
+      INTEGER IIUNIT, IOUNIT, IIFILE, IOFILE, ILATN, ILATS
+      INTEGER IOFF, IPR, IERR, JOLAT, I
       CHARACTER*2 NEWFILE, MSKFILE
-      INTEGER XIIUNIT, XIOUNIT, II
-      DATA XIIUNIT/0/
-      DATA XIOUNIT/0/
-      SAVE  XHIFILE, XHOFILE, XIIUNIT, XIOUNIT
-C
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 23400)
+c     INTEGER ISTRIDEN, ISTRIDES
+      INTEGER ILINEN, ILINES, INDEXN, INDEXS, JLON
+      REAL RSTRIDEN, RSTRIDES
+
+      CHARACTER*256 XHIFILE, XHOFILE
+      SAVE          XHIFILE, XHOFILE
+
+      INTEGER XIIUNIT,    XIOUNIT
+      DATA    XIIUNIT/0/, XIOUNIT/0/
+      SAVE    XIIUNIT,    XIOUNIT
 C
 C     External functions
 C
@@ -239,13 +255,13 @@ C
       IOFILE = JINDEX(HOFILE)
 C
       IF( KPR.GE.1 ) THEN
-        CALL INTLOG(JP_DEBUG,'IRLSMB: Input field parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,'IRLSMB: LSM filename is.',JPQUIET)
-        CALL INTLOG(JP_DEBUG, HIFILE(1:IIFILE), JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IRLSMB: Input parameters.',JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IRLSMB: LSM filename:',JPQUIET)
+        CALL INTLOG(JP_DEBUG,HIFILE(1:IIFILE),JPQUIET)
         IF( OISTAND ) THEN
-            CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: TRUE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: TRUE',JPQUIET)
         ELSE
-            CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: FALSE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: FALSE',JPQUIET)
         ENDIF
         CALL INTLOG(JP_DEBUG,'IRLSMB: LSM file rec len = ',KIREC)
         CALL INTLOG(JP_DEBUG,'IRLSMB: Grid stride WE = ',KIGRID(1))
@@ -253,12 +269,13 @@ C
         CALL INTLOG(JP_DEBUG,'IRLSMB: Grid start N = ',KILINE(1))
         CALL INTLOG(JP_DEBUG,'IRLSMB: Grid start W = ',KILINE(2))
 C
-        CALL INTLOG(JP_DEBUG,'IRLSMB: Output field parameters.',JPQUIET)
-        CALL INTLOG(JP_DEBUG, HOFILE(1:IOFILE),JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IRLSMB: Output parameters.',JPQUIET)
+        CALL INTLOG(JP_DEBUG,'IRLSMB: LSM filename:',JPQUIET)
+        CALL INTLOG(JP_DEBUG,HOFILE(1:IOFILE),JPQUIET)
         IF( OOSTAND ) THEN
-            CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: TRUE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: TRUE',JPQUIET)
         ELSE
-            CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: FALSE',JPQUIET)
+          CALL INTLOG(JP_DEBUG,'IRLSMB: Standard fld: FALSE',JPQUIET)
         ENDIF
         CALL INTLOG(JP_DEBUG,'IRLSMB: LSM file rec len = ',KOREC)
         CALL INTLOG(JP_DEBUG,'IRLSMB: Grid stride WE = ',KOGRID(1))
@@ -267,12 +284,6 @@ C
         CALL INTLOG(JP_DEBUG,'IRLSMB: Grid start W = ',KOLINE(2))
       ENDIF
 C
-      IF( MOLONG(2).GE.MOLONG(1) ) THEN
-         IOSTRIDE = MOLONG(2) - MOLONG(1)
-      ELSE
-         IOSTRIDE = MOLONG(2) + JP360 - MOLONG(1)
-      ENDIF
-C
 C     -----------------------------------------------------------------|
 C*    Section 2. Open files for input and output land sea masks
 C     -----------------------------------------------------------------|
@@ -284,8 +295,8 @@ C
 C     See if first time through or input land sea mask filename has
 C     changed since last access
 C
-      II = JINDEX(HIFILE)
-      IF( XHIFILE(1:II).NE.HIFILE(1:II) ) THEN
+      I = JINDEX(HIFILE)
+      IF( XHIFILE(1:I).NE.HIFILE(1:I) ) THEN
 C
 C       Open input land sea mask file
 C
@@ -305,7 +316,7 @@ C
           GOTO 900
         ENDIF
         XIIUNIT = IIUNIT
-        XHIFILE(1:II) = HIFILE(1:II)
+        XHIFILE(1:I) = HIFILE(1:I)
         NEWFILE(1:1) = 'Y'
 C
 C     Just rewind if same file still in use
@@ -318,8 +329,8 @@ C
 C     See if first time through or output land sea mask filename has
 C     changed since last access
 C
-      II = JINDEX(HOFILE)
-      IF( XHOFILE(1:II).NE.HOFILE(1:II) ) THEN
+      I = JINDEX(HOFILE)
+      IF( XHOFILE(1:I).NE.HOFILE(1:I) ) THEN
 C
 C       Open output land sea mask file
 C
@@ -332,6 +343,7 @@ C
             CALL INTLOG(JP_ERROR,'IRLSMB: PBOPEN return code = ',IERR)
             CALL INTLOG(JP_ERROR,'IRLSMB: trying to open file',JPQUIET)
             CALL INTLOG(JP_ERROR, HOFILE(1:IOFILE),JPQUIET)
+C
           ENDIF
 C
           IF( KERR.EQ.0 ) CALL INTLOG(JP_FATAL,
@@ -339,7 +351,7 @@ C
           GOTO 900
         ENDIF
         XIOUNIT = IOUNIT
-        XHOFILE(1:II) = HOFILE(1:II)
+        XHOFILE(1:I) = HOFILE(1:I)
         NEWFILE(2:2) = 'Y'
 C
 C     Just rewind if same file still in use
@@ -391,12 +403,12 @@ C
         ILATS = MNSIND(JP_I_S, JOLAT)
 C
         ILINEN = MILLEN(ILATN)
-        ISTRIDEN = JP360 / ILINEN
+c       ISTRIDEN = JP360 / ILINEN
+        RSTRIDEN = 360./REAL(ILINEN)
 C
         ILINES = MILLEN(ILATS)
-        ISTRIDES = JP360 / ILINES
-C
-        IZERO = 0
+c       ISTRIDES = JP360 / ILINES
+        RSTRIDES = 360./REAL(ILINEN)
 C
 C       Get lines for input array
 C
@@ -424,7 +436,8 @@ C
         ELSE
 C
           DO JLON = 0, ILINEN - 1
-            MILONG(JLON + 1) = ISTRIDEN * JLON
+c           MILONG(JLON + 1) = ISTRIDEN * JLON
+            MILONG(JLON + 1) = INT(RSTRIDEN * REAL(JLON))
           ENDDO
 C
           IERR = IGLSM01(IIUNIT, ILINEN, MILONG, MILATG(ILATN),
@@ -436,7 +449,8 @@ C
           ENDIF
 C
           DO JLON = 0, ILINES - 1
-            MILONG(JLON + 1) = ISTRIDES * JLON
+c           MILONG(JLON + 1) = ISTRIDES * JLON
+            MILONG(JLON + 1) = INT(RSTRIDES * REAL(JLON))
           ENDDO
 C
           IERR = IGLSM01(IIUNIT, ILINES, MILONG, MILATG(ILATS),
diff --git a/interpolation/irscan.F b/interpolation/irscan.F
deleted file mode 100644
index de4ed0b..0000000
--- a/interpolation/irscan.F
+++ /dev/null
@@ -1,306 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION IRSCAN (PMAT, KLEN, KLLEN, KNNS, KSCAN, KPR,
-     1   KERR)
-C
-C---->
-C**** *IRSCAN*
-C
-C     PURPOSE
-C     _______
-C
-C     This routine transforms a field between the specified external
-C     scanning mode and a standard internal scanning mode where the
-C     array represents a quasi regular field.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IRSCAN (PMAT, KLEN, KLLEN, KNNS, KSCAN, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     PMAT       - The input matrix of length (KLEN).
-C
-C     KLEN       - The number of points in the matrix.
-C
-C     KLLEN      - This array contains the quasi regular Gaussian
-C                  line length definitions.
-C
-C     KNNS       - The number of points in the North-South direction.
-C
-C     KSCAN      - A standard GRIB byte variable with bits 1 to 3
-C                  separately significant. This means that the final
-C                  value is the sum of the bit settings.
-C
-C                  128 , Set if points scan East to West.
-C                   64 , Set if points scan South to North.
-C                   32 , Set if points in the North South direction
-C                        are consecutive.
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     PMAT       - The transposed matrix.
-C
-C     Return value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     7201  The scanning mode was not in the range 0 to 255.
-C     7202  A scanning mode with consecutive values in the North
-C           South direction was requested. This is not compatible
-C           with a quasi regular Gaussian field.
-C     7203  The total number of points given by the array KLLEN was
-C           not equal to KLEN.
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C     EXTERNALS
-C     _________
-C
-C     IRLREV     - Routine to reverse the elements within each row
-C                  or each column of a quasi regular Gaussian field.
-C     INTLOG     - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     KSCAN = 128 is implemented by swapping elements within each
-C                 column of the matrix.
-C
-C     KSCAN = 64  is implemented by reversing the order of the columns.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     Program contains sections 0 to 2 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Jan 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     REAL         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-C     Implicit statement to force declarations
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Dummy arguments
-C
-      INTEGER KLEN, KNNS, KSCAN, KPR, KERR
-C
-      INTEGER KLLEN (KNNS)
-C
-      REAL PMAT (KLEN)
-C
-C     Local variables
-C
-      LOGICAL GNSMOD, GWEMOD, GTRMOD
-C
-      INTEGER ISCAN, IDIR, ITOTAL, IERR
-C
-      INTEGER JSTEP
-C
-      INTEGER JPROUTINE
-C
-      PARAMETER (JPROUTINE = 7200)
-C
-C     External functions
-C
-      INTEGER IRLREV
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Initialisation - Evaluate scan modes
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IRSCAN: Section 1.',JPQUIET)
-C
-      IRSCAN = 0
-C
-      IF (KPR .GE. 1) THEN
-         CALL INTLOG(JP_DEBUG,'IRSCAN: Input parameters',JPQUIET)
-         CALL INTLOG(JP_DEBUG,'IRSCAN: Total length of matrix is ',KLEN)
-         CALL INTLOG(JP_DEBUG,'IRSCAN: Latitude lines are ',KNNS)
-         CALL INTLOG(JP_DEBUG,'IRSCAN: Scan mode is ',KSCAN)
-      ENDIF
-C
-      IF (KSCAN .LT. 0 .OR. KSCAN .GE. 256) THEN
-         IRSCAN = JPROUTINE + 1
-         IF (KERR .GE. 0) CALL INTLOG(JP_ERROR,
-     X     'IRSCAN: Scan mode is not in range 0 to 255 = ',KSCAN)
-         IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X    'IRSCAN: Interpolation fails.',IRSCAN)
-         GO TO 900
-      ENDIF
-C
-C     Zero KSCAN means no transformation
-C
-      IF (KSCAN .EQ. 0) GO TO 900
-C
-      ISCAN = KSCAN
-      GWEMOD = .FALSE.
-      GNSMOD = .FALSE.
-C
-      IF (ISCAN .GE. 128) THEN
-         ISCAN = ISCAN - 128
-         GWEMOD = .TRUE.
-      ENDIF
-C
-      IF (ISCAN .GE. 64) THEN
-         ISCAN = ISCAN - 64
-         GNSMOD = .TRUE.
-      ENDIF
-C
-      GTRMOD = ISCAN .GE. 32
-C
-      IF (GTRMOD) THEN
-        IRSCAN = JPROUTINE + 2
-        IF (KERR .GE. 0) THEN
-         CALL INTLOG(JP_ERROR,
-     X     'IRSCAN: scan mode wants consecutive N to S points',JPQUIET)
-           CALL INTLOG(JP_ERROR,
-     X      'IRSCAN: Not feasible for a quasi regular grid',JPQUIET)
-          IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X      'IRSCAN: Interpolation fails.',IRSCAN)
-        ENDIF
-        GO TO 900
-      ENDIF
-C
-      ITOTAL = 0
-C
-      DO 110 JSTEP = 1, KNNS
-        ITOTAL = ITOTAL + KLLEN (JSTEP)
-  110 CONTINUE
-C
-      IF (ITOTAL .NE. KLEN) THEN
-        IRSCAN = JPROUTINE + 3
-        IF (KERR .GE. 0) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'IRSCAN: Array length provided = ',KLEN)
-            CALL INTLOG(JP_ERROR,
-     X       'IRSCAN: not equal to sum of line lengths = ',ITOTAL)
-           IF (KERR .EQ. 0) CALL INTLOG(JP_FATAL,
-     X       'IRSCAN: Interpolation fails.',IRSCAN)
-         ENDIF
-         GO TO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 2. Any field as order is unimportant
-C
-C                Potential operations in order are
-C
-C                1 Modify West East mode
-C                2 Modify North South mode
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IRSCAN: Section 2.',JPQUIET)
-C
-      IF (GWEMOD) THEN
-C
-         IDIR = 1
-C
-         IERR = IRLREV (PMAT, KLEN, KLLEN, KNNS, IDIR, KPR)
-C
-         IF (IERR .GT. 0) THEN
-            IRSCAN = IERR
-            GO TO 900
-         ENDIF
-C
-      ENDIF
-C
-      IF (GNSMOD) THEN
-C
-         IDIR = 2
-C
-         IERR = IRLREV (PMAT, KLEN, KLLEN, KNNS, IDIR, KPR)
-C
-         IF (IERR .GT. 0) THEN
-            IRSCAN = IERR
-            GO TO 900
-         ENDIF
-C
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,'IRSCAN: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/is_wave_direction.F b/interpolation/is_wave_direction.F
new file mode 100644
index 0000000..1cb33cf
--- /dev/null
+++ b/interpolation/is_wave_direction.F
@@ -0,0 +1,31 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+C     Determine if parameter is a wave direction parameter and
+C     therefore requiring special interpolation treatment, given its ID
+C     (warning: parameter table is not checked.)
+
+      LOGICAL FUNCTION IS_WAVE_DIRECTION(PARAM)
+
+      IMPLICIT NONE
+      INTEGER PARAM
+
+      IS_WAVE_DIRECTION =
+     X  ((PARAM.EQ.122) .OR. !mwd1
+     X   (PARAM.EQ.125) .OR. !mwd2
+     X   (PARAM.EQ.128) .OR. !mwd3
+     X   (PARAM.EQ.230) .OR. !mwd
+     X   (PARAM.EQ.235) .OR. !mdww
+     X   (PARAM.EQ.238) .OR. !mdts
+     X   (PARAM.EQ.242) .OR. !mdwi
+     X   (PARAM.EQ.249))     !dwi
+
+      END
+
diff --git a/interpolation/iscrsz.F b/interpolation/iscrsz.F
index 6496092..d3cd779 100644
--- a/interpolation/iscrsz.F
+++ b/interpolation/iscrsz.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -17,7 +17,7 @@ C     -------
 C
 C     Calculate size of scratch space required for output field of
 C     interpolation.
-C     
+C
 C
 C     Interface
 C     ---------
@@ -62,14 +62,13 @@ C
       IMPLICIT NONE
 C
 #include "parim.h"
-#include "nifld.common"
 #include "nofld.common"
 #include "grfixed.h"
 C
 C     Local variables
 C
       INTEGER LOOP
-      REAL PNORTH, PWEST, PSOUTH, PEAST, GRID, TEMP
+      REAL PNORTH, PWEST, PSOUTH, PEAST, TEMP !, GRID
 C
 C     Externals
 C
@@ -139,11 +138,10 @@ C
         NONS  = JNORSGG( PSOUTH, ROGAUSS, NOGAUSS, 1) - NO1NS + 1
         TEMP = FLOAT(NOAREA(4)) - FLOAT(NOAREA(2))
         TEMP = (TEMP * FLOAT(NOGAUSS) ) / FLOAT(JP90)
-        NOWE  = NINT(TEMP) + 1
 CS added for grib2
-        IF(NONS.EQ.NOGAUSS*2.AND.NOAREA(2).EQ.0) THEN
-           LGLOBL = .TRUE.
-        ENDIF
+        LGLOBL = (NONS.EQ.NOGAUSS*2.AND.NOAREA(2).EQ.0)
+        NOWE = NINT(TEMP) + 1
+        IF( LGLOBL ) NOWE = 4*NOGAUSS
 C
         ISCRSZ = NONS * NOWE
         CALL INTLOG(JP_DEBUG,'ISCRSZ: number of latitudes = ', NONS)
@@ -167,17 +165,20 @@ C
         NO1NS = JNORSGG( PNORTH, ROGAUSS, NOGAUSS, 1)
         NONS  = JNORSGG( PSOUTH, ROGAUSS, NOGAUSS, 1) - NO1NS + 1
 CS added for grib2
-        IF(NONS.EQ.NOGAUSS*2.AND.NOAREA(2).EQ.0) THEN
-           LGLOBL = .TRUE.
-        ENDIF
-        NOWE  = 0
+        LGLOBL = (NONS.EQ.NOGAUSS*2.AND.NOAREA(2).EQ.0)
+        NOWE = 0
 C
         NOPCNT = 0
         DO LOOP = 1, NOGAUSS*2
           IF( SOUTHOF(PNORTH,ROGAUSS(LOOP)).AND.
      X        SOUTHOF(ROGAUSS(LOOP),PSOUTH) ) THEN
-            GRID = 360.0 / REAL(NOLPTS(LOOP))
-            NOPCNT = NOPCNT + NUMPTWE(PWEST,PEAST,GRID)
+C
+C           EMOS-186: disregard area cropping east/west-wise, it seems
+C           NUMPTWE assumptions don't hold for RGG/octahedral
+C           GRID = 360.0 / REAL(NOLPTS(LOOP))
+C           NOPCNT = NOPCNT + NUMPTWE(PWEST,PEAST,GRID)
+            NOPCNT = NOPCNT + NOLPTS(LOOP)
+C
           ENDIF
         ENDDO
 C
diff --git a/interpolation/isggvalid.F b/interpolation/isggvalid.F
new file mode 100644
index 0000000..89a735d
--- /dev/null
+++ b/interpolation/isggvalid.F
@@ -0,0 +1,65 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      LOGICAL FUNCTION ISGGVALID(HTYPE,KNUM)
+C
+C---->
+C**** ISGGVALID
+C
+C     PURPOSE
+C     _______
+C
+C     This function checks if a Gaussian grid definition is valid.
+C
+C
+C     Parameters (input)
+C     __________________
+C
+C     KNUM     - Gaussian grid number
+C     HTYPE    - Gaussian grid type
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
+C                = 'U' for a user-defined gaussian grid
+C
+C----<
+      IMPLICIT NONE
+
+      INTEGER KNUM
+      CHARACTER*1 HTYPE
+
+      ! Condition:
+      ! - for regular_gg or user-defined, valid for KNUM>=2
+      ! - for reduced_gg, check grid number
+      ISGGVALID = ( HTYPE.EQ.'F' .OR. HTYPE.EQ.'f' .OR.
+     .              HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     .              HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) .AND.
+     .            ( KNUM.GE.   2 )
+     .            .OR.
+     .            ( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' ) .AND.
+     .            ( KNUM.EQ.  32 .OR.
+     .              KNUM.EQ.  48 .OR.
+     .              KNUM.EQ.  64 .OR.
+     .              KNUM.EQ.  80 .OR.
+     .              KNUM.EQ.  96 .OR.
+     .              KNUM.EQ. 128 .OR.
+     .              KNUM.EQ. 160 .OR.
+     .              KNUM.EQ. 200 .OR.
+     .              KNUM.EQ. 256 .OR.
+     .              KNUM.EQ. 320 .OR.
+     .              KNUM.EQ. 400 .OR.
+     .              KNUM.EQ. 512 .OR.
+     .              KNUM.EQ. 640 .OR.
+     .              KNUM.EQ.1024 .OR.
+     .              KNUM.EQ.1280 .OR.
+     .              KNUM.EQ.2000 )
+
+      END
+
diff --git a/interpolation/isoctahedral.F b/interpolation/isoctahedral.F
new file mode 100644
index 0000000..220076a
--- /dev/null
+++ b/interpolation/isoctahedral.F
@@ -0,0 +1,63 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence 
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities 
+C granted to it by virtue of its status as an intergovernmental organisation 
+C nor does it submit to any jurisdiction.
+C
+
+      LOGICAL FUNCTION ISOCTAHEDRAL(KNUM,KPTS)
+C
+C---->
+C**** *ISOCTAHEDRAL*
+C
+C     PURPOSE
+C     _______
+C
+C     Check if KPTS (pl array) represents a octahedral progression series
+C
+C
+C     Input parameters
+C     ________________
+C
+C     KNUM - Gaussian grid number
+C
+C     KPTS - Array giving number of points at each gaussian 
+C            latitude, both hemispheres (pl array)
+C
+C----<
+      IMPLICIT NONE
+
+
+C     Arguments
+      INTEGER KNUM, KPTS(*)
+
+
+C     Local variables
+      INTEGER LOOP, IMAGE, NLAT
+      CHARACTER*1 HTYPEO
+      INTEGER QGOCT
+      EXTERNAL QGOCT
+      LOGICAL ISGGVALID
+      EXTERNAL ISGGVALID
+
+
+C     Check octahedral progression series
+C     (symmetry is checked as well, return on first failure)
+      HTYPEO = 'O'
+      ISOCTAHEDRAL = ISGGVALID(HTYPEO,KNUM)
+      IF( ISOCTAHEDRAL ) THEN
+        DO LOOP = 1, KNUM
+          IMAGE = 2 * KNUM - LOOP + 1
+          NLAT  = QGOCT(LOOP)
+          ISOCTAHEDRAL = ( NLAT.EQ.KPTS(LOOP)  )
+     X             .AND. ( NLAT.EQ.KPTS(IMAGE) )
+          IF( .NOT.ISOCTAHEDRAL ) GOTO 900
+        ENDDO
+      ENDIF
+
+ 900  CONTINUE
+      ENDFUNCTION
+
diff --git a/interpolation/issame.F b/interpolation/issame.F
index f5b91e2..4faf1fc 100644
--- a/interpolation/issame.F
+++ b/interpolation/issame.F
@@ -65,9 +65,13 @@ C
 C
 C     Local variables
 C
-      INTEGER LOOP, IDIFF
+      INTEGER IDIFF
       LOGICAL LDEFIN, LDEFOUT, LSUBAREA
-      CHARACTER*12 YFLAG
+C
+C     Externals
+C
+      LOGICAL ISSAMEIARRAY, ISSAMERARRAY
+      EXTERNAL ISSAMEIARRAY, ISSAMERAARAY
 C
 C     -----------------------------------------------------------------|
 C
@@ -106,42 +110,32 @@ C     Check for same formats, representation and bit packing accuracy.
 C
 cs      IF( NIFORM.NE.NOFORM) ISSAME = .FALSE.
       IF( NIREPR.NE.NOREPR) ISSAME = .FALSE.
-cs This is used just for processing with gribex
-C     Force repacking for different accuracy 
-cs      IF(LACCUR) THEN
-cs        IF( NIACC .NE. NOACC) ISSAME = .FALSE.
-cs      ENDIF
-C
-C     Exit if both input and output are same (reduced  or quasi)
-C     gaussian with the same resolution and area, since no
-C     postprocessing is required.
-C
-cs      IF( (NOREPR.EQ.JPNOTYPE) .AND. (NIGAUSS.EQ.NOGAUSS) .AND.
-cs NOREPR.EQ.NIREPR  because NOREPR is always set trough describe input field
-      IF(NOREPR.EQ.JPQUASI) THEN
-      IF( (NOREPR.EQ.NIREPR) .AND. (NIGAUSS.EQ.NOGAUSS)) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'ISSAME: Input and output are same Reduced Gaussian',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'ISSAME: with the same resolution;',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'ISSAME: no postprocessing required.',JPQUIET)
-        ISSAME = .TRUE.
-        RETURN
-      ENDIF
-      ENDIF
-      IF(NOREPR.EQ.JPGAUSSIAN) THEN
-      IF( (NOREPR.EQ.NIREPR) .AND. (NIGAUSS.EQ.NOGAUSS) .AND.
-     X     (.NOT.LSUBAREA)) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'ISSAME: Input and output are same  Regular Gaussian',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'ISSAME: with the same resolution and area;',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X    'ISSAME: no postprocessing required.',JPQUIET)
-        ISSAME = .TRUE.
-        RETURN
+
+      IF( (NOREPR.EQ.JPQUASI).AND.(NIREPR.EQ.JPQUASI) ) THEN
+        ISSAME = ISSAMEIARRAY(NIGAUSS,MILLEN, NOGAUSS,NOLPTS)
+     X     .AND. ISSAMERARRAY(NIGAUSS,RIGAUSS,NOGAUSS,ROGAUSS)
+        IF (ISSAME) THEN
+          CALL INTLOG(JP_DEBUG,
+     X      'ISSAME: Input and output are Reduced Gaussian',JPQUIET)
+          CALL INTLOG(JP_DEBUG,
+     X      'ISSAME: with the same PL and latitudes arrays;',JPQUIET)
+          CALL INTLOG(JP_DEBUG,
+     X      'ISSAME: no postprocessing required.',JPQUIET)
+          RETURN
+        ENDIF
       ENDIF
+
+      IF( (NOREPR.EQ.JPGAUSSIAN) .AND. (NIREPR.EQ.JPGAUSSIAN) ) THEN
+        IF( (NIGAUSS.EQ.NOGAUSS) .AND. (.NOT.LSUBAREA) ) THEN
+          ISSAME = .TRUE.
+          CALL INTLOG(JP_DEBUG,
+     X      'ISSAME: Input and output are Regular Gaussian',JPQUIET)
+          CALL INTLOG(JP_DEBUG,
+     X      'ISSAME: with the same resolution and area;',JPQUIET)
+          CALL INTLOG(JP_DEBUG,
+     X      'ISSAME: no postprocessing required.',JPQUIET)
+          RETURN
+        ENDIF
       ENDIF
 C
 C     If input is quasi gaussian and output required to be the same (ie
@@ -230,14 +224,11 @@ C
 C     If gaussian, check for same grid specification.
 C
       IF( (NIREPR.EQ.JPGAUSSIAN) .AND. (NOREPR.EQ.JPGAUSSIAN) ) THEN
-        IF( NIGAUSS.NE.NOGAUSS) ISSAME = .FALSE.
+        ISSAME = (NIGAUSS.EQ.NOGAUSS)
       ENDIF
       IF( (NIREPR.EQ.JPQUASI) .AND. (NOREPR.EQ.JPQUASI) ) THEN
-        IF( NIGAUSS.NE.NOGAUSS) ISSAME = .FALSE.
-        DO LOOP = 1, NOGAUSS
-          IF( RIGAUSS(LOOP).NE.ROGAUSS(LOOP) ) ISSAME = .FALSE.
-          IF( MILLEN(LOOP).NE.NOLPTS(LOOP) ) ISSAME = .FALSE.
-        ENDDO
+        ISSAME = ISSAMEIARRAY(NIGAUSS,MILLEN, NOGAUSS,NOLPTS)
+     X     .AND. ISSAMERARRAY(NIGAUSS,RIGAUSS,NOGAUSS,ROGAUSS)
       ENDIF
 C
 C     Check for same scanning mode.
diff --git a/interpolation/issameiarray.F b/interpolation/issameiarray.F
new file mode 100644
index 0000000..2e1c0ca
--- /dev/null
+++ b/interpolation/issameiarray.F
@@ -0,0 +1,51 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      LOGICAL FUNCTION ISSAMEIARRAY(N1,AN1,N2,AN2)
+C
+C---->
+C**** *ISSAMEIARRAY*
+C
+C     PURPOSE
+C     _______
+C
+C     Check if two integer arrays have the same entries.
+C
+C
+C     Input parameters
+C     ________________
+C
+C     N1   - Array 1 length
+C     AN1  - Array 1 entries (integer values)
+C     N2   - Array 2 length
+C     AN2  - Array 2 entries (integer values)
+C
+C----<
+      IMPLICIT NONE
+      INTEGER N1, AN1(*), N2, AN2(*)
+      INTEGER I
+
+
+C     Cover special cases
+      ISSAMEIARRAY =
+     X  N1.GT.0 .AND.
+     X  N2.GT.0 .AND.
+     X  N1.EQ.N2
+
+
+C     Iterate through entries, failing on first difference
+      I = 1
+      DO WHILE (ISSAMEIARRAY .AND. I.LE.N1)
+        ISSAMEIARRAY = AN1(I).EQ.AN2(I)
+        I = I+1
+      ENDDO
+
+      END FUNCTION
+
diff --git a/interpolation/issamerarray.F b/interpolation/issamerarray.F
new file mode 100644
index 0000000..2391c01
--- /dev/null
+++ b/interpolation/issamerarray.F
@@ -0,0 +1,51 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      LOGICAL FUNCTION ISSAMERARRAY(N1,AN1,N2,AN2)
+C
+C---->
+C**** *ISSAMERARRAY*
+C
+C     PURPOSE
+C     _______
+C
+C     Check if two real arrays have the same entries.
+C
+C
+C     Input parameters
+C     ________________
+C
+C     N1   - Array 1 length
+C     AN1  - Array 1 entries (real values)
+C     N2   - Array 2 length
+C     AN2  - Array 2 entries (real values)
+C
+C----<
+      IMPLICIT NONE
+      INTEGER N1, AN1(*), N2, AN2(*)
+      INTEGER I
+
+
+C     Cover special cases
+      ISSAMERARRAY =
+     X  N1.GT.0 .AND.
+     X  N2.GT.0 .AND.
+     X  N1.EQ.N2
+
+
+C     Iterate through entries, failing on first difference
+      I = 1
+      DO WHILE (ISSAMERARRAY .AND. I.LE.N1)
+        ISSAMERARRAY = AN1(I).EQ.AN2(I)
+        I = I+1
+      ENDDO
+
+      END FUNCTION
+
diff --git a/interpolation/ixtract.c b/interpolation/ixtract.c
deleted file mode 100644
index d0e1063..0000000
--- a/interpolation/ixtract.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define IINSERT iinsert
-#define RINSERT rinsert
-#define DINSERT dinsert
-#define IXTRACT ixtract
-#define RXTRACT rxtract
-#define DXTRACT dxtract
-#define RMOVEN  rmoven
-#define JLOC    jloc
-#else
-#define IINSERT iinsert_
-#define RINSERT rinsert_
-#define DINSERT dinsert_
-#define IXTRACT ixtract_
-#define RXTRACT rxtract_
-#define DXTRACT dxtract_
-#define RMOVEN  rmoven_
-#define JLOC    jloc_
-#endif
-
-#include <memory.h>
-#include "common/fortint.h"
-
-fortint IXTRACT(JPointer * array, fortint * index) {
-fortint * p = (fortint *) *array;
-/*
-// Extracts a Fortran integer from an array.
-// Note that the array pointer is given by reference.
-*/
-  return (fortint) p[(*index)-1];
-}
-
-fortreal RXTRACT(RPointer * array, fortint * index) {
-fortreal * p = (fortreal *) *array;
-/*
-// Extracts a Fortran real from an array.
-// Note that the array pointer is given by reference.
-*/
-
-  return (fortreal) p[(*index)-1];
-}
-
-void DXTRACT(void * target, void ** array, fortint * index) {
-/*
-// Extracts a Fortran REAL*8 from an array of doubles.
-// Note that the array pointer is given by reference.
-*/
-unsigned char * p = (unsigned char*)(*array) + ((*index)-1)*8;
-
-  memmove(target, p, 8);
-  return;
-}
-
-void IINSERT(JPointer * array, fortint * index, fortint * value) {
-fortint * p = (fortint *) *array;
-/*
-// Inserts a Fortran integer into an array.
-// Note that the array pointer is given by reference.
-*/
-  p[(*index)-1] = *value;
-  return;
-}
-
-void RINSERT(RPointer * array, fortint * index, fortreal * value) {
-fortreal * p = (fortreal *) *array;
-/*
-// Inserts a Fortran real into an array.
-// Note that the array pointer is given by reference.
-*/
-  p[(*index)-1] = *value;
-  return;
-}
-
-void DINSERT(void ** array, fortint * index, void * value) {
-/*
-// Inserts a Fortran single into a (double) array.
-// Note that the array pointer is given by reference.
-*/
-unsigned char * p = (unsigned char*)(*array) + ((*index)-1)*8;
-
-  memmove(p,value,8);
-  return;
-}
-
-void RMOVEN(RPointer * target, RPointer * source, fortint * number) {
-fortreal * Target = (fortreal *) *target;
-fortreal * Source = (fortreal *) *source;
-size_t N = (*number) * sizeof(fortreal);
-/*
-// Moves Fortran reals from one array to another.
-// Note that the array pointers are given by reference.
-*/
-  memmove(Target, Source, N);
-}
-
-RPointer JLOC(RPointer array) {
-/*
-// Emulates the Fortran %LOC function
-*/
-  return array;
-}
diff --git a/interpolation/jacobif.F b/interpolation/jacobif.F
deleted file mode 100644
index 14e4681..0000000
--- a/interpolation/jacobif.F
+++ /dev/null
@@ -1,836 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      LOGICAL FUNCTION JACOBIF(DATA,NM,W,ROTANG)
-C
-C---->
-C**** JACOBIF
-C
-C     Purpose
-C     -------
-C
-C     Rotates spectral field by latitude (Fujitsu only).
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = JACOBIF(DATA,NM,W,ROTANG)
-C
-C     Input
-C     -----
-C
-C     NM      - Triangular truncation number of the field.
-C     DATA    - Linear array of REAL*8s of size (NM+1)*(NM+2)
-C               holding the field.
-C     W       - Work array of REAL*8s of size (NM+1)*(NM+2).
-C     ROTANG  - Rotation angle (degrees, REAL*8)
-C              (degrees, negative => rotate counter-clockwise about the
-C                                    new Z-axis).
-C     
-C
-C     Output
-C     ------
-C
-C     DATA    - The transformed field.
-C
-C     Function returns .FALSE. if data cannot be transformed.
-C
-C
-C     Method
-C     ------
-C
-C     See reference paper below.
-C
-C     Coefficients are read into or are created in memory. A large
-C     amount of memory may be required; eg, for truncation NM:
-C       8*(NM*(2*NM*NM + 9*NM +13)/3) bytes.
-C
-C     Optionally, if the environment variable PP_SAVE_ROT is set, a
-C     file of coefficients can be created in the directory given by
-C     environment variable PP_ROT_DIR.
-C
-C     The name of the file of rotation coefficients indicates the
-C     triangular truncation NM and the rotation angle ROTANG:
-C
-C           $PP_ROT_DIR/rot_coefs_Tttt_nnnnnnnnn
-C     or    $TMPDIR/rot_coefs_Tttt_nnnnnnnnn
-C
-C     where:
-C            ttt =  triangular truncation
-C      nnnnnnnnn =  ROTANG*100000,
-C     or
-C           $PP_ROT_DIR/rot_coefs_Tttt_Mnnnnnnnn
-C     or    $TMPDIR/rot_coefs_Tttt_Mnnnnnnnn
-C
-C     where:
-C            ttt =  triangular truncation
-C       nnnnnnnn =  -ROTANG*100000 if ROTANG is negative.
-C        
-C
-C     Externals
-C     ---------
-C
-C     INTLOG  - Logs messages.
-C     INTLOGR - Logs messages.
-C     GETENV  - To get environment variable data.
-C     UNLINK  - To remove a file.
-C     PPALLOW - Checks if the rotation coefficients can go into mrfs.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF       April 1999
-C
-C
-C     Reference.
-C     ----------
-C
-C     "Spectral synthesis on rotated and regular grids"
-C     by P.Lynch and R.McGrath (Irish Meteorological Service).
-C
-C
-C----<
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "jparams.h"
-#include "parim.h"
-C
-C     Function arguments.
-C
-      REAL*8 DATA, W
-      DIMENSION DATA(*), W(*)
-      INTEGER NM
-      REAL*8 ROTANG
-C
-C     Parameters.
-C
-      REAL*8 EPS
-      PARAMETER(EPS = 1.0E-10)
-      INTEGER JPNM_MAX, JPMAXMM, JPMEM20
-      PARAMETER( JPNM_MAX = 640 )
-      PARAMETER( JPMAXMM = 3 )
-C                          `--> maximum number of memory slots
-C                               used for rotation coefficients
-      PARAMETER( JPMEM20 = 20 )
-C                           `--> offset in memory allocation table of
-C                                first memory slot for rotation
-C                                coefficients
-C
-C     Local variables.
-C
-      LOGICAL LFOR, LALLOW
-      INTEGER I, ISKIP, J, N, MM, K, IEND
-      INTEGER NN, M, NDEX, IMEMORY
-C
-      REAL*4 SROTANG
-      REAL*8 SIMAG, S, TEMP, DROTANG
-      REAL*8 RAD, TANB, SINB, COSB, Q, RNKN, BNKN, SQNN
-      REAL*8 SQNN1, SQ2N, PKN, PK1N, RNKN1, SREAL ,RNK0, RNK1
-      REAL*8 INDEXR(JPNM_MAX), INDEXI(JPNM_MAX)
-      REAL*8 MINUS1(JPNM_MAX)
-      REAL*8 FACTOR(JPNM_MAX)
-      REAL*8 WISQR(JPNM_MAX)
-      REAL*8 WIB(JPNM_MAX)
-      REAL*8 WIR(JPNM_MAX)
-      REAL*8 WIDAT(2*JPNM_MAX)
-C
-      CHARACTER*256 FILENAME
-      CHARACTER*40 COEFILE
-      DATA COEFILE/'rot_coefs_Tnnn_nnnnnnnnn'/
-C
-      INTEGER IUNIT, IRET, ILAT, OLDLAT(3), OLDTRUN(3), IOFFSET
-      INTEGER IFSIZE, ICNDEX
-      INTEGER LOOP, NMP1TM, MAXMEM
-      LOGICAL LINMEM, LEXIST
-C
-      INTEGER CURRENT, OLDEST
-      DATA OLDEST/1/, MAXMEM/JPMAXMM/
-      SAVE OLDEST, MAXMEM
-C
-      DATA OLDLAT/3*9999999/, OLDTRUN/3*0/
-      DATA LINMEM/.FALSE./, LEXIST/.FALSE./
-      SAVE IUNIT, ILAT, OLDLAT, OLDTRUN, COEFILE, LINMEM, LEXIST
-C
-#ifdef POINTER_64
-Cjdc  INTEGER*8 ICOEFF
-#endif
-      REAL*8 ACOEFF
-      DIMENSION ACOEFF(1)
-      POINTER ( ICOEFF, ACOEFF )
-C
-C     Externals
-C
-      INTEGER JCHMOD, UNLINK
-      LOGICAL PPALLOW
-      EXTERNAL JCHMOD, UNLINK, PPALLOW
-C
-C     Statement function
-C
-      REAL*8 A, B
-      LOGICAL ABSCHK
-      ABSCHK(A,B) = (ABS(A-B) .LT. EPS*(ABS(A) + ABS(B)))
-C
-C     W array: 1 -> (NM+1)*(NM+2) for PMN/SQRT(2*N+1) values.
-C
-C     RNKM values in WIR (for M>0),
-C                 in WIB (M<0).
-C     Array of temporary SQRT values in WISQR, and
-C     temporary transformed data in WIDAT
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      JACOBIF = .FALSE.
-C
-      LALLOW = PPALLOW(NM,ROTANG)
-C
-      CALL INTLOG(JP_DEBUG,'JACOBIF: truncation = ', NM)
-      SROTANG = SNGL(ROTANG)
-      CALL INTLOGR(JP_DEBUG,'JACOBIF: rotation angle = ', SROTANG)
-C
-C     Exit immediately if rotation angle is zero.
-C
-      IF (ABS(ROTANG).LT.EPS) THEN
-        CALL INTLOG(JP_DEBUG,'JACOBIF: No rotation necessary',JPQUIET)
-        JACOBIF = .TRUE.
-        GOTO 999
-      ENDIF
-C
-C     Change to radians.
-C
-      RAD   = 180.0/PPI
-      DROTANG = ROTANG/RAD
-      TANB  = TAN(DROTANG/(2.0))
-      SINB  = SIN(DROTANG)
-      COSB  = COS(DROTANG)
-      Q     = SQRT(2.0)/2.0
-C
-      ICNDEX = 0
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.   Generate PMN/SQRT(2*N+1) values in W.
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-      W(1)  = 1.0
-      W(2)  = COSB
-C
-      ISKIP = NM + 1
-!OCL SCALAR
-      DO I = 1,ISKIP
-        W(1+ISKIP*I)   = W(1+ISKIP*I-ISKIP)*SINB*
-     X                   SQRT(DBLE(2*I-1)/DBLE(2*I))
-        W(1+ISKIP*I+1) = COSB*DSQRT(DBLE(2*I+1))*W(1+ISKIP*I)
-      ENDDO
-C
-!OCL SCALAR
-      DO I = 2,ISKIP-1
-C
-!OCL VECTOR
-        DO J = 0,ISKIP-I+1
-          FACTOR(J) = 1.0/DSQRT(DBLE((I+2*J)*I))
-        ENDDO
-C
-        DO J = 0,ISKIP-I+1
-          W(I+J*ISKIP+1) = COSB*DBLE(2*I+2*J-1)
-     X                     *FACTOR(J)*W(I+J*ISKIP)
-     X                     - DSQRT(DBLE((I-1)*(I+2*J-1)))
-     X                     *FACTOR(J)*W(I+J*ISKIP-1)
-        ENDDO
-C
-      ENDDO
-C
-      MINUS1(1) = -1
-!OCL SCALAR
-      DO I = 2, JPNM_MAX
-        MINUS1(I) = -MINUS1(I-1)
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C*    Section 3.   Pick up the rotation coefficients RNKM.
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-C     Change the interpolation coefficents if the input latitude is
-C     not the same as the one used the last time through.
-C
-      ILAT = NINT(ROTANG*100000)
-C
-      DO LOOP = 1, MAXMEM
-        IF( ILAT.EQ.OLDLAT(LOOP).AND.(OLDTRUN(LOOP).EQ.NM) ) THEN
-C
-C         Set flags to show the rotation coefficients are in memory
-C
-          LINMEM = .TRUE.
-          LEXIST = .TRUE.
-          CURRENT = LOOP + JPMEM20 - 1
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: Existing memory slot re-used = ', CURRENT)
-          CALL JMEMHAN( CURRENT, ICOEFF, IMEMORY, 1, IRET)
-          IF( IRET.NE.0 ) THEN
-            CALL INTLOG(JP_FATAL,
-     X        'JACOBIF: Failed to pick up existing memory pool',CURRENT)
-            JACOBIF = .FALSE.
-            GOTO 999
-          ENDIF
-          GOTO 310
-        ENDIF
-      ENDDO
-C
-      LINMEM = .FALSE.
-      LEXIST = .FALSE.
-      CURRENT = OLDEST + JPMEM20 - 1
-      OLDLAT(OLDEST)  = ILAT
-      OLDTRUN(OLDEST) = NM
-      OLDEST  = OLDEST + 1
-      IF( OLDEST.GT.MAXMEM ) OLDEST = 1
-      CALL INTLOG(JP_DEBUG,
-     X  'JACOBIF: Different memory slot selected = ', CURRENT)
-C
-  310 CONTINUE
-C
-      IF( .NOT. LINMEM ) THEN
-C
-C       Calculate the coefficients file size (coefficients are REAL*8)
-C
-        IFSIZE = 8*(NM*(2*NM*NM + 9*NM +13)/3)
-C
-C       Allocate memory for the REAL*8 coefficients
-C
-#ifdef REAL_8
-        IMEMORY = (NM*(2*NM*NM + 9*NM +13)/3)
-#else
-        IMEMORY = 2*(NM*(2*NM*NM + 9*NM +13)/3)
-#endif
-C
-  320   CONTINUE
-C
-        CALL JMEMHAN( CURRENT, ICOEFF, IMEMORY, 1, IRET)
-        IF( IRET.NE.0 ) THEN
-C
-C         If memory allocation fails, reduce the number of slots in the
-C         memory pool. Exit if the pool is already down to one slot.
-C
-          IF( MAXMEM.LT.2 ) THEN
-            CALL INTLOG(JP_FATAL,
-     X        'JACOBIF: memory allocation error',ICOEFF)
-            JACOBIF = .FALSE.
-            GOTO 999
-          ENDIF
-          MAXMEM = MAXMEM - 1
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: Reduce number of memory slots to ', MAXMEM)
-          LINMEM = .FALSE.
-          LEXIST = .FALSE.
-          OLDEST = 1
-          OLDLAT(OLDEST)  = ILAT
-          OLDTRUN(OLDEST) = NM
-          CURRENT = OLDEST + JPMEM20 - 1
-          OLDEST = OLDEST + 1
-          IF( OLDEST.GT.MAXMEM ) OLDEST = 1
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: Different memory slot selected = ', CURRENT)
-          GOTO 320
-        ENDIF
-        ICNDEX = 0
-C
-C       If the file already exists, read it into memory.
-C       For 'standard' rotations try PP_ROT_DIR, otherwise TMPDIR.
-C
-        IF( LALLOW ) THEN
-          CALL GETENV('PP_ROT_DIR',FILENAME)
-        ELSE
-          CALL GETENV('TMPDIR',FILENAME)
-        ENDIF
-        IOFFSET = INDEX(FILENAME,' ')
-        IF( IOFFSET.EQ.1) THEN
-          CALL INTLOG(JP_WARN,
-     X      'JACOBIF: Unable to open rotation coefficents.',JPQUIET)
-C
-        ELSE
-C
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: Existing coefficients sought in:',JPQUIET)
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: '// FILENAME(1:IOFFSET-1),JPQUIET)
-C
-          WRITE(COEFILE(12:14),'(I3.3)') NM
-          IF( ILAT.GE.0) THEN
-            WRITE(COEFILE(16:),'(I9.9)') ILAT
-          ELSE
-            COEFILE(16:) = 'M'
-            WRITE(COEFILE(17:),'(I8.8)') -ILAT
-          ENDIF
-          FILENAME = FILENAME(1:IOFFSET-1) // '/' // COEFILE
-          IOFFSET = INDEX(FILENAME,' ') - 1
-C
-          CALL PBOPEN(IUNIT,FILENAME(1:IOFFSET),'r',IRET)
-          IF( IRET.EQ.0 ) THEN
-C
-C           Let user know that a existing file has been opened
-C
-            CALL INTLOG(JP_DEBUG,
-     X        'JACOBIF: Existing coefficients found in file:',JPQUIET)
-            CALL INTLOG(JP_DEBUG,'JACOBIF: '// COEFILE, JPQUIET)
-C
-C           Read coefficients into memory
-C
-            CALL PBREAD(IUNIT,ACOEFF,IFSIZE,IRET)
-            IF( IRET.NE.IFSIZE ) THEN
-              CALL INTLOG(JP_WARN,'JACOBIF: PBREAD failed.',JPQUIET)
-            ELSE
-C
-C           Set flags to show the rotation coefficients are in memory
-C           and exist.
-C
-              LINMEM = .TRUE.
-              LEXIST = .TRUE.
-            ENDIF
-C
-            CALL PBCLOSE(IUNIT,IRET)
-          ENDIF
-C
-        ENDIF
-C
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 4.   Generate the rotation coefficients RNKM.
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-C
-C     Generate the rotation coefficients RNKM (K = M dashed in note)
-C     and store in W.  For K = 0 special case.
-C
-C     PMN = W(M*(NM+1) + (N-M+1))
-C
-!OCL VECTOR
-      DO 630 N = 1,NM
-        RNKN  = (0.5*(1.0 + COSB))**N
-        BNKN  = (0.5*(1.0 - COSB))**N
-        SQNN  = DSQRT(DBLE((N+1)*N))
-        SQNN1 = SQNN*SINB
-        SQ2N  = DSQRT(2.0/DBLE(N))/SINB
-C
-C       Save SQRTS.
-C
-!OCL VECTOR
-        DO MM = 0,N
-          WISQR(MM+1) = DSQRT(DBLE((N+MM)*(N-MM+1)))*SINB
-        ENDDO
-C
-        NN = 1
-C
-C       Generate RNKM, M = 0 to N.
-C
-!OCL SCALAR
-        DO 590 K = N,0,-1
-C
-C         If the coefficients are not (yet) in memory, they have to
-C         be calculated.
-C
-          IF( .NOT. LINMEM ) THEN
-C
-            PKN = W(K*(NM+1) + (N-K+1))
-            IF (K.EQ.0) GOTO 500
-C
-C           For K > 0, go forward from zero.
-C
-            PK1N = W((K-1)*(NM+1) + (N-(K-1)+1))
-C
-C           Flip sign if necessary.
-C
-            IF (MOD(K,2).NE.0)THEN
-              PKN = -PKN
-            ELSE
-              PK1N = -PK1N
-            ENDIF
-C
-C           Work using forward recurrence as long as coefficient
-C           calculated passes checks.
-C
-            LFOR = .TRUE.
-C
-            RNK0 = PKN
-            RNK1 = (-DBLE(K)*TANB*PKN + (WISQR(K+1)/SINB)*PK1N)/SQNN
-C
-C           Recurrence starts at 2 for M = 0
-C
-            WIR(1) = RNK0
-            WIR(2) = RNK1
-C
-!OCL SCALAR
-            DO MM = 1,N-1
-              WIR(MM+2) = (2.0*WIR(MM+1)*(DBLE(MM)*COSB-DBLE(K))
-     X                    - WISQR(MM+1)*WIR(MM)) /WISQR(MM+2)
-C
-C             Apply check to generated coefficient to see if its
-C             absolute value is greater than 1.  If so, have to
-C             switch to using backwards recurrences.
-C
-              IF (ABS(WIR(MM+2)).GT.1.0)THEN
-                LFOR = .FALSE.
-                IEND = MM + 3
-                GOTO 435
-              ENDIF
-            ENDDO
-C
-C           If forward recurrence appears OK so far,
-C           test last element RNKN by comparing with WIR(N+1).
-C
-            IEND = N + 2
-            IF (ABSCHK(RNKN,WIR(N+1))) GOTO 445
-C
-C           If test failed, try generating coefficients using
-C           backwards recurrences.
-C
-  435       CONTINUE
-C
-C           Work backwards from the top.
-C           Specify N; K is already set from the loop above.
-C           Stop at M = 1 (NOT 0).
-C
-            RNKN1 = RNKN*SQ2N*(DBLE(N)*COSB-DBLE(K))
-            WIR(N+1) = RNKN
-C
-C           Check whether difference is within prescribed tolerance.
-C
-            IF (LFOR .AND. ABSCHK(RNKN1,WIR(N))) GO  TO 445
-            WIR(N) = RNKN1
-C
-C           For M = 0:
-C
-!OCL SCALAR
-            DO MM = N-1,1,-1
-              S = (2.0*WIR(MM+1)*(DBLE(MM)*COSB-DBLE(K))
-     X              - (WISQR(MM+2)*WIR(MM+2))) / WISQR(MM+1)
-C
-C             Accept these if forward recursion failed before
-C             reaching this point.
-C
-              IF (MM+1.LT.IEND)THEN
-                IF (ABSCHK(S,WIR(MM))) GOTO 445
-              ENDIF
-              WIR(MM) = S
-C
-C             If absolute value is greater than 1, give up gracefully
-C
-              IF (ABS(S).GT.1.0) GOTO 920
-C
-            ENDDO
-C
-            GOTO 920
-C
-  445       CONTINUE
-C
-C           Now RNKM for M = 0,-N
-C
-C           RNKM M = -1,-N
-C
-C           Forward recurrence starts at 1 for M = 0, 2 for -1 etc.
-C
-            LFOR = .TRUE.
-C
-            WIB(1) = RNK0
-            WIB(2) = -RNK1-RNK0*DBLE(2*K)/(SQNN1)
-C
-!OCL SCALAR
-            DO MM = 1,(N-1)
-              WIB(MM+2) = (2.0*WIB(MM+1)*(DBLE(-MM)*COSB-DBLE(K))
-     X              - WISQR(MM+1)*SINB*WIB(MM)) /WISQR(MM+2)
-C
-C             Apply check to generated coefficient to see if its
-C             absolute value is greater than 1.  If so, have to
-C             switch to using backwards recurrences.
-C
-              IF (ABS(WIB(MM+2)).GT.1.0)THEN
-                LFOR = .FALSE.
-                IEND = MM + 3
-                GOTO 455
-              ENDIF
-            ENDDO
-C
-C           If forward recurrence appears OK so far,
-C           test last element BNKN by comparing with WIB(N+1).
-C
-            IEND = N + 1
-            IF (ABSCHK(BNKN,WIB(N+1))) GOTO 500
-C
-C           If test failed, try generating coefficients using backwards
-C           recurrences.
-C
-  455       CONTINUE
-C
-C           Get R values.
-C           First RNKN, then next highest RNKN1.
-C
-            RNKN1 = -BNKN*SQ2N*(DBLE(N)*COSB + DBLE(K))
-C
-C           Work backwards from the top.
-C           Specify N; K is already set from the loop above.
-C
-C           Stop at M = 1 (NOT 0).
-C
-            WIB(N+1) = BNKN
-            IF (LFOR .AND. ABSCHK(RNKN1,WIB(N))) GOTO 500
-            WIB(N) = RNKN1
-C
-!OCL SCALAR
-            DO MM = N-1,1,-1
-              S = (2.0*WIB(MM+1)*(DBLE(-MM)*COSB-DBLE(K))
-     X            - (WISQR(MM+2)*WIB(MM+2))) / WISQR(MM+1)
-C
-C             Accept backwards generated coefficients if forward
-C             recursion failed before reaching this point.
-C
-              IF ( (MM.LT.IEND ) .AND. ABSCHK(S,WIB(MM)) ) GOTO 500
-              WIB(MM) = S
-C
-C             If absolute value is greater than 1, give up.
-C
-              IF (ABS(S).GT.1.0) GOTO 910
-C
-            ENDDO
-C
-C           End of backwards recurrences reached with no agreed
-C           coefficients, give up.
-C
-            GOTO 910
-C
-C     -----------------------------------------------------------------|
-C*    Section 5.   Got RNKM. Now transform spectral data.
-C     -----------------------------------------------------------------|
-C
-  500       CONTINUE
-C
-C           Put coefficients in allocated memory
-C
-!OCL VECTOR
-            DO LOOP = 1, N+1
-              ACOEFF(ICNDEX    +LOOP) = WIR(LOOP)
-              ACOEFF(ICNDEX+N+1+LOOP) = WIB(LOOP)
-            ENDDO
-C
-          ENDIF
-C
-C         Coefficients are in memory
-C
-          PKN  = W(K*(NM+1) + (N-K+1))
-          PK1N = W((K-1)*(NM+1) + (N-(K-1)+1))
-C
-C         Flip sign if necessary.
-C
-          IF (MOD(K,2).NE.0)THEN
-            PKN  = -PKN
-          ELSE
-            PK1N = -PK1N
-          ENDIF
-C
-!OCL VECTOR
-          DO LOOP = 1, N+1
-            WIR(LOOP) = ACOEFF(ICNDEX    +LOOP)
-            WIB(LOOP) = ACOEFF(ICNDEX+N+1+LOOP)
-          ENDDO
-          ICNDEX = ICNDEX + 2*(N+1)
-C
-C
-C         Special case when K=0.
-C
-          IF( K.EQ.0) THEN
-C
-            SREAL = DATA(2*(N+1)-1)*PKN
-            SIMAG = 0.0
-!OCL VECTOR
-            DO M = 1,N
-              SREAL = SREAL
-     X        + 2.0*DATA(2*((NM+1)*M-((M-1)*M)/2+1+N-M)-1)
-     X        * W((NM+1)*M+(N-M+1))
-            ENDDO
-C
-            NDEX       = 1+N
-            WIDAT(NN)   = SREAL
-            WIDAT(NN+1) = SIMAG
-            NN          = NN + 2
-C
-          ELSE
-C
-            SREAL  = DATA(2*(N+1)-1)*PKN
-            SIMAG  = 0.0
-!OCL VECTOR
-            DO M = 1,N
-              INDEXR(M) = 2*((NM+1)*M-((M-1)*M)/2+1+N-M)-1
-            ENDDO
-!OCL VECTOR
-            DO M = 1,N
-              INDEXI(M) = INDEXR(M) + 1
-            ENDDO
-C
-!OCL VECTOR
-            DO M = 1,N
-              SREAL = SREAL +
-     X              DATA(INDEXR(M))
-     X              * (WIR(M+1)+WIB(M+1)*MINUS1(M))
-              SIMAG = SIMAG -
-     X              DATA(INDEXI(M))
-     X              * (-WIR(M+1)+WIB(M+1)*MINUS1(M))
-            ENDDO
-C
-            NDEX       = (NM+1)*K - ((K-1)*K)/2+1+N-K
-            WIDAT(NN)   = SREAL
-            WIDAT(NN+1) = SIMAG
-            NN          = NN + 2
-          ENDIF
-C
-C         Update RNKN at both ends of the forward and backward
-C         recurrences.
-C
-          TEMP = DSQRT(DBLE(N+K)/DBLE(N-K+1))
-          RNKN = RNKN*TEMP*SINB/(1+COSB)
-          BNKN = -BNKN*TEMP*(1+COSB)/SINB
-C
-C       End of inner loop.
-C
-  590   CONTINUE
-C
-C     -----------------------------------------------------------------|
-C*    Section 6.   Now place the values of the rotated spectral
-C                  coefficients in DATA.
-C     -----------------------------------------------------------------|
-C
-  600 CONTINUE
-C
-        NN = 1
-!OCL VECTOR
-        DO K = N,0,-1
-          NDEX = (NM+1)*K - ((K-1)*K)/2+1+N-K
-          DATA(2*NDEX-1) = WIDAT(NN)
-          DATA(2*NDEX)   = WIDAT(NN+1)
-          NN = NN + 2
-C
-        ENDDO
-C
-C     End of outer loop.
-C
-  630 CONTINUE
-C
-C     -----------------------------------------------------------------|
-C*    Section 9.   Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      LINMEM = .TRUE.
-C
-      IF( .NOT. LEXIST ) THEN
-C
-C       If the environment variable PP_SAVE_ROT is set, save the
-C       rotation coefficients in a file.
-C       'Standard' rotations go into PP_ROT_DIR, others into TMPDIR.
-C
-        LEXIST = .TRUE.
-        CALL GETENV('PP_SAVE_ROT',FILENAME)
-        IOFFSET = INDEX(FILENAME,' ')
-        IF( IOFFSET.GT.1 ) THEN
-          IF( LALLOW ) THEN
-            CALL GETENV('PP_ROT_DIR',FILENAME)
-          ELSE
-            CALL GETENV('TMPDIR',FILENAME)
-          ENDIF
-          IOFFSET = INDEX(FILENAME,' ')
-          IF( IOFFSET.EQ.1) THEN
-            CALL INTLOG(JP_WARN,
-     X        'JACOBIF: Unable to save rotation coefficents.',JPQUIET)
-C
-          ELSE
-C
-C         Let user know that a new file is being created.
-C
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: Creating new coefficients in directory',JPQUIET)
-          CALL INTLOG(JP_DEBUG,
-     X      'JACOBIF: '// FILENAME(1:IOFFSET-1),JPQUIET)
-C
-            WRITE(COEFILE(12:14),'(I3.3)') NM
-            IF( ILAT.GE.0) THEN
-              WRITE(COEFILE(16:),'(I9.9)') ILAT
-            ELSE
-              COEFILE(16:) = 'M'
-              WRITE(COEFILE(17:),'(I8.8)') -ILAT
-            ENDIF
-            FILENAME = FILENAME(1:IOFFSET-1) // '/' // COEFILE
-            IOFFSET = INDEX(FILENAME,' ')
-C
-            CALL PBOPEN(IUNIT,FILENAME(1:IOFFSET-1),'w',IRET)
-            IF( IRET.NE.0 ) THEN
-              CALL INTLOG(JP_WARN,
-     X          'JACOBIF: PBOPEN for write failed',JPQUIET)
-              GOTO 995
-            ENDIF
-C
-            CALL INTLOG(JP_DEBUG,
-     X        'JACOBIF: New coefficients filename:',JPQUIET)
-            CALL INTLOG(JP_DEBUG,'JACOBIF: '// COEFILE, JPQUIET)
-C
-C           Change access mode to 'read only' for all users.
-C
-            IRET = JCHMOD(FILENAME(1:IOFFSET-1),'0444')
-            IF( IRET.NE.0 )
-     X        CALL INTLOG(JP_WARN,'JACOBIF: JCHMOD error.',IRET)
-C
-C           Write coefficients to file
-C
-            CALL PBWRITE(IUNIT,ACOEFF,IFSIZE,IRET)
-            IF( IRET.NE.IFSIZE ) THEN
-              CALL INTLOG(JP_FATAL,'JACOBIF: PBWRITE failed.',JPQUIET)
-              IRET = UNLINK(FILENAME(1:IOFFSET-1))
-              IF( IRET.NE.0 )
-     X          CALL INTLOG(JP_FATAL,'JACOBIF: UNLINK failed',JPQUIET)
-              CALL PBCLOSE(IUNIT,IRET)
-              JACOBIF = .FALSE.
-              GOTO 999
-            ENDIF
-            CALL PBCLOSE(IUNIT,IRET)
-            LINMEM = .TRUE.
-          ENDIF
-        ENDIF
-      ENDIF
-C
-  995 CONTINUE
-C
-      JACOBIF = .TRUE.
-C
-  999 CONTINUE
-      RETURN
-C
-C     Failure to converge with M < 0.
-C
-  910 CONTINUE
-      CALL INTLOG(JP_FATAL,'JACOBIF: Fail to converge M < 0', JPQUIET)
-      JACOBIF = .FALSE.
-      GOTO 999
-C
-C     Failure to converge with M > 0.
-C
-  920 CONTINUE
-      CALL INTLOG(JP_FATAL,'JACOBIF: Fail to converge M > 0', JPQUIET)
-      JACOBIF = .FALSE.
-      GOTO 999
-      END
diff --git a/interpolation/jagggp.F b/interpolation/jagggp.F
index 371eef6..7321ff3 100644
--- a/interpolation/jagggp.F
+++ b/interpolation/jagggp.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -37,8 +37,9 @@ C     PWEST    - Westernmost longitude for output field (degrees)
 C     PEAST    - Easternmost longitude for output field (degrees)
 C     KNUM     - Gaussian grid number
 C     HTYPE    - Gaussian grid type
-C                = 'R' for reduced, 
-C                = 'F' for full
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
 C                = 'U' for user-defined reduced gaussian grid
 C     KPTS     - Array specifying number of points at each line of
 C                latitude if HTYPE = 'U'.
@@ -82,7 +83,7 @@ C     JOPNGGSM - Opens the legendre functions file and memory maps it.
 C     JJSET99  - Sets up FFT
 C     JNORSGG  - Determines which latitude row in a gaussian grid is
 C                north or south of a given latitude
-C     JSYMGG   - Generate symmetric grid from spherical harmonics 
+C     JSYMGG   - Generate symmetric grid from spherical harmonics
 C     JWSCAL   - Apply latitude correction to wind component field
 C     JMVUGG   - Moves grid point data to output array
 C     JMKOFGG  - Builds offsets into storage array
@@ -91,6 +92,8 @@ C     INTLOG   - Logs output messages
 C     INTLOGR  - Logs output messages
 C     GETCONF  - Decides how to handle legendre coefficients
 C     GETENV   - Get value of an environment variable
+c     FORCED_FFTW - determine if FFTW should be used, instead of the
+C                usual FFT99 (as per the environment)
 #ifdef SHAREDMEMORY
 C     SMREAD   - Gets interpolation coefficients in a shared memory array
 #endif
@@ -136,7 +139,7 @@ C     Subroutine arguments
 C
       COMPLEX   PSHUP
       DIMENSION PSHUP(*)
-      INTEGER   KTRUNC, KNUM, KPTS, KRET
+      INTEGER   KTRUNC, KNUM, KPTS, KRET, KRET2
       DIMENSION KPTS(*)
       CHARACTER*1 HTYPE
       REAL      PNORTH, PSOUTH, PWEST, PEAST
@@ -151,11 +154,12 @@ C
 C
 C     Local variables
 C
-      INTEGER ILON, ITOUP1, IJPWR, NUMPTS, ITYPE
+      INTEGER ILON, ITOUP1, IJPWR, NUMPTS
       DIMENSION IJPWR(JPMAX)
       INTEGER ILUNIT
       INTEGER NXTROW
       REAL RINTVL, GNUM
+      LOGICAL LUSEFFTW
 C
       INTEGER IMFAX
       REAL ATRIGS
@@ -176,11 +180,10 @@ C
       SAVE ISIZE, IZFA
 C
       CHARACTER*10 PLAINUV
+      CHARACTER*6  HUSEFFT
 C
-      CHARACTER*8 FILENAME
-      DATA FILENAME/'Nxxx_DEF'/
       INTEGER NGROUP
-      INTEGER FILENM, J108, NNORTH, NSOUTH, NCASE, NFLAG
+      INTEGER FILENM, J, NNORTH, NSOUTH, NCASE, NFLAG
       INTEGER NOFSET, LOOP
       DIMENSION NOFSET(JPMAX)
       INTEGER INORTH, ISOUTH, IMAGE, NFIRST, NDIFF
@@ -193,15 +196,18 @@ C
       LOGICAL LDEBUG, LFIRST, LPLAINU
       DATA LFIRST/.TRUE./, LPLAINU/.FALSE./
       SAVE LDEBUG, LFIRST, LPLAINU
-      CHARACTER*20 CONFIG
       INTEGER IBLANK
 C
+C     External
+C
       INTEGER  JNORSGG
       EXTERNAL JNORSGG
 #ifdef SHAREDMEMORY
       INTEGER  SHAREDGG, SHAREDDT
       EXTERNAL SHAREDGG, SHAREDDT
 #endif
+      LOGICAL FORCED_FFTW
+      EXTERNAL FORCED_FFTW
 C     _______________________________________________________
 C
 C*    Section 1.    Initialization.
@@ -265,6 +271,8 @@ C
 C
         IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' ) CALL INTLOG(JP_DEBUG,
      X    'JAGGGP: Grid type is Reduced.',JPQUIET)
+        IF( HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' ) CALL INTLOG(JP_DEBUG,
+     X    'JAGGGP: Grid type is Reduced/octahedral.',JPQUIET)
         IF( HTYPE.EQ.'F' .OR. HTYPE.EQ.'f' ) CALL INTLOG(JP_DEBUG,
      X    'JAGGGP: Grid type is Full.',JPQUIET)
         IF( HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) CALL INTLOG(JP_DEBUG,
@@ -272,7 +280,7 @@ C
         CALL INTLOG(JP_DEBUG,
      X    'JAGGGP: Field code( = 1 for U or V) = ', LUV)
 C
-        IF ( HTYPE .EQ. 'u' .OR. HTYPE .EQ. 'U' ) THEN
+        IF( HTYPE.EQ.'u' .OR. HTYPE.EQ.'U' ) THEN
           CALL INTLOG(JP_DEBUG,'JAGGGP: User-supplied values.',JPQUIET)
           CALL INTLOG(JP_DEBUG,'JAGGGP: No. pts at each line:',JPQUIET)
           DO NDBGLP = 1, 20
@@ -285,7 +293,7 @@ C     Pick up the file containing the definition of the gaussian grid.
 C
       IF( (NOGAUSO.NE.KNUM).OR.(HOGAUST.NE.HTYPE) ) THEN
         CALL JGETGG( KNUM, HTYPE, ALAT, KPTS, KRET)
-        IF ( KRET .NE. 0 ) GOTO 990
+        IF( KRET.NE.0 ) GOTO 990
         NOGAUSO = KNUM
         HOGAUST = HTYPE
       ELSE
@@ -306,25 +314,21 @@ C
           KRET = JPROUTINE + 2
           GOTO 990
         ENDIF
-        CALL JOPNGG( ALEG, KNUM, KTRUNC, ILUNIT, ALAT, KRET)
+        CALL JOPNGG(ALEG,KNUM,KTRUNC,ILUNIT,ALAT,KRET)
       ELSE IF( LMEMORY ) THEN
-        CALL JOPNGGF( IALEG, KNUM, KTRUNC, ILUNIT, ALAT, KRET)
+        CALL JOPNGGF(IALEG,KNUM,KTRUNC,ILUNIT,ALAT,KRET)
       ELSE IF( LMAPPED ) THEN
-        CALL JOPNGGSM( IALEG, KNUM, KTRUNC, ILUNIT, ALAT, KRET)
+        CALL JOPNGGSM(IALEG,KNUM,KTRUNC,ILUNIT,ALAT,KRET)
 #ifdef SHAREDMEMORY
       ELSE IF( LSHARED ) THEN
         GNUM = REAL(KNUM)
-        IF( LDEBUG ) THEN
-           CALL INTLOG(JP_DEBUG,'JAGGGP: call SHAREDGG', JPQUIET)
-        ENDIF
-C
-        KRET =  SHAREDGG(IALEG,KTRUNC,KNUM)
-C
+        CALL INTLOG(JP_DEBUG,'JAGGGP: call SHAREDGG', JPQUIET)
+        KRET = SHAREDGG(IALEG,KTRUNC,KNUM)
         IF( KRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X      'JAGGGP: SHARED MEMORY Failed to get legendre coeff.',KRET)
-	      KRET = JPROUTINE + 3
-	      GOTO 990
+          KRET = JPROUTINE + 3
+          GOTO 990
         ENDIF
         GOTO 102
 #endif
@@ -341,13 +345,13 @@ C
       IF( KRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'JAGGGP: Failed to get legendre coefficients',KRET)
-	KRET = JPROUTINE + 3
-	GOTO 990
+        KRET = JPROUTINE + 3
+        GOTO 990
       ENDIF
 C
   102 CONTINUE
 C
-C     Determine which latitude rows in the gaussian grid are in the 
+C     Determine which latitude rows in the gaussian grid are in the
 C     requested area
 C
       NNORTH = JNORSGG( PNORTH, ALAT, KNUM, 1)
@@ -361,28 +365,28 @@ C
 C
 C
 C     For calculation purposes, the number of longitude points for each
-C     latitude row has to be greater than 2*(output truncation) to 
-C     ensure the fourier transform is exact (see Reference, page 10). 
+C     latitude row has to be greater than 2*(output truncation) to
+C     ensure the fourier transform is exact (see Reference, page 10).
 C
-C     The following loop calculates the power of 2 to be used as a 
+C     The following loop calculates the power of 2 to be used as a
 C     multipier for each row to ensure there are enough points.
 C     Later, when filling the output array POUTF, the longitude points
 C     have to be taken selectively to avoid the intermediate generated
 C     points, picking up values only at the required longitudes.
 C
       ITOUP1 = KTRUNC
-      DO 108 J108 = 1, KNUM
-	IMAGE = 2*KNUM - J108 + 1
-	ILON        = KPTS(J108)
-        IJPWR(J108) = 1
+      DO J = 1, KNUM
+        IMAGE = 2*KNUM - J + 1
+        ILON     = KPTS(J)
+        IJPWR(J) = 1
  104    CONTINUE
           IF(ILON .GT. 2*ITOUP1) GOTO 106
-	  IJPWR(J108) = IJPWR(J108)*2
+          IJPWR(J) = IJPWR(J)*2
           ILON        = ILON*2
           GOTO 104
  106    CONTINUE
-	IJPWR(IMAGE) = IJPWR(J108)
- 108  CONTINUE
+        IJPWR(IMAGE) = IJPWR(J)
+      ENDDO
 C
 C     _______________________________________________________
 C
@@ -392,7 +396,7 @@ C
  200  CONTINUE
 C
 C     Latitude rows are generated from row INORTH to ISOUTH.
-C     Selection is carried out for actual requested rows when the 
+C     Selection is carried out for actual requested rows when the
 C     calculated values are moved to the output array.
 C
 C     Start with assumption that the area is symmetrical about equator.
@@ -407,47 +411,47 @@ C     Northern hemisphere only ?
 C
       IF ( PSOUTH .GE. 0.0 ) THEN
         NCASE  = 2
-	NFLAG  = 1
-	INORTH = NNORTH
-	ISOUTH = NSOUTH
+        NFLAG  = 1
+        INORTH = NNORTH
+        ISOUTH = NSOUTH
         IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
      X    'JAGGGP: North hemisphere only.',JPQUIET)
-	GOTO 220
+        GOTO 220
       ENDIF
 C
 C     Southern hemisphere only ?
 C
       IF ( PNORTH .LE. 0.0 ) THEN
         NCASE  = 3
-	NFLAG  = 2
+        NFLAG  = 2
         INORTH = 2*KNUM - NSOUTH + 1
         ISOUTH = 2*KNUM - NNORTH + 1
         IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
      X    'JAGGGP: South hemisphere only.',JPQUIET)
-	GOTO 220
+        GOTO 220
       ENDIF
 C
 C     Straddles equator ...
 C     ... more north than south?
 C
       IF ( PNORTH .GT. -PSOUTH ) THEN
-	NCASE  = 4
-	INORTH = NNORTH
-	ISOUTH = KNUM
+        NCASE  = 4
+        INORTH = NNORTH
+        ISOUTH = KNUM
         IF( LDEBUG ) THEN
           CALL INTLOG(JP_DEBUG,'JAGGGP: Straddles equator.',JPQUIET)
           CALL INTLOG(JP_DEBUG,'JAGGGP: More north than south',JPQUIET)
         ENDIF
-	GOTO 220
+        GOTO 220
       ENDIF
 C
 C     ... more south than north?
 C
       IF ( PNORTH .LT. -PSOUTH ) THEN
-	NCASE  = 5
-	INORTH = 2*KNUM - NSOUTH + 1
-	ISOUTH = KNUM
-	NDIFF  = NNORTH - INORTH
+        NCASE  = 5
+        INORTH = 2*KNUM - NSOUTH + 1
+        ISOUTH = KNUM
+        NDIFF  = NNORTH - INORTH
         IF( LDEBUG ) THEN
           CALL INTLOG(JP_DEBUG,'JAGGGP: Straddles equator.',JPQUIET)
           CALL INTLOG(JP_DEBUG,'JAGGGP: More south than north',JPQUIET)
@@ -466,17 +470,44 @@ C
 C
 C     _______________________________________________________
 C
-C*    Section 3.    Process all latitude rows
+C*    Section 3.    Check which version of FFT to use
 C     _______________________________________________________
 C
  300  CONTINUE
 C
+      LUSEFFTW = FORCED_FFTW(LOCTAHEDRAL)
+      HUSEFFT = 'FFT99'
+#ifdef HAVE_FFTW
+      IF( LDEBUG .AND. .NOT. LUSEFFTW ) CALL INTLOG(JP_DEBUG,
+     X  'JAGGGP: Check which version of FFT to use.',JPQUIET)
+      DO LOOP = 1, KNUM !*2 (only half of KPTS/IJPWR needs to be checked)
+        IF( LUSEFFTW ) EXIT
+        ILON = KPTS(LOOP) * IJPWR(LOOP)
+        CALL JJSET99( ATRIGS, IMFAX, ILON, KRET )
+        LUSEFFTW = ( KRET .NE. 0 )
+      ENDDO
+#ifdef REAL_8
+      IF( LUSEFFTW ) HUSEFFT = 'DFFTW'
+#else
+      IF( LUSEFFTW ) HUSEFFT = 'SFFTW'
+#endif
+#endif
+      IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
+     X  'JAGGGP: Will use '//HUSEFFT,JPQUIET)
+C
+C     _______________________________________________________
+C
+C*    Section 4.    Process all latitude rows
+C     _______________________________________________________
+C
+ 400  CONTINUE
+C
       IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
      X  'JAGGGP: Process latitude rows.',JPQUIET)
 C
       NGROUP = 0
 C
-      DO 320 NXTROW = INORTH, ISOUTH
+      DO NXTROW = INORTH, ISOUTH
 C
 C       Build up a group of lines of the same length which can all
 C       be transformed at the same time.
@@ -485,8 +516,8 @@ C
 C       Initialise FFT constants for the group
 C
         IF ( NGROUP .EQ. 1 ) THEN
-	  NFIRST = NXTROW
-	  ILON = KPTS(NFIRST) * IJPWR(NFIRST)
+          NFIRST = NXTROW
+          ILON = KPTS(NFIRST) * IJPWR(NFIRST)
 C
           IF( LDEBUG ) THEN
             CALL INTLOG(JP_DEBUG,
@@ -497,9 +528,11 @@ C
      X        'JAGGGP: No. of calculated long.pts = ', ILON)
           ENDIF
 C
-          CALL JJSET99( ATRIGS, IMFAX, ILON, KRET)
-          IF( KRET .NE. 0 ) GOTO 990
-	ENDIF
+          IF( .NOT. LUSEFFTW ) THEN
+            CALL JJSET99( ATRIGS, IMFAX, ILON, KRET)
+            IF( KRET .NE. 0 ) GOTO 990
+          ENDIF
+        ENDIF
 C
 C       If the current line is the last to be processed,
 C       or the next line is not suitable for the current group,
@@ -515,19 +548,21 @@ C
      X      'JAGGGP: Number in group = ', NGROUP)
 C
           CALL JSYMGG( PSHUP, KTRUNC, NFIRST, ILUNIT, NGROUP, ILON,
-     X                 ALAT, ALEG, ATRIGS, IMFAX, ZFA, KRET)
-	  IF( KRET .NE. 0 ) GOTO 990
+     X                 ALAT, ALEG, ATRIGS, IMFAX, LUSEFFTW, ZFA, KRET )
+          IF( KRET .NE. 0 ) GOTO 990
 C
 C         If it is a wind component field formed from spectral Ucos(theta)
 C         and Vcos(theta) (ie not just spectral U and V), apply a
 C         latitude correction
 C
-	  IF( (LUV.EQ.1).AND.(.NOT.LPLAINU) )
+          IF( (LUV.EQ.1).AND.(.NOT.LPLAINU) )
      X      CALL JWSCAL(ZFA, NGROUP, ILON, NFIRST, ALAT)
 C
 C         Store away the generated latitudes
 C
-          IF( (HTYPE .EQ. 'U') .OR. (HTYPE .EQ. 'R') ) THEN
+          IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' .OR.
+     X        HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     X        HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) THEN
             NUMPTS = KPTS(NFIRST)
           ELSE
             RINTVL = (PEAST - PWEST)*FLOAT( KPTS(NFIRST) ) / 360.0
@@ -537,7 +572,7 @@ C
 C         Is the area unequally distributed about the equator?
 C
           IF ( NCASE .EQ. 4 .OR. NCASE .EQ. 5 ) THEN
-	    CALL JMVUGG( ZFA, NNORTH, NSOUTH, PWEST, KNUM, NFIRST,
+            CALL JMVUGG( ZFA, NNORTH, NSOUTH, PWEST, KNUM, NFIRST,
      X                   NDIFF, NGROUP, NUMPTS, ILON,
      X                   IJPWR(NFIRST), NOFSET, POUTF)
             NDIFF  = MAX( 0, (NDIFF - NGROUP) )
@@ -545,36 +580,33 @@ C
 C         No, it is all in one hemisphere or is symmetrical
 C         about the equator
 C
-	  ELSE
-	    CALL JMOVGG( ZFA, PWEST, KNUM, NFIRST, NGROUP, NUMPTS,
-     X  		 ILON, IJPWR(NFIRST), NOFSET, POUTF, NFLAG)
+          ELSE
+            CALL JMOVGG( ZFA, PWEST, KNUM, NFIRST, NGROUP, NUMPTS,
+     X                   ILON, IJPWR(NFIRST), NOFSET, POUTF, NFLAG)
           ENDIF
 C
 C         Startup next group of latitudes
 C
-	  NGROUP = 0
+          NGROUP = 0
         ENDIF
 C
- 320  CONTINUE
+      ENDDO
 C
 C     _______________________________________________________
 C
 C*    Section 9. Return to calling routine. Format statements
 C     _______________________________________________________
 C
- 930  CONTINUE
-      KRET = 0
-C
  990  CONTINUE
 #ifdef SHAREDMEMORY
-      KRET = SHAREDDT(IALEG) 
-      IF( LDEBUG ) 
-     X  CALL INTLOG(JP_DEBUG,'JAGGGP: release_shared_file  = ', KRET)
-      KRET = 0
+C     note: shareddt return value ignored
+      KRET2 = SHAREDDT(IALEG)
+      IF( LDEBUG )
+     X  CALL INTLOG(JP_DEBUG,'JAGGGP: release_shared_file  = ', KRET2)
 #endif
 
 C
-      IF( LDEBUG ) CALL INTLOG(JP_DEBUG,'JAGGGP: Return code = ', KRET)
+      IF( LDEBUG ) CALL INTLOG(JP_DEBUG,'JAGGGP: Return code = ',KRET)
 C
       RETURN
       END
diff --git a/interpolation/jallgp.F b/interpolation/jallgp.F
index f9e5eed..e229e95 100644
--- a/interpolation/jallgp.F
+++ b/interpolation/jallgp.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -66,7 +66,7 @@ C                of it into dynamically allocated memory.
 C     JOPNLLSM - Opens the legendre functions file and memory maps it.
 C
 C     JJSET99  - Sets up FFT
-C     JSYMLL   - Generate symmetric grid from spherical harmonics 
+C     JSYMLL   - Generate symmetric grid from spherical harmonics
 C     JWINDLL  - Generate symmetric grid from spherical harmonics(wind)
 C     JMOVLL   - Move points of symmetric grid to array
 C     JMVULL   - Move points of unsymmetric grid to array
@@ -95,7 +95,7 @@ C     This is a redesign, based on SPECGP.F
 C
 C     It handles transformations to a regular lat/long grid assuming.
 C
-C     It is not for U and V fields (no correction is applied at the 
+C     It is not for U and V fields (no correction is applied at the
 C     poles).
 C
 C
@@ -146,7 +146,7 @@ C     Local variables
 C
       REAL PSTART, PNORMX, PDIFF
       REAL ZDEGR, ZBUILD
-      INTEGER ILON, IOLON, ITOUP1, IJPWR, ITYPE
+      INTEGER ILON, IOLON, ITOUP1, IJPWR
       INTEGER ILUNIT, ISTART
       INTEGER NEXT, NCALLS, NLEFT, NROWS, NFLAG, NCASE, NUMLON
 C
@@ -175,8 +175,6 @@ C
       LOGICAL LDEBUG, LFIRST
       DATA LFIRST/.TRUE./
       SAVE LDEBUG, LFIRST
-      CHARACTER*20 CONFIG
-      INTEGER IBLANK
 C
 C     Externals
 C
@@ -266,8 +264,8 @@ c        print*,' jallgp.F KRET=',KRET
         IF( KRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,
      X     'JALLGP: SHARED Failed to get legendre coeff.',KRET)
-	      KRET = JPROUTINE + 3
-	      GOTO 900
+          KRET = JPROUTINE + 3
+          GOTO 900
         ENDIF
         GOTO 102
 #endif
@@ -297,7 +295,7 @@ C
 C
 C     For calculation purposes, ILON, the number of longitude points,
 C     has to be greater than 2*(output truncation) to ensure that the
-C     fourier transform is exact (see Reference, page 10). 
+C     fourier transform is exact (see Reference, page 10).
 C     The following loop increases ILON*IJPWR until ILON=>2*ITOUP1.
 C     Later, when filling the output array POUTF, the longitude points
 C     have to be taken selectively to avoid the intermediate generated
@@ -349,9 +347,8 @@ C
         NROWS = NINT( PDIFF/PLATINC )  + 1
         IF( ( ABS((NROWS-1)*PLATINC)-PNORTH).GT.PEPS ) NROWS = NROWS - 1
         IF( LDEBUG )
-     X    CALL INTLOG(JP_DEBUG,
-     X      'JALLGP: North hemisphere only.', JPQUIET)
-	GOTO 300
+     X    CALL INTLOG(JP_DEBUG,'JALLGP: North hemisphere only.',JPQUIET)
+        GOTO 300
       ENDIF
 C
 C     Southern hemisphere only ?
@@ -366,9 +363,8 @@ C
      X    NROWS = NROWS - 1
 C
         IF( LDEBUG )
-     X    CALL INTLOG(JP_DEBUG,
-     X      'JALLGP: South hemisphere only.', JPQUIET)
-	GOTO 300
+     X    CALL INTLOG(JP_DEBUG,'JALLGP: South hemisphere only.',JPQUIET)
+        GOTO 300
       ENDIF
 C
 C     Straddles equator ...
@@ -455,7 +451,7 @@ C
           CALL JSYMLL( PSHUP, KTRUNC, PSTART, ZBUILD, PLATINC, ILUNIT,
      X                 JP32,ILON,ALEG,ATRIGS,IMFAX,ZFA,KRET)
         ENDIF
-	IF( KRET.NE.0 ) GOTO 900
+        IF( KRET.NE.0 ) GOTO 900
 C
 C       If area straddles the equator and has different number of
 C       north/south rows, only move a selection of rows to output array.
@@ -504,7 +500,7 @@ C
           CALL JSYMLL( PSHUP, KTRUNC, PSTART, ZBUILD, PLATINC, ILUNIT,
      X                 NLEFT,ILON,ALEG,ATRIGS,IMFAX,ZFA,KRET)
         ENDIF
-	IF( KRET.NE.0 ) GOTO 900
+        IF( KRET.NE.0 ) GOTO 900
 C
 C       If area straddles the equator and has different number of
 C       north/south rows, only move a selection of rows to output array.
@@ -524,8 +520,8 @@ C
 C
       KRET = 0
 #ifdef SHAREDMEMORY
-      KRET = SHAREDDT(IALEG) 
-      IF( LDEBUG ) 
+      KRET = SHAREDDT(IALEG)
+      IF( LDEBUG )
      X  CALL INTLOG(JP_DEBUG,'JALLGP: release_shared_file  = ', KRET)
       KRET = 0
 #endif
diff --git a/interpolation/jgetgg.F b/interpolation/jgetgg.F
index c829a6d..2b0a12c 100644
--- a/interpolation/jgetgg.F
+++ b/interpolation/jgetgg.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      SUBROUTINE JGETGG( KNUM, HTYPE, PLAT, KPTS, KRET)
+      SUBROUTINE JGETGG(KNUM,HTYPE,PLAT,KPTS,KRET)
 C
 C---->
 C**** JGETGG
@@ -22,7 +22,7 @@ C
 C     INTERFACE
 C     _________
 C
-C     CALL JGETGG( KNUM, HTYPE, PLAT, KPTS, KRET)
+C     CALL JGETGG(KNUM,HTYPE,PLAT,KPTS,KRET)
 C
 C
 C     Input parameters
@@ -30,9 +30,10 @@ C     ________________
 C
 C     KNUM     - Gaussian grid number
 C     HTYPE    - Gaussian grid type
-C                = 'R' for reduced, 
-C                = 'F' for full
-C                = 'U' for a user defined gaussian grid
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
+C                = 'U' for a user-defined gaussian grid
 C     KPTS     - Array giving users definition of the number of points
 C                at each gaussian latitude if HTYPE  = 'U'
 C
@@ -41,10 +42,10 @@ C     Output parameters
 C     ________________
 C
 C     PLAT     - Array of gaussian latitudes (both hemispheres)
-C     KPTS     - Array giving number of points at each gaussian 
+C     KPTS     - Array giving number of points at each gaussian
 C                latitude, both hemispheres
-C                ( unchanged from input if HTYPE  = 'U' )
-C     KRET      - Return status code
+C                (unchanged from input if HTYPE = 'U')
+C     KRET     - Return status code
 C                0 = OK
 C
 C
@@ -65,10 +66,9 @@ C
 C     Externals
 C     _________
 C
-C     GETENV   - Get value of an environment variable
 C     INTLOG   - Output log message
-C     IGGLAT   - Computes Gaussian latitude lines for given truncation.
-C     EMOSNUM  - Gives current EMOSLIB version number.
+C     IGGLAT   - Computes Gaussian latitude lines for given truncation
+C     QGOCT    - Reduced Gaussian grid, octahedral progression series
 C
 C
 C     Reference
@@ -115,27 +115,21 @@ C
 C
 C     Parameters
 C
-      INTEGER JPROUTINE, JPMAXN
+      INTEGER JPROUTINE
       PARAMETER ( JPROUTINE = 30100 )
-      PARAMETER ( JPMAXN = 4000 )
-C                           `---> dimension for internal array for
-C                                 gaussian grid definitions
 C
 C     Subroutine arguments
 C
-      INTEGER KNUM, KPTS, KRET
+      INTEGER KNUM, KPTS(*), KRET
       CHARACTER*1 HTYPE
-      DIMENSION KPTS(*)
-      REAL PLAT
-      DIMENSION  PLAT(*)
+      REAL PLAT(*)
 C
 C     Local variables
 C
 #include "parim.h"
+! nifld.common only for NGSPEC
 #include "nifld.common"
-#include "nofld.common"
 #include "grfixed.h"
-#include "intf.h"
 #include "rgauss_032.h"
 #include "rgauss_048.h"
 #include "rgauss_064.h"
@@ -155,16 +149,19 @@ C
 #include "rgauss_1280.h"
 #include "rgauss_2000.h"
 C
-      CHARACTER*6 YEMOSNM
-      INTEGER IEMOSNM
-      INTEGER IERR, JJPR, JJERR
-      INTEGER LOOP, NLAT, IOFFSET
-      INTEGER IMAGE, K1, INUM, NGOT
+      INTEGER IERR
+      INTEGER IMAGE
+      INTEGER INUM
+      INTEGER JJERR
+      INTEGER JJPR
+      INTEGER LOOP
 C
 C     Externals
 C
-      INTEGER EMOSNUM, IGGLAT
-      EXTERNAL EMOSNUM, IGGLAT
+      LOGICAL ISGGVALID
+      EXTERNAL ISGGVALID
+      INTEGER IGGLAT, QGOCT
+      EXTERNAL IGGLAT, QGOCT
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.    Set up standard latitudes
@@ -172,16 +169,19 @@ C     -----------------------------------------------------------------|
 C
   100 CONTINUE
 C
-      IF( KNUM.GT.JPMAXN) THEN
+      IF( KNUM.GT.JPMAXNG .OR. .NOT.ISGGVALID(HTYPE,KNUM) ) THEN
         CALL INTLOG(JP_ERROR,
-     X    'JGETGG: Grid too big for internal array dimension ',JPMAXN)
+     X    'JGETGG: Grid not valid: '//HTYPE,KNUM)
+        CALL INTLOG(JP_ERROR,
+     X    'JGETGG: maybe too big for internal array dimension ',JPMAXNG)
         GOTO 910
       ENDIF
 C
       INUM = KNUM*2
 C
       IF( (HTYPE.EQ.'U').OR.(HTYPE.EQ.'u') ) GOTO 500
-      IF( (HTYPE.EQ.'R').OR.(HTYPE.EQ.'r') ) GOTO 200
+      IF( (HTYPE.EQ.'R').OR.(HTYPE.EQ.'r').OR.
+     X    (HTYPE.EQ.'O').OR.(HTYPE.EQ.'o') ) GOTO 200
 C
 C     If a regular gaussian grid, calculate the gaussian latitudes
 C
@@ -201,9 +201,7 @@ C     Fill in the number of points at each latitude
 C
       CALL INTLOG(JP_DEBUG,'JGETGG: Regular gaussian grid N ',KNUM)
 C
-      DO LOOP = 1, INUM
-        KPTS(LOOP) = KNUM*4
-      ENDDO
+      KPTS(1:INUM) = KNUM*4
 C
       GOTO 930
 C
@@ -213,29 +211,6 @@ C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
-C     Check that the definition is known
-C
-      IF( (KNUM.NE. 32 ).AND.
-     X    (KNUM.NE. 48 ).AND.
-     X    (KNUM.NE. 64 ).AND.
-     X    (KNUM.NE. 80 ).AND.
-     X    (KNUM.NE. 96 ).AND.
-     X    (KNUM.NE.128 ).AND.
-     X    (KNUM.NE.160 ).AND.
-     X    (KNUM.NE.200 ).AND.
-     X    (KNUM.NE.256 ).AND.
-     X    (KNUM.NE.320 ).AND.
-     X    (KNUM.NE.400 ).AND.
-     X    (KNUM.NE.512 ).AND.
-     X    (KNUM.NE.640 ).AND.
-     X    (KNUM.NE.1024 ).AND.
-     X    (KNUM.NE.1280 ).AND.
-     X    (KNUM.NE.2000 ) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'JGETGG: unknown reduced gaussian grid definition: ', KNUM)
-        GOTO 910
-      ENDIF
-C
 C     Fill in the gaussian latitudes
 C
       JJPR  = 1
@@ -249,7 +224,14 @@ C
 C
 C     Fill the array for each row in both hemispheres.
 C
-      IF( KNUM.EQ. 32 ) THEN
+      IF ((HTYPE.EQ.'O').OR.(HTYPE.EQ.'o')) THEN
+          DO LOOP = 1, KNUM
+              IMAGE       = INUM - LOOP +1
+              KPTS(LOOP)  = QGOCT(LOOP)
+              KPTS(IMAGE) = KPTS(LOOP)
+          ENDDO
+          GOTO 930
+      ELSEIF( KNUM.EQ. 32 ) THEN
         DO LOOP = 1, KNUM
           IMAGE       = INUM - LOOP +1
           KPTS(LOOP)  = QG032(LOOP)
@@ -389,7 +371,7 @@ C
         GOTO 930
 C
       ELSE
-C This is the default grid to use.
+C       This is the default grid to use (N=1024)
         DO LOOP = 1, KNUM
           IMAGE       = INUM - LOOP +1
           KPTS(LOOP)  = QG1024(LOOP)
@@ -432,3 +414,4 @@ C
  990  CONTINUE
       RETURN
       END
+
diff --git a/interpolation/jintend.F b/interpolation/jintend.F
deleted file mode 100644
index 9a927a3..0000000
--- a/interpolation/jintend.F
+++ /dev/null
@@ -1,129 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE JINTEND
-C
-C---->
-C**** JINTEND
-C
-C     PURPOSE
-C     _______
-C
-C     This routine deallocates heap memory (if any) allocated
-C     by JINTLL, JINTGG and/or INTF.
-C
-C     INTERFACE
-C     _________
-C
-C     CALL JINTEND( )
-C
-C
-C     Input parameters
-C     ________________
-C
-C     None.
-C
-C
-C     Output parameters
-C     ________________
-C
-C     None.
-C
-C
-C     Common block usage
-C     __________________
-C
-C     None.
-C
-C
-C     Method
-C     ______
-C
-C     None.
-C
-C
-C     Externals
-C     _________
-C
-C     None.
-C
-C
-C     Reference
-C     _________
-C
-C     None.
-C
-C
-C     Comments
-C     ________
-C
-C     None.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      *ECMWF*      May 1994
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None.
-C
-C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-C     Local variables
-C
-#ifdef POINTER_64
-      INTEGER*8 IZERO
-#else
-      INTEGER IZERO
-#endif
-      INTEGER IRET
-      DATA IZERO/0/
-C
-C     _______________________________________________________
-C
-C*    Section 1.    Deallocate heap memory.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-C     Lat/long (JINTLL)
-C
-      CALL JMEMHAN( 1, IZERO, 0, 0, IRET )
-C
-C     Gaussian (JINTGG)
-C
-      CALL JMEMHAN( 2, IZERO, 0, 0, IRET )
-C
-C     Scratch (INTF)
-C
-      CALL JMEMHAN( 3, IZERO, 0, 0, IRET )
-      CALL JMEMHAN( 4, IZERO, 0, 0, IRET )
-      CALL JMEMHAN( 5, IZERO, 0, 0, IRET )
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine.
-C     _______________________________________________________
-C
- 900  CONTINUE
-C
-      RETURN
-C
-      END
diff --git a/interpolation/jintgg.F b/interpolation/jintgg.F
deleted file mode 100644
index c4b656a..0000000
--- a/interpolation/jintgg.F
+++ /dev/null
@@ -1,415 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE JINTGG( KIBUFF, KLENI, PWEST, PEAST, PNORTH, PSOUTH,
-     X                   KNUM, HTYPE, KPTS, LUV, KOBUFF, KLENO, KBITS,
-     X                   KRET)
-C
-C---->
-C**** JINTGG
-C
-C     PURPOSE
-C     _______
-C
-C     This routine converts spectral input fields to gaussian
-C     grid fields.
-C
-C     INTERFACE
-C     _________
-C
-C     CALL JINTGG( KIBUFF, KLENI, PWEST, PEAST, PNORTH, PSOUTH,
-C    X             KNUM, HTYPE, KPTS, LUV, KOBUFF, KLENO, KBITS, KRET)
-C
-C     Input parameters
-C     ________________
-C
-C     KIBUFF  - Array containing input spherical harmonic field
-C               in GRIB format.
-C     KLENI   - Length in words of KIBUFF.
-C     PWEST   - Required area, west longitude(degrees)
-C     PEAST   - Required area, east longitude(degrees)
-C     PNORTH  - Required area, north latitude(degrees)
-C     PSOUTH  - Required area, south latitude(degrees)
-C     KNUM    - Gaussian grid number
-C     HTYPE   - Gaussian grid type
-C               = 'R' for reduced, 
-C               = 'F' for full
-C               = 'U' for user-defined reduced gaussian grid
-C     KPTS    - Array specifying number of points at each line of
-C               latitude if HTYPE = 'U'.
-C               (Must be big enough for both hemispheres, but only
-C                needs to give Northern hemisphere values from pole
-C                to latitude nearest the Equator.)
-C     LUV     - Code indicating whether or not the field is a wind
-C               component field;
-C               = 1 if U or V field.
-C     KLENO   - Length in words of KOBUFF.
-C     KBITS   - Number of bits to be used for packing values in KOBUFF.
-C
-C
-C     Output parameters
-C     ________________
-C
-C
-C     KPTS    - Array specifying number of points at each line of
-C               latitude; user defined values if HTYPE = 'U'.
-C               (Must be big enough for both hemispheres)
-C     KOBUFF  - Array containing output spherical harmonic field
-C               in GRIB format.
-C     KLENO   - Number of words of KOBUFF occupied by GRIB.
-C     KRET    - Return status code
-C               0 = OK
-C
-C
-C     Common block usage
-C     __________________
-C
-C     JDCNDGB
-C
-C
-C     Method
-C     ______
-C
-C     None.
-C
-C
-C     Externals
-C     _________
-C
-C     JDEBUG    - Checks environment variable to switch on/off debug
-C     JGETGG    - Get the gaussian grid definition
-C     GRIBEX    - Decodes/encodes GRIB product
-C     JAGGGP    - Transform from spherical harmonics to gaussian grid.
-C     JMEMHAN   - Handles memory allocation
-C     INTLOG   - Output log message
-C     INTLOGR  - Output log message (with real value)
-C
-C
-C     Reference
-C     _________
-C
-C     None.
-C
-C
-C     Comments
-C     ________
-C
-C     If PWEST, PEAST, PNORTH, PSOUTH are all 0.0, then the area
-C     defaults to global.
-C
-C     If KBITS, the number of bits to be used for packing values, is
-C     0, the number of bits used in the input spectral field is used.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      *ECMWF*      May 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers     ECMWF        Feb 1997
-C     Allow for 64-bit pointers
-C
-C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     Real         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-      IMPLICIT NONE
-#include "jparams.h"
-#include "parim.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 30200 )
-C     Arrays are dimensioned to accommodate spectral T639 data and
-C     gaussian resolution of N160
-      INTEGER JPACK, JPMNUM
-      PARAMETER (JPACK=420000)
-      PARAMETER (JPMNUM=160)
-C
-C     Subroutine arguments
-      INTEGER KIBUFF, KLENI, KNUM, KPTS, KOBUFF, KLENO, KBITS, KRET
-      CHARACTER*1 HTYPE
-      INTEGER LUV
-      DIMENSION KIBUFF(KLENI)
-      DIMENSION KPTS(*)
-      DIMENSION KOBUFF(*)
-      REAL PWEST, PEAST, PNORTH, PSOUTH
-C
-C     Local variables
-      REAL NORTH, SOUTH, EAST, WEST
-      INTEGER IPUNP, ITRUNC, NBITS, JPLOOP
-      INTEGER ISEC0, ISEC1, ISEC2, ISEC3, ISEC4
-      REAL ZSEC2, ZSEC3, ZSEC4
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IZOUTBF
-#endif
-#endif
-      REAL ZOUTBF
-      POINTER ( IZOUTBF, ZOUTBF )
-      DIMENSION ZOUTBF( 1 )
-      INTEGER IWORD
-      REAL ZLAT
-      DIMENSION ZLAT(2*JPMNUM)
-C
-C     Array for integer parameters from section 0 of GRIB message.
-      DIMENSION ISEC0(JPGRIB_ISEC0)
-C
-C     Array for integer parameters from section 1 of GRIB message.
-      DIMENSION ISEC1(JPGRIB_ISEC1)
-C
-C     Array for integer parameters from section 2 of GRIB message.
-      DIMENSION ISEC2(JPGRIB_ISEC2)
-C
-C     Array for integer parameters from section 3 of GRIB message.
-      DIMENSION ISEC3(JPGRIB_ISEC3)
-C
-C     Array for integer parameters from section 4 of GRIB message.
-      DIMENSION ISEC4(JPGRIB_ISEC4)
-C
-C     Array for real parameters from section 2 of GRIB message.
-      DIMENSION ZSEC2(JPGRIB_RSEC2)
-C
-C     Array for real parameters from section 3 of GRIB message.
-      DIMENSION ZSEC3(JPGRIB_RSEC3)
-C
-C     Array for real parameters from section 4 of GRIB message.
-C     This is the binary data section and the array to hold
-C     the unpacked data may need to be 4 times as long as that
-C     for the packed data.
-C
-      DIMENSION ZSEC4(JPACK)
-C
-C     _______________________________________________________
-C
-C*    Section 1.    Unpack the input GRIB product.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      CALL JDEBUG( )
-C
-      IF ( NDBG .GT. 0) THEN
-        CALL INTLOG(JP_DEBUG,'JINTGG - Input parameters:', JPQUIET)
-        DO 101 NDBGLP = 1, 20
-          CALL INTLOGR(JP_DEBUG,' ',KIBUFF( NDBGLP ))
-  101   CONTINUE
-        CALL INTLOG(JP_DEBUG,
-     X    'JINTGG - Length(words) of input product = ', KLENI)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTGG - Required area, west long(deg) = ', PWEST)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTGG - Required area, east long(deg) = ', PEAST)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTGG - Required area, north lat(deg) = ', PNORTH)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTGG - Required area, south lat(deg) = ', PSOUTH)
-        CALL INTLOG(JP_DEBUG,'JINTGG - Gaussian grid number = ', KNUM)
-        CALL INTLOG(JP_DEBUG,'JINTGG - Gaussian grid type = ', HTYPE)
-        CALL INTLOG(JP_DEBUG,'JINTGG - Wind field code = ', LUV)
-        CALL INTLOG(JP_DEBUG,
-     X    'JINTGG - Length in words of KOBUFF = ', KLENO)
-        CALL INTLOG(JP_DEBUG,
-     X  'JINTGG - Number of bits for packing = ', KBITS)
-      ENDIF
-C
-      IPUNP = JPACK*4
-      KRET = 1
-      IF ( NDBG .GT. 0) CALL GRSDBG(1)
-C
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,KIBUFF,KLENI,IWORD,'D',KRET)
-C
-      IF ( NDBG .GT. 0) CALL INTLOG(JP_DEBUG,
-     X  'JINTGG - Return from GRIBEX decoding = ', KRET)
-C
-C     Check return code.
-      IF (KRET.GT.0) GOTO 900
-C
-C     Set number of bits to same as input if user did not give a number
-      IF ( KBITS .LE. 0 ) THEN
-        NBITS = ISEC4(2)
-      ELSE
-        NBITS = KBITS
-      ENDIF
-C     _______________________________________________________
-C
-C*    Section 2.    Interpolate to a gaussian grid.
-C     _______________________________________________________
-C
- 200  CONTINUE
-C
-C     Setup geographical limits
-      IF ( (PWEST.EQ.0.0) .AND. (PEAST.EQ.0.0) .AND.
-     X     (PNORTH.EQ.0.0) .AND. (PSOUTH.EQ.0.0) ) THEN
-        NORTH = 90.0
-        SOUTH = -90.0
-        WEST  = 0.0
-        EAST  = 360.0 - (360.0/FLOAT(4*KNUM))
-      ELSE
-        WEST  = PWEST
-        EAST  = PEAST
-        NORTH = PNORTH
-        SOUTH = PSOUTH
-      ENDIF
-C
-C     Use input truncation
-      ITRUNC = ISEC2(2)
-C
-      IF ( NDBG .GT. 0) THEN
-        CALL INTLOG(JP_DEBUG,'JINTGG - WEST = ', WEST)
-        CALL INTLOG(JP_DEBUG,'JINTGG - EAST = ', EAST)
-        CALL INTLOG(JP_DEBUG,'JINTGG - NORTH = ', NORTH)
-        CALL INTLOG(JP_DEBUG,'JINTGG - SOUTH = ', SOUTH)
-        CALL INTLOG(JP_DEBUG,'JINTGG - ITRUNC = ', ITRUNC)
-      ENDIF
-C
-C     Get the gaussian grid definition
-      CALL JGETGG( KNUM, HTYPE, ZLAT, KPTS, KRET)
-C
-C     Count the points in the definition to give a memory size
-      IPUNP = 0
-      DO 210 JPLOOP = 1, KNUM*2
-        IPUNP = IPUNP + KPTS(JPLOOP)
-  210 CONTINUE
-C
-      IF ( NDBG .GT. 0) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'JINTGG - Total number of grid points = ', IPUNP)
-      ENDIF
-C
-C     Allocate memory for scratch array.
-      CALL JMEMHAN( 2, IZOUTBF, IPUNP, 1, KRET)
-      IF ( KRET .NE. 0 ) THEN
-        KRET =  JPROUTINE + 1
-        CALL INTLOG(JP_ERROR,'JINTGG - Memory allocation failed.',KRET)
-        GOTO 900
-      ENDIF
-C
-      CALL JAGGGP( ZSEC4, ITRUNC, NORTH, SOUTH, WEST, EAST,
-     X                    KNUM, HTYPE, KPTS, ZOUTBF, LUV, KRET)
-C
-      IF ( KRET .NE. 0 ) GOTO 900
-C
-C     _______________________________________________________
-C
-C*    Section 3.    Pack the output GRIB product.
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-C
-      ISEC1(4) = 255
-      ISEC1(5) = 128
-      ISEC1(19) = 0
-      ISEC1(20) = 0
-C
-C     Build section 2 for gaussian grid
-      ISEC2(1) = 4
-      IF ( HTYPE .EQ. 'F' ) THEN
-        ISEC2(2) = KPTS(1)
-      ELSE
-        ISEC2(2) = 0
-      ENDIF
-      ISEC2(3) = KNUM*2
-      ISEC2(4) = ( NORTH * 1000.0 )
-      ISEC2(5) = ( WEST * 1000.0 )
-      IF ( ISEC2(5) .LT. 0 ) ISEC2(5) = 360000 + ISEC2(5)
-      IF ( ISEC2(5) .GT. 360000 ) ISEC2(5) = ISEC2(5) - 360000
-      IF ( HTYPE .EQ. 'F' ) THEN
-        ISEC2(6) = 128
-      ELSE
-        ISEC2(6) = 0
-      ENDIF
-      ISEC2(7) = ( SOUTH * 1000.0 )
-      ISEC2(8) = ( EAST * 1000.0 + 0.5 )
-      IF ( ISEC2(8) .LT. 0 ) ISEC2(8) = 360000 + ISEC2(8)
-      IF ( ISEC2(8) .GT. 360000 ) ISEC2(8) = ISEC2(8) - 360000
-      IF ( HTYPE .EQ. 'F' ) THEN
-        ISEC2(9) = NINT( 360.0/FLOAT(KPTS(1)) * 1000.0 )
-      ELSE
-        ISEC2(9) = 0
-      ENDIF
-      ISEC2(10) = KNUM
-      ISEC2(11) = 0
-      IF ( HTYPE .EQ. 'F' ) THEN
-        ISEC2(17) = 0
-      ELSE
-        ISEC2(17) = 1
-      ENDIF
-C
-C     For reduced or quasi-regular grids, fill in number of points
-C     along each parallel.
-      IF ( HTYPE .NE. 'F' ) THEN
-        DO 220 JPLOOP = 1, KNUM*2
-          ISEC2(22+JPLOOP) = KPTS(JPLOOP)
-  220   CONTINUE
-      ENDIF
-C
-C     Build section 4 for gaussian grid
-      ISEC4(1) = IPUNP
-      ISEC4(2) = NBITS
-      ISEC4(3) = 0
-      ISEC4(4) = 0
-      ISEC4(5) = 0
-      ISEC4(6) = 0
-      ISEC4(8) = 0
-      ISEC4(9) = 0
-      ISEC4(10) = 0
-      ISEC4(11) = 0
-      DO 230 JPLOOP = 12, 33
-        ISEC4(JPLOOP) = 0
-  230 CONTINUE
-C
-      IF ( NDBG .GT. 0) CALL GRSDBG(1)
-C
-      KRET = 1
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZOUTBF,IPUNP,KOBUFF,KLENO,KLENO,'C',KRET)
-C
-C     Check return code.
-      IF ( NDBG .GT. 0) CALL INTLOG(JP_DEBUG,
-     X    'JINTGG - status from GRIBEX encoding = ', KRET)
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine.
-C     _______________________________________________________
-C
- 900  CONTINUE
-C
-      RETURN
-C
-      END
diff --git a/interpolation/jintll.F b/interpolation/jintll.F
deleted file mode 100644
index f11bd88..0000000
--- a/interpolation/jintll.F
+++ /dev/null
@@ -1,364 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE JINTLL( KIBUFF, KLENI, PWEST, PEAST, PNORTH, PSOUTH,
-     X                   PLATINC, PLONINC, KOBUFF, KLENO, KBITS, KRET)
-C
-C---->
-C**** JINTLL
-C
-C     PURPOSE
-C     _______
-C
-C     This routine converts spectral input fields to standard
-C     lat/long grid fields.
-C
-C     INTERFACE
-C     _________
-C
-C     CALL JINTLL( KIBUFF, KLENI, PWEST, PEAST, PNORTH, PSOUTH,
-C    X             PLATINC, PLONINC, KOBUFF, KLENO, KBITS, KRET)
-C
-C     Input parameters
-C     ________________
-C
-C     KIBUFF  - Array containing input spherical harmonic field
-C               in GRIB format.
-C     KLENI   - Length in words of KIBUFF.
-C     PWEST   - Required area, west longitude(degrees)
-C     PEAST   - Required area, east longitude(degrees)
-C     PNORTH  - Required area, north latitude(degrees)
-C     PSOUTH  - Required area, south latitude(degrees)
-C     PLATINC - Required latitude interval in degrees.
-C     PLONINC - Required longitude interval in degrees.
-C     KLENO   - Length in words of KOBUFF.
-C     KBITS   - Number of bits to be used for packing values in KOBUFF.
-C
-C
-C     Output parameters
-C     ________________
-C
-C     KOBUFF  - Array containing output spherical harmonic field
-C               in GRIB format.
-C     KLENO   - Number of words of KOBUFF occupied by GRIB.
-C     KRET    - Return status code
-C               0 = OK
-C
-C
-C     Common block usage
-C     __________________
-C
-C     JDCNDGB
-C
-C
-C     Method
-C     ______
-C
-C     None.
-C
-C
-C     Externals
-C     _________
-C
-C     JDEBUG    - Checks environment variable to switch on/off debug
-C     GRIBEX    - Decodes/encodes GRIB product
-C     JALLGP    - Transform from spherical harmonics to regular lat/long
-C                 grid.
-C     JMEMHAN   - Handles memory allocation.
-C     INTLOG   - Output log message
-C     INTLOGR  - Output log message (with real value)
-C
-C
-C     Reference
-C     _________
-C
-C     None.
-C
-C
-C     Comments
-C     ________
-C
-C     If PWEST, PEAST, PNORTH, PSOUTH are all 0.0, then the area
-C     defaults to global.
-C
-C     If KBITS, the number of bits to be used for packing values, is
-C     0, the number of bits used in the input spectral field is used.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers     ECMWF        Feb 1997
-C     Allow for 64-bit pointers
-C
-C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-C*    Prefix conventions for variable names
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy argument
-C                  G, local variable
-C                  LP, parameter.
-C     Character    C, global or common.
-C                  H, dummy argument
-C                  Y (but not YP), local variable
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy argument
-C                  I, local variable
-C                  J (but not JP), loop control
-C                  JP, parameter.
-C     Real         A to F and Q to X, global or common.
-C                  P (but not PP), dummy argument
-C                  Z, local variable
-C                  PP, parameter.
-C
-      IMPLICIT NONE
-#include "jparams.h"
-#include "parim.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 30300 )
-C     Arrays are dimensioned to accommodate spectral T639 data and
-C     maximum resolution of (0.5 * 0.5) deg.
-      INTEGER JPACK, JPMLAT, JPMLON
-      PARAMETER (JPACK=420000)
-      PARAMETER (JPMLAT=361)
-      PARAMETER (JPMLON=720)
-C
-C     Subroutine arguments
-      INTEGER KIBUFF, KLENI, KOBUFF, KLENO, KBITS, KRET
-      DIMENSION KIBUFF(KLENI)
-      DIMENSION KOBUFF(*)
-      REAL PWEST, PEAST, PNORTH, PSOUTH, PLATINC, PLONINC
-C
-C     Local variables
-      REAL NORTH, SOUTH, EAST, WEST
-      INTEGER IPUNP, ITRUNC, NBITS
-      INTEGER ISEC0, ISEC1, ISEC2, ISEC3, ISEC4
-      REAL ZSEC2, ZSEC3, ZSEC4
-#ifndef _CRAYFTN
-#ifdef POINTER_64
-      INTEGER*8 IZOUTBF
-#endif
-#endif
-      REAL ZOUTBF
-      POINTER ( IZOUTBF, ZOUTBF )
-      DIMENSION ZOUTBF( 1 )
-      INTEGER ILAT, ILON, IWORD
-C
-C     Array for integer parameters from section 0 of GRIB message.
-      DIMENSION ISEC0(JPGRIB_ISEC0)
-C
-C     Array for integer parameters from section 1 of GRIB message.
-      DIMENSION ISEC1(JPGRIB_ISEC1)
-C
-C     Array for integer parameters from section 2 of GRIB message.
-      DIMENSION ISEC2(JPGRIB_ISEC2)
-C
-C     Array for integer parameters from section 3 of GRIB message.
-      DIMENSION ISEC3(JPGRIB_ISEC3)
-C
-C     Array for integer parameters from section 4 of GRIB message.
-      DIMENSION ISEC4(JPGRIB_ISEC4)
-C
-C     Array for real parameters from section 2 of GRIB message.
-      DIMENSION ZSEC2(JPGRIB_RSEC2)
-C
-C     Array for real parameters from section 3 of GRIB message.
-      DIMENSION ZSEC3(JPGRIB_RSEC3)
-C
-C     Array for real parameters from section 4 of GRIB message.
-C     This is the binary data section and the array to hold
-C     the unpacked data may need to be 4 times as long as that
-C     for the packed data.
-C
-      DIMENSION ZSEC4(JPACK)
-C
-C     _______________________________________________________
-C
-C*    Section 1.    Unpack the input GRIB product.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      CALL JDEBUG( )
-C
-      IF ( NDBG .GT. 0) THEN
-        CALL INTLOG(JP_DEBUG,'JINTLL - Input parameters:',JPQUIET)
-        DO 101 NDBGLP = 1, 20
-          CALL INTLOGR(JP_DEBUG,' ',KIBUFF( NDBGLP ))
-  101   CONTINUE
-        CALL INTLOG(JP_DEBUG,
-     X    'JINTLL - Length(words) of input product = ', KLENI)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTLL - Required area, west long(deg) = ', PWEST)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTLL - Required area, east long(deg) = ', PEAST)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTLL - Required area, north lat(deg) = ', PNORTH)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTLL - Required area, south lat(deg) = ', PSOUTH)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTLL - Latitude grid interval (deg) = ', PLATINC)
-        CALL INTLOGR(JP_DEBUG,
-     X    'JINTLL - Longitude grid interval (deg) = ', PLONINC)
-        CALL INTLOG(JP_DEBUG,
-     X    'JINTLL - Length in words of KOBUFF = ', KLENO)
-        CALL INTLOG(JP_DEBUG,
-     X    'JINTLL - Number of bits for packing = ', KBITS)
-      ENDIF
-C
-      IPUNP = JPACK*4
-C
-      IF ( NDBG .GT. 0) CALL GRSDBG(1)
-C
-      KRET = 1
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,KIBUFF,KLENI,IWORD,'D',KRET)
-C
-      IF ( NDBG .GT. 0) CALL INTLOG(JP_DEBUG,
-     X    'JINTLL - Return from GRIBEX decoding = ', KRET)
-C
-C     Check return code.
-      IF (KRET.GT.0) GOTO 900
-C
-C     Set number of bits to same as input if user did not give a number
-      IF ( KBITS .LE. 0 ) THEN
-        NBITS = ISEC4(2)
-      ELSE
-        NBITS = KBITS
-      ENDIF
-C     _______________________________________________________
-C
-C*    Section 2.    Interpolate to a latitude/longitude grid.
-C     _______________________________________________________
-C
- 200  CONTINUE
-C
-C     Setup geographical limits
-      IF ( (PWEST.EQ.0.0) .AND. (PEAST.EQ.0.0) .AND.
-     X     (PNORTH.EQ.0.0) .AND. (PSOUTH.EQ.0.0) ) THEN
-        NORTH = 90.0
-        SOUTH = -90.0
-        WEST  = 0.0
-        EAST  = 360.0 - PLONINC
-      ELSE
-        WEST  = PWEST
-        EAST  = PEAST
-        NORTH = PNORTH
-        SOUTH = PSOUTH
-      ENDIF
-C
-C     Use input truncation
-      ITRUNC = ISEC2(2)
-C
-      IF ( NDBG .GT. 0) THEN
-        CALL INTLOG(JP_DEBUG,'JINTLL - WEST = ', WEST)
-        CALL INTLOG(JP_DEBUG,'JINTLL - EAST = ', EAST)
-        CALL INTLOG(JP_DEBUG,'JINTLL - NORTH = ', NORTH)
-        CALL INTLOG(JP_DEBUG,'JINTLL - SOUTH = ', SOUTH)
-        CALL INTLOG(JP_DEBUG,'JINTLL - ITRUNC = ', ITRUNC)
-      ENDIF
-C
-      ILAT = NINT( (EAST - WEST)/PLATINC ) + 1
-      ILON = NINT( (NORTH - SOUTH)/PLONINC ) + 1
-      IPUNP = ILAT * ILON
-C
-      IF ( NDBG .GT. 0) THEN
-        CALL INTLOG(JP_DEBUG,'JINTLL - Number of lat. points = ', ILAT)
-        CALL INTLOG(JP_DEBUG,'JINTLL - Number of long.points = ', ILON)
-        CALL INTLOG(JP_DEBUG,'JINTLL - Total no.of grid pnts = ', IPUNP)
-      ENDIF
-C
-C     Allocate memory for scratch array.
-      CALL JMEMHAN( 1, IZOUTBF, IPUNP, 1, KRET)
-      IF ( KRET .NE. 0 ) THEN
-        KRET =  JPROUTINE + 1
-        CALL INTLOG(JP_ERROR,'JINTLL - Memory allocation failed',KRET)
-        GOTO 900
-      ENDIF
-C
-      CALL JALLGP( ZSEC4, ITRUNC, NORTH, SOUTH, WEST, EAST,
-     X                    PLATINC, PLONINC, ZOUTBF, KRET)
-C
-      IF ( KRET .NE. 0 ) GOTO 900
-C
-C     _______________________________________________________
-C
-C*    Section 3.    Pack the output GRIB product.
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-C
-      ISEC1(4) = 255
-      ISEC1(5) = 128
-      ISEC1(19) = 0
-      ISEC1(20) = 0
-C
-      ISEC2(1) = 0
-      ISEC2(2) = ILAT
-      ISEC2(3) = ILON
-      ISEC2(4) = ( NORTH * 1000.0 )
-      ISEC2(5) = ( WEST * 1000.0 )
-      IF ( ISEC2(5) .LT. 0 ) ISEC2(5) = 360000 + ISEC2(5)
-      IF ( ISEC2(5) .GT. 360000 ) ISEC2(5) = ISEC2(5) - 360000
-      ISEC2(6) = 128
-      ISEC2(7) = ( SOUTH * 1000.0 )
-      ISEC2(8) = ( EAST * 1000.0 + 0.5 )
-      IF ( ISEC2(8) .LT. 0 ) ISEC2(8) = 360000 + ISEC2(8)
-      IF ( ISEC2(8) .GT. 360000 ) ISEC2(8) = ISEC2(8) - 360000
-      ISEC2(9) = NINT( PLONINC * 1000.0 )
-      ISEC2(10) = NINT( PLATINC * 1000.0 )
-      ISEC2(11) = 0
-      ISEC2(17) = 0
-C
-      ISEC4(1) = IPUNP
-      ISEC4(2) = NBITS
-      ISEC4(3) = 0
-      ISEC4(4) = 0
-      ISEC4(5) = 0
-      ISEC4(6) = 0
-      ISEC4(8) = 0
-      ISEC4(9) = 0
-      ISEC4(10) = 0
-      ISEC4(11) = 0
-C
-      IF ( NDBG .GT. 0) CALL GRSDBG(1)
-C
-      KRET = 1
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZOUTBF,IPUNP,KOBUFF,KLENO,KLENO,'C',KRET)
-C
-C     Check return code.
-      IF ( NDBG .GT. 0)
-     X  CALL INTLOG(JP_DEBUG,'JINTLL - status GRIBEX coding = ', KRET)
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine.
-C     _______________________________________________________
-C
- 900  CONTINUE
-C
-      RETURN
-C
-      END
diff --git a/interpolation/jmakll.F b/interpolation/jmakll.F
index c1c7f5c..687a8ca 100644
--- a/interpolation/jmakll.F
+++ b/interpolation/jmakll.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -126,7 +126,7 @@ c      INTEGER*8 NEWPOS, NSIZE, NRET
       INTEGER NEWPOS, NSIZE, NRET
       INTEGER NROWCT, NBYTES
 
-      REAL ZLATEST, ZLATIT, ZLAT, ALAT, PIBY2, DEG2RAD
+      REAL ZLATEST, ZLAT, ALAT, PIBY2, DEG2RAD
       INTEGER NEXT, FIRST, LAST
 C
 C     _______________________________________________________
@@ -153,7 +153,7 @@ C
         ZLAT = PLAT
       ENDIF
 C
-C     Calculate the byte offset into the file where the legendre 
+C     Calculate the byte offset into the file where the legendre
 C     functions for the latitude should be.
 C
 #ifdef REAL_8
@@ -168,8 +168,8 @@ C
       CALL PBSEEK( KUNIT, 0, 2, NRET)
       IF( NRET.LT.0 ) THEN
         CALL INTLOG(JP_ERROR,'JMAKLL: PBSEEK error',NRET)
-	KRET = JPROUTINE + 2
-	GOTO 990
+        KRET = JPROUTINE + 2
+        GOTO 990
       ENDIF
 C
 C     Use the length to determine how many rows have already been
@@ -218,9 +218,9 @@ C
         IF( NRET.LT.NSIZE ) THEN
           CALL INTLOG(JP_ERROR,'JMAKLL: PBWRITE error.', NRET)
           CALL INTLOG(JP_ERROR,'JMAKLL: bytes required = ', NSIZE)
-	  KRET = JPROUTINE + 3
-	  GOTO 990
-	ENDIF
+          KRET = JPROUTINE + 3
+          GOTO 990
+        ENDIF
       ENDDO
 C     _______________________________________________________
 C
diff --git a/interpolation/jmemhan.F b/interpolation/jmemhan.F
index 0530ca4..ddcfad7 100644
--- a/interpolation/jmemhan.F
+++ b/interpolation/jmemhan.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -314,7 +314,7 @@ C
                 IZOUTBF(7) = 0
                 IEXIST(7) = -1
                 NISIZE7 = 0
-                YOLDGG = 'xxxxxxxxxxxxxxx'
+                YOLDGG = 'xxxxxxxxxxxxxxxxxxxx'
               ENDIF
             ENDIF
 C
@@ -328,7 +328,7 @@ C
                 IZOUTBF(6) = 0
                 IEXIST(6) = -1
                 NISIZE6 = 0
-                YOLDLL = 'xxxxxxxxxxxxxxxxxxx'
+                YOLDLL = 'xxxxxxxxxxxxxxxxxxxx'
               ENDIF
             ENDIF
           ENDIF
diff --git a/interpolation/jmemhan2.F b/interpolation/jmemhan2.F
index ea2c719..50bdcb2 100644
--- a/interpolation/jmemhan2.F
+++ b/interpolation/jmemhan2.F
@@ -316,7 +316,7 @@ C
                 IZOUTBF(7) = 0
                 IEXIST(7) = -1
                 NISIZE7 = 0
-                YOLDGG = 'xxxxxxxxxxxxxxx'
+                YOLDGG = 'xxxxxxxxxxxxxxxxxxxx'
               ENDIF
             ENDIF
 C
@@ -330,7 +330,7 @@ C
                 IZOUTBF(6) = 0
                 IEXIST(6) = -1
                 NISIZE6 = 0
-                YOLDLL = 'xxxxxxxxxxxxxxxxxxx'
+                YOLDLL = 'xxxxxxxxxxxxxxxxxxxx'
               ENDIF
             ENDIF
           ENDIF
diff --git a/interpolation/jmkofgg.F b/interpolation/jmkofgg.F
index 471e80f..857b7c1 100644
--- a/interpolation/jmkofgg.F
+++ b/interpolation/jmkofgg.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -30,15 +30,16 @@ C
 C     Input parameters
 C     ________________
 C
-C     HTYPE    - Gaussian grid type
-C                = 'R' for reduced,
-C                = 'F' for full
-C                = 'U' for user-defined reduced gaussian grid
+C     KNUM    - Gaussian grid number
+C     HTYPE   - Gaussian grid type
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full,
+C               = 'U' for user-defined reduced gaussian grid
 C     KNORTH  - Northern latitude row number
 C     KSOUTH  - Southern latitude row number
 C     PWEST   - Westernmost longitude for output field (degrees)
 C     PEAST   - Easternmost longitude for output field (degrees)
-C     KNUM    - Gaussian grid number
 C     KPTS    - Array giving the number of points in each row for the
 C               gaussian grid
 C
@@ -79,7 +80,7 @@ C
 C     Comments
 C     ________
 C
-C     
+C
 C
 C     Author
 C     ______
@@ -113,41 +114,32 @@ C     Local variables
 C
       INTEGER LAT, NUMPTS
       REAL RINTVL
-      LOGICAL LREDUCE
-C
-C     _______________________________________________________
-C
-C*    Section 1. Dummy
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-C     Is it a reduced gaussian or user defined gaussian grid.
-      LREDUCE = ( (HTYPE .EQ. 'U') .OR. (HTYPE .EQ. 'R') )
 C
 C     _______________________________________________________
 C
-C*    Section 2. Fill in array of offsets
+C*    Section 1. Fill in array of offsets
 C     _______________________________________________________
 C
   200 CONTINUE
 C
 C     Loop through all possible latitudes
       DO LAT = 1, 2*KNUM
-	IF ( (LAT .LT. KNORTH) .OR. (LAT .GT. KSOUTH) ) THEN
-	  KOFSET(LAT) = 0
-        ELSE 
-	  IF ( LAT .EQ. KNORTH ) THEN
-	    KOFSET(LAT) = 1
-	  ELSE
-            IF( LREDUCE ) THEN
+        IF ( (LAT .LT. KNORTH) .OR. (LAT .GT. KSOUTH) ) THEN
+          KOFSET(LAT) = 0
+        ELSE
+          IF ( LAT .EQ. KNORTH ) THEN
+            KOFSET(LAT) = 1
+          ELSE
+            IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' .OR.
+     X          HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     X          HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) THEN
               NUMPTS = KPTS(LAT -1)
             ELSE
               RINTVL = (PEAST - PWEST)*FLOAT( KPTS(LAT -1) ) / 360.0
               NUMPTS = NINT( RINTVL ) + 1
             ENDIF
-	    KOFSET(LAT) = KOFSET(LAT -1) + NUMPTS
-	  ENDIF
+            KOFSET(LAT) = KOFSET(LAT -1) + NUMPTS
+          ENDIF
         ENDIF
       ENDDO
 C
diff --git a/interpolation/jmovgg.F b/interpolation/jmovgg.F
index 0e1d40f..5b2f0e7 100644
--- a/interpolation/jmovgg.F
+++ b/interpolation/jmovgg.F
@@ -17,7 +17,7 @@ C
 C     Purpose
 C     _______
 C
-C     This routine moves gausssian grid point data from array PZFA to 
+C     This routine moves gaussian grid point data from array PZFA to 
 C     array POUTF.
 C
 C
@@ -211,15 +211,15 @@ C
         IF ( NDBG .GT. 1) CALL INTLOG(JP_DEBUG,
      X    'JMOVGG -  Storing North latitudes',JPQUIET)
 C
-        DO 222 NXTLAT = 1, KROWS*2, 2
+        DO NXTLAT = 1, KROWS*2, 2
 C
 C         Find start offset in storage array
           IOFFN  = KOFSET(KSTART + NXTLAT/2) - 1
-          DO 220 NXTLON = 1, KCOLS
+          DO NXTLON = 1, KCOLS
             NEXTPT = 2 + MOD( NSTART + (NXTLON-1)*KJPWR , KLON)
             POUTF( NXTLON + IOFFN ) = PZFA( NEXTPT, NXTLAT)
- 220      CONTINUE
- 222    CONTINUE
+          ENDDO
+        ENDDO
       ENDIF
 C
 C     Store Southern latitudes ..
@@ -230,15 +230,15 @@ C
         IF ( NDBG .GT. 1) CALL INTLOG(JP_DEBUG,
      X    'JMOVGG -  Storing South latitudes',JPQUIET)
 C
-        DO  242 NXTLAT = 2, KROWS*2, 2
+        DO NXTLAT = 2, KROWS*2, 2
 C
 C         Find start offset in storage array
           IOFFS  = KOFSET(2*KGNUM - KSTART + 1 - NXTLAT/2 + 1) - 1
-          DO 240 NXTLON = 1, KCOLS
+          DO NXTLON = 1, KCOLS
             NEXTPT = 2 + MOD( NSTART + (NXTLON-1)*KJPWR , KLON)
             POUTF( NXTLON + IOFFS ) = PZFA( NEXTPT, NXTLAT)
- 240      CONTINUE
- 242    CONTINUE
+          ENDDO
+        ENDDO
 C
       ENDIF
 C
diff --git a/interpolation/jnumgg.F b/interpolation/jnumgg.F
index b00d290..7192a1a 100644
--- a/interpolation/jnumgg.F
+++ b/interpolation/jnumgg.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -16,7 +16,7 @@ C
 C     PURPOSE
 C     _______
 C
-C     This routine returns the number of points in each latitude of 
+C     This routine returns the number of points in each latitude of
 C     a gaussian grid.
 C
 C
@@ -31,13 +31,16 @@ C     ________________
 C
 C     KNUM     - Gaussian grid number
 C     HTYPE    - Gaussian grid type
-C                = 'R' for reduced, = 'F' for full
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
+C                = 'U' for user-defined reduced gaussian grid
 C
 C
 C     Output parameters
 C     ________________
 C
-C     KPTS    - Array giving number of points at each gaussian latitude 
+C     KPTS    - Array giving number of points at each gaussian latitude
 C               (both hemispheres)
 C     KRET     - Return status code
 C                0 = OK
@@ -102,7 +105,7 @@ C
 C     Local variables
 C
       REAL ZLAT
-      DIMENSION  ZLAT(JPMAX)
+      DIMENSION ZLAT(JPMAX)
 C     _______________________________________________________
 C
 C*    Section 1.    Get the information.
@@ -114,14 +117,14 @@ C
 C
 C     Make sure local array is big enough for return values.
 C
-      IF ( KNUM .GT. (JPMAX/2) ) THEN
+      IF( KNUM .GT. (JPMAX/2) ) THEN
         CALL INTLOG(JP_ERROR,
      X    'JNUMGG - Local array too small for return values.',JPMAX/2)
         KRET = JPROUTINE + 1
         GOTO 900
       ENDIF
 C
-      CALL JGETGG( KNUM, HTYPE, ZLAT, KPTS, KRET)
+      CALL JGETGG(KNUM, HTYPE, ZLAT, KPTS, KRET)
 C
 C     _______________________________________________________
 C
diff --git a/interpolation/jnumggq.F b/interpolation/jnumggq.F
deleted file mode 100644
index 9e76ff4..0000000
--- a/interpolation/jnumggq.F
+++ /dev/null
@@ -1,119 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION JNUMGGQ( KNUM, KPTS)
-C
-C---->
-C**** JNUMGGQ
-C
-C     PURPOSE
-C     -------
-C
-C     This routine returns the number of points in each latitude of 
-C     a gaussian grid.
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     CALL JNUMGGQ( KNUM, KPTS)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     KNUM - Gaussian grid number
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     KPTS - Array giving number of points at each gaussian latitude 
-C            (both hemispheres)
-C
-C     Returns 0 if OK, otherwise passes the return status from JNUMGG
-C
-C
-C     Common block usage
-C     ------------------
-C
-C     None.
-C
-C
-C     Method
-C     ------
-C
-C     Simplified interface to JNUMGG. 
-C
-C
-C     Externals
-C     ---------
-C
-C     JGETGG - Get the gaussian grid definition. 
-C
-C
-C     Reference
-C     ---------
-C
-C     None
-C
-C
-C     Comments
-C     --------
-C
-C     None
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      *ECMWF*      January 2002
-C
-C
-C     Modifications
-C     -------------
-C
-C     None.
-C
-C----<
-C
-      IMPLICIT NONE
-#include "jparams.h"
-#include "parim.h"
-C
-C     Subroutine arguments
-C
-      INTEGER KNUM, KPTS
-      DIMENSION KPTS(KNUM*2)
-C
-C     Local variables
-C
-      CHARACTER*1 HTYPE
-      INTEGER KRET
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.    Get the information.
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      HTYPE = 'R'
-      CALL JNUMGG( KNUM, HTYPE, KPTS, KRET)
-C
-C     -----------------------------------------------------------------|
-C*    Section 9. Return to calling routine. Format statements
-C     -----------------------------------------------------------------|
-C
- 900  CONTINUE
-C
-      JNUMGGQ = KRET
-C
-      RETURN
-      END
diff --git a/interpolation/jopngg.F b/interpolation/jopngg.F
index b9b5baf..71a7c73 100644
--- a/interpolation/jopngg.F
+++ b/interpolation/jopngg.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      SUBROUTINE JOPNGG( PLEG, KNUM, KTRUNC, KUNIT, PLAT, KRET)
+      SUBROUTINE JOPNGG(PLEG,KNUM,KTRUNC,KUNIT,PLAT,KRET)
 C
 C---->
 C**** JOPNGG
@@ -22,7 +22,7 @@ C
 C     Interface
 C     _________
 C
-C     CALL JOPNGG( PLEG, KNUM, KTRUNC, KUNIT, PLAT, KRET)
+C     CALL JOPNGG(PLEG,KNUM,KTRUNC,KUNIT,PLAT,KRET)
 C
 C     Input parameters
 C     ________________
@@ -51,7 +51,7 @@ C
 C     Builds a file name from the truncation and grid interval and
 C     tries to open a file of that name.
 C
-C     If the file is already open (from a previous call) the 
+C     If the file is already open (from a previous call) the
 C     previous unit number is returned.
 C     If a different file is already open (from a previous call), the
 C     existing file is closed first.
@@ -78,7 +78,7 @@ C     Comments
 C     ________
 C
 C     The filename for the legendre polynomials has the form:
-C         cf_xxxx_nnnn   Truncation xxx, Gaussian number yyy
+C         cf_xxxx_nnnn   Truncation xxxx, Gaussian number nnnn
 C     For example,
 C         cf_0213_0160          T213    N160
 C         cf_0106_0080          T106    N80
@@ -121,36 +121,38 @@ C
 C
 C     Subroutine arguments
 C
-      REAL      PLAT, PLEG
-      DIMENSION PLAT(*)
-      DIMENSION PLEG(*)
+      REAL      PLAT(*), PLEG(*)
       INTEGER   KNUM, KTRUNC, KUNIT, KRET
 C
 C     Local variables
 C
-      INTEGER IRET, IOFFSET
+      INTEGER IRET
+      INTEGER IOFFSET
+      INTEGER NUNIT
       LOGICAL LFOUND
       CHARACTER*256 DIRNAME
-      CHARACTER*256 FILENAME, FILEDUM
+      CHARACTER*256 FILENAME
+      CHARACTER*256 FILEDUM
       CHARACTER*512 FULLPATH
-      CHARACTER*16 YPFN
-      CHARACTER*16 YOLD
+      CHARACTER*20 YPFN
+      CHARACTER*20 YOLD
+C
 #ifdef REAL_8
       DATA YPFN/'CF_xxxx_nnnn'/
 #else
       DATA YPFN/'cf_xxxx_nnnn'/
 #endif
-      DATA YOLD/'xxxxxxxxxxxx'/
-      INTEGER NUNIT
+      DATA YOLD/'xxxxxxxxxxxxxxxxxxxx'/
+      SAVE YOLD
       DATA NUNIT/0/
-C
-      SAVE NUNIT, YOLD
+      SAVE NUNIT
 C
 C     Externals
 C
-      LOGICAL JFINDIR
-      LOGICAL JFINDFN
+      LOGICAL JFINDIR, JFINDFN
       INTEGER JCHMOD, RENAME
+      EXTERNAL JFINDIR, JFINDFN
+      EXTERNAL JCHMOD, RENAME
 C
 C     _______________________________________________________
 C
@@ -159,10 +161,20 @@ C     _______________________________________________________
 C
   100 CONTINUE
 C
-C     Setup the filename: cf_xxxx_nnnn
+C     Initialize
 C
-      WRITE(YPFN(4:7), '(I4.4)' ) KTRUNC
-      WRITE(YPFN(9:12), '(I4.4)' ) KNUM
+      DIRNAME  = ''
+      FILENAME = ''
+      FILEDUM  = ''
+      FULLPATH = ''
+C
+C     Setup the file name
+C
+      WRITE(YPFN(4: 7), '(I4.4)') KTRUNC
+      WRITE(YPFN(9:12), '(I4.4)') KNUM
+      CALL INTLOG(JP_DEBUG,
+     X  'JOPNGG: Coefficients file to open is:', JPQUIET)
+      CALL INTLOG(JP_DEBUG, YPFN, JPQUIET)
 C
 C     If file already open, return the existing unit number
 C
@@ -174,12 +186,12 @@ C
 C     Otherwise, close the existing file
 C
       IF( NUNIT.NE.0 ) THEN
-	CALL PBCLOSE( NUNIT, IRET)
+        CALL PBCLOSE( NUNIT, IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,'JOPNGG: PBCLOSE error.',IRET)
-	  NUNIT = 0
-	  KRET = JPROUTINE + 1
-	  GOTO 990
+          NUNIT = 0
+          KRET = JPROUTINE + 1
+          GOTO 990
         ENDIF
       ENDIF
 C     _______________________________________________________
@@ -269,7 +281,7 @@ C
 C     Make coefficients file
 C
       CALL JMAKGG( NUNIT, KTRUNC, KNUM, PLAT, PLEG, KRET)
-      IF ( KRET .NE. 0 ) GOTO 990
+      IF( KRET.NE.0 ) GOTO 990
 C
 C      Close it, rename it, re-open for reading, leave it open.
 C
@@ -291,8 +303,10 @@ C
       ENDIF
 #endif
 C
+C     Reopen with read access
+C
       CALL PBOPEN( NUNIT, FILENAME(1:IOFFSET), 'r', IRET)
-      IF ( IRET .NE. 0 ) THEN
+      IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,'JOPNGG: PBOPEN error.',IRET)
         KRET = JPROUTINE + 6
         GOTO 990
diff --git a/interpolation/jopnggf.F b/interpolation/jopnggf.F
index 9a569e7..7921a8d 100644
--- a/interpolation/jopnggf.F
+++ b/interpolation/jopnggf.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      SUBROUTINE JOPNGGF( IPLEG, KNUM, KTRUNC, KUNIT, PLAT, KRET)
+      SUBROUTINE JOPNGGF(IPLEG,KNUM,KTRUNC,KUNIT,PLAT,KRET)
 C
 C---->
 C**** JOPNGGF
@@ -23,7 +23,7 @@ C
 C     Interface
 C     _________
 C
-C     CALL JOPNGGF( IPLEG, KNUM, KTRUNC, KUNIT, PLAT, KRET)
+C     CALL JOPNGGF(IPLEG,KNUM,KTRUNC,KUNIT,PLAT,KRET)
 C
 C     Input parameters
 C     ________________
@@ -52,7 +52,7 @@ C
 C     Builds a file name from the truncation and grid interval and
 C     tries to open a file of that name.
 C
-C     If the file is already open (from a previous call) the 
+C     If the file is already open (from a previous call) the
 C     previous unit number is returned.
 C     If a different file is already open (from a previous call), the
 C     existing file is closed.
@@ -79,7 +79,7 @@ C     Comments
 C     ________
 C
 C     The filename for the legendre polynomials has the form:
-C         cf_xxxx_0nnn   Truncation xxx, Gaussian number yyy
+C         cf_xxxx_nnnn   Truncation xxxx, Gaussian number nnnn
 C     For example,
 C         cf_0213_0160          T213    N160
 C         cf_0106_0080          T106    N80
@@ -124,14 +124,17 @@ C
 C
 C     Subroutine arguments
 C
-      REAL      PLAT
-      DIMENSION PLAT(*)
+      REAL      PLAT(*)
       INTEGER   KNUM, KTRUNC, KUNIT, KRET
 C
 C     Local variables
 C
-      INTEGER IRET, IOFFSET, NPBYTES, ISIZE
-      INTEGER*8 ITEMP,IRET1
+      INTEGER IRET
+      INTEGER IOFFSET
+      INTEGER NPBYTES
+      INTEGER ISIZE
+      INTEGER*8 ITEMP
+      INTEGER IRET1
       CHARACTER*12 YFLAG
 #ifdef REAL_8
       DATA NPBYTES/8/
@@ -149,7 +152,7 @@ C
       CHARACTER*256 DIRNAME
       CHARACTER*256 FILENAME
       CHARACTER*512 FULLPATH
-      CHARACTER*16 YPFN
+      CHARACTER*20 YPFN
 #ifdef REAL_8
       DATA YPFN/'CF_xxxx_nnnn'/
 #else
@@ -170,9 +173,10 @@ C
 C
 C     Externals
 C
-      LOGICAL JFINDIR
-      LOGICAL JFINDFN3
-      INTEGER JCHMOD, CHMOD
+      LOGICAL JFINDIR, JFINDFN3
+      INTEGER JCHMOD
+      EXTERNAL JFINDIR, JFINDFN3
+      EXTERNAL JCHMOD
 C
 C     _______________________________________________________
 C
@@ -183,12 +187,12 @@ C
 C
 C     Setup the file name
 C
-      WRITE(YPFN(4:7),'(I4.4)') KTRUNC
-      WRITE(YPFN(9:12),'(I4.4)') KNUM
+      WRITE(YPFN(4: 7), '(I4.4)') KTRUNC
+      WRITE(YPFN(9:12), '(I4.4)') KNUM
       CALL INTLOG(JP_DEBUG,
      X  'JOPNGGF: Coefficients file to open is:', JPQUIET)
       CALL INTLOG(JP_DEBUG, YPFN, JPQUIET)
-
+C
 C     If file already open, return the existing unit number
 C
       IF( YPFN.EQ.YOLDGG ) THEN
@@ -213,7 +217,7 @@ C     _______________________________________________________
 C
   200 CONTINUE
 C
-      IOFFSET = INDEX(YPFN, ' ') - 1
+      IOFFSET = INDEX(YPFN,' ') - 1
       FILENAME = YPFN(1:IOFFSET)
 C
       LFOUND = JFINDIR('PPDIR', DIRNAME)
@@ -348,7 +352,7 @@ C
 cs       ITEMP = ISIZE*NPBYTES
        ITEMP = ITEMP*8
 
-      CALL GETENV('USE_PBREAD4', YFLAG)  
+      CALL GETENV('USE_PBREAD4', YFLAG)
       IF(YFLAG(1:1).EQ.'1') THEN
            CALL PBREAD4(NUNIT, ALEG, ITEMP, IRET1)
       ELSE
@@ -372,9 +376,9 @@ C
       CALL PBCLOSE3( NUNIT, IRET)
       IF( IRET.NE.0 ) THEN
         CALL INTLOG(JP_FATAL,'JOPNGGF: PBCLOSE3 error.',IRET)
-	NUNIT = 0
-	KRET = JPROUTINE + 9
-	GOTO 990
+        NUNIT = 0
+        KRET = JPROUTINE + 9
+        GOTO 990
       ENDIF
       NUNIT=0
 C
@@ -383,7 +387,7 @@ C
 C
 C     _______________________________________________________
 C
-C*    Section 9. Return to calling routine. Format statements
+C*    Section 9. Return to calling routine.
 C     _______________________________________________________
 C
   900 CONTINUE
diff --git a/interpolation/jopnggsm.c b/interpolation/jopnggsm.c
index 0e6c57c..6c0f6be 100644
--- a/interpolation/jopnggsm.c
+++ b/interpolation/jopnggsm.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -17,7 +17,9 @@
 #include <sys/mman.h>
 #include <string.h>
 #include "common/fortint.h"
- 
+#include "common/fortreal.h"
+#include "common/JPointer.h"
+
 #ifdef FORTRAN_NO_UNDERSCORE
 #define JOPNGGSM jopnggsm
 #define JMAKGG jmakgg
@@ -40,7 +42,7 @@ typedef __off64_t off64_t;
 void *mmap64(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset);
 #endif
 #endif
-#endif 
+#endif
 
 #ifdef FOPEN64
 #define OFF_T off64_t
@@ -54,23 +56,13 @@ extern OFF_T ftello64(FILE *);
 void INTLOGT(char * message, long length);
 FILE * pbfp(long);
 
-#ifdef REAL_8
 void JOPNGGSM(
   JPointer *ipdum,
   fortint *knum,
   fortint *iktrunc,
   fortint *kunit,
-  double *plat,
-  fortint * kret)
-#else
-void JOPNGGSM(
-  JPointer *ipdum,
-  fortint *knum,
-  fortint *iktrunc,
-  fortint *kunit,
-  float *plat,
-  fortint * kret)
-#endif
+  fortfloat *plat,
+  fortint * kret )
 /*
 C
 C**** JOPNGGSM
@@ -85,7 +77,7 @@ C
 C     Interface
 C     _________
 C
-C     CALL JOPNGGSM( IPDUM, KNUM, KTRUNC, KUNIT, PLAT, KRET)
+C     CALL JOPNGGSM(IPDUM,KNUM,KTRUNC,KUNIT,PLAT,KRET)
 C
 C     Input parameters
 C     ________________
@@ -137,12 +129,12 @@ C     Comments
 C     ________
 C
 C     The filename for the legendre polynomials has the form:
-C         cf_xxxx_nnnn   Truncation xxxx, Gaussian number yyy
+C         cf_xxxx_nnnn   Truncation xxxx, Gaussian number nnnn
 C     For example,
-C         cf_0213_n160          T213    N160
-C         cf_0106_n080          T106    N80
+C         cf_0213_0160          T213    N160
+C         cf_0106_0080          T106    N80
 C
-C     On the C90, the file of polynomials may be cached in /owrk/marsint
+C     On the C90, the file of polynomials may be cached in /work/marsint
 C
 C     Otherwise the file is located in (or will be created in) the first
 C     directory given by one of the following (in the order listed, if
@@ -174,12 +166,12 @@ fortint l1, l2;
 #endif
 char filedum[128], filename[128];
 #ifdef REAL_8
-char ypfn[13] =        "CF_xxxx_nnnn";
+char ypfn[21] =        "CF_xxxx_nnnn";
 #else
-char ypfn[13] =        "cf_xxxx_nnnn";
+char ypfn[21] =        "cf_xxxx_nnnn";
 #endif
-static char yold[13] = "xxxxxxxxxxxx";
-static char yarray[12][13];
+static char yold[21] = "xxxxxxxxxxxxxxxxxxxx";
+static char yarray[12][21];
 static int ncnt = 0;
 static int nunit = -1;
 int i;
@@ -193,11 +185,7 @@ static void * result = 0;
 static void * oldresult = 0;
 static void * resultarray[12];
 static int unitarray[12];
-#ifdef REAL_8
-double * pleg;
-#else
-float * pleg;
-#endif
+fortfloat * pleg;
 int exist = 0;
 char message[] = "JOPNGGSM: creating coefficients file";
 int status;
@@ -205,15 +193,10 @@ pid_t process_id;
 int ktrunc = (int) (*iktrunc);
 
 /*
-//  Setup the file name: cf_xxxx_nnnn
+//  Setup the file name
 */
-#ifdef REAL_8
-  len_pleg =  sizeof(double) * (ktrunc+1) * (ktrunc+4) /2;
-  len =  *knum * sizeof(double) * (ktrunc+1) * (ktrunc+4) /2;
-#else
-  len_pleg =  sizeof(float) * (ktrunc+1) * (ktrunc+4) /2;
-  len =  *knum * sizeof(float) * (ktrunc+1) * (ktrunc+4) /2;
-#endif
+  len_pleg =          sizeof(fortfloat) * (ktrunc+1) * (ktrunc+4) /2;
+  len      =  *knum * sizeof(fortfloat) * (ktrunc+1) * (ktrunc+4) /2;
   sprintf( ypfn+3, "%04d", ktrunc);
   sprintf( ypfn+7, "_%04d", *knum);
 
@@ -221,7 +204,7 @@ int ktrunc = (int) (*iktrunc);
 //  If file already open, return the existing unit number
 */
   for(i=0;i<ncnt;i++) {
-    strncpy(yold,yarray[i],12);
+    strncpy(yold,yarray[i],20);
     strcat(yold,"\0");
     if( !strcmp( ypfn, yold ) ) {
       *kunit = (fortint) unitarray[i];
@@ -250,10 +233,10 @@ int ktrunc = (int) (*iktrunc);
   }
 */
 
-/* 
+/*
   If more than 12 files are memory mapped , error
 */
-  if(ncnt==13) {
+  if(ncnt>=12) {
     fprintf(stderr,"JOPNGGSM: attempt to memory map more than 12 files\n");
     *kret = (fortint) 999;
     return;
@@ -346,12 +329,7 @@ int ktrunc = (int) (*iktrunc);
 /*
 //  Setup scratch legendre file.
 */
-#ifdef REAL_8
-    pleg = (double *) malloc(len_pleg*2);
-#else
-    pleg = (float *) malloc(len_pleg*2);
-#endif
-
+    pleg = (fortfloat *) malloc(len_pleg*2);
     if( pleg == NULL ) {
       perror("JOPNGGSM: malloc error.");
       *kret = (fortint) 996;
diff --git a/interpolation/jopnll.F b/interpolation/jopnll.F
index 90a80df..4c115a4 100644
--- a/interpolation/jopnll.F
+++ b/interpolation/jopnll.F
@@ -137,7 +137,7 @@ C
 #else
       DATA YPFN/'cf_txxxx_raabbbbb'/
 #endif
-      DATA YOLD/'xxxxxxxxxxxxxxxxx'/
+      DATA YOLD/'xxxxxxxxxxxxxxxxxxxx'/
       INTEGER NUNIT
       DATA NUNIT/0/
 C
@@ -156,7 +156,7 @@ C     _______________________________________________________
 C
   100 CONTINUE
 C
-C     Setup the filename: cf_txxxx_raabbbbb
+C     Setup the file name
 C
       WRITE(YPFN(5:8),'(I4.4)') KTRUNC
       WRITE(YPFN(11:17),'(I7.7)') NINT(PINTVL*JPMULT)
@@ -176,13 +176,13 @@ C
 C     Otherwise, close the existing file
 C
       IF( NUNIT.NE.0 ) THEN
-	CALL PBCLOSE(NUNIT, IRET)
+        CALL PBCLOSE(NUNIT, IRET)
         IF( IRET.NE.0 ) THEN
           CALL INTLOG(JP_ERROR,'JOPNLL: PBCLOSE error',IRET)
-	  KRET = JPROUTINE + 1
-	  GOTO 990
+          KRET = JPROUTINE + 1
+          GOTO 990
         ENDIF
-	NUNIT = 0
+        NUNIT = 0
       ENDIF
 C     _______________________________________________________
 C
diff --git a/interpolation/jopnllsm.c b/interpolation/jopnllsm.c
index 98d3e19..9ba910a 100644
--- a/interpolation/jopnllsm.c
+++ b/interpolation/jopnllsm.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -24,6 +24,8 @@
 #include <sys/mman.h>
 #include <string.h>
 #include "common/fortint.h"
+#include "common/fortreal.h"
+#include "common/JPointer.h"
 
 
 
@@ -49,7 +51,7 @@ typedef __off64_t off64_t;
 void *mmap64(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset);
 #endif
 #endif
-#endif 
+#endif
 
 #ifdef FOPEN64
 #define OFF_T off64_t
@@ -60,34 +62,24 @@ extern OFF_T ftello64(FILE *);
 
 int iitimer(int *seconds)
 {
-   time_t timval1;
-	  time(&timval1);
+    time_t timval1;
+    time(&timval1);
 
-		 if (*seconds == 0) return (int)timval1;
+    if (*seconds == 0) return (int)timval1;
 
-			return (int)(timval1 - (time_t)*seconds);
+    return (int)(timval1 - (time_t)*seconds);
 }
 
 void INTLOGT(char * message, long length);
 FILE * pbfp(long);
 
-#ifdef REAL_8
-void JOPNLLSM(
-  JPointer* ipdum,
-  double* platinc,
-  fortint* iktrunc,
-  fortint* kunit,
-  double* zbuild,
-  fortint* kret)
-#else
 void JOPNLLSM(
   JPointer* ipdum,
-  float* platinc,
+  fortfloat* platinc,
   fortint* iktrunc,
   fortint* kunit,
-  float* zbuild,
+  fortfloat* zbuild,
   fortint* kret)
-#endif
 /*
 C
 C**** JOPNLLSM
@@ -193,12 +185,12 @@ fortint l1, l2;
 #endif
 char filedum[128], filename[128];
 #ifdef REAL_8
-char ypfn[18] =        "CF_Txxxx_Raabbbb";
+char ypfn[21] =        "CF_Txxxx_Raabbbb";
 #else
-char ypfn[18] =        "cf_txxxx_raabbbb";
+char ypfn[21] =        "cf_txxxx_raabbbb";
 #endif
-static char yold[18] = "xxxxxxxxxxxxxxxx";
-static char yarray[12][18]; 
+static char yold[21] = "xxxxxxxxxxxxxxxxxxxx";
+static char yarray[12][21];
 static int ncnt = 0;
 static int nunit = -1;
 int i;
@@ -213,13 +205,8 @@ static void * result = 0;
 static void * oldresult = 0;
 static void * resultarray[12];
 static int unitarray[12];
-#ifdef REAL_8
-double plat = 0.0;
-double * pleg;
-#else
-float plat = 0.0;
-float * pleg;
-#endif
+fortfloat plat = 0.0;
+fortfloat * pleg;
 int exist = 0;
 char message[] = "JOPNLLSM: creating coefficients file";
 int status;
@@ -227,22 +214,14 @@ pid_t process_id;
 int ktrunc = (int) (*iktrunc);
 
 /*
-//  Setup the filename: cf_txxxx_raabbbbb
+//  Setup the file name
 */
-#ifdef REAL_8
-  len_pleg =  sizeof(double) * (ktrunc+1) * (ktrunc+4) /2;
-#else
-  len_pleg =  sizeof(float) * (ktrunc+1) * (ktrunc+4) /2;
-#endif
+  len_pleg =  sizeof(fortfloat) * (ktrunc+1) * (ktrunc+4) /2;
 
   *zbuild = *platinc;
 
-  knum = (OFF_T) ( (90.0/(*zbuild)) + 0.5) + 1;
-#ifdef REAL_8
-  len =  (OFF_T)(knum * sizeof(double) * (ktrunc+1) * (ktrunc+4)/2);
-#else
-  len =  (OFF_T)(knum * sizeof(float) * (ktrunc+1) * (ktrunc+4)/2);
-#endif
+  knum = (OFF_T) ((90.0/(*zbuild)) + 0.5) + 1;
+  len  = (OFF_T) (knum * sizeof(fortfloat) * (ktrunc+1) * (ktrunc+4)/2);
 
 /*
 printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %d, ktrunc+4: %d\n",len,knum,sizeof(double),(ktrunc+1),(ktrunc+4));
@@ -263,7 +242,7 @@ printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %
 //  If file already open, return the existing unit number
 */
   for(i=0;i<ncnt;i++) {
-    strncpy(yold,yarray[i],17);
+    strncpy(yold,yarray[i],20);
     strcat(yold,"\0");
     if( !strcmp( ypfn, yold ) ) {
       *kunit = (fortint) unitarray[i];
@@ -276,7 +255,7 @@ printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %
 //  Otherwise, unmap and close the existing file
 */
   result = 0;
-/*                
+/*
   if( nunit != -1 ) {
     if( munmap((caddr_t) oldresult, oldlen) ) {
       perror("JOPNLLSM: munmap error");
@@ -389,12 +368,7 @@ printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %
 /*
 //  Setup scratch legendre file.
 */
-#ifdef REAL_8
-    pleg = (double *) malloc(len_pleg*2);
-#else
-    pleg = (float *) malloc(len_pleg*2);
-#endif
-
+    pleg = (fortfloat *) malloc(len_pleg*2);
     if( pleg == NULL ) {
       perror("JOPNLLSM: malloc error.");
       *kret = (fortint) 996;
@@ -445,22 +419,22 @@ printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %
 {
 
     struct stat64 st;
-    
+
     if(fstat64(fileno(fp),&st) == -1)
-	{
-		fprintf(stderr,"JOPNLLSM: coefficients file fstat failed\n");
-		*kret = (fortint) 993;
-		return;
-	}
+    {
+        fprintf(stderr,"JOPNLLSM: coefficients file fstat failed\n");
+        *kret = (fortint) 993;
+        return;
+    }
     else
-	{
-		if(len != st.st_size)
-		{
-			fprintf(stderr,"JOPNLLSM: coefficients file size should be %lld bytes, it is %lld\n", len,st.st_size);
-			*kret = (fortint) 993;
-			return;
-		}
-	}
+    {
+        if(len != st.st_size)
+        {
+            fprintf(stderr,"JOPNLLSM: coefficients file size should be %lld bytes, it is %lld\n", len,st.st_size);
+            *kret = (fortint) 993;
+            return;
+        }
+    }
 }
 #else
   fseeko64(fp, 0, 2);
@@ -476,7 +450,7 @@ printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %
   fseek(fp, 0, 2);
   if( len != ftell(fp) ) {
     long ftello = ftell(fp);
-    
+
     fprintf(stderr,"JOPNLLSM: coefficients file size should be %ld bytes, it is %ld\n", len,ftello);
     *kret = (fortint) 993;
     return;
@@ -498,7 +472,7 @@ printf("################# len: %lld, knum: %lld, sizeof(double): %d, ktrunc+1: %
     caddr_t addr = (caddr_t) (p?atol(p):0);
 
     /* time1 = 0; */
-	/* time2 = iitimer(&time1); */
+    /* time2 = iitimer(&time1); */
 
 #ifdef FOPEN64
     result =  (void *) mmap64(addr,(size_t) len, (PROT_READ),
diff --git a/interpolation/jparam2.h b/interpolation/jparam2.h
index 19f4cb8..f49c3f9 100644
--- a/interpolation/jparam2.h
+++ b/interpolation/jparam2.h
@@ -12,6 +12,5 @@ C     Handling of spectral -> grid interpolation coefficients memory
 C
       LOGICAL LFREECF
       INTEGER NFREECF, NISIZE6, NISIZE7
-      CHARACTER*15 YOLDGG
-      CHARACTER*19 YOLDLL
+      CHARACTER*20 YOLDGG, YOLDLL
       COMMON /JDCSPGP/ NFREECF,NISIZE6,NISIZE7,LFREECF,YOLDGG,YOLDLL
diff --git a/interpolation/jparams.h b/interpolation/jparams.h
index d486157..a4e51f2 100644
--- a/interpolation/jparams.h
+++ b/interpolation/jparams.h
@@ -10,18 +10,15 @@ C nor does it submit to any jurisdiction.
 C
 C     Parameters
 C
-      INTEGER JP32, JPLONO, J2NFFT, JPFFT, JPLOOK, JPMAX, JPMAXITER
+      INTEGER JP32, JPLONO, JPFFT, JPLOOK, JPMAX, JPMAXITER
       INTEGER JPMXTRY, JPTRNC, JPK, JPTRP1
       PARAMETER ( JP32 = 32 )
 C
-C     The following value for JPLONO (2560) will handle regular grids 
-C     from N1 to N720 derived from spectral truncations from T1 to
-C     T639.
-C
-Cjdc  PARAMETER ( JPLONO = 2560 , J2NFFT = 2 + JPLONO, JPFFT = 12000)
-c      PARAMETER ( JPLONO = 6000 , J2NFFT = 2 + JPLONO, JPFFT = 12000)
-      PARAMETER ( JPLONO = 8200 , J2NFFT = 2 + JPLONO, JPFFT = 12000)
+C     PARAMETER ( JPLONO = 2560 , JPFFT = 12000)  ! handles N1-N720, spectral truncations T1-T639
+C     PARAMETER ( JPLONO = 6000 , JPFFT = 12000)
+      PARAMETER ( JPLONO = 8200 , JPFFT = 12000)  ! [O|N]1280 require [5136|5120]+2 reals
       PARAMETER ( JPLOOK = 50)
+C     PARAMETER ( JPMAX = 2048 )
       PARAMETER ( JPMAX = 2560 )
       PARAMETER ( JPMAXITER = 10)
       PARAMETER ( JPMXTRY = 3 )
diff --git a/interpolation/jsgggp.F b/interpolation/jsgggp.F
index 66bae15..459909e 100644
--- a/interpolation/jsgggp.F
+++ b/interpolation/jsgggp.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -17,7 +17,7 @@ C
 C     PURPOSE
 C     _______
 C
-C     This routine converts strecthed spectral fields to a gaussian
+C     This routine converts streched spectral fields to a gaussian
 C     grid field.
 C
 C     INTERFACE
@@ -37,8 +37,9 @@ C     PWEST    - Westernmost longitude for output field (degrees)
 C     PEAST    - Easternmost longitude for output field (degrees)
 C     KNUM     - Gaussian grid number
 C     HTYPE    - Gaussian grid type
-C                = 'R' for reduced, 
-C                = 'F' for full
+C                = 'R' for reduced ("quasi-regular"),
+C                = 'O' for reduced/octahedral,
+C                = 'F' for full,
 C                = 'U' for user-defined reduced gaussian grid
 C     KPTS     - Array specifying number of points at each line of
 C                latitude if HTYPE = 'U'.
@@ -78,7 +79,7 @@ C     JGETGG   - Pick up the definition of the gaussian grid.
 C     JJSET99  - Sets up FFT
 C     JNORSGG  - Determines which latitude row in a gaussian grid is
 C                north or south of a given latitude
-C     JSYMGG   - Generate symmetric grid from spherical harmonics 
+C     JSYMGG   - Generate symmetric grid from spherical harmonics
 C     JWSCAL   - Apply latitude correction to wind component field
 C     JMVUGG   - Moves grid point data to output array
 C     JMKOFGG  - Builds offsets into storage array
@@ -224,6 +225,8 @@ C
 C
         IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' ) CALL INTLOG(JP_DEBUG,
      X    'JSGGGP: Grid type is Reduced.',JPQUIET)
+        IF( HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' ) CALL INTLOG(JP_DEBUG,
+     X    'JSGGGP: Grid type is Reduced/octahedral.',JPQUIET)
         IF( HTYPE.EQ.'F' .OR. HTYPE.EQ.'f' ) CALL INTLOG(JP_DEBUG,
      X    'JSGGGP: Grid type is Full.',JPQUIET)
         IF( HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) CALL INTLOG(JP_DEBUG,
@@ -231,7 +234,7 @@ C
         CALL INTLOG(JP_DEBUG,
      X    'JSGGGP: Field code( = 1 for U or V) = ', LUV)
 C
-        IF( (HTYPE.EQ.'u').OR.(HTYPE.EQ.'U') ) THEN
+        IF( HTYPE.EQ.'u' .OR. HTYPE.EQ.'U' ) THEN
           CALL INTLOG(JP_DEBUG,'JSGGGP: User-supplied values.',JPQUIET)
           CALL INTLOG(JP_DEBUG,'JSGGGP: No. pts at each line:',JPQUIET)
           DO NDBGLP = 1, 20
@@ -293,10 +296,10 @@ C
 C
 C
 C     For calculation purposes, the number of longitude points for each
-C     latitude row has to be greater than 2*(output truncation) to 
-C     ensure the fourier transform is exact (see Reference, page 10). 
+C     latitude row has to be greater than 2*(output truncation) to
+C     ensure the fourier transform is exact (see Reference, page 10).
 C
-C     The following loop calculates the power of 2 to be used as a 
+C     The following loop calculates the power of 2 to be used as a
 C     multipier for each row to ensure there are enough points.
 C     Later, when filling the output array POUTF, the longitude points
 C     have to be taken selectively to avoid the intermediate generated
@@ -304,8 +307,8 @@ C     points, picking up values only at the required longitudes.
 C
       ITOUP1 = KTRUNC
       DO 108 J108 = 1, KNUM
-	IMAGE = 2*KNUM - J108 + 1
-	ILON        = KPTS(J108)
+        IMAGE = 2*KNUM - J108 + 1
+        ILON        = KPTS(J108)
         IJPWR(J108) = 1
  104    CONTINUE
           IF(ILON .GT. 2*ITOUP1) GOTO 106
@@ -313,7 +316,7 @@ C
           ILON        = ILON*2
           GOTO 104
  106    CONTINUE
-	IJPWR(IMAGE) = IJPWR(J108)
+        IJPWR(IMAGE) = IJPWR(J108)
  108  CONTINUE
 C
 C     _______________________________________________________
@@ -324,7 +327,7 @@ C
  200  CONTINUE
 C
 C     Latitude rows are generated from row INORTH to ISOUTH.
-C     Selection is carried out for actual requested rows when the 
+C     Selection is carried out for actual requested rows when the
 C     calculated values are moved to the output array.
 C
       INORTH = NNORTH
@@ -376,12 +379,12 @@ C
 C       Calculate the points along the line of latitude
 C
         CALL JSYMGG( PSHUP, KTRUNC, NXTROW, ILUNIT, 1, ILON,
-     X               ALAT, ALEG, ATRIGS, IMFAX, ZFA, KRET)
-	IF( KRET.NE.0 ) GOTO 990
+     X               ALAT, ALEG, ATRIGS, IMFAX, .FALSE., ZFA, KRET)
+        IF( KRET.NE.0 ) GOTO 990
 C
 C       If it is a wind component field, apply latitude correction
 C
-	IF( LUV.EQ.1 ) THEN
+        IF( LUV.EQ.1 ) THEN
           ZLAT   = ALAT(NXTROW)
           ZCOSI  = ZFACTOR(NXTROW) / ABS( COS(ZLAT*DEG2RAD) )
           CALL SSCAL( ILON, ZCOSI, ZFA(2), 1)
@@ -389,7 +392,9 @@ C
 C
 C       Store away the generated latitudes
 C
-        IF( (HTYPE.EQ.'U').OR.(HTYPE.EQ.'R') ) THEN
+        IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' .OR.
+     X      HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     X      HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) THEN
           NUMPTS = KPTS(NXTROW)
         ELSE
           RINTVL = (PEAST - PWEST)*FLOAT( KPTS(NXTROW) ) / 360.0
@@ -399,7 +404,7 @@ C
 C       Move latitude line to output array
 C
         NFLAG = 1
-	CALL JMOVGG( ZFA, PWEST, KNUM, NXTROW, 1, NUMPTS,
+        CALL JMOVGG( ZFA, PWEST, KNUM, NXTROW, 1, NUMPTS,
      X    ILON, IJPWR(NXTROW), NOFSET, POUTF, NFLAG)
 C
       ENDDO
@@ -409,6 +414,7 @@ C
 C*    Section 9. Return to calling routine. Format statements
 C     _______________________________________________________
 C
+ 930  CONTINUE
       KRET = 0
 C
  990  CONTINUE
diff --git a/interpolation/jstrll.F b/interpolation/jstrll.F
index 15152bc..29f014a 100644
--- a/interpolation/jstrll.F
+++ b/interpolation/jstrll.F
@@ -276,7 +276,7 @@ C     _______________________________________________________
 C
  300  CONTINUE
 C
-      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,J2NFFT,KLONO,1,1)
+      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,JPLONO+2,KLONO,1,1)
 C   
 C     Apply map factor (squared) to vorticity or divergence
 C   
diff --git a/interpolation/jstrwll.F b/interpolation/jstrwll.F
index 43cb19e..82034e1 100644
--- a/interpolation/jstrwll.F
+++ b/interpolation/jstrwll.F
@@ -308,7 +308,7 @@ C     _______________________________________________________
 C
  300  CONTINUE
 C
-      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,J2NFFT,KLONO,2,1)
+      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,JPLONO+2,KLONO,2,1)
 C
       IF( NDBG.GT.1 ) THEN
         CALL INTLOG(JP_DEBUG,
diff --git a/interpolation/jsymgg.F b/interpolation/jsymgg.F
index 612e1d4..843da3f 100644
--- a/interpolation/jsymgg.F
+++ b/interpolation/jsymgg.F
@@ -3,16 +3,16 @@
 #endif
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      SUBROUTINE JSYMGG( PSHUP, KTRUNC, KSTART, KLUNIT, KLATO, KLONO,
-     X                    PLAT, PLEG, PTRIGS, KMFAX, PZFA, KRET)
+      SUBROUTINE JSYMGG( PSHUP,KTRUNC,KSTART,KLUNIT,KLATO,KLONO,
+     X                    PLAT,PLEG,PTRIGS,KMFAX,LUSEFFTW,PZFA,KRET)
 C
 C---->
 C**** JSYMGG
@@ -34,7 +34,7 @@ C     ________________
 C
 C     PSHUP    - Spherical harmonics field, unpacked
 C     KTRUNC   - Truncation number of spherical harmonics field
-C     KSTART   - Number of start latitude row (northernmost) for output 
+C     KSTART   - Number of start latitude row (northernmost) for output
 C                field (must be positive - see comments below)
 C     KLUNIT   - stream number of the legendre function file
 C     KLATO    - Number of latitude rows in output field
@@ -43,12 +43,13 @@ C     PLAT     - Array of gaussian latitudes
 C     PLEG     - Array used to hold legendre functions
 C     PTRIGS   - Initialized array of trig.functions (setup by JJSET99)
 C     KMFAX    - Initialized array of prime factors (setup by JJSET99)
+C     LUSEFFTW - Use FFTW instead of FFT99
 C
 C     Output parameters
 C     ________________
 C
-C     PZFA    - Output grid point field; contains upto 32 each of
-C               North and South latitude rows symmetrically.
+C     PZFA     - Output grid point field; contains up to 32 each of
+C                North and South latitude rows symmetrically.
 C     KRET     - Return status code
 C                0 = OK
 C
@@ -84,10 +85,10 @@ C
 C     This is a redesign, based on SPECGP.F
 C
 C     It handles transformation to a gaussian grid.
-C     The generated grid is symmetrical about the equator, so 
+C     The generated grid is symmetrical about the equator, so
 C     KSTART must be positive.
 C
-C     It is not for U and V fields (no correction is applied at the 
+C     It is not for U and V fields (no correction is applied at the
 C     poles).
 C
 C
@@ -105,24 +106,28 @@ C
 C----<
 C     _______________________________________________________
 C
+C
       IMPLICIT NONE
 #include "jparams.h"
 #include "parim.h"
 #include "nifld.common"
 C
+C     Parameters
+      INTEGER JPROUTINE
+      PARAMETER ( JPROUTINE = 31200 )
+C
 C     Subroutine arguments
       COMPLEX   PSHUP
       DIMENSION PSHUP(*)
       INTEGER   KTRUNC
       INTEGER   KSTART
       INTEGER   KLUNIT, KLATO, KLONO, KMFAX, KRET
-      REAL PLAT, PLEG, PTRIGS, PZFA
+      REAL      PLEG, PTRIGS, PZFA
+      LOGICAL   LUSEFFTW
       DIMENSION PZFA(JPLONO + 2, 64)
-      DIMENSION KMFAX(*), PLAT(*), PLEG(*), PTRIGS(*)
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 31200 )
+      DIMENSION KMFAX(*), PLEG(*), PTRIGS(*)
+      REAL      PLAT
+      DIMENSION PLAT(*)
 C
 C     Local variables
       INTEGER   ILIM, IMLIM, ILN
@@ -130,14 +135,20 @@ C     Local variables
       INTEGER   INORTH, ISOUTH
       INTEGER   JM, J, JNEXTLAT, JF
       INTEGER   NERR
-      INTEGER*8 IOFF
       INTEGER*8 JDCLOOP
+      INTEGER*8 IOFF
 C
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 IWORK
 #endif
 #endif
+#ifdef HAVE_FFTW
+      INTEGER*8 PLAN
+      INTEGER   N(64), IDIST, ODIST
+      REAL      X1, XN
+#include "fftw3.f"
+#endif
       REAL WORK
       DIMENSION WORK(1)
       POINTER ( IWORK, WORK )
@@ -157,7 +168,7 @@ C
 C
 C     First time through, dynamically allocate memory for workspace
 C
-      IF( ISIZE.EQ.0 ) THEN
+      IF( ISIZE.EQ.0 .AND. .NOT. LUSEFFTW ) THEN
         ISIZE =  2*JPFFT*64
         CALL JMEMHAN( 9, IWORK, ISIZE, 1, KRET)
         IF( KRET.NE.0 ) THEN
@@ -170,9 +181,9 @@ C
       IF ( NDBG .GT. 1) THEN
         CALL INTLOG(JP_DEBUG,
      X    'JSYMGG: Spherical harmonic coeffs(first 20):',JPQUIET)
-        DO 101 NDBGLP = 1, 20
+        DO NDBGLP = 1, 20
           CALL INTLOGR(JP_DEBUG,' ',PSHUP( NDBGLP ))
-  101   CONTINUE
+        ENDDO
         CALL INTLOG(JP_DEBUG,'JSYMGG: Input parameters:',JPQUIET)
         CALL INTLOG(JP_DEBUG,
      X    'JSYMGG: Spherical harmonic truncation = ', KTRUNC)
@@ -184,16 +195,18 @@ C
      X    'JSYMGG: Number of lat. rows in output = ', KLATO)
         CALL INTLOG(JP_DEBUG,
      X    'JSYMGG: Number of long. pts per row = ', KLONO)
-        CALL INTLOG(JP_DEBUG,
-     X    'JSYMGG: Trig.functions (setup by JJSET99):',JPQUIET)
-        DO 102 NDBGLP = 1, 10
-          CALL INTLOGR(JP_DEBUG,' ',PTRIGS( NDBGLP ))
-  102   CONTINUE
-        CALL INTLOG(JP_DEBUG,
-     X    'JSYMGG: Prime factors (setup by JJSET99):',JPQUIET)
-        DO 103 NDBGLP = 1, 10
-          CALL INTLOG(JP_DEBUG,' ',KMFAX( NDBGLP ))
-  103   CONTINUE
+        IF( .NOT. LUSEFFTW ) THEN
+          CALL INTLOG(JP_DEBUG,
+     X      'JSYMGG: Trig.functions (setup by JJSET99):',JPQUIET)
+          DO NDBGLP = 1, 10
+            CALL INTLOGR(JP_DEBUG,' ',PTRIGS( NDBGLP ))
+          ENDDO
+          CALL INTLOG(JP_DEBUG,
+     X      'JSYMGG: Prime factors (setup by JJSET99):',JPQUIET)
+          DO NDBGLP = 1, 10
+            CALL INTLOG(JP_DEBUG,' ',KMFAX( NDBGLP ))
+          ENDDO
+        ENDIF
       ENDIF
 C
       ILIM   = KTRUNC + 1
@@ -212,7 +225,7 @@ C
 C     For each latitude, the north and corresponding south latitude row
 C     are calculated at the same time from the same legendre functions.
 C
-      DO 280 JNEXTLAT = KSTART, KSTART+KLATO-1
+      DO JNEXTLAT = KSTART, KSTART+KLATO-1
 C
         IF ( NDBG .GT. 1)
      X    CALL INTLOG(JP_DEBUG,'JSYMGG: Next latitude = ', JNEXTLAT)
@@ -230,26 +243,25 @@ C
             GOTO 990
           ENDIF
         ELSE
-C          IOFF = (JNEXTLAT-1)*(KTRUNC+1)*(KTRUNC+4)/2
-
-           IOFF = (JNEXTLAT-1)
-           IOFF = (KTRUNC+1) * IOFF
-           IOFF = (KTRUNC+4) * IOFF
-           IOFF = IOFF / 2
-
+C         IOFF = (JNEXTLAT-1)*(KTRUNC+1)*(KTRUNC+4)/2
+          IOFF = (JNEXTLAT-1)
+          IOFF = (KTRUNC+1) * IOFF
+          IOFF = (KTRUNC+4) * IOFF
+          IOFF = IOFF/2
         ENDIF
 C
 C       Clear unused slots in array.
+C       Note there are two slots in the array - one for north latitude
 C       and one for the corresponding south latitude.
 C
         INORTH = INORTH + 2
         ISOUTH = INORTH + 1
-        DO 241 JF = 2*IMLIM + 1, ILN
+        DO JF = 2*IMLIM + 1, ILN
           PZFA(JF, INORTH) = 0.0
           PZFA(JF, ISOUTH) = 0.0
- 241    CONTINUE
+        ENDDO
 C
-C      Now fill slots which are used
+C       Now fill slots which are used
 C
         IMN = 0
         IMP = 0
@@ -263,7 +275,7 @@ C
             IF( LFILEIO ) THEN
               CHOLD=CHOLD+PLEG(IMP+J)*PSHUP(IMN+J)
             ELSE
-              JDCLOOP = IOFF + IMP + J
+              JDCLOOP = IMP + J + IOFF
               CHOLD=CHOLD+PLEG(JDCLOOP)*PSHUP(IMN+J)
             ENDIF
           ENDDO
@@ -273,7 +285,7 @@ C
             IF( LFILEIO ) THEN
               CHOLD=CHOLD+PLEG(IMP+J)*PSHUP(IMN+J)
             ELSE
-              JDCLOOP = IOFF + IMP + J
+              JDCLOOP = IMP + J + IOFF
               CHOLD=CHOLD+PLEG(JDCLOOP)*PSHUP(IMN+J)
             ENDIF
           ENDDO
@@ -291,16 +303,16 @@ C       are COMPLEX.  There are pairs of values for each coefficient
 C       (real and imaginary parts) and pairs of values for each
 C       latitude (north and south).
 C
-        DO 246 JM = 1, IMLIM
+        DO JM = 1, IMLIM
           PZFA(2*JM -1, INORTH) = REAL(ZSUMS(JM))  + REAL(ZSUMA(JM))
           PZFA(2*JM   , INORTH) = AIMAG(ZSUMS(JM)) + AIMAG(ZSUMA(JM))
           PZFA(2*JM -1, ISOUTH) = REAL(ZSUMS(JM))  - REAL(ZSUMA(JM))
           PZFA(2*JM   , ISOUTH) = AIMAG(ZSUMS(JM)) - AIMAG(ZSUMA(JM))
- 246    CONTINUE
+        ENDDO
 C
 C*    End of main loop through latitude rows.
 C
- 280  CONTINUE
+      ENDDO
 C
 C     _______________________________________________________
 C
@@ -312,15 +324,55 @@ C
       IF ( NDBG .GT. 1) CALL INTLOG(JP_DEBUG,
      X  'JSYMGG: FFT, no.of rows (N and S) = ',ISOUTH)
 C
-      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,J2NFFT,KLONO,ISOUTH,1)
+#ifdef HAVE_FFTW
+      IF( LUSEFFTW ) THEN
+        N    = 0
+        N(1) = KLONO
+        IDIST = (JPLONO+2)/2
+        ODIST = (JPLONO+2)
+#ifdef REAL_8
+C       double precision fftw
+        CALL DFFTW_PLAN_MANY_DFT_C2R( PLAN, 1, N, ISOUTH,
+     X         PZFA, 0, 1, IDIST,  ! in,  inembed, istride, idist
+     X         PZFA, 0, 1, ODIST,  ! out, onembed, ostride, odist
+     X         FFTW_ESTIMATE + FFTW_UNALIGNED + FFTW_NO_SIMD +
+     X         FFTW_DESTROY_INPUT )
+        CALL DFFTW_EXECUTE( PLAN )
+        CALL DFFTW_DESTROY_PLAN( PLAN )
+#else
+C       single precision fftw
+        CALL SFFTW_PLAN_MANY_DFT_C2R( PLAN, 1, N, ISOUTH,
+     X         PZFA, 0, 1, IDIST,
+     X         PZFA, 0, 1, ODIST,
+     X         FFTW_ESTIMATE + FFTW_UNALIGNED + FFTW_NO_SIMD )
+        CALL SFFTW_EXECUTE( PLAN )
+        CALL SFFTW_DESTROY_PLAN( PLAN )
+#endif
+C
+C       shift right and enforce periodicity (see FFT99 documentation):
+C         from [ x1, x2, ..., xN-1, xN,   0,  0,  (0...) ]
+C         to   [ xN, x1, x2, ...,   xN-1, xN, x1, (0...) ]
+        DO J=1, ISOUTH
+          X1 = PZFA(   1,   J )
+          XN = PZFA( KLONO, J )
+          PZFA( 2:KLONO+1, J ) = PZFA(1:KLONO,J)
+          PZFA(     1,     J ) = XN
+          PZFA(  KLONO+2,  J ) = X1
+        ENDDO
+      ELSE
+        CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,JPLONO+2,KLONO,ISOUTH,1)
+      ENDIF
+#else
+      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,JPLONO+2,KLONO,ISOUTH,1)
+#endif
 C
       IF ( NDBG .GT. 1) THEN
         CALL INTLOG(JP_DEBUG,
      X    'JSYMGG: Values calculated by FFT:',JPQUIET)
-        DO 301 NDBGLP = 1, 20
+        DO NDBGLP = 1, 20
           CALL INTLOGR(JP_DEBUG,' ',PZFA( 1, NDBGLP ))
           CALL INTLOGR(JP_DEBUG,' ',PZFA( 2, NDBGLP ))
-  301   CONTINUE
+        ENDDO
       ENDIF
 C
 C     _______________________________________________________
@@ -329,10 +381,10 @@ C*    Section 9. Return to calling routine. Format statements
 C     _______________________________________________________
 C
 C
-  900 CONTINUE
+ 900  CONTINUE
 C
       KRET = 0
 C
-  990 CONTINUE
+ 990  CONTINUE
       RETURN
       END
diff --git a/interpolation/jsymll.F b/interpolation/jsymll.F
index ca7eeb0..a30e177 100644
--- a/interpolation/jsymll.F
+++ b/interpolation/jsymll.F
@@ -136,8 +136,8 @@ C     Local variables
       INTEGER NERR
       INTEGER*8 JDCLOOP
       INTEGER*8 IOFF
-	  Integer Itimer,timer1,timer280,timerFFT
-      Integer timer246,timer244,time
+      !Integer Itimer,timer1,timer280,timerFFT
+      !Integer timer246,timer244,time
 C
 #ifndef _CRAYFTN
 #ifdef POINTER_64
@@ -149,7 +149,6 @@ C
       POINTER ( IWORK, WORK )
       COMPLEX   ZSUMS(JPTRNC + 1), ZSUMA(JPTRNC + 1)
       COMPLEX*16 CHOLD
-      INTEGER LOOP
 C
       INTEGER ISIZE
       DATA ISIZE/0/
@@ -329,7 +328,7 @@ C
       IF ( NDBG .GT. 1) CALL INTLOG(JP_DEBUG,
      X  'JSYMLL: FFT, no.of rows (N and S) = ', ISOUTH)
 C
-      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,J2NFFT,KLONO,ISOUTH,1)
+      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,JPLONO+2,KLONO,ISOUTH,1)
 C
       IF ( NDBG .GT. 1) THEN
         CALL INTLOG(JP_DEBUG,
diff --git a/interpolation/jtimer.c b/interpolation/jtimer.c
deleted file mode 100644
index 8b8bf25..0000000
--- a/interpolation/jtimer.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <sys/times.h>
-#include <time.h>
-
-#include <unistd.h>
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define JTIMER jtimer
-#else
-#define JTIMER jtimer_
-#endif
-
-void JTIMER(const long * param)
-{
-static struct tms before, after;
-static time_t utime, stime;
-static long startime, endtime;
-
-/*  If input parameter is zero, initialise the time record */
-    if ( *param == 0 )
-    {
-      startime = times(&before);
-    }
-
-/*  Otherwise, publish elapsed time since last initialisation */
-    else
-    {
-      endtime = times(&after);
-  
-      utime = after.tms_utime - before.tms_utime;
-      stime = after.tms_stime - before.tms_stime;
-/* Sinisa  CLOCKS_PER_SEC
-    The value of this macro is the number of clock ticks per second measured by the clock function. 
-
-	int CLK_TCK is an obsolete name for CLOCKS_PER_SEC. 
-*/
-      printf("CPU time used in user space = %f sec\n", 
-             (float) utime/(float)CLOCKS_PER_SEC);
-      printf("CPU time used by the system = %f sec\n", 
-             (float) stime/(float)CLOCKS_PER_SEC);
-      printf("Wall clock time used by process = %f sec\n", 
-             (float) (endtime - startime)/(float)CLOCKS_PER_SEC);
-    }
-    return;
-}
diff --git a/interpolation/juvpole.F b/interpolation/juvpole.F
index b80bc74..74c3c99 100644
--- a/interpolation/juvpole.F
+++ b/interpolation/juvpole.F
@@ -99,7 +99,8 @@ C     Local variables
 C
       REAL EAST, WEST, LAT, POUTF(18), ALATS(320)
       REAL XLONG, WLEFT, XSTEP, GSTEP
-      INTEGER KPTS(320), NUM, LOOP, NLEFT, NRIGHT
+      INTEGER KPTS(320), NUM, LOOP, NLEFT, NRIGHT, LUV
+      CHARACTER*1 HTYPE
 C
 C     Externals
 C
@@ -129,8 +130,10 @@ C
 C     Form the N160 reduced gaussian grid latitude near the North pole
 C
       LAT = 90.0
-      CALL JAGGGP( PSHUP, KTRUNC, LAT, LAT, WEST, EAST,
-     X             NUM, 'R', KPTS, POUTF, 1, KRET)
+      HTYPE = 'R'
+      LUV = 1
+      CALL JAGGGP(PSHUP, KTRUNC, LAT, LAT, WEST, EAST,
+     X            NUM, HTYPE, KPTS, POUTF, LUV, KRET)
       IF( KRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'JUVPOLE: problem forming Northern gaussian grid latitude',
@@ -182,8 +185,10 @@ C
 C     Form the N160 reduced gaussian grid latitude near the South pole
 C
       LAT = -90.0
-      CALL JAGGGP( PSHUP, KTRUNC, LAT, LAT, WEST, EAST,
-     X             NUM, 'U', KPTS, POUTF, 1, KRET)
+      HTYPE = 'U'
+      LUV = 1
+      CALL JAGGGP(PSHUP, KTRUNC, LAT, LAT, WEST, EAST,
+     X            NUM, HTYPE, KPTS, POUTF, LUV, KRET)
       IF( KRET.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'JUVPOLE: problem forming Southern gaussian grid latitude',
diff --git a/interpolation/jwindll.F b/interpolation/jwindll.F
index b0d8ecb..6516411 100644
--- a/interpolation/jwindll.F
+++ b/interpolation/jwindll.F
@@ -378,7 +378,7 @@ C
       IF( NDBG.GT.1 ) CALL INTLOG(JP_DEBUG,
      X  'JWINDLL: FFT, no.of rows (N and S) = ', ISOUTH)
 C
-      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,J2NFFT,KLONO,ISOUTH,1)
+      CALL FFT99(PZFA,WORK,PTRIGS,KMFAX,1,JPLONO+2,KLONO,ISOUTH,1)
 C
       IF( NDBG.GT.1 ) THEN
         CALL INTLOG(JP_DEBUG,
diff --git a/interpolation/kintrg.F b/interpolation/kintrg.F
index 3e5f7e0..72c84eb 100644
--- a/interpolation/kintrg.F
+++ b/interpolation/kintrg.F
@@ -88,20 +88,13 @@ C
 #include "nifld.common"
 #include "nofld.common"
 C
-C     Parameters
-C
-C      Here: Maximum N which can be processed
-C
-      INTEGER JPMAXNG
-      PARAMETER (JPMAXNG=4000)
-C
 C     Local variables
 C
       LOGICAL LVEGGY
       INTEGER TOTAL, NEXT, LOOP, NEWOFF(JPMAXNG), OLDOFF(JPMAXNG)
-      INTEGER LATIT, LONG, NEWTYPE, IRET, NPTS
+      INTEGER LATIT, LONG, IRET, NPTS
       INTEGER LAT(2), LON(4)
-      INTEGER PT(4), TYPE(4)
+      INTEGER PT(4)
       REAL OLAT(2), OLON(4)
       REAL RLATOLD(JPMAXNG), RLATNEW(JPMAXNG), RLAT, RLON
 C
diff --git a/interpolation/knfrom4.F b/interpolation/knfrom4.F
index 2c9b7bb..211b234 100644
--- a/interpolation/knfrom4.F
+++ b/interpolation/knfrom4.F
@@ -70,12 +70,11 @@ C
       INTEGER PT(4)
 C
 #include "intisl.h"
-#include "parim.h"
 #include "nifld.common"
 C
 C     Local variables
 C
-      INTEGER COUNT, LOOP, NEAREST
+      INTEGER COUNT, NEAREST
       REAL WEIGHT(4), NWEIGHT, SWEIGHT, NORMAL
 
 C     Additional local variables for calculation
diff --git a/interpolation/krg2rg.F b/interpolation/krg2rg.F
index 6f8f3dd..4bcbefe 100644
--- a/interpolation/krg2rg.F
+++ b/interpolation/krg2rg.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -72,13 +72,12 @@ C
       INTEGER NUMGG, OLDFLD(*), NEWFLD(*)
 C
 #include "parim.h"
-#include "intisl.h"
 #include "nifld.common"
 #include "nofld.common"
 C
 C     Parameters
 C
-      INTEGER JPACK, JUNPACK, JPINTB, JPREALB, JPMAXNG
+      INTEGER JPACK, JUNPACK, JPINTB, JPREALB
       PARAMETER (JPACK   = 4000000)
       PARAMETER (JUNPACK = 6000000)
 #ifdef INTEGER_8
@@ -86,7 +85,6 @@ C
 #else
       PARAMETER (JPINTB = 4)
 #endif
-      PARAMETER (JPMAXNG=4000)
 #ifdef REAL_8
       PARAMETER (JPREALB = 8)
 #else
@@ -97,10 +95,10 @@ C     Local variables
 C
       INTEGER IFSEC0(JPGRIB_ISEC0),IFSEC1(JPGRIB_ISEC1),
      X IFSEC2(JPGRIB_ISEC2),IFSEC3(JPGRIB_ISEC3),IFSEC4(JPGRIB_ISEC4)
-      INTEGER NFSEC0(JPGRIB_ISEC0),NFSEC1(JPGRIB_ISEC1),
-     X NFSEC2(JPGRIB_ISEC2),NFSEC3(JPGRIB_ISEC3),NFSEC4(JPGRIB_ISEC4)
+      INTEGER NFSEC2(JPGRIB_ISEC2),NFSEC3(JPGRIB_ISEC3)
       INTEGER ISIZE, LOOP
       LOGICAL LFIRST
+      CHARACTER*1 HTYPE
 #ifndef _CRAYFTN
 #if (!defined sgi)
 #ifdef POINTER_64
@@ -208,7 +206,9 @@ C
       DO LOOP = 1, JPMAXNG
         NFSEC2(LOOP) = IFSEC2(LOOP)
       ENDDO
-      CALL JGETGG( NUMGG, 'R', PLAT, NFSEC2(23), IRET)
+      HTYPE = 'R'
+      IF( LOCTAHEDRAL ) HTYPE = 'O'
+      CALL JGETGG( NUMGG, HTYPE, PLAT, NFSEC2(23), IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RG: Problem calling JGETGG, status = ',IRET
         KRG2RG = -1
@@ -217,7 +217,9 @@ C
       NFSEC2(3)  = NUMGG * 2
       NFSEC2(4)  = NINT(PLAT(1)*1000.0)
       NFSEC2(7)  = NINT(PLAT(NUMGG*2)*1000.0)
-      NFSEC2(8)  = NINT((360.0-(360.0/REAL(NUMGG*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     NFSEC2(8)  = NINT((360.0-(360.0/REAL(NUMGG*4)))*1000.0)
+      NFSEC2(8)  = NINT((360.0-(360.0/REAL(NFSEC2(23+NUMGG))))*1000.0)
       NFSEC2(10) = NUMGG
 C
       IRET = KINTRG(IFSEC2, NFSEC2, ZFSEC4, PFSEC4)
diff --git a/interpolation/krg2rgd.F b/interpolation/krg2rgd.F
index 59a6b6a..360a9e1 100644
--- a/interpolation/krg2rgd.F
+++ b/interpolation/krg2rgd.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -18,7 +18,7 @@ C     -------
 C
 C     Interpolate a field based on one reduced gaussian grid to a
 C     field based on a different reduced gaussian grid, using
-C     intermediate interpolation 
+C     intermediate interpolation
 C
 C
 C     Interface
@@ -75,13 +75,12 @@ C
       INTEGER NUMME, NUMGG, OLDFLD(*), NEWFLD(*)
 C
 #include "parim.h"
-#include "intisl.h"
 #include "nifld.common"
 #include "nofld.common"
 C
 C     Parameters
 C
-      INTEGER JPACK, JUNPACK, JPINTB, JPREALB, JPMAXNG
+      INTEGER JPACK, JUNPACK, JPINTB, JPREALB
       PARAMETER (JPACK   = 4000000)
       PARAMETER (JUNPACK = 6000000)
 #ifdef INTEGER_8
@@ -89,7 +88,6 @@ C
 #else
       PARAMETER (JPINTB = 4)
 #endif
-      PARAMETER (JPMAXNG=4000)
 #ifdef REAL_8
       PARAMETER (JPREALB = 8)
 #else
@@ -100,11 +98,11 @@ C     Local variables
 C
       INTEGER IFSEC0(JPGRIB_ISEC0),IFSEC1(JPGRIB_ISEC1),
      X IFSEC2(JPGRIB_ISEC2),IFSEC3(JPGRIB_ISEC3),IFSEC4(JPGRIB_ISEC4)
-      INTEGER NFSEC0(JPGRIB_ISEC0),NFSEC1(JPGRIB_ISEC1),
-     X NFSEC2(JPGRIB_ISEC2),NFSEC3(JPGRIB_ISEC3),NFSEC4(JPGRIB_ISEC4)
+      INTEGER NFSEC2(JPGRIB_ISEC2),NFSEC3(JPGRIB_ISEC3)
       INTEGER NEWGEO(2048)
       INTEGER ISIZE, LOOP
       LOGICAL LFIRST
+      CHARACTER*1 HTYPE
 #ifndef _CRAYFTN
 #if (!defined sgi)
 #ifdef POINTER_64
@@ -223,7 +221,9 @@ C
         NFSEC2(LOOP) = IFSEC2(LOOP)
         NEWGEO(LOOP) = 0
       ENDDO
-      CALL JGETGG( NUMME, 'R', PLAT, NEWGEO(23), IRET)
+      HTYPE = 'R'
+      IF( LOCTAHEDRAL ) HTYPE = 'O'
+      CALL JGETGG( NUMME, HTYPE, PLAT, NEWGEO(23), IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RGD: Problem calling JGETGG, status = ',IRET
         KRG2RGD = -1
@@ -233,7 +233,9 @@ C
       NEWGEO(4)  = NINT(PLAT(1)*1000.0)
       NEWGEO(5)  = 0
       NEWGEO(7)  = NINT(PLAT(NUMME*2)*1000.0)
-      NEWGEO(8)  = NINT((360.0-(360.0/REAL(NUMME*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     NEWGEO(8)  = NINT((360.0-(360.0/REAL(NUMME*4)))*1000.0)
+      NEWGEO(8)  = NINT((360.0-(360.0/REAL(NEWGEO(23+NUMME))))*1000.0)
       NEWGEO(10) = NUMME
 C
       IRET = KINTRG(IFSEC2, NEWGEO, ZFSEC4, MEDFLD)
@@ -252,7 +254,9 @@ C*    Section 4. Create new field from intermediate and put in GRIB
 C     -----------------------------------------------------------------|
 C
 
-      CALL JGETGG( NUMGG, 'R', PLAT, NFSEC2(23), IRET)
+      HTYPE = 'R'
+      IF( LOCTAHEDRAL ) HTYPE = 'O'
+      CALL JGETGG( NUMGG, HTYPE, PLAT, NFSEC2(23), IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RGD: Problem calling JGETGG, status = ',IRET
         KRG2RGD = -1
@@ -261,7 +265,9 @@ C
       NFSEC2(3)  = NUMGG * 2
       NFSEC2(4)  = NINT(PLAT(1)*1000.0)
       NFSEC2(7)  = NINT(PLAT(NUMGG*2)*1000.0)
-      NFSEC2(8)  = NINT((360.0-(360.0/REAL(NUMGG*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     NFSEC2(8)  = NINT((360.0-(360.0/REAL(NUMGG*4)))*1000.0)
+      NFSEC2(8)  = NINT((360.0-(360.0/REAL(NFSEC2(23+NUMGG))))*1000.0)
       NFSEC2(10) = NUMGG
 C
       IRET = KINTRG(NEWGEO, NFSEC2, MEDFLD, PFSEC4)
diff --git a/interpolation/krg2rgu.F b/interpolation/krg2rgu.F
index 23881de..94c7600 100644
--- a/interpolation/krg2rgu.F
+++ b/interpolation/krg2rgu.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -65,7 +65,7 @@ C
 C     Modifications
 C     -------------
 C
-C     Use grid definistion from input GRIB header to
+C     Use grid definition from input GRIB header to
 C     cater for octahedral grid
 C     S.Siemen         ECMWF     April 2015
 C
@@ -79,14 +79,12 @@ C
       REAL OLDFLD(*), NEWFLD(*)
 C
 #include "parim.h"
-#include "intisl.h"
-#include "nifld.common"
 #include "nofld.common"
 #include "grfixed.h"
 C
 C     Parameters
 C
-      INTEGER JPINTB, JPREALB, JPMAXNG
+      INTEGER JPINTB
       INTEGER JSEC2
       PARAMETER (JSEC2 = 5000)
 #ifdef INTEGER_8
@@ -94,20 +92,13 @@ C
 #else
       PARAMETER (JPINTB = 4)
 #endif
-      PARAMETER (JPMAXNG=4000)
-#ifdef REAL_8
-      PARAMETER (JPREALB = 8)
-#else
-      PARAMETER (JPREALB = 8)
-#endif
 C
 C     Local variables
 C
       INTEGER OLDGEO(JSEC2), NEWGEO(JSEC2)
       INTEGER LOOP
-C
+      CHARACTER*1 HTYPE
       REAL PLAT(JPMAXNG)
-      REAL PFSEC3(2)
 C
       INTEGER IRET
 C
@@ -137,34 +128,34 @@ C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
-      DO LOOP = 1, JPMAXNG
-        OLDGEO(LOOP) = 0
-      ENDDO
+      OLDGEO(1:JPMAXNG) = 0
       DO LOOP = 1, 2*NUMGGO
-            OLDGEO(22+LOOP) = MILLEN(LOOP)
+        OLDGEO(22+LOOP) = MILLEN(LOOP)
       ENDDO
-      CALL JGETGG( NUMGGO, 'U', PLAT, OLDGEO(23), IRET)
+      HTYPE = 'U'
+      CALL JGETGG(NUMGGO,HTYPE,PLAT,OLDGEO(23),IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RGU: Problem calling JGETGG, status = ',IRET
         KRG2RGU = -1
       RETURN
       ENDIF
-C      DO LOOP = 1, NUMGGO
-C        WRITE(*,*) 'KRG2RGU: >>>>> ',LOOP,' = ',OLDGEO(22+LOOP),'',MILLEN(LOOP)
-C      ENDDO
 
 C
       OLDGEO(3)  = NUMGGO * 2
       OLDGEO(4)  = NINT(PLAT(1)*1000.0)
       OLDGEO(5)  = 0
       OLDGEO(7)  = NINT(PLAT(NUMGGO*2)*1000.0)
-      OLDGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGO*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     OLDGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGO*4)))*1000.0)
+      OLDGEO(8)  = NINT((360.0-(360.0/REAL(OLDGEO(23+NUMGGO))))*1000.0)
       OLDGEO(10) = NUMGGO
 C
       DO LOOP = 1, JPMAXNG
         NEWGEO(LOOP) = 0
       ENDDO
-      CALL JGETGG( NUMGGN, 'R', PLAT, NEWGEO(23), IRET)
+      HTYPE = 'R'
+      IF( LOCTAHEDRAL ) HTYPE = 'O'
+      CALL JGETGG(NUMGGN,HTYPE,PLAT,NEWGEO(23),IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RGU: Problem calling JGETGG, status = ',IRET
         KRG2RGU = -1
@@ -174,7 +165,9 @@ C
       NEWGEO(4)  = NINT(PLAT(1)*1000.0)
       NEWGEO(5)  = 0
       NEWGEO(7)  = NINT(PLAT(NUMGGN*2)*1000.0)
-      NEWGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGN*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     NEWGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGN*4)))*1000.0)
+      NEWGEO(8)  = NINT((360.0-(360.0/REAL(NEWGEO(23+NUMGGN))))*1000.0)
       NEWGEO(10) = NUMGGN
 C
       IRET = KINTRG(OLDGEO, NEWGEO, OLDFLD, NEWFLD)
diff --git a/interpolation/krg2rgy.F b/interpolation/krg2rgy.F
index d7d484f..49eece6 100644
--- a/interpolation/krg2rgy.F
+++ b/interpolation/krg2rgy.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -72,23 +72,15 @@ C
       INTEGER NUMGG, OLDFLD(*), NEWFLD(*)
 C
 #include "parim.h"
-#include "intisl.h"
 #include "nifld.common"
 #include "nofld.common"
 #include "grfixed.h"
-#include "current.h"
 C
 C     Parameters
 C
-      INTEGER JPACK, JUNPACK, JPINTB, JPREALB, JPMAXNG
+      INTEGER JPACK, JUNPACK, JPREALB
       PARAMETER (JPACK   = 4000000)
       PARAMETER (JUNPACK = 6000000)
-#ifdef INTEGER_8
-      PARAMETER (JPINTB = 8)
-#else
-      PARAMETER (JPINTB = 4)
-#endif
-      PARAMETER (JPMAXNG=4000)
 #ifdef REAL_8
       PARAMETER (JPREALB = 8)
 #else
@@ -99,11 +91,10 @@ C     Local variables
 C
       INTEGER IFSEC0(JPGRIB_ISEC0),IFSEC1(JPGRIB_ISEC1),
      X IFSEC2(JPGRIB_ISEC2),IFSEC3(JPGRIB_ISEC3),IFSEC4(JPGRIB_ISEC4)
-      INTEGER NFSEC0(JPGRIB_ISEC0),NFSEC1(JPGRIB_ISEC1),
-     X NFSEC2(JPGRIB_ISEC2),NFSEC3(JPGRIB_ISEC3),NFSEC4(JPGRIB_ISEC4)
-
+      INTEGER NFSEC2(JPGRIB_ISEC2)
       INTEGER ISIZE, LOOP
       LOGICAL LFIRST
+      CHARACTER*1 HTYPE
 #ifndef _CRAYFTN
 #if (!defined sgi)
 #ifdef POINTER_64
@@ -116,7 +107,6 @@ C
 C
       REAL PLAT(JPMAXNG)
       REAL ZFSEC2(5000), ZFSEC3(2), ZFSEC4(1)
-      REAL PFSEC3(2), PFSEC4(1)
 C
       POINTER( IZFSEC4, ZFSEC4 )
 C
@@ -200,7 +190,9 @@ C
       DO LOOP = 1, JPMAXNG
         NFSEC2(LOOP) = IFSEC2(LOOP)
       ENDDO
-      CALL JGETGG( NUMGG, 'R', PLAT, NFSEC2(23), IRET)
+      HTYPE = 'R'
+      IF( LOCTAHEDRAL ) HTYPE = 'O'
+      CALL JGETGG( NUMGG, HTYPE, PLAT, NFSEC2(23), IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RGY: Problem calling JGETGG, status = ',IRET
         KRG2RGY = -1
@@ -209,7 +201,9 @@ C
       NFSEC2(3)  = NUMGG * 2
       NFSEC2(4)  = NINT(PLAT(1)*1000.0)
       NFSEC2(7)  = NINT(PLAT(NUMGG*2)*1000.0)
-      NFSEC2(8)  = NINT((360.0-(360.0/REAL(NUMGG*4)))*1000.0)
+c     EMOS-199: NFSEC2(8) adjusted for reduced_gg/octahedral
+c     NFSEC2(8)  = NINT((360.0-(360.0/REAL(NUMGG*4)))*1000.0)
+      NFSEC2(8)  = NINT((360.0-(360.0/REAL(NFSEC2(23+NUMGG))))*1000.0)
       NFSEC2(10) = NUMGG
 C
       IRET = KINTRG(IFSEC2, NFSEC2, ZFSEC4, NEWFLD)
@@ -219,28 +213,20 @@ C
         RETURN
       ENDIF
       IF( LDOUBLE ) THEN
-         CALL INTLOG(JP_DEBUG,
-     X   'KRG2RGY: Set NIAREA - double interpolation',JPQUIET)
-c         NIAREA(1)  = NFSEC2(4)*100
-c         NIAREA(2)  = NFSEC2(5)*100
-c         NIAREA(3)  = NFSEC2(7)*100
-c         NIAREA(4)  = NFSEC2(8)*100
-         NIAREA(1)  = 0
-         NIAREA(2)  = 0
-         NIAREA(3)  = 0 
-         NIAREA(4)  = 0
-         NIGAUSS    = NUMGG
-        DO LOOP = 1, NINS
-          RIGAUSS(LOOP) = 0
-          MILLEN(LOOP) = 0
-        ENDDO
-         NINS       = NUMGG*2
-         CALL INTLOG(JP_DEBUG, 'KRG2RGY: NIAREA(1) ',NIAREA(1))
-         CALL INTLOG(JP_DEBUG, 'KRG2RGY: NIAREA(2) ',NIAREA(2))
-         CALL INTLOG(JP_DEBUG, 'KRG2RGY: NIAREA(3) ',NIAREA(3))
-         CALL INTLOG(JP_DEBUG, 'KRG2RGY: NIAREA(4) ',NIAREA(4))
-         CALL INTLOG(JP_DEBUG, 'KRG2RGY: NIGAUSS ',NIGAUSS)
-         CALL INTLOG(JP_DEBUG, 'KRG2RGY: NINS ',NINS)
+        CALL INTLOG(JP_DEBUG,
+     X    'KRG2RGY: Set NIAREA - double interpolation',JPQUIET)
+c       NIAREA(1)  = NFSEC2(4)*100
+c       NIAREA(2)  = NFSEC2(5)*100
+c       NIAREA(3)  = NFSEC2(7)*100
+c       NIAREA(4)  = NFSEC2(8)*100
+        NIAREA(1)  = 0
+        NIAREA(2)  = 0
+        NIAREA(3)  = 0
+        NIAREA(4)  = 0
+        NIGAUSS    = NUMGG
+        RIGAUSS(1:NINS) = 0
+        MILLEN (1:NINS) = 0
+        NINS       = NUMGG*2
       ENDIF
 
 C
diff --git a/interpolation/krg2rgz.F b/interpolation/krg2rgz.F
index 90209ae..81cbb3a 100644
--- a/interpolation/krg2rgz.F
+++ b/interpolation/krg2rgz.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -72,14 +72,13 @@ C
       REAL OLDFLD(*), NEWFLD(*)
 C
 #include "parim.h"
-#include "intisl.h"
 #include "nifld.common"
 #include "nofld.common"
 #include "grfixed.h"
 C
 C     Parameters
 C
-      INTEGER JPINTB, JPREALB, JPMAXNG
+      INTEGER JPINTB
       INTEGER JSEC2
       PARAMETER (JSEC2 = 5000)
 #ifdef INTEGER_8
@@ -87,23 +86,15 @@ C
 #else
       PARAMETER (JPINTB = 4)
 #endif
-      PARAMETER (JPMAXNG=4000)
-#ifdef REAL_8
-      PARAMETER (JPREALB = 8)
-#else
-      PARAMETER (JPREALB = 8)
-#endif
 C
 C     Local variables
 C
       INTEGER OLDGEO(JSEC2), NEWGEO(JSEC2)
       INTEGER LOOP
-C
+      CHARACTER*1 HTYPE
       REAL PLAT(JPMAXNG)
-      REAL PFSEC3(2)
 C
       INTEGER IRET
-      LOGICAL LDEBUG
 C
 C     Externals
 C
@@ -135,7 +126,8 @@ C
 cs        OLDGEO(LOOP) = 0
         OLDGEO(LOOP+22) = MILLEN(LOOP)
       ENDDO
-cs      CALL JGETGG( NUMGGO, 'R', PLAT, OLDGEO(23), IRET)
+cs      HTYPE = 'R'
+cs      CALL JGETGG(NUMGGO,HTYPE,PLAT,OLDGEO(23),IRET)
 cs      IF( IRET.NE.0 ) THEN
 cs        WRITE(*,*) 'KRG2RGZ: Problem calling JGETGG, status = ',IRET
 cs        KRG2RGZ = -1
@@ -147,13 +139,17 @@ C
       OLDGEO(4)  = NINT(PLAT(1)*1000.0)
       OLDGEO(5)  = 0
       OLDGEO(7)  = NINT(PLAT(NUMGGO*2)*1000.0)
-      OLDGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGO*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     OLDGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGO*4)))*1000.0)
+      OLDGEO(8)  = NINT((360.0-(360.0/REAL(OLDGEO(23+NUMGGO))))*1000.0)
       OLDGEO(10) = NUMGGO
 C
       DO LOOP = 1, JPMAXNG
         NEWGEO(LOOP) = 0
       ENDDO
-      CALL JGETGG( NUMGGN, 'R', PLAT, NEWGEO(23), IRET)
+      HTYPE = 'R'
+      IF( LOCTAHEDRAL ) HTYPE = 'O'
+      CALL JGETGG(NUMGGN,HTYPE,PLAT,NEWGEO(23),IRET)
       IF( IRET.NE.0 ) THEN
         WRITE(*,*) 'KRG2RGZ: Problem calling JGETGG, status = ',IRET
         KRG2RGZ = -1
@@ -163,7 +159,9 @@ C
       NEWGEO(4)  = NINT(PLAT(1)*1000.0)
       NEWGEO(5)  = 0
       NEWGEO(7)  = NINT(PLAT(NUMGGN*2)*1000.0)
-      NEWGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGN*4)))*1000.0)
+c     EMOS-199: adjusted for reduced_gg/octahedral
+c     NEWGEO(8)  = NINT((360.0-(360.0/REAL(NUMGGN*4)))*1000.0)
+      NEWGEO(8)  = NINT((360.0-(360.0/REAL(NEWGEO(23+NUMGGN))))*1000.0)
       NEWGEO(10) = NUMGGN
 C
       IRET = KINTRG(OLDGEO, NEWGEO, OLDFLD, NEWFLD)
@@ -195,14 +193,6 @@ cs          RIGAUSS(LOOP) = 0
 cs          MILLEN(LOOP) = 0
 cs        ENDDO
          NINS       = NUMGGN*2
-cs         IF( LDEBUG ) THEN
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NIAREA(1) ',NIAREA(1))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NIAREA(2) ',NIAREA(2))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NIAREA(3) ',NIAREA(3))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NIAREA(4) ',NIAREA(4))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NIGAUSS ',NIGAUSS)
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NINS ',NINS)
-cs         ENDIF
       ELSE
 c sinisa for merging with grib_api
          NONS      = 2 * NUMGGN
@@ -215,14 +205,6 @@ c sinisa for merging with grib_api
          NOAREA(2) = NEWGEO(5)*JPMICRO
          NOAREA(3) = NEWGEO(7)*JPMICRO
          NOAREA(4) = NEWGEO(8)*JPMICRO
-cs         IF( LDEBUG ) THEN
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NOAAPI(1) ',NOAAPI(1))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NOAAPI(2) ',NOAAPI(2))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NOAAPI(3) ',NOAAPI(3))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NOAAPI(4) ',NOAAPI(4))
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NOGAUSS ',NOGAUSS)
-           CALL INTLOG(JP_DEBUG, 'KRG2RGZ: NONS ',NONS)
-cs         ENDIF
       ENDIF
 C
 C     -----------------------------------------------------------------|
diff --git a/interpolation/lgrpr4.F b/interpolation/lgrpr4.F
deleted file mode 100644
index bf24dcd..0000000
--- a/interpolation/lgrpr4.F
+++ /dev/null
@@ -1,225 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE LGRPR4 (KSEC0,KLINE,KSEC4,PSEC4)
-C
-C---->
-C**** lgrpr4 - Print information from Section 4 of GRIB code.
-C
-C     Purpose.
-C     --------
-C
-C           Print the information in the Binary data section
-C           Section (Section 4) of decoded GRIB data.
-C
-C**   Interface.
-C     ----------
-C
-C           CALL lgrpr4 (KSEC0,KSEC4,PSEC4)
-C
-C           Integer    K.
-C           Real       P.
-C           Logical    O.
-C           Character  H.
-C
-C               Input Parameters.
-C               -----------------
-C
-C               KSEC0 - Array of decoded integers from Section 0.
-C
-C               KSEC4 - Array of decoded integers from Section 4.
-C
-C               PSEC4 - Array of decoded reals from Section 4.
-C
-C               Output Parameters.
-C               ------------------
-C
-C               None.
-C
-C     Method.
-C     -------
-C
-C           Fields printed as integers or reals.
-C
-C     Externals.
-C     ----------
-C
-C           None.
-C
-C     Reference.
-C     ----------
-C
-C           WMO Manual on Codes re GRIB Code.
-C           See also routine GRIBEX.
-C
-C     Comments.
-C     ---------
-C
-C           Routine contains Sections 0 to 1 and Section 9.
-C
-C     Author.
-C     -------
-C
-C           J. Hennessy    ECMWF 11.09.91
-C
-C     Modifications.
-C     --------------
-C
-C           K. Fielding    ecmwf 03/08/92
-C           Special version with reduced printout for Monthly
-C           means and time series
-C
-C----<
-C     -----------------------------------------------------------------
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------
-      IMPLICIT NONE
-C
-C*    Prefix conventions for variable names.
-C
-C     Logical      L (but not LP), global or common.
-C                  O, dummy arguments.
-C                  G, local variable.
-C                  LP, parameter.
-C     Character    C, Global or common.
-C                  H, dummy arguments.
-C                  Y (but not YP), local variables.
-C                  YP, parameter.
-C     Integer      M and N, global or common.
-C                  K, dummy arguments.
-C                  I, local variables.
-C                  J (but not JP), loop control.
-C                  JP, parameter.
-C     Real         A to F and Q to X, global or common.
-C                  P (but not PP), dummy arguments.
-C                  Z, local variables.
-C                  PP, parameter.
-C
-*IF DEF,CRAY
-C     IMPLICIT NONE
-*ENDIF
-C
-      INTEGER INUM
-C
-      INTEGER J210, J220
-C
-      INTEGER KSEC0
-      INTEGER KSEC4
-      INTEGER KLINE
-C
-      REAL PSEC4
-C
-      DIMENSION KSEC0(*)
-      DIMENSION KSEC4(*)
-C
-      DIMENSION PSEC4(*)
-C
-C     -----------------------------------------------------------------
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C*    Section 1 . Print integer information from KSEC4.
-C     -----------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WRITE (*,9000)
-      WRITE (*,9001)
-      WRITE (*,9002)
-C
-      WRITE (*,9003) KSEC4(1)
-      WRITE (*,9004) KSEC4(2)
-C     WRITE (*,9005) KSEC4(3)
-C     WRITE (*,9006) KSEC4(4)
-C     WRITE (*,9007) KSEC4(5)
-C     WRITE (*,9008) KSEC4(6)
-C     WRITE (*,9009) KSEC4(7)
-C     WRITE (*,9010) KSEC4(8)
-C
-C     -----------------------------------------------------------------
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C
-C*    Section 2. Print real values from PSEC4.
-C     -----------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      WRITE (*,9000)
-C
-      INUM = KSEC4(1)
-      IF (INUM.LT.0)  INUM = - INUM
-      IF (INUM.GT.10) INUM = 10
-C
-C     Print first INUM values.
-C
-      WRITE (*,9011) INUM
-      DO 220 J220 = 0, 3
-         WRITE (*, *)
-      DO 210 J210=1,INUM
-	 WRITE (*,9012) PSEC4(J220 * KLINE + J210)
-  210 CONTINUE
-  220 CONTINUE
-C
-C     -----------------------------------------------------------------
-C
-C
-C
-C
-C
-C
-C
-C*    Section 9 . Format statements. Return to calling routine.
-C     -----------------------------------------------------------------
-C
-  900 CONTINUE
-C
- 9000 FORMAT (1H )
- 9001 FORMAT (1H ,'Section 4 - Binary Data  Section.')
- 9002 FORMAT (1H ,'-------------------------------------')
- 9003 FORMAT (1H ,'Number of data values coded/decoded.         ',I9)
- 9004 FORMAT (1H ,'Number of bits per data value.               ',I9)
- 9005 FORMAT (1H ,'Type of data indicator.                      ',I9)
- 9006 FORMAT (1H ,'Type of packing indicator.                   ',I9)
- 9007 FORMAT (1H ,'Type of data representation.                 ',I9)
- 9008 FORMAT (1H ,'Additional flags indicator.                  ',I9)
- 9009 FORMAT (1H ,'Reserved.                                    ',I9)
- 9010 FORMAT (1H ,'Number of values indicator.                  ',I9)
- 9011 FORMAT (1H ,'First ',I4,' data values.')
- 9012 FORMAT (1H ,F30.15)
-C
-      RETURN
-C
-      END
diff --git a/interpolation/lrekam.F b/interpolation/lrekam.F
deleted file mode 100644
index 44b616f..0000000
--- a/interpolation/lrekam.F
+++ /dev/null
@@ -1,191 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION LREKAM(SHCIN,KTRUNC,SHCOUT,RANGLES)
-C
-C---->
-C**** LREKAM
-C
-C     Purpose
-C     -------
-C
-C     Reverses the rotation of a spherical harmonic field done by
-C     MAKERL.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = LREKAM(SHCIN,KTRUNC,SHCOUT,RANGLES)
-C
-C     Input
-C     -----
-C
-C     SHCIN   - Input array of spherical harmonics.
-C     KTRUNC  - Truncation of the spherical harmonics.
-C     RANGLES - Coordinates of the south pole of rotation:
-C               latitude/longitude.
-C
-C
-C     Output
-C     ------
-C
-C     SHCOUT  - Output array of rotated spherical harmonics.
-C
-C     Function returns 0 if all OK, otherwise the rotations failed.
-C
-C
-C     Method
-C     ------
-C
-C     Calls JACOBI and RPHI in the reverse order to that done by MAKERL.
-C
-C
-C     Externals
-C     ---------
-C
-C     RPHI    - Rotates spectral coefficients by longitude.
-C     JACOBI  - Rotates spectral coefficients by latitude.
-C     INTLOG  - Logs messages.
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers         ECMWF     October, 1995.
-C
-C
-C----<
-C---------------------------------------------------------------------
-C
-C
-      IMPLICIT NONE
-#include "parim.h"
-#include "nofld.common"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 28400)
-      INTEGER JPLEN, JPNM
-      PARAMETER ( JPNM = JPSTRUNC )
-      PARAMETER ( JPLEN = (JPNM+1)*(JPNM+2) )
-C
-C     Function arguments.
-C
-      REAL SHCIN, SHCOUT, RANGLES
-      DIMENSION SHCIN(*), SHCOUT(*), RANGLES(*)
-      INTEGER KTRUNC
-C
-C     Local variables
-C
-      REAL*8 DLON, DLAT
-      REAL*8 WORK
-      DIMENSION WORK(2*(JPNM+1)*(JPNM+6))
-      LOGICAL LOK
-      INTEGER NBYTES, LOOP
-#if (defined REAL_8)
-      DATA NBYTES/8/
-#else
-      DATA NBYTES/4/
-      REAL*8 DATA
-      DIMENSION DATA(JPLEN)
-#endif
-C
-C     Externals
-C
-      LOGICAL JACOBI
-      EXTERNAL JACOBI
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialise.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      LREKAM = 0
-C
-C     Check truncation not too big to handle.
-C
-      IF( KTRUNC .GT. JPSTRUNC ) THEN
-        CALL INTLOG(JP_FATAL,'LREKAM: Truncation max exceeded', JPQUIET)
-        CALL INTLOG(JP_FATAL,'LREKAM: Truncation = ', KTRUNC)
-        CALL INTLOG(JP_FATAL,'LREKAM: Allowed maximum = ', JPSTRUNC)
-        LREKAM = JPROUTINE + 1
-         GOTO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 2. Rotate the spectral coefficients.
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-#if (defined REAL_8)
-      DLAT = -(-90.0 - RANGLES(1))
-      DLON = RANGLES(2)
-C
-C     Rotate the spectral field by latitude.
-C     Negative DLAT => rotate counter-clockwise about new polar axis.
-C
-      LOK = JACOBI( SHCIN, KTRUNC, WORK, DLAT)
-      IF(.NOT.LOK) THEN
-        CALL INTLOG(JP_FATAL,'LREKAM: JACOBI failed.', JPQUIET)
-        LREKAM = JPROUTINE + 2
-         GOTO 900
-      ENDIF
-C
-C     Rotate the spectral field by longitude.
-C     Positive DLON => frame rotated from west to east.
-C
-      DO 210 LOOP = 1, (KTRUNC+1)*(KTRUNC+2)
-        SHCOUT(LOOP) = SHCIN(LOOP)
-  210 CONTINUE
-      CALL RPHI( SHCOUT, KTRUNC, WORK, DLON)
-#else
-      DLAT = -(-90.0 - DBLE(RANGLES(1)))
-      DLON = DBLE(RANGLES(2))
-C
-C     Expand spectral coefficients to REAL*8
-      DO 210 LOOP = 1, (KTRUNC+1)*(KTRUNC+2)
-        DATA(LOOP) = DBLE(SHCIN(LOOP))
-  210 CONTINUE
-C
-C     Rotate the spectral field by latitude.
-C     Negative DLAT => rotate counter-clockwise about new polar axis.
-C
-      LOK = JACOBI( DATA, KTRUNC, WORK, DLAT)
-      IF(.NOT.LOK) THEN
-        CALL INTLOG(JP_FATAL,'LREKAM: JACOBI failed.', JPQUIET)
-        LREKAM = JPROUTINE + 2
-         GOTO 900
-      ENDIF
-C
-C     Rotate the spectral field by longitude.
-C     Positive DLON => frame rotated from west to east.
-C
-      CALL RPHI( DATA, KTRUNC, WORK, DLON)
-C
-C     Repack spectral coefficients to REAL*4.
-      DO 220 LOOP = 1, (KTRUNC+1)*(KTRUNC+2)
-        SHCOUT(LOOP) = SNGL(DATA(LOOP))
-  220 CONTINUE
-#endif
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return.
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/lsmfld.F b/interpolation/lsmfld.F
index 8fb297e..0930bea 100644
--- a/interpolation/lsmfld.F
+++ b/interpolation/lsmfld.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -77,6 +77,7 @@ C
 C
 C     If 'uselsm' has been forced to 'yes' ...
 C
+      LSMFLD = .FALSE.
       IF( LSMSET ) THEN
         LSMFLD = LSM
         GOTO 900
@@ -90,8 +91,8 @@ C
 C     ECMWF local code table 128 for meteorological parameters
 C
       ELSEIF ( (NITABLE.EQ.128).OR.(NITABLE.EQ.129) ) THEN
-        LIKELY = ( NIPARAM.NE.151 ).AND.
-     X           ( NIPARAM.NE.172 )
+        LIKELY = ( NIPARAM.NE.151 ).AND.  !msl
+     X           ( NIPARAM.NE.172 )       !lsm
       ELSE
         LIKELY = .FALSE.
       ENDIF
diff --git a/interpolation/makemap.c b/interpolation/makemap.c
index 1324079..52ed6ab 100644
--- a/interpolation/makemap.c
+++ b/interpolation/makemap.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -15,6 +15,7 @@
 #include <ctype.h>
 
 #include "bitmap.h"
+#include "common/fortint.h"
 
 #define BUFFLEN 50000
 #define NOTSET -1
diff --git a/interpolation/makerl.F b/interpolation/makerl.F
deleted file mode 100644
index d9b6905..0000000
--- a/interpolation/makerl.F
+++ /dev/null
@@ -1,192 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION MAKERL(SHCIN,KTRUNC,SHCOUT,RANGLES)
-C
-C---->
-C**** MAKERL
-C
-C     Purpose
-C     -------
-C
-C     Rotates a spherical harmonic field.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = MAKERL(SHCIN,KTRUNC,SHCOUT,RANGLES)
-C
-C     Input
-C     -----
-C
-C     SHCIN   - Input array of spherical harmonics.
-C     KTRUNC  - Truncation of the spherical harmonics.
-C     RANGLES - Coordinates of the south pole of rotation:
-C               latitude/longitude.
-C
-C
-C     Output
-C     ------
-C
-C     SHCOUT  - Output array of rotated spherical harmonics.
-C
-C     Function returns 0 if all OK, otherwise the rotations failed.
-C
-C
-C     Method
-C     ------
-C
-C     None.
-C
-C
-C     Externals
-C     ---------
-C
-C     RPHI    - Rotates spectral coefficients by longitude.
-C     JACOBI  - Rotates spectral coefficients by latitude.
-C     INTLOG  - Logs messages.
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers         ECMWF     October, 1995.
-C
-C
-C----<
-C---------------------------------------------------------------------
-C
-C
-      IMPLICIT NONE
-#include "parim.h"
-#include "nofld.common"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 28300)
-      INTEGER JPLEN, JPNM
-      PARAMETER ( JPNM = JPSTRUNC )
-      PARAMETER ( JPLEN = (JPNM+1)*(JPNM+2) )
-C
-C     Function arguments.
-C
-      REAL SHCIN, SHCOUT, RANGLES
-      DIMENSION SHCIN(*), SHCOUT(*), RANGLES(*)
-      INTEGER KTRUNC
-C
-C     Local variables
-C
-      REAL*8 DLON, DLAT
-      REAL*8 WORK
-      DIMENSION WORK(2*(JPNM+1)*(JPNM+6))
-      LOGICAL LOK
-      INTEGER NBYTES, LOOP
-#if (defined REAL_8)
-      DATA NBYTES/8/
-#else
-      DATA NBYTES/4/
-      REAL*8 DATA
-      DIMENSION DATA(JPLEN)
-#endif
-C
-C     Externals
-C
-      LOGICAL JACOBI
-      EXTERNAL JACOBI
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialise.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      MAKERL = 0
-C
-C     Check truncation not too big to handle.
-C
-      IF( KTRUNC .GT. JPSTRUNC ) THEN
-        CALL INTLOG(JP_FATAL,'MAKERL: Truncation max exceeded', JPQUIET)
-        CALL INTLOG(JP_FATAL,'MAKERL: Truncation = ', KTRUNC)
-        CALL INTLOG(JP_FATAL,'MAKERL: Allowed maximum = ', JPSTRUNC)
-        MAKERL = JPROUTINE + 1
-         GOTO 900
-      ENDIF
-C
-C     _______________________________________________________
-C
-C*    Section 2. Rotate the spectral coefficients.
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-#if (defined REAL_8)
-      DLAT = -90.0 - RANGLES(1)
-      DLON = -RANGLES(2)
-C
-C     Rotate the spectral field by longitude.
-C     Positive DLON => frame rotated from west to east.
-C
-      DO 210 LOOP = 1, (KTRUNC+1)*(KTRUNC+2)
-        SHCOUT(LOOP) = SHCIN(LOOP)
-  210 CONTINUE
-      CALL RPHI( SHCOUT, KTRUNC, WORK, DLON)
-C
-C     Rotate the spectral field by latitude.
-C     Negative DLAT => rotate counter-clockwise about new polar axis.
-C
-      LOK = JACOBI( SHCOUT, KTRUNC, WORK, DLAT)
-      IF(.NOT.LOK) THEN
-        CALL INTLOG(JP_FATAL,'MAKERL: JACOBI failed.', JPQUIET)
-        MAKERL = JPROUTINE + 2
-         GOTO 900
-      ENDIF
-#else
-      DLAT = -90.0 - DBLE(RANGLES(1))
-      DLON = -DBLE(RANGLES(2))
-C
-C     Expand spectral coefficients to REAL*8
-C
-      DO 210 LOOP = 1, (KTRUNC+1)*(KTRUNC+2)
-        DATA(LOOP) = DBLE(SHCIN(LOOP))
-  210 CONTINUE
-C
-C     Rotate the spectral field by longitude.
-C     Positive DLON => frame rotated from west to east.
-C
-      CALL RPHI( DATA, KTRUNC, WORK, DLON)
-C
-C     Rotate the spectral field by latitude.
-C     Negative DLAT => rotate counter-clockwise about new polar axis.
-C
-      LOK = JACOBI( DATA, KTRUNC, WORK, DLAT)
-      IF(.NOT.LOK) THEN
-        CALL INTLOG(JP_FATAL,'MAKERL: JACOBI failed.', JPQUIET)
-        MAKERL = JPROUTINE + 2
-         GOTO 900
-      ENDIF
-C
-C     Repack spectral coefficients to REAL*4.
-C
-      DO 220 LOOP = 1, (KTRUNC+1)*(KTRUNC+2)
-        SHCOUT(LOOP) = SNGL(DATA(LOOP))
-  220 CONTINUE
-#endif
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return.
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/my_ialloc.c b/interpolation/my_ialloc.c
deleted file mode 100644
index a68cb96..0000000
--- a/interpolation/my_ialloc.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-
-#define IA_CONT 00001
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define MY_IALLOC my_ialloc 
-#else
-#define MY_IALLOC my_ialloc_
-#endif
-
-void MY_IALLOC( FILE ** kunit, long * isize, long * kret)
-{
-    *kret = 0;
-    return;
-}
diff --git a/interpolation/ngintrp.F b/interpolation/ngintrp.F
index 9acacc6..a7a4fd5 100644
--- a/interpolation/ngintrp.F
+++ b/interpolation/ngintrp.F
@@ -1,14 +1,14 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      SUBROUTINE NGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,TYPE,FIELD,
+      SUBROUTINE NGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,HTYPE,FIELD,
      X                   GLATS, NGPTS)
 C
 C---->
@@ -23,7 +23,7 @@ C
 C     INTERFACE
 C     _________
 C
-C     CALL NGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,TYPE,FIELD)
+C     CALL NGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,HTYPE,FIELD)
 C
 C
 C     Input parameters
@@ -34,10 +34,12 @@ C     NEXT    - Start offset of the latitude row being created
 C     INROW   - The number of points in the latitude row
 C     OLAT    - Latitude of target point
 C     OLON    - Longitude of target point
-C     NGAUSS  - Gaussian field number
-C     TYPE    - Original unrotated gaussian field type
-C               = 'F' for full (regular) gaussian field
-C               = 'R' for reduced (quasi) gaussian field
+C     NGAUSS  - Gaussian grid number (original, unrotated)
+C     HTYPE   - Gaussian grid type (original, unrotated)
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full,
+C               = 'U' for user-defined reduced gaussian grid
 C     FIELD   - Original gaussian field
 C     GLATS   - Gaussian latitudes for original field
 C     NGPTS   - Number of points along original field latitudes
@@ -111,15 +113,16 @@ C
 C
 C     Function arguments
 C
-      REAL NEWFLD(*),OLAT(*),OLON(*),FIELD(*),GLATS(*)
-      INTEGER NEXT,INROW,NGAUSS,NGPTS(*)
-      CHARACTER*1 TYPE
+      REAL NEWFLD, OLAT, OLON, FIELD
+      DIMENSION NEWFLD(*), OLAT(*), OLON(*), FIELD(*)
+      INTEGER NEXT, INROW, NGAUSS
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
       INTEGER LOOP, IVALUE
       INTEGER NORTH, SOUTH, IWESTN, IWESTS, IEASTN, IEASTS
-      REAL NSTEP, SSTEP
+      REAL NSTEP, SSTEP, PEAST
       DIMENSION NORTH(JPMAXGG), SOUTH(JPMAXGG)
       DIMENSION IWESTN(JPMAXGG), IWESTS(JPMAXGG)
       DIMENSION IEASTN(JPMAXGG), IEASTS(JPMAXGG)
@@ -128,8 +131,10 @@ C
       DIMENSION DNORTH(JPMAXGG), DSOUTH(JPMAXGG)
       DIMENSION DWESTN(JPMAXGG), DWESTS(JPMAXGG)
       DIMENSION DEASTN(JPMAXGG), DEASTS(JPMAXGG)
+      REAL GLATS(*)
+      INTEGER NGPTS(*)
       INTEGER KOFSET(JPMAXGG/2)
-      INTEGER KRET, OLDGAUS
+      INTEGER OLDGAUS
       DATA OLDGAUS/0/
       CHARACTER*1 OLDTYPE
       DATA OLDTYPE/' '/
@@ -153,26 +158,29 @@ C     _______________________________________________________
 C
   100 CONTINUE
 C
-C     Fixup gaussian grid definition (first time only)
+C     Get gaussian grid definition (first time only)
 C
-      IF ( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.TYPE) ) THEN
+      IF ( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.HTYPE) ) THEN
 C
         CALL INTLOG(JP_DEBUG,
-     X    'NGINTRP: Fixup gaussian grid definition:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
+     X    'NGINTRP: Get gaussian grid type:',JPQUIET)
+        CALL INTLOG(JP_DEBUG,HTYPE,JPQUIET)
         CALL INTLOG(JP_DEBUG, 'NGINTRP: grid number:',NGAUSS)
 C
 C       Build array of offsets in field to start of each latitude line
 C
         CALL INTLOG(JP_DEBUG,'NGINTRP: Build row offsets',JPQUIET)
-        IF( TYPE.EQ.'R') THEN
-          CALL JMKOFGG(TYPE,1,NGAUSS*2,0.0,360.0,NGAUSS,NGPTS,KOFSET)
+        IF( HTYPE.EQ.'R' .OR. HTYPE.EQ.'r' .OR.
+     X      HTYPE.EQ.'O' .OR. HTYPE.EQ.'o' .OR.
+     X      HTYPE.EQ.'U' .OR. HTYPE.EQ.'u' ) THEN
+C         (this value will not be used by JMKOFGG)
+          PEAST = 360.
         ELSE
-          CALL JMKOFGG(TYPE,1,NGAUSS*2,0.0,(360.0-(90.0/NGAUSS)),
-     X                 NGAUSS,NGPTS,KOFSET)
+          PEAST = 360. - (90./NGAUSS)
         ENDIF
+        CALL JMKOFGG(HTYPE,1,NGAUSS*2,0.0,PEAST,NGAUSS,NGPTS,KOFSET)
         OLDGAUS = NGAUSS
-        OLDTYPE = TYPE
+        OLDTYPE = HTYPE
       ENDIF
 C
 C     _______________________________________________________
diff --git a/interpolation/ngrotat.F b/interpolation/ngrotat.F
index 8333594..6788d64 100644
--- a/interpolation/ngrotat.F
+++ b/interpolation/ngrotat.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION NGROTAT(OLDFLD, NEWFLD, NUMPTS, POLELAT, POLELON,
-     X                         TYPE, NGAUSS)
+     X                         HTYPE, NGAUSS)
 C
 C---->
 C**** NGROTAT
@@ -22,24 +22,26 @@ C
 C     INTERFACE
 C     _________
 C
-C     IRET = NGROTAT(OLDFLD,NEWFLD,NUMPTS,POLELAT,POLELON,TYPE,NGAUSS)
+C     IRET = NGROTAT(OLDFLD,NEWFLD,NUMPTS,POLELAT,POLELON,HTYPE,NGAUSS)
 C
 C
 C     Input parameters
 C     ________________
 C
-C     OLDFLD  = Original gaussian grid field.
-C     NUMPTS  = Total number of points in the original field.
-C     POLELAT = Latitude of the South Pole of rotation.
-C     POLELON = Longitude of the South Pole of rotation.
-C     TYPE    = 'R' if the gaussian field is reduced (quasi) gaussian.
-C             = 'F' if the gaussian field is regular (full) gaussian.
-C     NGAUSS  = Gaussian grid number (number of latitude rows between
-C               the pole and the equator).
+C     OLDFLD  - Original gaussian grid field.
+C     NUMPTS  - Total number of points in the original field.
+C     POLELAT - Latitude of the South Pole of rotation.
+C     POLELON - Longitude of the South Pole of rotation.
+C     NGAUSS  - Gaussian grid number
+C     HTYPE   - Gaussian grid type
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full,
+C               = 'U' for user-defined reduced gaussian grid
 C
 C     Output parameters
 C     ________________
-C    
+C
 C     NEWFLD  = New gaussian grid field.
 C               (This can be the same array as OLDFLD).
 C
@@ -114,7 +116,7 @@ C
       REAL OLDFLD, NEWFLD, POLELAT, POLELON
       INTEGER NUMPTS, NGAUSS
       DIMENSION OLDFLD(NUMPTS), NEWFLD(NUMPTS)
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -127,7 +129,7 @@ C
       SAVE GLATS, NGPTS, OLDGAUS, OLDTYPE
 C
       INTEGER NEXT, NEXLAT, INROW, LOOP, KRET
-      REAL STEPLON, CUTOFF, RLAT, RLON
+      REAL STEPLON, RLAT, RLON
       DIMENSION RLON(JPMAXGG*2)
 C
       INTEGER ISIZE
@@ -157,15 +159,15 @@ C
       CALL INTLOGR(JP_DEBUG,
      X  'NGROTAT: Longitude of the South Pole of rotation = ',POLELON)
       CALL INTLOG(JP_DEBUG,'NGROTAT: Get gaussian grid type:',JPQUIET)
-      CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
+      CALL INTLOG(JP_DEBUG,HTYPE,JPQUIET)
       CALL INTLOG(JP_DEBUG,'NGROTAT: grid number:',NGAUSS)
 C
 C     Get gaussian grid definition (first time only)
 C
-      IF( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.TYPE)) THEN
+      IF( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.HTYPE)) THEN
         CALL INTLOG(JP_DEBUG,
      X    'NGROTAT: Get definitions for gaussian grid type:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
+        CALL INTLOG(JP_DEBUG,HTYPE,JPQUIET)
         CALL INTLOG(JP_DEBUG,'NGROTAT: grid number:',NGAUSS)
 C
         KRET = IGGLAT(NGAUSS*2, GLATS, 0, 1)
@@ -179,7 +181,7 @@ C
           NGPTS(2*NGAUSS+1-LOOP) = NGPTS(LOOP)
         ENDDO
         OLDGAUS = NGAUSS
-        OLDTYPE = TYPE
+        OLDTYPE = HTYPE
       ENDIF
 C
 C     Allocate work space if not already done.
@@ -223,7 +225,7 @@ C
 C       Rotate the current line of latitude
 C
         CALL NGVALUE(NEWFLD,NEXT,INROW,RLAT,RLON,
-     X               POLELAT,POLELON,NGAUSS,TYPE,DUMI,GLATS,NGPTS)
+     X               POLELAT,POLELON,NGAUSS,HTYPE,DUMI,GLATS,NGPTS)
 C
         NEXT = NEXT + INROW
 C
diff --git a/interpolation/ngvalue.F b/interpolation/ngvalue.F
index 76a31e4..d0e854f 100644
--- a/interpolation/ngvalue.F
+++ b/interpolation/ngvalue.F
@@ -1,15 +1,15 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       SUBROUTINE NGVALUE(NEWFLD, NEXT, INROW, RLAT, RLON,
-     X                   POLELAT, POLELON, NGAUSS, TYPE, FIELD,
+     X                   POLELAT, POLELON, NGAUSS, HTYPE, FIELD,
      X                   GLATS, NGPTS)
 C
 C---->
@@ -24,7 +24,7 @@ C     INTERFACE
 C     _________
 C
 C     CALL NGVALUE(NEWFLD, NEXT, INROW, RLAT, RLON,
-C    X             POLELAT,POLELON,NGAUSS,TYPE,FIELD,GLATS,NGPTS)
+C    X             POLELAT,POLELON,NGAUSS,HTYPE,FIELD,GLATS,NGPTS)
 C
 C
 C     Input parameters
@@ -37,10 +37,12 @@ C     RLAT    - Target point latitude in the rotated grid
 C     RLON    - Target point longitude in the rotated grid
 C     POLELAT - Latitude of the rotated South Pole
 C     POLELON - Longitude of the rotated South Pole
-C     NGAUSS  - Original unrotated gaussian field number
-C     TYPE    - Original unrotated gaussian field type
-C               = 'F' for full (regular) gaussian field
-C               = 'R' for reduced (quasi) gaussian field
+C     NGAUSS  - Gaussian grid number (original, unrotated)
+C     HTYPE   - Gaussian grid type (original, unrotated)
+C               = 'R' for reduced ("quasi-regular"),
+C               = 'O' for reduced/octahedral,
+C               = 'F' for full,
+C               = 'U' for user-defined reduced gaussian grid
 C     FIELD   - Original unrotated gaussian field values
 C     GLATS   - Gaussian latitudes for original field
 C     NGPTS   - Number of points along original field latitudes
@@ -115,7 +117,7 @@ C
       REAL RLAT, POLELAT, POLELON
       REAL NEWFLD(*), RLON(*), FIELD(*), GLATS(*)
       INTEGER NEXT, INROW, NGAUSS, NGPTS(*)
-      CHARACTER*1 TYPE
+      CHARACTER*1 HTYPE
 C
 C     Local variables
 C
@@ -150,7 +152,7 @@ C
 C     Interpolate the original unrotated grid to the points in the
 C     rotated line
 C
-      CALL NGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,TYPE,FIELD,
+      CALL NGINTRP(NEWFLD,NEXT,INROW,OLAT,OLON,NGAUSS,HTYPE,FIELD,
      X             GLATS,NGPTS)
 C
       RETURN
diff --git a/interpolation/nptwe32.F b/interpolation/nptwe32.F
deleted file mode 100644
index df8913e..0000000
--- a/interpolation/nptwe32.F
+++ /dev/null
@@ -1,128 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION NPTWE32(WEST,EAST,GRIDSTEP)
-C
-C---->
-C**** NPTWE32
-C
-C     Purpose
-C     -------
-C
-C     Calculate number of grid points in the range from west to east.
-C     (32-bit REALs version)
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = NPTWE32(WEST,EAST,GRIDSTEP)
-C
-C     Input
-C     -----
-C
-C     WEST     - Western boundary in degrees
-C     EAST     - Eastern boundary in degrees
-C     GRIDSTEP - Grid interval in degrees
-C
-C
-C     Output
-C     ------
-C
-C     Function returns the number of grid points in the east-west
-C     interval.
-C
-C
-C     Method
-C     ------
-C
-C     The grid is assumed to start at Greenwich.
-C
-C
-C     Externals
-C     ---------
-C
-C     None.
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF     Mar 1998
-C
-C
-C     Modifications
-C     -------------
-C
-C     None.
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Function arguments
-C
-      REAL*4 EAST, WEST, GRIDSTEP
-C
-C     Local variables
-C
-      INTEGER NL
-      REAL*8 DEAST, DWEST
-      REAL*8 LEFT, RIGHT, STEP, EPS
-      DATA EPS/1.0E-3/
-C
-C     Statement function
-      LOGICAL EQUAL
-      REAL*8 A, B
-      EQUAL(A,B) = ( ABS(A-B) .LT.(ABS(A)*EPS) )
-C
-C ------------------------------------------------------------------
-C     Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-C     Make all longitudes positive for calculation of difference
-C
-      DEAST = EAST
-      DWEST = WEST
-      RIGHT = DEAST + 360.0
-      LEFT  = DWEST + 360.0
-      STEP  = GRIDSTEP
-      IF( RIGHT.LT.LEFT) RIGHT = RIGHT + 360.0
-C
-C ------------------------------------------------------------------
-C     Section 2.   Calculate the number of points in the interval
-C ------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-C     Equal boundaries
-C
-      IF( EQUAL(LEFT,RIGHT) ) THEN
-        NPTWE32 = 1
-        GOTO 900
-      ENDIF
-C
-C     Calculate offset of westernmost gridpoint
-C
-      NL = INT((LEFT+EPS)/STEP)
-      IF( .NOT. EQUAL(LEFT,(NL*STEP)) ) NL = NL + 1
-C
-      RIGHT = RIGHT - (NL*STEP)
-      NPTWE32 = INT((RIGHT+EPS)/STEP) + 1
-C
-C ------------------------------------------------------------------
-C     Section 9.   Return
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/oceanp.F b/interpolation/oceanp.F
index a5996d4..b156338 100644
--- a/interpolation/oceanp.F
+++ b/interpolation/oceanp.F
@@ -56,7 +56,6 @@ C     GRIBEX  - GRIB decoding/encoding.
 C     INTLOG  - Log error message.
 C     JMEMHAN - Allocate/deallocate scratch memory.
 C     INTOCN  - Carry out ocean field to field interpolation.
-C     IGSETUP - Setup GRIB sections for the output product.
 C
 C
 C     Author
@@ -82,7 +81,6 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grspace.h"
 #include "intf.h"
 C
 C     Parameters
@@ -107,9 +105,8 @@ C
       LOGICAL LHORIZN, LFLIP
       CHARACTER*1 HFUNC
       CHARACTER*1 HINTOPT
-      CHARACTER*6 YFLAG
       INTEGER IOLDN, IOLDW, IOLDS, IOLDE, IOLDEW, IOLDNS
-      INTEGER LOOPLAT, LOOPLON, I, J , IOS,LOOP
+      INTEGER LOOPLAT, LOOPLON, I, J
       REAL ZTEMP
       INTEGER IERR, KPR, IWORD, IOLDSIZ, INEWSIZ, IINTPOL, ISTAGP
       INTEGER NXP, NYP, INEWP, ITEMP
@@ -128,7 +125,7 @@ C
 C
 C     Externals
 C
-      INTEGER RESET_C, IGSETUP, INTOCN, FIXAREA
+      INTEGER RESET_C, INTOCN, FIXAREA
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
diff --git a/interpolation/oceanu.F b/interpolation/oceanu.F
index d6df31b..3b51fad 100644
--- a/interpolation/oceanu.F
+++ b/interpolation/oceanu.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -78,36 +78,34 @@ C
 #include "parim.h"
 #include "nifld.common"
 #include "nofld.common"
-#include "grspace.h"
-#include "intf.h"
 C
 C     Parameters
 C
       INTEGER JPROUTINE, JPALLOC, JPDEALL, JPSCR3, JPSCR4
       INTEGER JP_LAT, JP_LONG, JP_GUESS
       PARAMETER (JPROUTINE = 36900 )
-      PARAMETER (JPALLOC = 1) 
-      PARAMETER (JPDEALL = 0) 
-      PARAMETER (JPSCR3 = 3) 
-      PARAMETER (JPSCR4 = 4) 
-      PARAMETER (JP_LONG = 3) 
-      PARAMETER (JP_LAT  = 4) 
-      PARAMETER (JP_GUESS  = 18049691) 
-cs    PARAMETER (JP_GUESS  = 1675245) 
-cs    PARAMETER (JP_GUESS  = 1237104) 
-cs    PARAMETER (JP_GUESS  = 1038240) 
+      PARAMETER (JPALLOC = 1)
+      PARAMETER (JPDEALL = 0)
+      PARAMETER (JPSCR3 = 3)
+      PARAMETER (JPSCR4 = 4)
+      PARAMETER (JP_LONG = 3)
+      PARAMETER (JP_LAT  = 4)
+      PARAMETER (JP_GUESS  = 18049691)
+cs    PARAMETER (JP_GUESS  = 1675245)
+cs    PARAMETER (JP_GUESS  = 1237104)
+cs    PARAMETER (JP_GUESS  = 1038240)
 C                          `---> allow for 0.25*0.25 interpolated grid
 C
 C     Local variables
 C
       LOGICAL LHORIZN, LFLIP
-      CHARACTER*1 HFUNC
+c     CHARACTER*1 HFUNC
       CHARACTER*1 HINTOPT
       CHARACTER*6 YFLAG
       INTEGER IOLDN, IOLDW, IOLDS, IOLDE, IOLDEW, IOLDNS
       INTEGER LOOPLAT, LOOPLON, I, J, IOS, LOOP
       REAL ZTEMP
-      INTEGER IERR, KPR, IWORD, IOLDSIZ, INEWSIZ, IINTPOL, ISTAGP
+      INTEGER IERR, KPR, IOLDSIZ, INEWSIZ, IINTPOL, ISTAGP
       INTEGER NXP, NYP, INEWP, ITEMP
       REAL RTOP, RBOTT, RRIGHT, RLEFT, RYRES, RXRES
       REAL XARR, YARR
@@ -118,7 +116,7 @@ C
 C
 C     Externals
 C
-      INTEGER RESET_C, INTOCNU, FIXAREA
+      INTEGER INTOCNU, FIXAREA
 C
 C     -----------------------------------------------------------------|
 C*    Section 1.   Initialise
@@ -197,9 +195,9 @@ C
       ELSE
          INEWSIZ = JP_GUESS
       ENDIF
-cs	  print*,'OCEANU INEWSIZ ',INEWSIZ
-cs	  print*,'OCEANU JP_GUESS ',JP_GUESS
-cs	  print*,'OCEANU NOGRID(1): ',NOGRID(1),' NOGRID(2): ',NOGRID(2)
+cs    print*,'OCEANU INEWSIZ ',INEWSIZ
+cs    print*,'OCEANU JP_GUESS ',JP_GUESS
+cs    print*,'OCEANU NOGRID(1): ',NOGRID(1),' NOGRID(2): ',NOGRID(2)
       CALL JMEMHAN(JPSCR3, INEW, INEWSIZ*2, JPALLOC, IERR)
       IF( IERR.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
@@ -405,7 +403,7 @@ C
         IF( YFLAG(1:1).EQ.'1' ) THEN
           OPEN (UNIT=18,FILE='./out_ocean_gribapi.dat',STATUS='UNKNOWN',
      &    FORM='UNFORMATTED',IOSTAT=IOS)
-          IF (IOS.EQ.0) THEN    
+          IF (IOS.EQ.0) THEN
             WRITE (18)(OUTOCEAN(LOOP),LOOP=1,OUTLEN)
           ENDIF
           CLOSE(18)
diff --git a/interpolation/old/createSharedMemoryCoefficients.c b/interpolation/old/createSharedMemoryCoefficients.c
deleted file mode 100644
index 3d60256..0000000
--- a/interpolation/old/createSharedMemoryCoefficients.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
-
-extern int debugSet;
-
-#include "sharedmemory.h"
-#include "fortdefs.h"
-
-void createSharedMemoryCoefficients(
-     fortint Type,       /* SP2LL, SP2QG, .. */
-     fortint Truncation, /* spectral truncation */
-     fortreal Grid,      /* grid spacing or gaussian number */
-     fortint Numlat,     /* number of latitudes in the shared memory array */
-     key_t memoryKey,    /* shared memory key */
-     int size)           /* size of the shared memory */
-{
-int type = (int) Type;
-struct sembuf bufs[1];
-union semun {
-  int             val;
-  struct semid_ds *buf;
-  ushort          *array;
-} semvalues;
-fortreal * array;
-int shmflg, shmid;
-char * shmaddr;
-int status, i, oldmask;
-char mode[] = "00666";
-fortint gaussianNumber, one = 1, first = 1, returnCode;
-int semaphoreId, value;
-fortreal northPole = 90.0;
-
-/*
-// If the semaphore for the shared memory already exists,
-// wait for it to become ready to read, and return
-*/
-    if( DEBUG ) printf("createSharedMemoryCoefficients: see if shared memory semaphore exists\n");
-    semaphoreId = semget(memoryKey,1,0);
-
-    if( semaphoreId != -1 ) {
-      bufs[0].sem_num = 0;
-      bufs[0].sem_op  = -READY_TO_READ;
-      bufs[0].sem_flg = 0;
-      if( DEBUG ) printf("createSharedMemoryCoefficients: wait for shared memory semaphore\n");
-      status = semop(semaphoreId,bufs,(size_t)1);
-
-      semvalues.val = READY_TO_READ;
-      value = semctl((int)semaphoreId, (int)0, (int)SETVAL,semvalues);
-      if( DEBUG ) printf("createSharedMemoryCoefficients: set shared memory semaphore readable\n");
-      return;
-    }
-/*
-// Create semaphore for the shared memory array
-*/
-    if( DEBUG ) {
-      printf("createSharedMemoryCoefficients: have to create shared memory segment\n");
-      printf("createSharedMemoryCoefficients: so create shared memory semaphore\n");
-    }
-    oldmask = umask(000);
-    semaphoreId = semget(memoryKey,1,IPC_CREAT | 0666);
-    if( semaphoreId == -1 ) {
-      perror("creator: failed to create smaphore");
-      exit(1);
-    }
-    (void) umask(oldmask);
-/*
-// Create shared segment id
-*/
-    if( DEBUG ) printf("createSharedMemoryCoefficients: get shared memory segment\n");
-    (void) umask(0);
-    shmflg = IPC_CREAT | 0666;
-    shmid = shmget(memoryKey, (size_t)size, shmflg);
-    if ( shmid < 0 ) {
-       perror("shmget error");
-       exit(1);
-    }
-/*
-// Attach the shared segment
-*/
-    if( DEBUG ) printf("createSharedMemoryCoefficients: attach shared memory segment\n");
-    shmaddr = (char *) NULL;
-    shmflg = 0;
-    array = (fortreal *) shmat( shmid, shmaddr, shmflg);
-    if ( array == (fortreal *) -1 ) {
-       perror("shmat error");
-       exit(1);
-    }
-/*
-// Put some data into the shared segment
-*/
-    if( DEBUG ) printf("createSharedMemoryCoefficients: put data into the shared segment\n");
-    returnCode = 0;
-
-    JDEBUG();
-
-    switch( type ) {
-
-      case SP2LL:
-        if( DEBUG ) printf("createSharedMemoryCoefficients: call NMAKLL for SP2LL\n");
-        NMAKLL( &Truncation, &Grid, &northPole, &Numlat, array, &returnCode);
-        if( returnCode ) {
-          printf("Problem with NMAKLL, return code = %d\n", returnCode);
-          exit(1);
-        }
-        break;
-
-      case SP2RG:
-      case SP2QG:
-/*
-*/
-       {
-        char htype[2];
-        fortreal * plat;
-        fortint * kpts;
-
-        gaussianNumber = (fortint) Grid;
-
-        plat = (fortreal *) malloc( gaussianNumber*2*sizeof(fortreal));
-        if( plat == NULL ) {
-          perror("createSharedMemoryCoefficients: plat malloc problem");
-          exit(1);
-        }
-
-        kpts = (fortint *) malloc( gaussianNumber*2*sizeof(fortint));
-        if( kpts == NULL ) {
-          perror("createSharedMemoryCoefficients: kpts malloc problem");
-          exit(1);
-        }
-
-        if( type == SP2RG ) {
-          if( DEBUG ) printf("createSharedMemoryCoefficients: handle SP2RG\n");
-          strcpy(htype,"F");
-        }
-        else {
-          if( DEBUG ) printf("createSharedMemoryCoefficients: handle SP2QG\n");
-          strcpy(htype,"R");
-        }
-
-        if( DEBUG ) printf("createSharedMemoryCoefficients: call JGETGG\n");
-        JGETGG(&gaussianNumber, &htype, plat, kpts, &returnCode, one);
-        if( returnCode ) {
-          printf("Problem with JGETGG, return code = %d\n", returnCode);
-          exit(1);
-        }
-        if( DEBUG ) printf("createSharedMemoryCoefficients: call NMAKGG\n");
-        NMAKGG(&Truncation, &first, plat, &Numlat, array, &returnCode);
-        if( returnCode ) {
-          printf("Problem with NMAKGG, return code = %d\n", returnCode);
-          exit(1);
-        }
-
-        free(plat);
-        free(kpts);
-        break;
-       }
-/*
-*/
-      default:
-        printf("creator: Type %d not yet handled\n", type);
-        exit(1);
-    }
-/*
-// Set the semaphore to make the memory readable for cooperating processes
-*/
-    if( DEBUG ) printf("createSharedMemoryCoefficients: set semaphore to make memory readable\n");
-    semvalues.val = READY_TO_READ;
-    value = semctl((int)semaphoreId, (int)0, (int)SETVAL,semvalues);
-/*
-// Detach the shared segment
-*/
-    if( DEBUG ) printf("createSharedMemoryCoefficients: detach the shared segment\n");
-    status = shmdt(array);
-    if ( status < 0 ) {
-       perror("shmdt error");
-       exit(1);
-    }
-
-    return;
-}
diff --git a/interpolation/old/sharedMemoryCharacteristics.c b/interpolation/old/sharedMemoryCharacteristics.c
deleted file mode 100644
index ab55b30..0000000
--- a/interpolation/old/sharedMemoryCharacteristics.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-
-extern int debugSet;
-
-#include "sharedmemory.h"
-#include "fortdefs.h"
-
-#define MAC 1264
-
-int sharedMemoryCharacteristics(
-  int type,
-  int truncation,
-  float grid,
-  int * numlat,
-  size_t * size,
-  key_t * key )
-{
-/*
-// Input:
-//
-//   type - indicates the spectral to grid transformation:
-//          SP2LL for spectral to lat/long
-//          SP2RG for spectral to regular gaussian
-//          SP2QG for spectral to quasi-regular (reduced) gaussian
-//
-//   truncation - the spectral truncation (eg 511 for T511)
-//
-//   grid - specifies the desired grid:
-//          the grid spacing along a line of longitude for lat/long grids
-//          the gaussian grid number for gaussian grids (eg 80.0 for N80)
-//
-// Output:
-//
-//   numlat - the number of latitudes from pole to pole in the grid
-//
-//   size - size in bytes of the transformation coefficients
-//
-//   key - the key for the shared memory and its associated semaphore
-//
-// Function returns 0 if all OK.
-//
-// Files setup to generate shared memory and semaphore keys are held
-// in a desginated directory (see defaultDirectory below). This
-// directory can be specified using environment variable SHARED_DIRECTORY.
-//
-*/
-int status, gaussianNumber;
-char defaultDirectory[] = "./";
-/* char defaultDirectory[] = "/home/ma/emos/data/BlueStorm"; */
-char * directory;
-char filename[] = "SP2LL_Tnnnn_to_Grid_xxxxxxxxx";
-char * fullFilename;
-key_t Key;
-
-/*
-// Build the name of the file which is used to define a key.
-// If the file does not already exist, create it.
-*/
-    /* directory = getenv("SHARED_DIRECTORY"); */
-    directory = getenv("PPDIR");
-    if( directory == NULL ) directory = defaultDirectory;
-    fullFilename = (char *) malloc(strlen(directory)+strlen(filename));
-    if( fullFilename == NULL ) {
-      perror("malloc error");
-      exit(1);
-    }
-    strcpy(fullFilename, directory);
-    strcat(fullFilename, "/");
-
-    switch( type) {
-
-      case SP2LL:
-        sprintf(filename,"SP2LL_T%04d_to_Grid_%09.6f",truncation,grid);
-        break;
-
-      case SP2RG:
-        sprintf(filename,"SP2RG_T%04d_to_Regular_N%04.0f",truncation,grid);
-        break;
-
-      case SP2QG:
-        sprintf(filename,"SP2QG_T%04d_to_Reduced_N%04.0f",truncation,grid);
-        break;
-
-      default:
-        return (int) 1;
-    }
-    strcat(fullFilename, filename);
-    
-    if( DEBUG ) printf("fullFilename = %s\n", fullFilename);
-    Key = ftok(fullFilename, MAC);
-/*
-//  If file does not exist, ..
-*/
-    if( Key == -1 ) {
-      char * command = (char*) malloc(6+strlen(fullFilename));
-      if( command == NULL ) {
-        perror("malloc error");
-        exit(1);
-      }
-      strcpy(command,"touch ");
-      strcat(command,fullFilename);
-      if( DEBUG ) printf("%s\n", command);
-      status = system(command);
-      if( status ) {
-        printf("Unable to create file %s\n", fullFilename);
-        perror("File creation problem");
-        exit(1);
-      }
-      free(command);
-      Key = ftok(fullFilename, MAC);
-      if( Key == -1 ) {
-        perror("Error getting key from newly created file");
-        exit(1);
-      }
-    }
-    free(fullFilename);
-
-    *key = Key;
-    if( DEBUG ) printf("sharedMemoryCharacteristics: Key = %0x\n", Key);
-/*
-// Calculate the file characteristics
-*/
-    switch( type) {
-
-      case SP2LL:
-        *numlat = (int)(90.0/grid + 1.0);
-        break;
-
-      case SP2RG:
-      case SP2QG:
-        gaussianNumber = (int) grid;
-		/*
-        *numlat = gaussianNumber*2;
-		*/
-        *numlat = gaussianNumber;
-        break;
-
-      default:
-        printf("sharedMemoryCharacteristics: Type %d not yet handled\n", type);
-        return (int) 1;
-    }     
-
-    *size = (((truncation+1)*(truncation+4))/2) * (*numlat) * sizeof(fortreal);
-	printf("size=%ld\n",*size);
-	/*
-    *size = (((truncation+1)*(truncation+4))/2);
-	printf("size=%d\n",*size);
-	*size *= *numlat;
-	printf("size=%d\n",*size);
-	*size *= sizeof(fortreal);
-	printf("-----size=%ld\n",*size);
-	*size = 4736220160;
-	printf("------size=%ld\n",*size);
-	*/
-
-
-    if( DEBUG ) printf("sharedMemoryCharacteristics: truncation = %d sizeof-fortreal %d numlat=%d\n", truncation,sizeof(fortreal),*numlat);
-    if( DEBUG ) printf("sharedMemoryCharacteristics: Size = %ld bytes\n", *size);
-
-    return (int) 0;
-}
diff --git a/interpolation/old/smread.c b/interpolation/old/smread.c
deleted file mode 100644
index 8edf8b8..0000000
--- a/interpolation/old/smread.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
-#include "sharedmemory.h"
-#include "fortdefs.h"
-
-int sharedMemoryCharacteristics( int, int , float , int * , size_t * , key_t * );
-void createSharedMemoryCoefficients( fortint , fortint , fortreal , fortint , key_t , size_t );
-
-int debugSet = 0;
-static char * debugLevel;
- 
-fortint SMREAD(
-  fortreal ** fortranArrayPointer,  /* to be attached to shared memory */
-  fortint * Type,                   /* SP2LL, SP2QG, .. */
-  fortint * Truncation,             /* spectral truncation */
-  fortreal * Grid)                  /* grid spacing or gaussian number */
-/*
-// Callable from Fortran.
-//
-*/
-/*
-C
-C---->
-C**** SMREAD
-C
-C     Purpose
-C     -------
-C
-C     This routine gets interpolation coefficients in a shared memory array.
-C
-C
-C     Interface
-C     ---------
-C
-C     ISIZE = SMREAD(KARRAY,KTYPE,KTRUNC,GRID)
-C
-C
-C     Input parameters
-C     ----------------
-C
-C     KTYPE  - Type of spectral to grid transformation (SP2LL, SP2QG, ..)
-C     KTRUNC - Spectral truncation (eg 511 for T511)
-C     GRID   - longitude grid spacing (for lat/long) or gaussian number
-C
-C
-C     Output parameters
-C     -----------------
-C
-C     KARRAY - Pointer to a shared memory array of REALs
-C
-C     Function returns the size (in values) of the shared memory array
-C
-C
-C     Common block usage
-C     ------------------
-C
-C     None.
-C
-C
-C     Method
-C     ------
-C
-C     Looks for coefficients in shared memory.
-C     Waits on semaphore for coefficients to become available.
-C
-C
-C     Externals
-C     ---------
-C
-C     sharedMemoryCharacteristics    - to get key and size for shared memory
-C     createSharedMemoryCoefficients - creates coefficients if necessary
-C
-C
-C     Reference
-C     ---------
-C
-C     None.
-C
-C
-C     Comments
-C     --------
-C
-C     Environment variable SHARED_DEBUG can be set (1, 2, ..) to give
-C     diagnostic printout.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers      ECMWF      January 2002
-C
-C
-C     Modifications
-C     -------------
-C
-C     None.
-C
-C----<
-C     
-*/
-{
-int type = (int) *Type;
-int truncation = (int) *Truncation;
-float grid = (float) *Grid;
-key_t memoryKey;
-size_t size;
-int shmflg, shmid;
-char * shmaddr;
-int status, i;
-fortint numberOfValues = 0;
-char mode[] = "00666";
-int value, semaphoreId, numlat, returnCode;
-union semun {
-  int             val;
-  struct semid_ds *buf;
-  ushort          *array;
-} semvalues;
-fortint Numlat;
-struct sembuf bufs[1];
-
-/*
-// See if DEBUG switched on.
-*/
-    if( ! debugSet ) { 
-      debugLevel = getenv("SHARED_DEBUG");
-      if( debugLevel == NULL )
-        debugSet = DEBUGOFF;              /* off */
-      else {
-        int loop;
-        for( loop = 0; loop < strlen(debugLevel) ; loop++ ) {
-          if( ! isdigit(debugLevel[loop]) ) {
-            printf("Invalid number string in SHARED_DEBUG: %s\n", debugLevel);
-            printf("SHARED_DEBUG must comprise only digits [0-9].\n");
-            debugSet = DEBUGOFF;
-          }
-        }
-        debugSet = DEBUGOFF + atoi( debugLevel );
-      }
-      if( DEBUG ) printf("SHARED_DEBUG: debug switched on\n");
-    }
-/*
-// Get key and size for shared memory (whole globe)
-*/
-    if( DEBUG ) {
-      printf("SMREAD: type = %d\n",type);
-      printf("SMREAD: truncation = %d\n",truncation);
-      printf("SMREAD: grid = %f\n",grid);
-    }
-    status = sharedMemoryCharacteristics( type,
-                                          truncation,
-                                          grid,
-                                          &numlat,
-                                          &size,
-                                          &memoryKey);
-    if( status ) {
-      if( DEBUG ) printf("SMREAD: sharedMemoryCharacteristics call failed\n");
-      return (fortint) 0;
-    }
-    Numlat = numlat;
-/*
-// Wait for the shared memory array to become available
-*/
-    if( DEBUG ) printf("SMREAD: call createSharedMemoryCoefficients with numlat = %d\n", numlat);
-    createSharedMemoryCoefficients(*Type,*Truncation,*Grid,Numlat,memoryKey,size);
-
-    bufs[0].sem_num = 0;
-    bufs[0].sem_op  = -READY_TO_READ;
-    bufs[0].sem_flg = 0;
-
-    semaphoreId = (int) memoryKey;
-    if( DEBUG )
-      printf("SMREAD: wait for shared memory semaphore id %0x\n", semaphoreId);
-    status = semop(semaphoreId,bufs,1);
-/*
-// Locate shared segment
-*/
-    if( DEBUG ) printf("SMREAD: locate shared memory\n");
-    shmflg = 0666;
-    shmid = shmget( memoryKey, (size_t)size, shmflg);
-    if ( shmid < 0 ) {
-       perror("shmget error");
-       return (fortint) 0;
-    }
-/*
-// Attach the shared segment to the array pointer
-*/
-    if( DEBUG ) printf("SMREAD: attach shared memory to array\n");
-    shmaddr = (char *) NULL;
-    shmflg = 0;
-    *fortranArrayPointer = (fortreal *) shmat( shmid, shmaddr, shmflg);
-    if ( *fortranArrayPointer == (fortreal *) -1 ) {
-       perror("shmat error");
-       return (fortint) 0;
-    }
-/*
-// Set semaphore value to make memory readable for other readers
-*/
-    if( DEBUG ) printf("SMREAD: set semaphore to make memory readable\n");
-    semvalues.val = READY_TO_READ;
-    value = semctl((int)semaphoreId, (int)0, (int)SETVAL,semvalues);
-/*
-// Return the size (in values) of the shared segment
-*/
-    numberOfValues = (fortint) size/sizeof(fortreal);
-    if( DEBUG )
-      printf("SMREAD: number of values in shared memory = %d\n", numberOfValues);
-
-    return numberOfValues;
-}
diff --git a/interpolation/ouspace.h b/interpolation/ouspace.h
deleted file mode 100644
index 4c6116c..0000000
--- a/interpolation/ouspace.h
+++ /dev/null
@@ -1,84 +0,0 @@
-C
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-C**** "ouspace.h"
-C
-C     PURPOSE
-C     _______
-C
-C     This file contains the work space array definitions for the
-C     arrays to hold the unpacked real data from GRIB fields.
-C
-C     INTERFACE
-C     _________
-C
-C     #include "ouspace.h"
-C
-C     Common block usage
-C     __________________
-C
-C     GRIB_SPACE
-C
-C     NIFELD       - POINTER to array RIFELD.
-C     NOFELD       - POINTER to array ROFELD.
-C
-C     RIFELD       - Dynamic array of length (NIWE * NINS)
-C                    (see nifld.common) which holds the expanded
-C                    input field.
-C     ROFELD       - Dynamic array of length (NOWE * NONS)
-C                    (see nofld.common) which holds the expanded
-C                    output field.
-C
-C     METHOD
-C     ______
-C
-C     NONE
-C
-C     REFERENCE
-C     _________
-C
-C     NONE
-C
-C     COMMENTS
-C     ________
-C
-C     Contains sections 1
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Apr 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     NONE
-C
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Pointer and array combination
-C                Array dimensions are in nifld.common and
-C                nofld.common
-C     _______________________________________________________
-C
-      COMMON /GRIB_SPACE/
-     1   NIFELD, NOFELD
-C
-      SAVE /GRIB_SPACE/
-C
-      REAL RIFELD, ROFELD
-C
-C     RIFELD is actually only the accumulated field length for a
-C     quasi regular input field
-C
-      POINTER (NIFELD, RIFELD (NIWE * NINS) )
-      POINTER (NOFELD, ROFELD (NOWE * NONS) )
diff --git a/interpolation/parim.h b/interpolation/parim.h
index d6bb860..f9bdddb 100644
--- a/interpolation/parim.h
+++ b/interpolation/parim.h
@@ -1,11 +1,11 @@
 c
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 C**** "parim.h"
@@ -114,9 +114,13 @@ C                     (Real (360) / REAL (JPLONG) ).
 C
       INTEGER JPLONG, JPLAT, JPGTRUNC, JPSTRUNC
 C
+C     PARAMETER (JPLONG = 1440)
       PARAMETER (JPLONG = 4096)
-      PARAMETER (JPLAT  = 4000 )
+C     PARAMETER (JPLAT  = 2048)
+      PARAMETER (JPLAT  = 4000)
+C     PARAMETER (JPGTRUNC = 2048)
       PARAMETER (JPGTRUNC = 4000)
+C     PARAMETER (JPSTRUNC = 2047)
       PARAMETER (JPSTRUNC = 3999)
 C
       INTEGER JPLG01, JPLT01, JPPACK, JPML01
@@ -317,6 +321,7 @@ C
       INTEGER JPENSEMBLE, JPVERTICAL, JPBASE2
 C
       PARAMETER (JPENSEMBLE = 100)
+C     PARAMETER (JPVERTICAL = 100)
       PARAMETER (JPVERTICAL = 128)
       PARAMETER (JPBASE2 = 22)
 C
@@ -622,3 +627,9 @@ C     (see WAVEXX2, WV2DXX2, WV2DINT, WVQLIN2, WVQLINT, JPEXPAND)
 C
 CC    PARAMETER ( JPARRAYDIM_WAVE = 2880*1442)   !EMOS 000396
       PARAMETER ( JPARRAYDIM_WAVE = 3600*1802*2) !EMOS 4.0.0  <-- PRODGEN change
+C
+C --------------------------------------------------------------------
+C     Dimension for internal array for gaussian grid definitions
+      INTEGER JPMAXNG
+      PARAMETER ( JPMAXNG = 4000 )
+
diff --git a/interpolation/pddefs.F b/interpolation/pddefs.F
index a657153..01dc114 100644
--- a/interpolation/pddefs.F
+++ b/interpolation/pddefs.F
@@ -103,12 +103,8 @@ C
 C
 C     Local variables
 C
-      CHARACTER*6 YEMOSNM
-      INTEGER IEMOSNM
       CHARACTER*256 FILENAME
-      CHARACTER*256 YBASE
       CHARACTER*256 HLINE
-      CHARACTER*256 YENVBACK
       INTEGER IPARAM, INEXT, NUMDFS, LOOP, INDX, IOTABLE
       CHARACTER*1 HLSM, HWIND, HPREC, HLSMI
       LOGICAL LNLSM, LNWIND, LNPREC, LNSMPAR
diff --git a/interpolation/ppallow.F b/interpolation/ppallow.F
deleted file mode 100644
index 9f293af..0000000
--- a/interpolation/ppallow.F
+++ /dev/null
@@ -1,227 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      LOGICAL FUNCTION PPALLOW(NM,SLAT)
-C
-C---->
-C**** PPALLOW
-C
-C     Purpose
-C     -------
-C
-C     
-C     ---------
-C
-C     LFOUND = PPALLOW(NM,SLAT) 
-C
-C
-C     Input
-C     -----
-C
-C     NM      - Triangular truncation number of the field..
-C     SLAT    - Rotation angle (degrees, REAL*8)
-C              (degrees, negative => rotate counter-clockwise about the
-C                                    new Z-axis).
-C
-C
-C     Output
-C     ------
-C
-C     Function returns .TRUE. if coefficients are in the list of
-C     'standard' rotations and allowed in mrfs.
-C
-C
-C     Method
-C     ------
-C
-C     Checks a configuration file to find the allowed rotations.
-C     This file may have its pathname given by the environment variable
-C     PP_ALLOWED_ROTATIONS or may be in a standard directory.
-C     Only picks up configuration values on first call.
-C
-C     The configuration file is read by Fortran and has format
-C     (I4,1X,F8). Eg.
-C
-C      159 -14.0000
-C      319  60.0000
-C      319 -60.0000
-C
-C     Externals
-C     ---------
-C
-C     GETENV - Gets value in an environment variable.
-C     INTLOG - Output log message.
-C     JDEBUG - Checks environment to switch on/off debug.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF       June 2000
-C
-C
-C----<
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-#include "jparams.h"
-#include "parim.h"
-C
-C     Function arguments.
-C
-      INTEGER NM
-      REAL*8 SLAT
-C
-C     Parameters.
-C
-      INTEGER JPLIST, JPDEFL
-      PARAMETER (JPLIST = 20 )
-C                       = number of values which can be read
-C
-      PARAMETER (JPDEFL = 3 )
-C                       = number of values in default list
-C
-C     Local variables.
-C
-      INTEGER FILENM, LOOP, LISTLEN
-      INTEGER NMDEF(JPDEFL), INM(JPLIST)
-      REAL*8 SLATDEF(JPDEFL), XLAT(JPLIST)
-      CHARACTER*256 FILENAME
-      CHARACTER*256 STANDARD
-      CHARACTER*16 HOST
-      LOGICAL LDEBUG, LFOUND
-C
-C     Externals
-C
-      DATA NMDEF/159,319,319/, SLATDEF/-14.0,60.0,-60.0/
-      DATA LDEBUG/.FALSE./, LFOUND/.FALSE./
-      DATA FILENM/65/
-C
-      SAVE LDEBUG, LFOUND, INM, XLAT, LISTLEN
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.   Initialise
-C     -----------------------------------------------------------------|
-C
-  100 CONTINUE
-C
-      PPALLOW = .FALSE.
-C
-C     Only pick up configuration values on first call
-C
-      IF( LFOUND ) GOTO 400
-C
-      LFOUND = .TRUE.
-C
-      CALL JDEBUG()
-      LDEBUG = NDBG.GT.0
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.   Open the configuration file
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-C     If the environment variable points to a file, try to open it.
-C     Otherwise, get the file from a standard directory.
-C
-      CALL GETENV('PP_ALLOWED_ROTATIONS', FILENAME)
-      IF( FILENAME(1:1).NE.' ' ) THEN
-        IF( LDEBUG) CALL INTLOG(JP_DEBUG,
-     X    'PPALLOW: Trying to open file '//FILENAME,JPQUIET)
-        OPEN( FILENM, FILE=FILENAME, STATUS='OLD', ERR=300)
-C
-      ELSE
-C
-        CALL GETENV('HOST',HOST)
-        IF( HOST(1:7).EQ.'vpp5000') THEN
-          STANDARD = '/vpp5000/mrfs/postproc/pp_allowed_rotations'
-        ELSE IF (HOST(1:7).EQ.'vpp700e') THEN
-          STANDARD = '/vpp700e/mrfs/postproc/pp_allowed_rotations'
-        ELSE IF (HOST(1:6).EQ.'vpp700') THEN
-          STANDARD = '/vpp700/mrfs/postproc/pp_allowed_rotations'
-        ELSE
-          STANDARD = '/home/ma/emos/data/pp_allowed_rotations'
-        ENDIF
-        IF( LDEBUG) CALL INTLOG(JP_DEBUG,
-     X    'PPALLOW: Trying to open file '//STANDARD,JPQUIET)
-        OPEN( FILENM, FILE=STANDARD, STATUS='OLD', ERR=300)
-      ENDIF
-C
-      IF( LDEBUG) CALL INTLOG(JP_DEBUG, 'PPALLOW: Open OK.',JPQUIET)
-      LISTLEN = 0
-C
-  210 CONTINUE
-C
-      LISTLEN = LISTLEN + 1
-      READ(FILENM,'(I4,1X,F8.4)',END=220) INM(LISTLEN), XLAT(LISTLEN)
-      GOTO 210
-C
-  220 CONTINUE
-      CLOSE(FILENM)
-      LISTLEN = LISTLEN - 1
-C
-      GOTO 400
-C
-C     -----------------------------------------------------------------|
-C*    Section 3.   Use the internally defined values.
-C     -----------------------------------------------------------------|
-C
-  300 CONTINUE
-C
-      IF( LDEBUG) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'PPALLOW: No configuration file available.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X  'PPALLOW: Using internally defined values.',JPQUIET)
-      ENDIF
-C
-      DO LOOP = 1, JPDEFL
-        INM(LOOP)  = NMDEF(LOOP)
-        XLAT(LOOP) = SLATDEF(LOOP)
-      ENDDO
-      LISTLEN = JPDEFL
-C
-C     -----------------------------------------------------------------|
-C*    Section 4.   Check the current values against the list.
-C     -----------------------------------------------------------------|
-C
-  400 CONTINUE
-C
-      DO LOOP = 1, LISTLEN
-        IF( (NM.EQ.INM(LOOP)).AND.(SLAT.EQ.XLAT(LOOP)) ) THEN
-          IF( LDEBUG) THEN
-            CALL INTLOG(JP_DEBUG,
-     X      'PPALLOW: Rotation allowed in mrfs.',JPQUIET)
-            CALL INTLOG(JP_DEBUG, 'PPALLOW: Truncation = ',NM)
-            CALL INTLOGR(JP_DEBUG,'PPALLOW: Rotation = ', SLAT)
-          ENDIF
-          PPALLOW = .TRUE.
-          GOTO 900
-        ENDIF
-      ENDDO
-C
-      IF( LDEBUG ) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'PPALLOW: Rotation NOT allowed in mrfs.',JPQUIET)
-        CALL INTLOG(JP_DEBUG, 'PPALLOW: Truncation = ',NM)
-        CALL INTLOGR(JP_DEBUG,'PPALLOW: Rotation = ', SLAT)
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C*    Section 9.   Return.
-C     -----------------------------------------------------------------|
-C
-  900 CONTINUE
-C
-      RETURN
-      END
-
diff --git a/interpolation/psizes.F b/interpolation/psizes.F
deleted file mode 100644
index 5926eb5..0000000
--- a/interpolation/psizes.F
+++ /dev/null
@@ -1,13 +0,0 @@
-      subroutine psizes(s)
-      character*(*) s
-      character*(1) c1
-      character*(1) c2
-      integer len
-      integer i
-      real    r
-      inquire(iolength=len) r
-      c1 = char(len)
-      inquire(iolength=len) i 
-      c2 = char(len)
-      s = c1 // c2
-      end subroutine
diff --git a/interpolation/qgoct.F b/interpolation/qgoct.F
new file mode 100644
index 0000000..4f246ac
--- /dev/null
+++ b/interpolation/qgoct.F
@@ -0,0 +1,32 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      INTEGER FUNCTION QGOCT(NLAT)
+C
+C---->
+C**** QGOCT
+C
+C     PURPOSE
+C     _______
+C
+C     Returns number of points at each Gaussian latitude (to fill pl array)
+C     for a reduced Gaussian grid, in octahedral progression series
+C
+C
+C     Input parameters
+C     ________________
+C
+C     NLAT - latitude index starting from pole (1-based)
+C
+C----<
+      IMPLICIT NONE
+      INTEGER NLAT
+      QGOCT = 16+4*MAX(NLAT,1)
+      END FUNCTION
diff --git a/interpolation/rddefs.c b/interpolation/rddefs.c
deleted file mode 100644
index bcd23cd..0000000
--- a/interpolation/rddefs.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "common/fortint.h"
-
-#define LINESIZE 80
-#define format 0x666F726D
-#define table 0x7461626C
-#define parameter 0x70617261
-#define truncation 0x7472756E
-#define accuracy 0x61636375
-#define grid 0x67726964
-#define gaussian 0x67617573
-#define area 0x61726561
-#define scan 0x7363616E
-#define reduced 0x72656475
-#define uselsm 0x7573656C
-#define usewind 0x75736577
-#define useprecip 0x75736570
-#define lsm_param 0x6C736D5F
-
-/*
-// defines for FORTRAN subroutine
-*/
-#ifdef FORTRAN_NO_UNDERSCORE
-#define CLEAR_C clear_c
-#define IAINIT iainit
-#define INIT_CM init_cm
-#define RDDEFS rddefs
-#else
-#define CLEAR_C clear_c_
-#define IAINIT iainit_
-#define INIT_CM init_cm_
-#define RDDEFS rddefs_
-#endif
-
-#define NIFORM 1
-#define NOFORM 2
-#define NITABLE 3
-#define NIPARAM 4
-#define NIRESO 5
-#define NORESO 6
-#define NOACC 7
-#define NIGRID1 8
-#define NIGRID2 9
-#define NOGRID1 10
-#define NOGRID2 11
-#define NIGAUSS 12
-#define NOGAUSS 13
-#define NIAREA1 14
-#define NIAREA2 15
-#define NIAREA3 16
-#define NIAREA4 17
-#define NOAREA1 18
-#define NOAREA2 19
-#define NOAREA3 20
-#define NOAREA4 21
-#define NISCNM  22
-#define NOSCNM  23
-#define LSM     24
-#define LWIND   25
-#define LPREC   26
-#define NIREDU  27
-#define NOREDU  28
-#define LSMPAR  29
-
-/*
-// Prototypes
-*/
-void set_format(char * inputval, char * outputval);
-void set_table(char * inputval, char * outputval);
-void set_parameter(char * inputval, char * outputval);
-void set_truncation(char * inputval, char * outputval);
-void set_accuracy(char * inputval, char * outputval);
-void set_grid(char * inputval, char * outputval);
-void set_gaussian(char * inputval, char * outputval);
-void set_area(char * inputval, char * outputval);
-void set_scan(char * inputval, char * outputval);
-void set_reduced(char * inputval, char * outputval);
-void set_uselsm(char * inputval, char * outputval);
-void set_usewind(char * inputval, char * outputval);
-void set_useprecip(char * inputval, char * outputval);
-void set_lsm_param(char * inputval, char * outputval);
-void INIT_CM( fortint *, fortint *);
-
-fortint RDDEFS()
-{
-/*
-// The file handling is currently not used!
-//
-// char * fallback_defaults_file = "/home/ma/mac/public/gp2gp/request_defaults";
-// char * fallback_defaults_file = "/home/ma/mac/public/gp2gp/no_chance";
-// char * defaults_file;
-*/
-FILE * file;
-int i_status;
-char line[LINESIZE+1];
-char keyword[LINESIZE];
-char inputval[LINESIZE];
-char outputval[LINESIZE];
-int count = 0, i;
-unsigned long code=0;
-int kpr = 0;
-int kerr = 1;
-
-/*
-//  Clear the common block
-*/
-    CLEAR_C();
-    IAINIT( &kpr, kerr);
-
-/*
-// The file handling is currently not used!
-//
-// Open the file defining the defaults
-//
-// defaults_file = getenv("REQUEST_DEFAULTS");
-//  if( defaults_file == NULL )
-//      defaults_file = fallback_defaults_file;
-//
-//  file = fopen( defaults_file, "r");
-//
-//
-//  If no file, set the defaults here
-*/
-    file = NULL;                        /* file handling currently not used! */
-    if( file == NULL ) {
-      set_format("grib","grib");
-      set_table("128","");
-      set_parameter("0","");
-      set_area("0/0/0/0","0/0/0/0");
-      set_scan("0","0");
-      return 0;
-    }
-
-/*
-//  Ignore the 2 title lines, then a line at a time from the file
-*/
-    while( fgets( line, LINESIZE, file) != NULL ) {
-      count++;
-      if ( count > 2 ) {
-/*
-//      Split the line up
-*/
-        i_status = sscanf( line, "%s%s%s", keyword, inputval, outputval);
-        if ( (i_status != 3) && (i_status != EOF ) ) {
-          perror("sscanf failed");
-          exit(1);
-        }
-/*
-//      Move first 4 characters of the keyword into the switch variable
-*/
-        for( i = 0; i < 4; i++ )
-          code = ( (code << 8) + *(keyword+i) ) & 0xFFFFFFFF;
-
-/*
-//      Handle the keywords individually
-*/
-        switch( code ) {
-
-          case format:     set_format(inputval, outputval);
-                           break;
-
-          case table:      set_table(inputval, outputval);
-                           break;
-
-          case parameter:  set_parameter(inputval, outputval);
-                           break;
-
-          case truncation: set_truncation(inputval, outputval);
-                    break;
-
-          case accuracy:   set_accuracy(inputval, outputval);
-                           break;
-
-          case grid:       set_grid(inputval, outputval);
-                           break;
-
-          case gaussian:   set_gaussian(inputval, outputval);
-                           break;
-
-          case area:       set_area(inputval, outputval);
-                           break;
-
-          case scan:       set_scan(inputval, outputval);
-                           break;
-
-          case reduced:    set_reduced(inputval, outputval);
-                           break;
-
-          case uselsm:     set_uselsm(inputval, outputval);
-                           break;
-
-          case usewind:    set_usewind(inputval, outputval);
-                           break;
-
-          case useprecip:  set_useprecip(inputval, outputval);
-                           break;
-
-          case lsm_param:  set_lsm_param(inputval, outputval);
-                           break;
-
-          default:         printf("Invalid code: %x\n", code);
-                           break;
-        }
-      }
-    }
-
-    return 0;
-}
-
-void set_format(char * inputval, char * outputval)
-{
-fortint p1, p_1 = 1, p_0 = 0;
-
-    p1 = NIFORM;
-    if ( strcmp( inputval, "grib") == 0 )
-        INIT_CM( &p1, &p_1);
-    else
-        INIT_CM( &p1, &p_0);
-
-    p1 = NOFORM;
-    if ( strcmp( outputval, "grib") == 0 )
-        INIT_CM( &p1, &p_1);
-    else
-        INIT_CM( &p1, &p_0);
-
-    return;
-}
-
-void set_table(char * inputval, char * outputval)
-{
-fortint p1, p2;
-int q2;
-
-    p1 = NITABLE;
-    q2 = atoi( inputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
-
-    return;
-}
-
-void set_parameter(char * inputval, char * outputval)
-{
-fortint p1, p2;
-int q2;
-
-    p1 = NIPARAM;
-    q2 = atoi( inputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
-
-    return;
-}
-
-void set_truncation(char * inputval, char * outputval)
-{
-fortint p1, p2;
-int q2;
-
-    p1 = NIRESO;
-    q2 = atoi( inputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
-
-    p1 = NORESO;
-    q2 = atoi( outputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
-
-    return;
-}
-
-void set_accuracy(char * inputval, char * outputval)
-{
-fortint p1, p2;
-int q2;
- 
-    p1 = NOACC;
-    q2 = atoi( outputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
- 
-    return;
-}
-
-void set_grid(char * inputval, char * outputval)
-{
-fortint p1,p2,p3;
-int q2,q3;
-
-    p1 = NIGRID1;
-    sscanf( inputval, "%d/%d", &q2, &q3);
-    p2 = (fortint) q2;
-    p3 = (fortint) q3;
-    INIT_CM( &p1, &p2);
-
-    p1 = NIGRID2;
-    INIT_CM( &p1, &p3);
-    
-    p1 = NOGRID1;
-    sscanf( outputval, "%d/%d", &q2, &q3);
-    p2 = (fortint) q2;
-    p3 = (fortint) q3;
-    INIT_CM( &p1, &p2);
-
-    p1 = NOGRID2;
-    INIT_CM( &p1, &p3);
-    
-    return;
-}
-
-void set_gaussian(char * inputval, char * outputval)
-{
-fortint p1, p2;
-int q2;
-
-    p1 = NIGAUSS;
-    q2 = atoi( inputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
-
-    p1 = NOGAUSS;
-    q2 = atoi( outputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
-
-    return;
-}
-
-void set_area(char * inputval, char * outputval)
-{
-fortint p1,p2,p3,p4,p5;
-int q2, q3, q4, q5;
-
-    p1 = NIAREA1;
-    sscanf( inputval, "%d/%d/%d/%d", &q2, &q3,&q4,&q5);
-    p2 = (fortint) q2;
-    p3 = (fortint) q3;
-    p4 = (fortint) q4;
-    p5 = (fortint) q5;
-    INIT_CM( &p1, &p2);
-
-    p1 = NIAREA2;
-    INIT_CM( &p1, &p3);
-
-    p1 = NIAREA3;
-    INIT_CM( &p1, &p4);
-
-    p1 = NIAREA4;
-    INIT_CM( &p1, &p5);
-    
-    p1 = NOAREA1;
-    sscanf( outputval, "%d/%d/%d/%d", &q2, &q3,&q4,&q5);
-    p2 = (fortint) q2;
-    p3 = (fortint) q3;
-    p4 = (fortint) q4;
-    p5 = (fortint) q5;
-    INIT_CM( &p1, &p2);
-
-    p1 = NOAREA2;
-    INIT_CM( &p1, &p3);
-
-    p1 = NOAREA3;
-    INIT_CM( &p1, &p4);
-
-    p1 = NOAREA4;
-    INIT_CM( &p1, &p5);
-    
-    return;
-}
-
-void set_scan(char * inputval, char * outputval)
-{
-fortint p1, p2;
-int q2;
- 
-    p1 = NISCNM;
-    q2 = atoi( inputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
- 
-    p1 = NOSCNM;
-    q2 = atoi( outputval );
-    p2 = (fortint) q2;
-    INIT_CM( &p1, &p2);
- 
-    return;
-}
-
-void set_reduced(char * inputval, char * outputval)
-{
-fortint p1, p2;
- 
-    p1 = NIREDU;
-    if ( strcmp( inputval, "standard" ) == 0 )
-        p2 = 1;
-    else
-        p2 = 0;
-    INIT_CM( &p1, &p2);
- 
-    p1 = NOREDU;
-    if ( strcmp( outputval, "standard" ) == 0 )
-        p2 = 1;
-    else
-        p2 = 0;
-    INIT_CM( &p1, &p2);
-
-    return;
-}
-
-void set_uselsm(char * inputval, char * outputval)
-{
-fortint p1, p2;
- 
-    p1 = LSM;
-    if ( strcmp( inputval, "yes" ) == 0 )
-        p2 = 1;
-    else
-        p2 = 0;
-    INIT_CM( &p1, &p2);
- 
-    return;
-}
-
-void set_usewind(char * inputval, char * outputval)
-{
-fortint p1, p2;
- 
-    p1 = LWIND;
-    if ( strcmp( inputval, "yes" ) == 0 )
-        p2 = 1;
-    else
-        p2 = 0;
-    INIT_CM( &p1, &p2);
- 
-    return;
-}
-
-void set_useprecip(char * inputval, char * outputval)
-{
-fortint p1, p2;
- 
-    p1 = LPREC;
-    if ( strcmp( inputval, "yes" ) == 0 )
-        p2 = 1;
-    else
-        p2 = 0;
-    INIT_CM( &p1, &p2);
- 
-    return;
-}
-
-void set_lsm_param(char * inputval, char * outputval)
-{
-fortint p1, p2;
- 
-    p1 = LSMPAR;
-    if ( strcmp( inputval, "yes" ) == 0 )
-        p2 = 1;
-    else
-        p2 = 0;
-    INIT_CM( &p1, &p2);
-
-    return;
-}
-
diff --git a/interpolation/rename_unlink.c b/interpolation/rename_unlink.c
index bfb35c9..be1b54f 100644
--- a/interpolation/rename_unlink.c
+++ b/interpolation/rename_unlink.c
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "fortdefs.h"
+#include "common/fortint.h"
 
 /*
 // NB. Don't need the versions without underscore, they exist in
diff --git a/interpolation/reset_c.F b/interpolation/reset_c.F
index a4e15b4..5ea7038 100644
--- a/interpolation/reset_c.F
+++ b/interpolation/reset_c.F
@@ -8,7 +8,7 @@ C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
-      INTEGER FUNCTION RESET_C( KSEC1, KSEC2, PSEC2, KSEC4)
+      INTEGER FUNCTION RESET_C(KSEC1,KSEC2,PSEC2,KSEC4)
 C
 C---->
 C***  RESET_C
@@ -23,7 +23,7 @@ C
 C     Interface
 C     ---------
 C
-C     IRET = RESET_C( KSEC1, KSEC2, PSEC2, KSEC4)
+C     IRET = RESET_C(KSEC1,KSEC2,PSEC2,KSEC4)
 C
 C
 C     Input
@@ -73,6 +73,7 @@ C
       INTEGER JJPR, JJERR, ITEMP
       INTEGER I, IRET
       LOGICAL LSAME, LPQUASI
+      CHARACTER*1 HTYPE
 C
 C     Externals
 C
@@ -242,7 +243,8 @@ C       used.
 C
         IF( NOREPR.EQ.JPNOTYPE ) THEN
           IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-            CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
+            HTYPE = 'F'
+            CALL JGETGG(NOGAUSS,HTYPE,ROGAUSS,NOLPTS,IRET)
             IF( IRET.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,
      X          'RESET_C: JGETGG failed, NOGAUSS = ',NOGAUSS)
@@ -319,7 +321,8 @@ C       used.
 C
         IF( NOREPR.EQ.JPNOTYPE ) THEN
           IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-            CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
+            HTYPE = 'F'
+            CALL JGETGG(NOGAUSS,HTYPE,ROGAUSS,NOLPTS,IRET)
             IF( IRET.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,
      X          'RESET_C: JGETGG failed, NOGAUSS = ',NOGAUSS)
@@ -379,7 +382,8 @@ C
 C       Pick up gaussian definitions for input grid
 C
         IF( (NIGAUSO.NE.NIGAUSS).OR.(HIGAUST.NE.'F') ) THEN
-          CALL JGETGG( NIGAUSS, 'F', RIGAUSS, MILLEN, IRET)
+          HTYPE = 'F'
+          CALL JGETGG(NIGAUSS,HTYPE,RIGAUSS,MILLEN,IRET)
           IF( IRET.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'RESET_C: JGETGG failed, NIGAUSS = ',NIGAUSS)
@@ -408,7 +412,8 @@ C       to the input field if option 'gaussian' used.
 C
         IF( (NOREPR.EQ.JPNOTYPE).AND.(.NOT.LSAME) ) THEN
           IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-            CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
+            HTYPE = 'F'
+            CALL JGETGG(NOGAUSS,HTYPE,ROGAUSS,NOLPTS,IRET)
             IF( IRET.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,
      X          'RESET_C: JGETGG failed, NOGAUSS = ',NOGAUSS)
@@ -496,7 +501,8 @@ C       to the output field if option 'gaussian' used.
 C
         IF( (NOREPR.EQ.JPNOTYPE).AND.(.NOT.LSAME) ) THEN
           IF( (NOGAUSO.NE.NOGAUSS).OR.(HOGAUST.NE.'F') ) THEN
-            CALL JGETGG( NOGAUSS, 'F', ROGAUSS, NOLPTS, IRET)
+            HTYPE = 'F'
+            CALL JGETGG(NOGAUSS,HTYPE,ROGAUSS,NOLPTS,IRET)
             IF( IRET.NE.0 ) THEN
               CALL INTLOG(JP_ERROR,
      X          'RESET_C: JGETGG failed, NOGAUSS = ',NOGAUSS)
@@ -521,7 +527,8 @@ C
 C       Pick up gaussian definitions for input grid
 C
         IF( (NIGAUSO.NE.NIGAUSS).OR.(HIGAUST.NE.'F') ) THEN
-          CALL JGETGG( NIGAUSS, 'F', RIGAUSS, MILLEN, IRET)
+          HTYPE = 'F'
+          CALL JGETGG(NIGAUSS,HTYPE,RIGAUSS,MILLEN,IRET)
           IF( IRET.NE.0 ) THEN
             CALL INTLOG(JP_ERROR,
      X        'RESET_C: JGETGG failed, NIGAUSS = ',NIGAUSS)
diff --git a/interpolation/rgauss_080_19980130.h b/interpolation/rgauss_080_19980130.h
deleted file mode 100644
index 73c645b..0000000
--- a/interpolation/rgauss_080_19980130.h
+++ /dev/null
@@ -1,31 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-      REAL QG08018(80)
-      DATA QG08018/
-     X  18 ,  25 ,  36 ,  40,
-     X  45 ,  54 ,  60 ,  64,
-     X  72 ,  72 ,  80 ,  90,
-     X  96 , 100 , 108 , 120,
-     X 120 , 128 , 135 , 144,
-     X 144 , 150 , 160 , 160,
-     X 180 , 180 , 180 , 192,
-     X 192 , 200 , 200 , 216,
-     X 216 , 216 , 225 , 225,
-     X 240 , 240 , 240 , 256,
-     X 256 , 256 , 256 , 288,
-     X 288 , 288 , 288 , 288,
-     X 288 , 288 , 288 , 288,
-     X 300 , 300 , 300 , 300,
-     X 320 , 320 , 320 , 320,
-     X 320 , 320 , 320 , 320,
-     X 320 , 320 , 320 , 320,
-     X 320 , 320 , 320 , 320,
-     X 320 , 320 , 320 , 320,
-     X 320 , 320 , 320 , 320 /
diff --git a/interpolation/rgauss_640_octahedral_not_used.h b/interpolation/rgauss_640_octahedral_not_used.h
deleted file mode 100644
index 1baab64..0000000
--- a/interpolation/rgauss_640_octahedral_not_used.h
+++ /dev/null
@@ -1,139 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-	  REAL QG640(640) 
- 	  DATA QG640/
-     X 20, 24, 28, 32, 36,
-     X 40, 44, 48, 52, 56,
-     X 60, 64, 68, 72, 76,
-     X 80, 84, 88, 92, 96,
-     X 100, 104, 108, 112, 116,
-     X 120, 124, 128, 132, 136,
-     X 140, 144, 148, 152, 156,
-     X 160, 164, 168, 172, 176,
-     X 180, 184, 188, 192, 196,
-     X 200, 204, 208, 212, 216,
-     X 220, 224, 228, 232, 236,
-     X 240, 244, 248, 252, 256,
-     X 260, 264, 268, 272, 276,
-     X 280, 284, 288, 292, 296,
-     X 300, 304, 308, 312, 316,
-     X 320, 324, 328, 332, 336,
-     X 340, 344, 348, 352, 356,
-     X 360, 364, 368, 372, 376,
-     X 380, 384, 388, 392, 396,
-     X 400, 404, 408, 412, 416,
-     X 420, 424, 428, 432, 436,
-     X 440, 444, 448, 452, 456,
-     X 460, 464, 468, 472, 476,
-     X 480, 484, 488, 492, 496,
-     X 500, 504, 508, 512, 516,
-     X 520, 524, 528, 532, 536,
-     X 540, 544, 548, 552, 556,
-     X 560, 564, 568, 572, 576,
-     X 580, 584, 588, 592, 596,
-     X 600, 604, 608, 612, 616,
-     X 620, 624, 628, 632, 636,
-     X 640, 644, 648, 652, 656,
-     X 660, 664, 668, 672, 676,
-     X 680, 684, 688, 692, 696,
-     X 700, 704, 708, 712, 716,
-     X 720, 724, 728, 732, 736,
-     X 740, 744, 748, 752, 756,
-     X 760, 764, 768, 772, 776,
-     X 780, 784, 788, 792, 796,
-     X 800, 804, 808, 812, 816,
-     X 820, 824, 828, 832, 836,
-     X 840, 844, 848, 852, 856,
-     X 860, 864, 868, 872, 876,
-     X 880, 884, 888, 892, 896,
-     X 900, 904, 908, 912, 916,
-     X 920, 924, 928, 932, 936,
-     X 940, 944, 948, 952, 956,
-     X 960, 964, 968, 972, 976,
-     X 980, 984, 988, 992, 996,
-     X 1000, 1004, 1008, 1012, 1016,
-     X 1020, 1024, 1028, 1032, 1036,
-     X 1040, 1044, 1048, 1052, 1056,
-     X 1060, 1064, 1068, 1072, 1076,
-     X 1080, 1084, 1088, 1092, 1096,
-     X 1100, 1104, 1108, 1112, 1116,
-     X 1120, 1124, 1128, 1132, 1136,
-     X 1140, 1144, 1148, 1152, 1156,
-     X 1160, 1164, 1168, 1172, 1176,
-     X 1180, 1184, 1188, 1192, 1196,
-     X 1200, 1204, 1208, 1212, 1216,
-     X 1220, 1224, 1228, 1232, 1236,
-     X 1240, 1244, 1248, 1252, 1256,
-     X 1260, 1264, 1268, 1272, 1276,
-     X 1280, 1284, 1288, 1292, 1296,
-     X 1300, 1304, 1308, 1312, 1316,
-     X 1320, 1324, 1328, 1332, 1336,
-     X 1340, 1344, 1348, 1352, 1356,
-     X 1360, 1364, 1368, 1372, 1376,
-     X 1380, 1384, 1388, 1392, 1396,
-     X 1400, 1404, 1408, 1412, 1416,
-     X 1420, 1424, 1428, 1432, 1436,
-     X 1440, 1444, 1448, 1452, 1456,
-     X 1460, 1464, 1468, 1472, 1476,
-     X 1480, 1484, 1488, 1492, 1496,
-     X 1500, 1504, 1508, 1512, 1516,
-     X 1520, 1524, 1528, 1532, 1536,
-     X 1540, 1544, 1548, 1552, 1556,
-     X 1560, 1564, 1568, 1572, 1576,
-     X 1580, 1584, 1588, 1592, 1596,
-     X 1600, 1604, 1608, 1612, 1616,
-     X 1620, 1624, 1628, 1632, 1636,
-     X 1640, 1644, 1648, 1652, 1656,
-     X 1660, 1664, 1668, 1672, 1676,
-     X 1680, 1684, 1688, 1692, 1696,
-     X 1700, 1704, 1708, 1712, 1716,
-     X 1720, 1724, 1728, 1732, 1736,
-     X 1740, 1744, 1748, 1752, 1756,
-     X 1760, 1764, 1768, 1772, 1776,
-     X 1780, 1784, 1788, 1792, 1796,
-     X 1800, 1804, 1808, 1812, 1816,
-     X 1820, 1824, 1828, 1832, 1836,
-     X 1840, 1844, 1848, 1852, 1856,
-     X 1860, 1864, 1868, 1872, 1876,
-     X 1880, 1884, 1888, 1892, 1896,
-     X 1900, 1904, 1908, 1912, 1916,
-     X 1920, 1924, 1928, 1932, 1936,
-     X 1940, 1944, 1948, 1952, 1956,
-     X 1960, 1964, 1968, 1972, 1976,
-     X 1980, 1984, 1988, 1992, 1996,
-     X 2000, 2004, 2008, 2012, 2016,
-     X 2020, 2024, 2028, 2032, 2036,
-     X 2040, 2044, 2048, 2052, 2056,
-     X 2060, 2064, 2068, 2072, 2076,
-     X 2080, 2084, 2088, 2092, 2096,
-     X 2100, 2104, 2108, 2112, 2116,
-     X 2120, 2124, 2128, 2132, 2136,
-     X 2140, 2144, 2148, 2152, 2156,
-     X 2160, 2164, 2168, 2172, 2176,
-     X 2180, 2184, 2188, 2192, 2196,
-     X 2200, 2204, 2208, 2212, 2216,
-     X 2220, 2224, 2228, 2232, 2236,
-     X 2240, 2244, 2248, 2252, 2256,
-     X 2260, 2264, 2268, 2272, 2276,
-     X 2280, 2284, 2288, 2292, 2296,
-     X 2300, 2304, 2308, 2312, 2316,
-     X 2320, 2324, 2328, 2332, 2336,
-     X 2340, 2344, 2348, 2352, 2356,
-     X 2360, 2364, 2368, 2372, 2376,
-     X 2380, 2384, 2388, 2392, 2396,
-     X 2400, 2404, 2408, 2412, 2416,
-     X 2420, 2424, 2428, 2432, 2436,
-     X 2440, 2444, 2448, 2452, 2456,
-     X 2460, 2464, 2468, 2472, 2476,
-     X 2480, 2484, 2488, 2492, 2496,
-     X 2500, 2504, 2508, 2512, 2516,
-     X 2520, 2524, 2528, 2532, 2536,
-     X 2540, 2544, 2548, 2552, 2556,
-     X 2560, 2564, 2568, 2572, 2576 /
diff --git a/interpolation/rgauss_8000.h b/interpolation/rgauss_8000.h
deleted file mode 100644
index eddb4c2..0000000
--- a/interpolation/rgauss_8000.h
+++ /dev/null
@@ -1,1611 +0,0 @@
-C Copyright 1981-2014 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities
-C granted to it by virtue of its status as an intergovernmental organisation
-C nor does it submit to any jurisdiction.
-C
-      REAL QG8000(8000)
-          DATA QG8000/
-     X   16,    24,    30,    36,    40,    
-     X   45,    54,    60,    64,    72,    
-     X   72,    75,    81,    90,    90,    
-     X   96,    100,    108,    120,    120,    
-     X   120,    125,    128,    135,    144,    
-     X   144,    150,    160,    160,    160,    
-     X   180,    180,    180,    180,    192,    
-     X   192,    192,    200,    216,    216,    
-     X   216,    216,    225,    225,    240,    
-     X   240,    240,    243,    250,    250,    
-     X   256,    270,    270,    270,    288,    
-     X   288,    288,    288,    300,    300,    
-     X   300,    320,    320,    320,    320,    
-     X   324,    360,    360,    360,    360,    
-     X   360,    360,    360,    360,    375,    
-     X   375,    375,    375,    384,    384,    
-     X   400,    400,    400,    405,    405,    
-     X   432,    432,    432,    432,    432,    
-     X   432,    450,    450,    450,    450,    
-     X   480,    480,    480,    480,    480,    
-     X   480,    480,    486,    500,    500,    
-     X   500,    512,    512,    512,    540,    
-     X   540,    540,    540,    540,    540,    
-     X   540,    576,    576,    576,    576,    
-     X   576,    576,    576,    576,    600,    
-     X   600,    600,    600,    600,    625,    
-     X   625,    625,    625,    625,    625,    
-     X   640,    640,    640,    640,    648,    
-     X   675,    675,    675,    675,    675,    
-     X   675,    675,    720,    720,    720,    
-     X   720,    720,    720,    720,    720,    
-     X   720,    720,    729,    729,    750,    
-     X   750,    750,    750,    750,    768,    
-     X   768,    768,    768,    800,    800,    
-     X   800,    800,    800,    800,    800,    
-     X   800,    810,    810,    864,    864,    
-     X   864,    864,    864,    864,    864,    
-     X   864,    864,    864,    864,    864,    
-     X   864,    900,    900,    900,    900,    
-     X   900,    900,    900,    900,    960,    
-     X   960,    960,    960,    960,    960,    
-     X   960,    960,    960,    960,    960,    
-     X   960,    960,    960,    972,    972,    
-     X   972,    1000,    1000,    1000,    1000,    
-     X   1000,    1000,    1024,    1024,    1024,    
-     X   1024,    1024,    1024,    1080,    1080,    
-     X   1080,    1080,    1080,    1080,    1080,    
-     X   1080,    1080,    1080,    1080,    1080,    
-     X   1080,    1125,    1125,    1125,    1125,    
-     X   1125,    1125,    1125,    1125,    1125,    
-     X   1125,    1125,    1152,    1152,    1152,    
-     X   1152,    1152,    1152,    1200,    1200,    
-     X   1200,    1200,    1200,    1200,    1200,    
-     X   1200,    1200,    1200,    1200,    1215,    
-     X   1215,    1215,    1215,    1250,    1250,    
-     X   1250,    1250,    1250,    1250,    1250,    
-     X   1250,    1280,    1280,    1280,    1280,    
-     X   1280,    1280,    1280,    1296,    1296,    
-     X   1296,    1350,    1350,    1350,    1350,    
-     X   1350,    1350,    1350,    1350,    1350,    
-     X   1350,    1350,    1350,    1350,    1440,    
-     X   1440,    1440,    1440,    1440,    1440,    
-     X   1440,    1440,    1440,    1440,    1440,    
-     X   1440,    1440,    1440,    1440,    1440,    
-     X   1440,    1440,    1440,    1440,    1440,    
-     X   1458,    1458,    1458,    1458,    1500,    
-     X   1500,    1500,    1500,    1500,    1500,    
-     X   1500,    1500,    1500,    1500,    1536,    
-     X   1536,    1536,    1536,    1536,    1536,    
-     X   1536,    1536,    1536,    1600,    1600,    
-     X   1600,    1600,    1600,    1600,    1600,    
-     X   1600,    1600,    1600,    1600,    1600,    
-     X   1600,    1600,    1600,    1620,    1620,    
-     X   1620,    1620,    1728,    1728,    1728,    
-     X   1728,    1728,    1728,    1728,    1728,    
-     X   1728,    1728,    1728,    1728,    1728,    
-     X   1728,    1728,    1728,    1728,    1728,    
-     X   1728,    1728,    1728,    1728,    1728,    
-     X   1728,    1728,    1728,    1800,    1800,    
-     X   1800,    1800,    1800,    1800,    1800,    
-     X   1800,    1800,    1800,    1800,    1800,    
-     X   1800,    1800,    1800,    1800,    1800,    
-     X   1875,    1875,    1875,    1875,    1875,    
-     X   1875,    1875,    1875,    1875,    1875,    
-     X   1875,    1875,    1875,    1875,    1875,    
-     X   1875,    1875,    1875,    1920,    1920,    
-     X   1920,    1920,    1920,    1920,    1920,    
-     X   1920,    1920,    1920,    1944,    1944,    
-     X   1944,    1944,    1944,    1944,    2000,    
-     X   2000,    2000,    2000,    2000,    2000,    
-     X   2000,    2000,    2000,    2000,    2000,    
-     X   2000,    2000,    2025,    2025,    2025,    
-     X   2025,    2025,    2025,    2048,    2048,    
-     X   2048,    2048,    2048,    2160,    2160,    
-     X   2160,    2160,    2160,    2160,    2160,    
-     X   2160,    2160,    2160,    2160,    2160,    
-     X   2160,    2160,    2160,    2160,    2160,    
-     X   2160,    2160,    2160,    2160,    2160,    
-     X   2160,    2160,    2160,    2160,    2160,    
-     X   2187,    2187,    2187,    2187,    2187,    
-     X   2187,    2250,    2250,    2250,    2250,    
-     X   2250,    2250,    2250,    2250,    2250,    
-     X   2250,    2250,    2250,    2250,    2250,    
-     X   2250,    2304,    2304,    2304,    2304,    
-     X   2304,    2304,    2304,    2304,    2304,    
-     X   2304,    2304,    2304,    2304,    2400,    
-     X   2400,    2400,    2400,    2400,    2400,    
-     X   2400,    2400,    2400,    2400,    2400,    
-     X   2400,    2400,    2400,    2400,    2400,    
-     X   2400,    2400,    2400,    2400,    2400,    
-     X   2400,    2400,    2430,    2430,    2430,    
-     X   2430,    2430,    2430,    2430,    2500,    
-     X   2500,    2500,    2500,    2500,    2500,    
-     X   2500,    2500,    2500,    2500,    2500,    
-     X   2500,    2500,    2500,    2500,    2500,    
-     X   2560,    2560,    2560,    2560,    2560,    
-     X   2560,    2560,    2560,    2560,    2560,    
-     X   2560,    2560,    2560,    2560,    2592,    
-     X   2592,    2592,    2592,    2592,    2592,    
-     X   2592,    2592,    2700,    2700,    2700,    
-     X   2700,    2700,    2700,    2700,    2700,    
-     X   2700,    2700,    2700,    2700,    2700,    
-     X   2700,    2700,    2700,    2700,    2700,    
-     X   2700,    2700,    2700,    2700,    2700,    
-     X   2700,    2700,    2700,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2880,    2880,    2880,    2880,    
-     X   2880,    2916,    2916,    2916,    2916,    
-     X   2916,    2916,    2916,    2916,    3000,    
-     X   3000,    3000,    3000,    3000,    3000,    
-     X   3000,    3000,    3000,    3000,    3000,    
-     X   3000,    3000,    3000,    3000,    3000,    
-     X   3000,    3000,    3000,    3000,    3072,    
-     X   3072,    3072,    3072,    3072,    3072,    
-     X   3072,    3072,    3072,    3072,    3072,    
-     X   3072,    3072,    3072,    3072,    3072,    
-     X   3072,    3125,    3125,    3125,    3125,    
-     X   3125,    3125,    3125,    3125,    3125,    
-     X   3125,    3125,    3125,    3125,    3200,    
-     X   3200,    3200,    3200,    3200,    3200,    
-     X   3200,    3200,    3200,    3200,    3200,    
-     X   3200,    3200,    3200,    3200,    3200,    
-     X   3200,    3200,    3240,    3240,    3240,    
-     X   3240,    3240,    3240,    3240,    3240,    
-     X   3240,    3375,    3375,    3375,    3375,    
-     X   3375,    3375,    3375,    3375,    3375,    
-     X   3375,    3375,    3375,    3375,    3375,    
-     X   3375,    3375,    3375,    3375,    3375,    
-     X   3375,    3375,    3375,    3375,    3375,    
-     X   3375,    3375,    3375,    3375,    3375,    
-     X   3375,    3375,    3375,    3375,    3456,    
-     X   3456,    3456,    3456,    3456,    3456,    
-     X   3456,    3456,    3456,    3456,    3456,    
-     X   3456,    3456,    3456,    3456,    3456,    
-     X   3456,    3456,    3456,    3600,    3600,    
-     X   3600,    3600,    3600,    3600,    3600,    
-     X   3600,    3600,    3600,    3600,    3600,    
-     X   3600,    3600,    3600,    3600,    3600,    
-     X   3600,    3600,    3600,    3600,    3600,    
-     X   3600,    3600,    3600,    3600,    3600,    
-     X   3600,    3600,    3600,    3600,    3600,    
-     X   3600,    3600,    3645,    3645,    3645,    
-     X   3645,    3645,    3645,    3645,    3645,    
-     X   3645,    3645,    3645,    3750,    3750,    
-     X   3750,    3750,    3750,    3750,    3750,    
-     X   3750,    3750,    3750,    3750,    3750,    
-     X   3750,    3750,    3750,    3750,    3750,    
-     X   3750,    3750,    3750,    3750,    3750,    
-     X   3750,    3750,    3750,    3840,    3840,    
-     X   3840,    3840,    3840,    3840,    3840,    
-     X   3840,    3840,    3840,    3840,    3840,    
-     X   3840,    3840,    3840,    3840,    3840,    
-     X   3840,    3840,    3840,    3840,    3840,    
-     X   3888,    3888,    3888,    3888,    3888,    
-     X   3888,    3888,    3888,    3888,    3888,    
-     X   3888,    3888,    4000,    4000,    4000,    
-     X   4000,    4000,    4000,    4000,    4000,    
-     X   4000,    4000,    4000,    4000,    4000,    
-     X   4000,    4000,    4000,    4000,    4000,    
-     X   4000,    4000,    4000,    4000,    4000,    
-     X   4000,    4000,    4000,    4050,    4050,    
-     X   4050,    4050,    4050,    4050,    4050,    
-     X   4050,    4050,    4050,    4050,    4050,    
-     X   4096,    4096,    4096,    4096,    4096,    
-     X   4096,    4096,    4096,    4096,    4096,    
-     X   4096,    4096,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4320,    4320,    4320,    4320,    
-     X   4320,    4374,    4374,    4374,    4374,    
-     X   4374,    4374,    4374,    4374,    4374,    
-     X   4374,    4374,    4374,    4374,    4500,    
-     X   4500,    4500,    4500,    4500,    4500,    
-     X   4500,    4500,    4500,    4500,    4500,    
-     X   4500,    4500,    4500,    4500,    4500,    
-     X   4500,    4500,    4500,    4500,    4500,    
-     X   4500,    4500,    4500,    4500,    4500,    
-     X   4500,    4500,    4500,    4500,    4608,    
-     X   4608,    4608,    4608,    4608,    4608,    
-     X   4608,    4608,    4608,    4608,    4608,    
-     X   4608,    4608,    4608,    4608,    4608,    
-     X   4608,    4608,    4608,    4608,    4608,    
-     X   4608,    4608,    4608,    4608,    4608,    
-     X   4800,    4800,    4800,    4800,    4800,    
-     X   4800,    4800,    4800,    4800,    4800,    
-     X   4800,    4800,    4800,    4800,    4800,    
-     X   4800,    4800,    4800,    4800,    4800,    
-     X   4800,    4800,    4800,    4800,    4800,    
-     X   4860,    4860,    4860,    4860,    4860,    
-     X   4860,    5000,    5000,    5000,    5000,    
-     X   5000,    5000,    5000,    5000,    5000,    
-     X   5000,    5000,    5000,    5000,    5000,    
-     X   5000,    5000,    5000,    5120,    5120,    
-     X   5120,    5120,    5120,    5120,    5120,    
-     X   5120,    5120,    5120,    5120,    5120,    
-     X   5120,    5184,    5184,    5184,    5184,    
-     X   5184,    5184,    5184,    5400,    5400,    
-     X   5400,    5400,    5400,    5400,    5400,    
-     X   5400,    5400,    5400,    5400,    5400,    
-     X   5400,    5400,    5400,    5400,    5400,    
-     X   5400,    5400,    5400,    5400,    5400,    
-     X   5400,    5400,    5400,    5625,    5625,    
-     X   5625,    5625,    5625,    5625,    5625,    
-     X   5625,    5625,    5625,    5625,    5625,    
-     X   5625,    5625,    5625,    5625,    5625,    
-     X   5625,    5625,    5625,    5625,    5625,    
-     X   5625,    5625,    5625,    5625,    5625,    
-     X   5760,    5760,    5760,    5760,    5760,    
-     X   5760,    5760,    5760,    5760,    5760,    
-     X   5760,    5760,    5760,    5760,    5760,    
-     X   5760,    5832,    5832,    5832,    5832,    
-     X   5832,    5832,    5832,    5832,    5832,    
-     X   6000,    6000,    6000,    6000,    6000,    
-     X   6000,    6000,    6000,    6000,    6000,    
-     X   6000,    6000,    6000,    6000,    6000,    
-     X   6000,    6000,    6000,    6000,    6000,    
-     X   6000,    6075,    6075,    6075,    6075,    
-     X   6075,    6075,    6075,    6075,    6075,    
-     X   6144,    6144,    6144,    6144,    6144,    
-     X   6144,    6144,    6144,    6250,    6250,    
-     X   6250,    6250,    6250,    6250,    6250,    
-     X   6250,    6250,    6250,    6250,    6250,    
-     X   6250,    6250,    6400,    6400,    6400,    
-     X   6400,    6400,    6400,    6400,    6400,    
-     X   6400,    6400,    6400,    6400,    6400,    
-     X   6400,    6400,    6400,    6400,    6400,    
-     X   6400,    6480,    6480,    6480,    6480,    
-     X   6480,    6480,    6480,    6480,    6480,    
-     X   6480,    6480,    6561,    6561,    6561,    
-     X   6561,    6561,    6561,    6561,    6561,    
-     X   6561,    6750,    6750,    6750,    6750,    
-     X   6750,    6750,    6750,    6750,    6750,    
-     X   6750,    6750,    6750,    6750,    6750,    
-     X   6750,    6750,    6750,    6750,    6750,    
-     X   6750,    6750,    6750,    6750,    6750,    
-     X   6750,    6912,    6912,    6912,    6912,    
-     X   6912,    6912,    6912,    6912,    6912,    
-     X   6912,    6912,    6912,    6912,    6912,    
-     X   6912,    6912,    6912,    6912,    6912,    
-     X   6912,    6912,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7200,    7200,    7200,    7200,    7200,    
-     X   7290,    7290,    7290,    7290,    7290,    
-     X   7290,    7290,    7290,    7290,    7290,    
-     X   7290,    7290,    7500,    7500,    7500,    
-     X   7500,    7500,    7500,    7500,    7500,    
-     X   7500,    7500,    7500,    7500,    7500,    
-     X   7500,    7500,    7500,    7500,    7500,    
-     X   7500,    7500,    7500,    7500,    7500,    
-     X   7500,    7500,    7500,    7500,    7500,    
-     X   7500,    7680,    7680,    7680,    7680,    
-     X   7680,    7680,    7680,    7680,    7680,    
-     X   7680,    7680,    7680,    7680,    7680,    
-     X   7680,    7680,    7680,    7680,    7680,    
-     X   7680,    7680,    7680,    7680,    7680,    
-     X   7680,    7776,    7776,    7776,    7776,    
-     X   7776,    7776,    7776,    7776,    7776,    
-     X   7776,    7776,    7776,    8000,    8000,    
-     X   8000,    8000,    8000,    8000,    8000,    
-     X   8000,    8000,    8000,    8000,    8000,    
-     X   8000,    8000,    8000,    8000,    8000,    
-     X   8000,    8000,    8000,    8000,    8000,    
-     X   8000,    8000,    8000,    8000,    8000,    
-     X   8000,    8000,    8000,    8000,    8000,    
-     X   8100,    8100,    8100,    8100,    8100,    
-     X   8100,    8100,    8100,    8100,    8100,    
-     X   8100,    8100,    8100,    8100,    8192,    
-     X   8192,    8192,    8192,    8192,    8192,    
-     X   8192,    8192,    8192,    8192,    8192,    
-     X   8192,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8640,    8640,    8640,    8640,    8640,    
-     X   8748,    8748,    8748,    8748,    8748,    
-     X   8748,    8748,    8748,    8748,    8748,    
-     X   8748,    8748,    8748,    8748,    8748,    
-     X   8748,    9000,    9000,    9000,    9000,    
-     X   9000,    9000,    9000,    9000,    9000,    
-     X   9000,    9000,    9000,    9000,    9000,    
-     X   9000,    9000,    9000,    9000,    9000,    
-     X   9000,    9000,    9000,    9000,    9000,    
-     X   9000,    9000,    9000,    9000,    9000,    
-     X   9000,    9000,    9000,    9000,    9000,    
-     X   9000,    9216,    9216,    9216,    9216,    
-     X   9216,    9216,    9216,    9216,    9216,    
-     X   9216,    9216,    9216,    9216,    9216,    
-     X   9216,    9216,    9216,    9216,    9216,    
-     X   9216,    9216,    9216,    9216,    9216,    
-     X   9216,    9216,    9216,    9216,    9216,    
-     X   9216,    9216,    9375,    9375,    9375,    
-     X   9375,    9375,    9375,    9375,    9375,    
-     X   9375,    9375,    9375,    9375,    9375,    
-     X   9375,    9375,    9375,    9375,    9375,    
-     X   9375,    9375,    9375,    9375,    9375,    
-     X   9375,    9600,    9600,    9600,    9600,    
-     X   9600,    9600,    9600,    9600,    9600,    
-     X   9600,    9600,    9600,    9600,    9600,    
-     X   9600,    9600,    9600,    9600,    9600,    
-     X   9600,    9600,    9600,    9600,    9600,    
-     X   9600,    9600,    9600,    9600,    9600,    
-     X   9600,    9600,    9600,    9720,    9720,    
-     X   9720,    9720,    9720,    9720,    9720,    
-     X   9720,    9720,    9720,    9720,    9720,    
-     X   9720,    9720,    9720,    9720,    9720,    
-     X   9720,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10000,    10000,    
-     X   10000,    10000,    10000,    10125,    10125,    
-     X   10125,    10125,    10125,    10125,    10125,    
-     X   10125,    10125,    10125,    10125,    10125,    
-     X   10125,    10125,    10125,    10125,    10125,    
-     X   10125,    10125,    10240,    10240,    10240,    
-     X   10240,    10240,    10240,    10240,    10240,    
-     X   10240,    10240,    10240,    10240,    10240,    
-     X   10240,    10240,    10240,    10240,    10240,    
-     X   10368,    10368,    10368,    10368,    10368,    
-     X   10368,    10368,    10368,    10368,    10368,    
-     X   10368,    10368,    10368,    10368,    10368,    
-     X   10368,    10368,    10368,    10368,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10800,    
-     X   10800,    10800,    10800,    10800,    10935,    
-     X   10935,    10935,    10935,    10935,    10935,    
-     X   10935,    10935,    10935,    10935,    10935,    
-     X   10935,    10935,    10935,    10935,    10935,    
-     X   10935,    10935,    10935,    10935,    10935,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11250,    
-     X   11250,    11250,    11250,    11250,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11520,    11520,    11520,    11520,    11520,    
-     X   11664,    11664,    11664,    11664,    11664,    
-     X   11664,    11664,    11664,    11664,    11664,    
-     X   11664,    11664,    11664,    11664,    11664,    
-     X   11664,    11664,    11664,    11664,    11664,    
-     X   11664,    11664,    11664,    11664,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12000,    12000,    12000,    12000,    
-     X   12000,    12150,    12150,    12150,    12150,    
-     X   12150,    12150,    12150,    12150,    12150,    
-     X   12150,    12150,    12150,    12150,    12150,    
-     X   12150,    12150,    12150,    12150,    12150,    
-     X   12150,    12150,    12150,    12150,    12150,    
-     X   12150,    12288,    12288,    12288,    12288,    
-     X   12288,    12288,    12288,    12288,    12288,    
-     X   12288,    12288,    12288,    12288,    12288,    
-     X   12288,    12288,    12288,    12288,    12288,    
-     X   12288,    12288,    12500,    12500,    12500,    
-     X   12500,    12500,    12500,    12500,    12500,    
-     X   12500,    12500,    12500,    12500,    12500,    
-     X   12500,    12500,    12500,    12500,    12500,    
-     X   12500,    12500,    12500,    12500,    12500,    
-     X   12500,    12500,    12500,    12500,    12500,    
-     X   12500,    12500,    12500,    12500,    12500,    
-     X   12500,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12800,    
-     X   12800,    12800,    12800,    12800,    12960,    
-     X   12960,    12960,    12960,    12960,    12960,    
-     X   12960,    12960,    12960,    12960,    12960,    
-     X   12960,    12960,    12960,    12960,    12960,    
-     X   12960,    12960,    12960,    12960,    12960,    
-     X   12960,    12960,    12960,    12960,    13122,    
-     X   13122,    13122,    13122,    13122,    13122,    
-     X   13122,    13122,    13122,    13122,    13122,    
-     X   13122,    13122,    13122,    13122,    13122,    
-     X   13122,    13122,    13122,    13122,    13122,    
-     X   13122,    13122,    13122,    13122,    13122,    
-     X   13122,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13500,    
-     X   13500,    13500,    13500,    13500,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    13824,    13824,    13824,    
-     X   13824,    13824,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14400,    14400,    
-     X   14400,    14400,    14400,    14580,    14580,    
-     X   14580,    14580,    14580,    14580,    14580,    
-     X   14580,    14580,    14580,    14580,    14580,    
-     X   14580,    14580,    14580,    14580,    14580,    
-     X   14580,    14580,    14580,    14580,    14580,    
-     X   14580,    14580,    14580,    14580,    14580,    
-     X   14580,    14580,    14580,    14580,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15000,    
-     X   15000,    15000,    15000,    15000,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15360,    15360,    15360,    
-     X   15360,    15360,    15552,    15552,    15552,    
-     X   15552,    15552,    15552,    15552,    15552,    
-     X   15552,    15552,    15552,    15552,    15552,    
-     X   15552,    15552,    15552,    15552,    15552,    
-     X   15552,    15552,    15552,    15552,    15552,    
-     X   15552,    15552,    15552,    15552,    15552,    
-     X   15552,    15552,    15552,    15552,    15625,    
-     X   15625,    15625,    15625,    15625,    15625,    
-     X   15625,    15625,    15625,    15625,    15625,    
-     X   15625,    15625,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16000,    16000,    16000,    
-     X   16000,    16000,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16200,    16200,    
-     X   16200,    16200,    16200,    16384,    16384,    
-     X   16384,    16384,    16384,    16384,    16384,    
-     X   16384,    16384,    16384,    16384,    16384,    
-     X   16384,    16384,    16384,    16384,    16384,    
-     X   16384,    16384,    16384,    16384,    16384,    
-     X   16384,    16384,    16384,    16384,    16384,    
-     X   16384,    16384,    16384,    16384,    16384,    
-     X   16384,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    16875,    16875,    
-     X   16875,    16875,    16875,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17280,    17280,    17280,    17280,    17280,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    17496,    17496,    17496,    17496,    
-     X   17496,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18000,    18000,    
-     X   18000,    18000,    18000,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18225,    18225,    18225,    18225,    18225,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18432,    18432,    18432,    
-     X   18432,    18432,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    18750,    18750,    
-     X   18750,    18750,    18750,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19200,    19200,    
-     X   19200,    19200,    19200,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19440,    19440,    19440,    19440,    19440,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    19683,    19683,    
-     X   19683,    19683,    19683,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20000,    
-     X   20000,    20000,    20000,    20000,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20250,    
-     X   20250,    20250,    20250,    20250,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20480,    20480,    20480,    20480,    
-     X   20480,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    20736,    20736,    
-     X   20736,    20736,    20736,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21600,    21600,    21600,    21600,    
-     X   21600,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    21870,    
-     X   21870,    21870,    21870,    21870,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    22500,    22500,    
-     X   22500,    22500,    22500,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23040,    
-     X   23040,    23040,    23040,    23040,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    23328,    
-     X   23328,    23328,    23328,    23328,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24000,    24000,    24000,    
-     X   24000,    24000,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24300,    24300,    24300,    24300,    24300,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    24576,    24576,    24576,    
-     X   24576,    24576,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25000,    25000,    25000,    25000,    
-     X   25000,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25600,    25600,    
-     X   25600,    25600,    25600,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    25920,    25920,    25920,    
-     X   25920,    25920,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    26244,    26244,    26244,    26244,    
-     X   26244,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27000,    27000,    27000,    27000,    
-     X   27000,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    27648,    27648,    27648,    27648,    
-     X   27648,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28125,    28125,    28125,    28125,    28125,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    28800,    
-     X   28800,    28800,    28800,    28800,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    29160,    29160,    
-     X   29160,    29160,    29160,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30000,    30000,    30000,    
-     X   30000,    30000,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30375,    30375,    30375,    30375,    30375,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    30720,    30720,    
-     X   30720,    30720,    30720,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31104,    31104,    
-     X   31104,    31104,    31104,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    31250,    31250,    31250,    31250,    
-     X   31250,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000,    
-     X   32000,    32000,    32000,    32000,    32000 /    
diff --git a/interpolation/rphi.F b/interpolation/rphi.F
index 44fc2fd..9c7c9ee 100644
--- a/interpolation/rphi.F
+++ b/interpolation/rphi.F
@@ -90,7 +90,7 @@ C     Parameters
 C
 C     Local variables
       COMPLEX*16 CC
-      INTEGER I, IPMN, NS, M, J
+      INTEGER IPMN, NS, M, J
       REAL*8 RAD, XLON
 C
 C ------------------------------------------------------------------
diff --git a/interpolation/shareddt.c b/interpolation/shareddt.c
index ea05237..3d6f837 100644
--- a/interpolation/shareddt.c
+++ b/interpolation/shareddt.c
@@ -1,16 +1,17 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
-#include "common/fortint.h"
 #include "sharedlib.h"
+#include "common/fortint.h"
+#include "common/JPointer.h"
 
 #ifdef FORTRAN_NO_UNDERSCORE
 #define SHAREDDT shareddt
@@ -19,7 +20,7 @@
 #endif
 
 fortint SHAREDDT(
-  JPointer* ipdum) 
+  JPointer* ipdum)
 /*
 C
 C**** SHAREDDT
diff --git a/interpolation/sharedgg.c b/interpolation/sharedgg.c
index 9bda70e..6973c72 100644
--- a/interpolation/sharedgg.c
+++ b/interpolation/sharedgg.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -25,8 +25,9 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <string.h>
-#include "common/fortint.h"
 #include "sharedlib.h"
+#include "common/fortint.h"
+#include "common/JPointer.h"
 
 #include <sys/ipc.h>
 #include <sys/shm.h>
@@ -47,7 +48,7 @@
 fortint SHAREDGG(
   JPointer* ipdum,
   fortint* iktrunc,
-  fortint* knum)
+  fortint* knum )
 
 /*
 C
@@ -68,8 +69,12 @@ fortint l1, l2;
 #endif
 
 char filedum[128], filename[128];
-char ypfn[13] =        "CF_xxxx_nnnn";
-static char yold[13] = "xxxxxxxxxxxx";
+#ifdef REAL_8
+char ypfn[21] =        "CF_xxxx_nnnn";
+#else
+char ypfn[21] =        "cf_xxxx_nnnn";
+#endif
+static char yold[21] = "xxxxxxxxxxxxxxxxxxxx";
 char defaultDirectory[] = "./";
 int kbuild ;
 char * fn;
@@ -84,10 +89,6 @@ pid_t process_id;
 int ktrunc = (int) (*iktrunc);
 
 /*
-//  Setup the filename: cf_txxxx_raabbbbb
-*/
-
-/*
 //  Setup the file name
 */
   sprintf( ypfn+3, "%04d", ktrunc);
@@ -108,8 +109,8 @@ int ktrunc = (int) (*iktrunc);
   }
   /* printf("gg share_file filename=%s\n",filename); */
 
-	result = (void *) share_file(filename);
-  	if (result == NULL) kret = 1;
+  result = (void *) share_file(filename);
+  if (result == NULL) kret = 1;
 
   *ipdum = (JPointer) result;
 
diff --git a/interpolation/sharedll.c b/interpolation/sharedll.c
index bd501d7..d28395c 100644
--- a/interpolation/sharedll.c
+++ b/interpolation/sharedll.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -25,8 +25,9 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <string.h>
-#include "common/fortint.h"
 #include "sharedlib.h"
+#include "common/fortint.h"
+#include "common/JPointer.h"
 
 #include <sys/ipc.h>
 #include <sys/shm.h>
@@ -69,8 +70,12 @@ fortint l1, l2;
 #endif
 
 char filedum[128], filename[128];
-char ypfn[18] =        "CF_Txxxx_Raabbbb";
-static char yold[18] = "xxxxxxxxxxxxxxxx";
+#ifdef REAL_8
+char ypfn[21] =        "CF_Txxxx_Raabbbb";
+#else
+char ypfn[21] =        "cf_txxxx_raabbbb";
+#endif
+static char yold[21] = "xxxxxxxxxxxxxxxxxxxx";
 char defaultDirectory[] = "./";
 int kbuild ;
 char * fn;
@@ -85,15 +90,15 @@ pid_t process_id;
 int ktrunc = (int) (*iktrunc);
 
 /*
-//  Setup the filename: cf_txxxx_raabbbbb
-*/
-
-/*
 //  Setup the file name
 */
   sprintf( ypfn+4, "%04d", ktrunc);
   kbuild = (int) (((*platinc)*100000.0) + 0.5);
+#ifdef REAL_8
   sprintf( ypfn+8, "_R%07d", kbuild);
+#else
+  sprintf( ypfn+8, "_r%07d", kbuild);
+#endif
 
 /*
 //  See if the  file has already been created.
diff --git a/interpolation/sharedmemory.h b/interpolation/sharedmemory.h
deleted file mode 100644
index d1180d4..0000000
--- a/interpolation/sharedmemory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-#ifndef SHAREDMEMORY_H
-#define SHAREDMEMORY_H
-
-#define SP2LL 0
-#define SP2RG 1
-#define SP2QG 2
-#define READY_TO_READ 5
-#define SLEEP_TIME 3
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define SMREAD smread
-#define NMAKLL nmakll
-#define NMAKGG nmakgg
-#define JGETGG jgetgg
-#define JNUMGG jnumgg
-#define JDEBUG jdebug
-#else
-#define SMREAD smread_
-#define NMAKLL nmakll_
-#define NMAKGG nmakgg_
-#define JGETGG jgetgg_
-#define JNUMGG jnumgg_
-#define JDEBUG jdebug_
-#endif
-
-/*
-// Debug flags.
-*/
-#define DEBUGOFF 1
-#define DEBUG (debugSet > DEBUGOFF ) 
-
-#endif /* end of SHAREDMEMORY_H */
diff --git a/interpolation/showmap.c b/interpolation/showmap.c
deleted file mode 100644
index a75d937..0000000
--- a/interpolation/showmap.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-
-#include "bitmap.h"
-
-void SHOWMAP(
-  char ** mybuffer,
-  int * rowCount,
-  int * columnCount) {
-/*
-// Displays the bits in a bitmap.
-//
-// Called from FORTRAN:
-//
-// CALL SHOWMAP(BITMAP,ROWCNT,COLCNT)
-//
-// where:
-//
-// BITMAP is an array containing the bitmap.
-// ROWCNT is the number of rows
-// COLCNT is the number of columns
-//
-*/
-int value, i, j, bitNumber, byte, bit;
-int rowTotal = *rowCount;
-int columnTotal = *columnCount;
-char * buffer;
-
-  buffer = *mybuffer;
-
-  for( i = 0; i < rowTotal; i++ ) {
-    printf("\n");
-    for( j = 0; j < columnTotal; j++ ) {
-      bitNumber = i*columnTotal + j;
-      byte = bitNumber / 8;
-      bit  = bitNumber % 8;
-      value = (buffer[byte] >> (7-bit)) & 0x01;
-      printf("%d ", value);
-    }
-  }
-  printf("\n");
-
-}
diff --git a/interpolation/soffset.c b/interpolation/soffset.c
deleted file mode 100644
index 9b2d7f1..0000000
--- a/interpolation/soffset.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include "common/fortint.h"
-
-
-/* defines for FORTRAN subroutine */
-#ifdef FORTRAN_NO_UNDERSCORE
-#define SOFFSET soffset
-#else
-#define SOFFSET soffset_
-#endif
-
-#define ERROR(a,b) {perror(a);return b;}
-#define GRIB 0x47524942
-#define len3oct(p) ((((long)*(p))<<16) + (((long)*(p+1))<<8) + (long)*(p+2))
-#define BIT1 0x80
-#define BIT2 0x40
-#define BIT3 0x20
-#define BIT4 0x10
-#define BIT5 0x08
-#define BIT6 0x04
-#define BIT7 0x02
-#define BIT8 0x01
-
-static int grab(unsigned char * , unsigned char * , long ,long ,long * );
-
-fortint soffset_(
-  unsigned char * buffer,
-  fortint* is0,
-  fortint* is1,
-  fortint* is2,
-  fortint* is3,
-  fortint* is4,
-  fortint* iedition) {
-long s0, s1, s2, s3, s4, edition;
-int large = 0;
-int found = 0;
-int code = 0;
-long bytes_read = 0, advance;
-unsigned char p, edit_num, flag23;
-unsigned char size[3];
-int section0 = 8, section1, section2, section3, section4;
-long total;
-unsigned char grp_7777[5];
-
-/*  Read bytes until "GRIB" found */
-
-    do
-    {
-        if( grab(buffer, &p, 1, 1, &bytes_read) != 0) return 1;
-        code = ( (code << 8) + p ) & 0xFFFFFFFF;
-        if (code == GRIB ) found = 1;
-    } while ( ! found );
-    s0 = bytes_read - 4;
-    bytes_read = 4;
-
-/*  Now find out which edition of GRIB is present (default is 1) */
-
-    edition = 1;
-    s1 = s0 + 8;
-    if( (*(buffer+21-s0) == '\0') && (*(buffer+22-s0) == '\0') )
-    {
-        edition = -1;                            /* GRIB edition -1 */
-        s1 = s0;
-        section1 = 20;
-        section0 = 4;
-    }
-    else
-    {
-        if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-        total = len3oct(size);
-        if( total == 24 )
-        {
-/*          Move past the edition number */
-            if( grab(buffer, &edit_num, 1, 1, &bytes_read) != 0) return 1;
-            edition = 0;                         /* GRIB edition 0 */
-            section1 = 24;
-            s1 = s0 + 4;
-            section0 = 4;
-        }
-    }
-
-    if( edition == 1 )
-    {
-/*      See if it is an extra large (wave) product */
-        if( total > 0x800000 ) {
-            total = (total&0x7fffff) * 120;
-            large = 1;
-        }
-/*      Move past the edition number */
-        if( grab(buffer, &edit_num, 1, 1, &bytes_read) != 0) return 1;
-
-/*      Read length of section 1 */
-        if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-        section1 = len3oct(size);
-    }
-
-/*  Now figure out if sections 2/3 are present */
-
-    advance = 4;
-    bytes_read += advance;
-    if( grab(buffer, &flag23, 1, 1, &bytes_read) != 0) return 1;
-    section2 = flag23 & BIT1;
-    section3 = flag23 & BIT2;
-
-/*  Advance to end of section 1 */
-
-    advance = section1 - (bytes_read - section0);
-    bytes_read += advance;
-
-/*  Read section 2 length if it is given*/
-
-    if( section2 )
-    {
-        s2 = s0 + bytes_read;
-        if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-        section2 = len3oct(size);
-        advance = section2 - (bytes_read - section0 - section1);
-        bytes_read += advance;
-    }
-    else
-    {
-        section2 = 0;
-	s2 = 0;
-    }
-
-/*  Read section 3 length if it is given*/
-
-    if( section3 )
-    {
-        s3 = s0 + bytes_read;
-        if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-        section3 = len3oct(size);
-        advance = section3 - (bytes_read - section0 - section1 - section2);
-        bytes_read += advance;
-    }
-    else
-    {
-        section3 = 0;
-	s3 = 0;
-    }
-
-/*  Read section 4 length */
-
-    s4 = s0 + bytes_read;
-    if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-    section4 = len3oct(size);
-    if( large ) section4 = total + 3 - bytes_read - section4; 
-    advance = section4 - (bytes_read - section0 - section1 - section2 - section3);
-    bytes_read += advance;
-
-/*  Check 7777 group is in the expected place */
-
-    if( grab(buffer, grp_7777, 4, 1, &bytes_read) != 0) return 1;
-    grp_7777[4] = '\0';
-    if( strcmp((char *)grp_7777,"7777") != 0 )
-      ERROR("7777 group not found", 15);
-  
-
-/*  Success! */
-    *is0 = (fortint) s0;
-    *is1 = (fortint) s1;
-    *is2 = (fortint) s2;
-    *is3 = (fortint) s3;
-    *is4 = (fortint) s4;
-    *iedition = (fortint) edition;
-    return 0;
-}
-
-fortint soffset(
-  unsigned char * buffer,
-  fortint* is0,
-  fortint* is1,
-  fortint* is2,
-  fortint* is3,
-  fortint* is4,
-  fortint* iedition) {
-  return soffset_(buffer,is0,is1,is2,is3,is4,iedition);
-}
-
-static int grab(unsigned char * buffer, unsigned char * where, long size,long cnt,long * num_bytes_read)
-{
-long number = size*cnt;
-
-    memcpy(where, (buffer+(*num_bytes_read)), number);
-    *num_bytes_read += number;
-
-    return 0;
-}
diff --git a/interpolation/sprotat.F b/interpolation/sprotat.F
deleted file mode 100644
index 6305c2e..0000000
--- a/interpolation/sprotat.F
+++ /dev/null
@@ -1,229 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION SPROTAT(INGRIB,INLEN,SLON,SLAT,OUTGRIB,OUTLEN)
-C
-C---->
-C**** SPROTAT
-C
-C     Purpose
-C     -------
-C
-C     Rotates a spherical harmonic field.
-C
-C
-C     Interface
-C     ---------
-C
-C     IRET = SPROTAT(INGRIB,INLEN,SLON,SLAT,OUTGRIB,OUTLEN)
-C
-C     Input
-C     -----
-C
-C     INGRIB  - Input GRIB field of spherical harmonics.
-C     INLEN   - Length in bytes of the input GRIB.
-C     SLON    - Longitude rotation required (degrees)
-C     SLAT    - Latitude rotation required (degrees)
-C
-C
-C     Output
-C     ------
-C
-C     OUTGRIB  - Output GRIB field of rotated spherical harmonics.
-C     OUTLEN   - Length in bytes of the output GRIB.
-C
-C     Function returns 0 if all OK, otherwise the rotation failed.
-C
-C
-C     Method
-C     ------
-C
-C     Externals
-C     ---------
-C
-C     GRIBEX  - Decode/encode a GRIB product.
-C     RPHI    - Rotates spectral coefficients by longitude.
-C     JACOBI  - Rotates spectral coefficients by latitude.
-C     INTLOG  - Logs messages.
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers         ECMWF     October, 1995.
-C
-C
-C---------------------------------------------------------------------
-C----<
-C
-      IMPLICIT NONE
-#include "parim.h"
-C
-C     Parameters
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 28300)
-      INTEGER JPLEN, JPNM
-      PARAMETER ( JPNM = JPSTRUNC )
-      PARAMETER ( JPLEN = (JPNM+1)*(JPNM+2) )
-C
-C     Function arguments.
-      INTEGER INGRIB, INLEN, OUTGRIB, OUTLEN
-      DIMENSION INGRIB(*), OUTGRIB(*)
-      REAL SLON, SLAT
-C
-C     Local variables
-      INTEGER KSEC0, KSEC1, KSEC2, KSEC3, KSEC4, KWORD, KLENP, KLENG
-      DIMENSION KSEC0(2),KSEC1(512),KSEC2(512),KSEC3(2),KSEC4(512)
-      REAL PSEC4, PSEC2, PSEC3
-      DIMENSION PSEC2(512),PSEC3(2),PSEC4(JPLEN)
-      REAL*8 DLON, DLAT
-      REAL*8 WORK
-      DIMENSION WORK(2*(JPNM+1)*(JPNM+6))
-      INTEGER ITRUNC, IRET, NBYTES, LOOP
-      LOGICAL LOK
-      REAL*8 DATA
-      DIMENSION DATA(JPLEN)
-C
-      DATA NBYTES/4/
-C
-C     Externals
-      LOGICAL JACOBI
-      EXTERNAL JACOBI
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialise.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      SPROTAT = 0
-      IRET    = 0
-#if (defined REAL_8)
-      DLON = SLON
-      DLAT = -90.0 - SLAT
-#else
-      DLON = DBLE(SLON)
-      DLAT = -90.0 - DBLE(SLAT)
-#endif
-C
-C     Decode the field.
-      KLENP = JPLEN
-      KLENG = (INLEN+NBYTES-1)/NBYTES
-      IRET  = 1
-      CALL GRIBEX(KSEC0, KSEC1, KSEC2, PSEC2, KSEC3, PSEC3, KSEC4, 
-     X            PSEC4, KLENP, INGRIB, KLENG, KWORD, 'D' , IRET )
-      IF(IRET.NE.0)THEN
-        CALL INTLOG(JP_FATAL,'SPROTAT: Error decoding GRIB,IRET=', IRET)
-        SPROTAT = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-C     Check that it really is a spherical harmonic field.
-      IF( (KSEC2(1).NE.50) .AND. (KSEC2(1).NE.60) ) THEN
-        CALL INTLOG(JP_FATAL,'SPROTAT: GRIB field not spectral',JPQUIET)
-        CALL INTLOG(JP_FATAL,'SPROTAT: GRIB KSEC2(1) = ', KSEC2(1))
-        SPROTAT = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-      ITRUNC = KSEC2(2)
-C
-C     _______________________________________________________
-C
-C*    Section 2. Rotate the spectral coefficients.
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-#if (defined REAL_8)
-C*********************************************************************
-C
-C     (REALs are already double precision)
-C
-C     Rotate the spectral field by longitude.
-C     Positive DLON => frame rotated from west to east.
-C
-      CALL RPHI( PSEC4, ITRUNC, WORK, DLON)
-C
-C     Rotate the spectral field by latitude.
-C     Negative DLAT => rotate counter-clockwise about new polar axis.
-C
-      LOK = JACOBI ( PSEC4, ITRUNC, WORK, DLAT)
-#else
-C*********************************************************************
-C
-C     (REALs are single precision)
-C
-C     Expand spectral coefficients to REAL*8
-      DO 210 LOOP = 1, KSEC4(1)
-        DATA(LOOP) = DBLE(PSEC4(LOOP))
-  210 CONTINUE
-C
-C     Rotate the spectral field by longitude.
-C     Positive DLON => frame rotated from west to east.
-C
-      CALL RPHI( DATA, ITRUNC, WORK, DLON)
-C
-C     Rotate the spectral field by latitude.
-C     Negative DLAT => rotate counter-clockwise about new polar axis.
-C
-      LOK = JACOBI ( DATA, ITRUNC, WORK, DLAT)
-      IF(.NOT.LOK) THEN
-        CALL INTLOG(JP_FATAL,'SPROTAT: JACOBI failed.', JPQUIET)
-        SPROTAT = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-C
-C     Repack spectral coefficients to REAL*4.
-      DO 220 LOOP = 1, KSEC4(1)
-        PSEC4(LOOP) = SNGL(DATA(LOOP))
-  220 CONTINUE
-C*********************************************************************
-#endif
-C
-C     _______________________________________________________
-C
-C*    Section 3. Repack the spectral coefficients.
-C     _______________________________________________________
-C
-  300 CONTINUE
-C
-C     Put in details of southern pole of rotation
-      KSEC2(13) = NINT(SLAT*1000.0)
-      KSEC2(14) = NINT(SLON*1000.0)
-C
-C     Put in indicator to show field has been rotated ..
-      KSEC2(1) = 60
-C
-C     .. unless south pole of rotation is (0,-90).
-      IF( (KSEC2(14).EQ.0) .AND. (KSEC2(13).EQ.-90000) ) KSEC2(1) = 50
-C
-C     Encode the field.
-      KLENP = KSEC4(1)
-      KLENG = (OUTLEN+NBYTES-1)/NBYTES
-      IRET  = 1
-      CALL GRIBEX(KSEC0, KSEC1, KSEC2, PSEC2, KSEC3, PSEC3, KSEC4, 
-     X            PSEC4, KLENP, OUTGRIB, KLENG, KWORD, 'C' , IRET )
-      IF(IRET.NE.0)THEN
-        CALL INTLOG(JP_FATAL,'SPROTAT: Error encoding GRIB,IRET=', IRET)
-        SPROTAT = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-      OUTLEN = KSEC0(1)
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return.
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/interpolation/strlat.F b/interpolation/strlat.F
index 0e11893..93d4cc1 100644
--- a/interpolation/strlat.F
+++ b/interpolation/strlat.F
@@ -114,7 +114,7 @@ C
 C
 C     Subroutine arguments
 C
-      REAL OLDLAT, STRETCH, NEWLAT, MFACTOR, MSCALE
+      REAL OLDLAT, STRETCH, NEWLAT, MFACTOR
       INTEGER KFLAG
 C
 C     Parameters
diff --git a/interpolation/tatorgg.F b/interpolation/tatorgg.F
deleted file mode 100644
index 87d2b1b..0000000
--- a/interpolation/tatorgg.F
+++ /dev/null
@@ -1,225 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION TATORGG(OLDFLD, NEWFLD, NUMPTS, POLELAT, POLELON,
-     X                         TYPE, NGAUSS)
-C
-C---->
-C**** TATORGG
-C
-C     PURPOSE
-C     _______
-C
-C     Generates a rotated gaussian grid.
-C     (Reverses the effects of GGROTAT).
-C
-C     INTERFACE
-C     _________
-C
-C     IRET = TATORGG(OLDFLD,NEWFLD,NUMPTS,POLELAT,POLELON,TYPE,NGAUSS)
-C
-C
-C     Input parameters
-C     ________________
-C
-C     OLDFLD  = Original gaussian grid field.
-C     NUMPTS  = Total number of points in the original field.
-C     POLELAT = Latitude of the South Pole of rotation.
-C     POLELON = Longitude of the South Pole of rotation.
-C     TYPE    = 'R' if the gaussian field is reduced (quasi) gaussian.
-C             = 'F' if the gaussian field is regular (full) gaussian.
-C     NGAUSS  = Gaussian grid number (number of latitude rows between
-C               the pole and the equator).
-C
-C     Output parameters
-C     ________________
-C    
-C     NEWFLD  = New gaussian grid field.
-C               (This can be the same array as OLDFLD).
-C
-C     Function returns zero if interpolation ran OK.
-C
-C
-C     METHOD
-C     ______
-C
-C     The nearest gaussian latitude row is found.
-C
-C     Work space is dynamically allocated. It is retained for future
-C     calls.
-C
-C
-C     EXTERNALS
-C     _________
-C
-C     JGETGG  - Pickup the gaussian grid definition.
-C     EULAVGG - Calculates the interpolated value at a point of the new
-C               gaussian grid.
-C     INTLOG  - Logs output messages
-C     JMEMHAN - Dynamically allocate work array
-C
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C
-C     COMMENTS
-C     ________
-C
-C     The input field is assumed to be global in extent, and a known
-C     definition, either N160 or N80 (reduced or regular).
-C     The output field has the same type and dimensions as the input
-C     field.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      ECMWF       April 1996
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None.
-C
-C
-C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMAXGG
-      PARAMETER( JPROUTINE = 38500 )
-      PARAMETER (JPMAXGG = 1280)
-C
-C     Subroutine arguments
-C
-      REAL OLDFLD, NEWFLD, POLELAT, POLELON
-      INTEGER NUMPTS, NGAUSS
-      DIMENSION OLDFLD(NUMPTS), NEWFLD(NUMPTS)
-      CHARACTER*1 TYPE
-C
-C     Local variables
-C
-      REAL GLATS(JPMAXGG)
-      INTEGER NGPTS(JPMAXGG)
-      INTEGER OLDGAUS
-      DATA OLDGAUS/0/
-      CHARACTER*1 OLDTYPE
-      DATA OLDTYPE/' '/
-      SAVE GLATS, NGPTS, OLDGAUS, OLDTYPE
-C
-      INTEGER NEXT, NEXLAT, INROW, LOOP, KRET
-      REAL STEPLON, CUTOFF, RLAT, RLON
-      DIMENSION RLON(JPMAXGG*2)
-C
-      INTEGER ISIZE
-      DATA ISIZE/0/
-      REAL WORK
-      POINTER (IWORK, WORK)
-      DIMENSION WORK(1)
-      SAVE IWORK, ISIZE
-C
-C     _______________________________________________________
-C
-C*    Section 1. Initialization.
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      TATORGG = 0
-C
-C     Get gaussian grid definition (first time only)
-C
-      IF( (OLDGAUS.NE.NGAUSS).OR.(OLDTYPE.NE.TYPE)) THEN
-        CALL INTLOG(JP_DEBUG,
-     X    'TATORGG: Get definitions for gaussian grid type:',JPQUIET)
-        CALL INTLOG(JP_DEBUG,TYPE,JPQUIET)
-        CALL INTLOG(JP_DEBUG,'TATORGG: grid number:',NGAUSS)
-C
-        CALL JGETGG(NGAUSS,TYPE,GLATS,NGPTS,KRET)
-        IF( KRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'TATORGG: Failed to get gaussian grid definition:',JPQUIET)
-          TATORGG = JPROUTINE + 1
-          GOTO 900
-        ENDIF
-        OLDGAUS = NGAUSS
-        OLDTYPE = TYPE
-      ENDIF
-C
-C     Allocate work space if not already done.
-C
-      IF( ISIZE.LT.NUMPTS ) THEN
-        ISIZE = NUMPTS
-        CALL JMEMHAN(18,IWORK,NUMPTS,1,KRET)
-        IF( KRET.NE.0 ) THEN
-          CALL INTLOG(JP_ERROR,
-     X      'TATORGG: Memory allocation failed: status = ',KRET)
-          TATORGG = JPROUTINE + 2
-          GOTO 900
-        ENDIF
-      ENDIF
-C
-C     Move the original field to the work array
-C
-      DO LOOP = 1, NUMPTS
-        WORK(LOOP) = OLDFLD(LOOP)
-      ENDDO
-C     _______________________________________________________
-C
-C*    Section 2. Work through latitude lines from north to south
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      NEXT = 1
-C
-      DO NEXLAT = 1, NGAUSS*2
-        INROW = NGPTS(NEXLAT)
-        STEPLON = FLOAT(3600000/INROW)/10000.0
-        RLAT = GLATS(NEXLAT)
-C
-C       Fill in longitudes along current line of latitude
-C
-        DO LOOP = 1, INROW
-          RLON(LOOP) = (LOOP-1)*STEPLON
-        ENDDO
-C
-C       Rotate the current line of latitude
-C
-        CALL EULAVGG(NEWFLD,NEXT,INROW,RLAT,RLON,
-     X               POLELAT,POLELON,WORK,NGAUSS,TYPE)
-C
-        NEXT = NEXT + INROW
-C
-      ENDDO
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine.
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      CALL INTLOG(JP_DEBUG,'TATORGG: Return from GGROTAT:',JPQUIET)
-C
-      RETURN
-      END
diff --git a/interpolation/valpina.c b/interpolation/valpina.c
deleted file mode 100644
index 446173a..0000000
--- a/interpolation/valpina.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include "common/fortint.h"
-
-#define CHARSIZE (long) (sizeof(char)*8)
-#define LEASTSIGBIT 0x01
-
-long bitmapValue(unsigned char * , long );
-long bitmapValueTotal(unsigned char * , long, long );
-fortint valpina(unsigned char * , fortint *, fortint * );
-fortint valpina_(unsigned char * , fortint *, fortint * );
-long separationBetweenValues(unsigned char * , long , long );
-fortint numvals(unsigned char *, fortint *, fortint *);
-fortint numvals_(unsigned char *, fortint *, fortint *);
-fortint onebits(unsigned char *, fortint *);
-fortint onebits_(unsigned char *, fortint *);
-
-fortint numvals_(unsigned char * grib, fortint* istart, fortint* ifinish) {
-/*
-// Returns a count of the number of 1s in a GRIB between positions
-// 'start' and 'finish'.
-// If start = 0, the static values in the function are initialised.
-*/
-long start = (long) (*istart);
-long finish = (long) (*ifinish);
-static long oldTotal;
-static long oldStart, oldFinish;
-unsigned char * bitmap = grib;
-static unsigned char * oldBitmap = 0;
-
-  if( !start ) {
-    oldBitmap = 0;
-    oldTotal = 0;
-    oldStart = oldFinish = 1;
-    return (fortint) oldTotal;
-  }
-
-  if( oldBitmap != bitmap ) {
-    oldBitmap = bitmap;
-    oldStart = oldFinish = 1;
-    oldTotal = 0;
-  }
-
-  if( start == finish ) {
-    oldStart = oldFinish = finish;
-    oldTotal = 0;
-    return (fortint) oldTotal;
-  }
-
-  if( oldStart != start ) {
-    oldTotal = bitmapValueTotal(bitmap, start+1, finish);
-  }
-  else {
-    if( oldFinish < finish )
-      oldTotal += bitmapValueTotal(bitmap, oldFinish+1, finish);
-    else if( oldFinish > finish )
-      oldTotal -= bitmapValueTotal(bitmap, finish+1, oldFinish);
-  }
-
-  oldStart = start;
-  oldFinish = finish;
-
-  return (fortint) oldTotal;
-
-}
-
-fortint numvals(unsigned char * grib, fortint* istart, fortint* ifinish) {
-  return numvals_(grib,istart,ifinish);
-}
-
-fortint onebits_(unsigned char * grib, fortint* isection_3_offset) {
-/*
-// Returns a count of the number of 1s in a GRIB section 3 bitmap.
-*/
-long section_3_offset = (long) (*isection_3_offset);
-unsigned char * bitmap = grib + section_3_offset;
-long length, unused;
-long number_of_bits, total;
-
-  length = (*bitmap)<<16 | (*(bitmap+1)<<8) | *(bitmap+2);
-  unused = *(bitmap+3);
-  number_of_bits = ((length-6)*CHARSIZE) - unused;
-
-  total = bitmapValueTotal((bitmap+6),1,number_of_bits);
-  return ( (fortint) total );
-}
-
-fortint onebits(unsigned char * grib, fortint* isection_3_offset) {
-  return onebits_(grib,isection_3_offset);
-}
-
-long bitmapValueTotal(unsigned char * bitmap, long start, long finish) {
-/*
-// Returns the count of 1 bits between start and finish in a bitmap.
-*/
-long total = 0;
-unsigned char * first, * last, * next;
-/*
-  Lookup table to count number of 1s in a char
-*/
-static const char lookup[256] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
-                                 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-                                 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-                                 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-                                 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-                                 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-                                 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-                                 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-                                 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-                                 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-                                 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-                                 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-                                 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-                                 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-                                 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-                                 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8};
-/*
-  Masks to remove bits from left- and right-hand end of a char
-*/
-static const unsigned char bottomMask[8] =
-  {0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01};
-static const unsigned char topMask[8]    =
-  {0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80};
-int bitsToAdd, bitsToSubtract;
-
-  first = bitmap + (start-1)/CHARSIZE;
-  last  = bitmap + (finish-1)/CHARSIZE;
-
-
-  bitsToAdd = (start-1)%CHARSIZE;
-  total = lookup[(*first & bottomMask[bitsToAdd])];
-
-  for( next = (first+1); next < last ; next++ )
-    total += lookup[*next];
-
-  if( last > first ) total += lookup[*last];
-
-  bitsToSubtract = CHARSIZE - 1 - (finish-1)%CHARSIZE;
-  total -= lookup[(*last & (~topMask[bitsToSubtract]))];
-
-  return total;
-}
-
-long bitmapValue(unsigned char * bitmap, long index) {
-/*
-// Returns the value (0,1) of the bit at position 'index' in a bitmap.
-*/
-unsigned char * next;
-int bitShift;
-
-  next = bitmap + (index-1)/CHARSIZE;
-  bitShift = CHARSIZE - 1 - ((index-1)%CHARSIZE);
-
-  return  (((*next) >> bitShift) & LEASTSIGBIT);
-
-}
-
-fortint valpina_(unsigned char * grib, fortint* ioffset, fortint* iindex) {
-/*
-//  A GRIB product starts at 'grib' and contains missing/non-missing values
-//  as described by a bitmap which is at position 'offset' in the GRIB.
-//
-//  'index' is the position of a point (missing/non-missing) in the field.
-//  If index = 0, the static values in the function are initialised.
-//
-//  Examines the bitmap and returns:
-//
-//  - the actual index of a non-missing value
-//
-//  - 0 for a missing value
-*/
-long offset = (long) (*ioffset);
-long index = (long) (*iindex);
-unsigned char * bitmap = (grib + offset);
-static unsigned char * oldBitmap;
-static long count = 0;
-static long oldIndex = 0;
-long value;
-
-  if( !(index) ) {
-    oldBitmap = 0;
-    count = 0;
-    oldIndex = 0;
-    return (fortint) 0;
-  }
-
-  if( oldBitmap != bitmap ) {
-    oldBitmap = bitmap;
-    count = 0;
-    oldIndex = 0;
-  }
-
-  value = bitmapValue(bitmap, index);
-
-  if( value ) {
-    if( (index) != oldIndex ) {
-      count += separationBetweenValues(bitmap, oldIndex, index);
-      oldIndex = index;
-    }
-    return (fortint) count;
-  }
-  else
-    return (fortint) 0;
-}
-
-fortint valpina(unsigned char * grib, fortint* ioffset, fortint* iindex) {
-  return valpina_(grib,ioffset,iindex);
-}
-
-long separationBetweenValues(unsigned char * bitmap,long oldIndex,long index) {
-/*
-//  Counts the number of actual (non-missing) values between two locations
-//  in the bitmap given by 'index' and 'oldIndex'.
-//
-//  The returned count can be positive or negative depending on whether
-//  index is after or before oldIndex.
-*/
-long start, finish, sign = 1, total = 0;
-
-  if( index > oldIndex ) {
-    start = oldIndex;
-    finish = index;
-  }
-  else {
-    start = index;
-    finish = oldIndex;
-    sign = -1;
-  }
-
-  total = bitmapValueTotal(bitmap, (start+1), finish);
-
-  return (sign*total);
-}
diff --git a/interpolation/w251idx.F b/interpolation/w251idx.F
index 44de597..dd2c354 100644
--- a/interpolation/w251idx.F
+++ b/interpolation/w251idx.F
@@ -110,12 +110,12 @@ C
 C
 C     Local arguments
 C
-      INTEGER K, NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
+      INTEGER NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
       INTEGER I_NW, I_SW, I_N, I_S, I_NE, I_SE
       REAL*8 DELONGN, DELONGS, DIFF, RESOL, DINC, DEPS
       REAL*8 DIST_NW, DIST_SW, DIST_NE, DIST_SE, DIST_N, DIST_S
       REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*8 ZXIN, ZXIS, LON, LAT, OWEST, OEAST
+      REAL*8 ZXIN, ZXIS, LON, OWEST, OEAST
       DIMENSION LON(JPNMOUT*2)
       LOGICAL LINGNS, LINGWE
       INTEGER INDEXI
diff --git a/interpolation/waveidx.F b/interpolation/waveidx.F
index 04b2b76..7db3138 100644
--- a/interpolation/waveidx.F
+++ b/interpolation/waveidx.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -94,12 +94,10 @@ C     Parameters
 C
       INTEGER JPROUTINE
       PARAMETER ( JPROUTINE = 19410 )
-      INTEGER JPLLMAX
-      PARAMETER ( JPLLMAX = 1801 )
-C                             `--> allow upto 0.1 degree resolution.
-      INTEGER JPNMOUT
-      PARAMETER ( JPNMOUT = 3600 )
-C                             `--> allow upto 0.1 degree resolution.
+      INTEGER JPLLMAX, JPNMOUT
+      PARAMETER ( JPLLMAX = 1801 ) ! allow up to 0.1 degree resolution
+      PARAMETER ( JPNMOUT = 3600 ) ! allow up to 0.1 degree resolution
+C
       INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
       INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
       PARAMETER (JPNW   = 1)
@@ -126,18 +124,19 @@ C
 C
 C     Local arguments
 C
-      INTEGER K, NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
+      INTEGER NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
       INTEGER I_NW, I_SW, I_N, I_S, I_NE, I_SE
-      REAL*8 DELONGN, DELONGS, DIFF, RESOL, DINC, DEPS
+      REAL*8 DELONGN, DELONGS, DIFF, RESOL, DEPS
       REAL*8 DIST_NW, DIST_SW, DIST_NE, DIST_SE, DIST_N, DIST_S
-      REAL*8 DISNW, DISNE, DISSW, DISSE
-      REAL*8 ZXIN, ZXIS, LON, LAT, OWEST, OEAST
+      REAL*8 ZXIN, ZXIS, LON, OWEST, OEAST
       DIMENSION LON(JPNMOUT*2)
       LOGICAL LINGNS, LINGWE
       INTEGER INDEXI
       DIMENSION INDEXI(JPLLMAX)
-      LOGICAL LGLOBAL, LFULLG, LGWRAP
+      LOGICAL LGLOBAL
       DATA DEPS/0.0005/
+      REAL*8 DINC
+      LOGICAL LFULLG, LGWRAP
 C
 C ---------------------------------------------------------------------
 C*    Section 1. Initalisation.
@@ -274,7 +273,7 @@ C
             IF( LINGNS .AND. LINGWE ) THEN
 C
 C             If point to be interpolated is inside the input field ,
-C             work out distances from new point to four neighbours.
+C             work out distances from new point to four neighbours
 C
               ZXIN = DMOD((LON(NEWCOL)+(DBLE(360.0)-OWEST)+DBLE(720.0)),
      X                     DBLE(360.0))
diff --git a/interpolation/wavexx1.F b/interpolation/wavexx1.F
deleted file mode 100644
index eb0caf8..0000000
--- a/interpolation/wavexx1.F
+++ /dev/null
@@ -1,663 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION WAVEXX1(NPARAM, ISEC2, ISEC4, NLATS, STEPNS,
-     X                        STEPWE, OLDWAVE, NEWIDX, DISTNEW,
-     X                         NEWWAVE, NORTH, WEST, PMISS)
-C
-C---->
-C*****WAVEXX1*
-C
-C     PURPOSE
-C     -------
-C
-C     Interpolates wave fields (except 2D spectra).
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     IRET = WAVEXX1(ISEC2, ISEC4, NLATS, STEPNS, STEPWE,
-C    X               OLDWAVE, NEWIDX, DISTNEW,
-C    X               NEWWAVE, NORTH, WEST, PMISS)
-C
-C     Input arguments
-C     ---------------
-C
-C     ISEC2   - Unpacked section 2 header from 2D wave spectra field
-C     ISEC4   - Unpacked section 4 header from 2D wave spectra field
-C     NLATS   - Number of points N-S in new grid
-C     STEPNS  - Output grid north-south resolution (degrees)
-C     STEPWE  - Output grid west-east resolution (degrees)
-C     OLDWAVE - Original wave field
-C     NORTH   - Output grid northernmost latitude (degrees)
-C     WEST    - Output grid westernmost longitude (degrees)
-C     PMISS   - Missing data value 
-C
-C     Output arguments
-C     ----------------
-C
-C     NEWIDX  - Indices of four neighbouring old grid points used for
-C               new grid points
-C     DISTNEW - Distances of surrounding box edges from new grid points
-C     NEWWAVE - New wave field
-C
-C     Function returns 0 if the interpolation was OK.
-C
-C
-C     METHOD
-C     ------
-C
-C     Builds the index of neighbouring points for the output grid.
-C     Then works through the output grid points, checking for subarea
-C     boundaries and looking up neighbouring point values and weights.
-C     (Neighbours may have missing data).
-C
-C
-C     EXTERNALS
-C     ---------
-C
-C     WAVEIDX - determines which nearest-neighbour values to use for
-C               interpolating to new output grid point
-C     NUMPTWE - Calculates number of grid points between west/east
-C               area boundaries
-C     VALPINA - Looks up bitmap value
-C     SOFFSET - Finds the section offsets in GRIB message
-C     INTLOG  - Log error message
-C
-C
-C     REFERENCE
-C     ---------
-C
-C     None.
-C
-C
-C     Author.
-C     -------
-C
-C     J.D.Chambers      ECMWF    January 1998
-C
-C
-C     Modifications
-C     -------------
-C     Handle reduced lat/long grid in 'pseudo-gaussian' layout
-C     J.D.Chambers      ECMWF    November 2003
-C
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMXLAT
-      PARAMETER (JPROUTINE = 40100)
-      PARAMETER (JPMXLAT = 1801)
-      INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
-      INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
-      PARAMETER (JPNW = 1)
-      PARAMETER (JPNE = 2)
-      PARAMETER (JPSW = 3)
-      PARAMETER (JPSE = 4)
-      PARAMETER (JPN  = 5)
-      PARAMETER (JPS  = 6)
-      PARAMETER (JPDISNW = 7)
-      PARAMETER (JPDISNE = 8)
-      PARAMETER (JPDISSW = 9)
-      PARAMETER (JPDISSE = 10)
-C
-C     Subroutine arguments
-C
-      INTEGER ISEC2, ISEC4, NLATS
-      DIMENSION ISEC2(*), ISEC4(*)
-      REAL STEPNS, STEPWE, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      REAL ONORTH
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-      INTEGER NEWIDX
-      DIMENSION NEWIDX(4,*)
-      REAL*4 DISTNEW
-      DIMENSION DISTNEW(10,*)
-C
-C     Local arguments
-C
-      INTEGER IEOFSET, IWOFSET, ISTART, IWEST
-      REAL SOUTH, PTLAT, AWEST, EAST, PTLONG, OLDWEST, OLDEAST
-      REAL REFVAL, SCALE
-      INTEGER NSPT1, INSPT, NEXP, NMANT, NRETA, NRETB, NLENG, NBIT
-      INTEGER NPARAM, ISCALE, NSCALE, IBITS, ITEMP
-      INTEGER IRET, IS0, IS1, IS2, IS3, IS4, IEDITN
-      INTEGER NEXT, NEXTWV, NROW, NCOL, INDEX, ILOCATE
-      INTEGER MISSLAT, LOOP, NPTS, NUMLATS, NUMNEW, KOLDNUM, KNEWNUM
-      DIMENSION NPTS(JPMXLAT), NUMNEW(JPMXLAT)
-      REAL RLATINC, OLDLATS, NEWLATS, ROWINC
-      DIMENSION OLDLATS(JPMXLAT), NEWLATS(JPMXLAT)
-      LOGICAL LDIREC
-      REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*4 NW_PT, NE_PT, SW_PT, SE_PT
-      REAL*4 RAD
-      DATA RAD/0.017453293/
-      REAL*4 DI1N, DI1S, DI2N, DI2S, DK1, DK2
-      REAL*4 CNW_PT, CNE_PT, CSW_PT, CSE_PT
-      REAL*4 SNW_PT, SNE_PT, SSW_PT, SSE_PT
-      REAL*4 U1, U2, C1, C2, S1, S2, CC, SS
-      INTEGER INW, INE, ISW, ISE, JNW, JNE, JSW, JSE
-C
-C     Externals
-C
-      INTEGER WAVEIDX, SOFFSET, VALPINA, NUMPTWE
-      EXTERNAL WAVEIDX, SOFFSET, VALPINA, NUMPTWE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grspace.h"
-C
-C ---------------------------------------------------------------------
-C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WAVEXX1 = 0
-
-C
-C     Initialise the bitmap value lookup function
-C
-      IRET = VALPINA(0,0,0)
-C
-      MISSLAT = 0
-C
-C     Calculate number of latitudes if grid had been full from
-C     North pole to South pole
-C
-      NUMLATS = (180000/ISEC2(10)) + 1
-      IF( NUMLATS.GT.JPMXLAT ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXX1: Number of latitudes in input grid = ',NUMLATS)
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXX1: And is greater than allowed maximum = ',JPMXLAT)
-        WAVEXX1 = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-cs      RLATINC = FLOAT(ISEC2(10))/1000
-      RLATINC = FLOAT(ISEC2(10))
-C
-C     Fill an array with the number of points at each latitude for the
-C     input field.
-C
-      IF( ISEC2(17).EQ.1 ) THEN
-C
-C       Input field is a reduced latitude/longitude grid
-C
-C       .. but it may be 'pseudo-gaussian' in layout
-C       (ie global, symmetric about the equator but no latitude
-C        at the equator)
-C
-        IF( (ISEC2(4).NE.90000).AND.(MOD(ISEC2(3),2).EQ.0) ) THEN
-C
-          NUMLATS = ISEC2(3)
-cs          RLATINC = FLOAT(ISEC2(10))/1000
-cs          ONORTH = FLOAT(ISEC2(4))/1000
-          ONORTH = FLOAT(ISEC2(4))
-C
-          DO LOOP = 1, NUMLATS
-cs            OLDLATS(LOOP) = ONORTH - (LOOP-1)*RLATINC
-            OLDLATS(LOOP) = (ONORTH - (LOOP-1)*RLATINC)/1000
-          ENDDO
-C
-          DO LOOP = 1, ISEC2(3)
-            NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-          ENDDO
-C
-        ELSE
-C
-          DO LOOP = 1, NUMLATS
-            OLDLATS(LOOP) = (90000.0 - (LOOP-1)*RLATINC)/1000
-cs            OLDLATS(LOOP) = 90.0 - (LOOP-1)*RLATINC
-          ENDDO
-C
-          MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-          DO LOOP = 1, MISSLAT
-            NPTS(LOOP)    = 0
-          ENDDO
-          KOLDNUM = 1 + (90000 - ISEC2(7))/ISEC2(10)
-          DO LOOP = 1, (KOLDNUM-MISSLAT)
-            NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-          ENDDO
-          DO LOOP = (KOLDNUM+1), NUMLATS
-            NPTS(LOOP)    = 0
-          ENDDO
-        ENDIF
-C
-      ELSE
-C
-C       Input field is a regular latitude/longitude grid
-C
-C
-        DO LOOP = 1, NUMLATS
-cs          OLDLATS(LOOP) = 90.0 - (LOOP-1)*RLATINC
-            OLDLATS(LOOP) = (90000.0 - (LOOP-1)*RLATINC)/1000
-        ENDDO
-C
-        MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-        DO LOOP = 1, MISSLAT
-          NPTS(LOOP)    = 0
-        ENDDO
-        KOLDNUM = 1 + (90000 - ISEC2(7))/ISEC2(10)
-        DO LOOP = 1, (KOLDNUM-MISSLAT)
-          NPTS(LOOP+MISSLAT) = ISEC2(2)
-        ENDDO
-        DO LOOP = (KOLDNUM+1), NUMLATS
-          NPTS(LOOP)    = 0
-        ENDDO
-      ENDIF
-C
-C ---------------------------------------------------------------------
-C*    Section 2. Setup number of points at each latitude for the
-C                output latitude/longitude field.
-C ---------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN) ) THEN
-C
-C       Reduced (quasi-regular) gaussian output
-C
-        KNEWNUM = NOGAUSS*2
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROGAUSS(LOOP)
-        ENDDO
-C
-      ELSE IF( NOREPR.EQ.JPREDLL ) THEN
-C
-C       Reduced (quasi-regular) lat/long output
-C
-        KNEWNUM = NOREDLL
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROREDLL(LOOP)
-        ENDDO
-C
-      ELSE
-C
-C       Regular output
-C
-        MISSLAT = NINT((90.0 - NORTH)/STEPNS)
-        DO LOOP = 1, MISSLAT
-          NUMNEW(LOOP)    = 0
-        ENDDO
-        DO LOOP = 1, NLATS
-          NUMNEW(LOOP+MISSLAT) = NINT(360.0/STEPWE)
-        ENDDO
-C
-        KNEWNUM = MISSLAT + NLATS
-        DO LOOP = 1, KNEWNUM
-          NEWLATS(LOOP) = 90.0 - (LOOP-1)*STEPNS
-        ENDDO
-C
-      ENDIF
-C
-C ---------------------------------------------------------------------
-C*    Section 3. Get the input GRIB field characteristics.
-C ---------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Calculate the indices of the input grid points to be used for
-C     the output points
-C
-      OLDWEST = FLOAT(NIAREA(2))/PPMULT
-      OLDEAST = FLOAT(NIAREA(4))/PPMULT
-cs      print*,'MARS NUMLATS ', NUMLATS,' RLATINC ',RLATINC
-cs      print*,'MARS OLDEAST ', OLDEAST,' OLDWEST ',OLDWEST
-cs      print*,'MARS KNEWNUM ', KNEWNUM,' STEPNS ',STEPNS
-
-cs21    format(i6)
-cs      OPEN (UNIT=12,FILE='./mars_offset.txt',STATUS='UNKNOWN',
-cs     &    FORM='FORMATTED')
-cs      WRITE (12,21)(NPTS(LOOP), LOOP=1,NUMLATS)
-
-      WAVEXX1 = WAVEIDX(NUMLATS,NPTS,OLDLATS,OLDWEST,OLDEAST,
-     X                  KNEWNUM, NUMNEW, NEWLATS,
-     X                  NEWIDX, DISTNEW)
-      IF( WAVEXX1.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXX1: Unable to calculate output grid indices',JPQUIET)
-        WAVEXX1 = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-C     Find bitmap (section 3) offset the GRIB product
-C
-cs      IRET = SOFFSET(OLDWAVE, IS0, IS1, IS2, IS3, IS4, IEDITN)
-C
-C     Get the overall length of OLDWAVE
-C
-cs#ifdef INTEGER_8
-cs      NBIT = 64
-cs#else
-cs      NBIT = 32
-cs#endif
-cs      INSPT = (IS0 + 4) * 8
-cs      CALL INXBIT(OLDWAVE,10,INSPT,NLENG,1,NBIT,24,'D',NRETA)
-cs      IF( NRETA.NE.0 ) THEN
-cs        CALL INTLOG(JP_ERROR,
-cs     X    'WAVEXX1: Problem extracting overall length of GRIB',JPQUIET)
-cs        WAVEXX1 = JPROUTINE + 3
-cs        GOTO 900
-cs      ENDIF
-C
-C     Get parameter identifier
-C
-cs      INSPT = (IS1 + 8) * 8
-cs      CALL INXBIT(OLDWAVE,10,INSPT,NPARAM,1,NBIT,8,'D',NRETA)
-cs      IF( NRETA.NE.0 ) THEN
-cs        CALL INTLOG(JP_ERROR,
-cs     X    'WAVEXX1: Problem getting parameter identifier',JPQUIET)
-cs        WAVEXX1 = JPROUTINE + 4
-cs        GOTO 900
-cs      ENDIF
-C
-C     Wave direction parameters need special handling
-C     (MWD, MDWW, MDPS, MDWI)
-C
-      LDIREC = ( (NPARAM.EQ.230) .OR.
-     X           (NPARAM.EQ.235) .OR.
-     X           (NPARAM.EQ.238) .OR.
-     X           (NPARAM.EQ.242) )
-C
-C     Get the scale factor
-C
-cs      INSPT = (IS4 + 4) * 8
-cs      CALL INXBIT(OLDWAVE,NLENG,INSPT,NSCALE,1,NBIT,16,'D',NRETA)
-cs      IF( NRETA.NE.0 ) THEN
-cs        CALL INTLOG(JP_ERROR,
-cs     X    'WAVEXX1: Problem extracting scale factor in GRIB',JPQUIET)
-cs        WAVEXX1 = JPROUTINE + 5
-cs        GOTO 900
-cs      ENDIF
-cs      CALL DSGNBT(ISCALE,NSCALE,16,NRETA)
-cs      IF( NRETA.NE.0 ) THEN
-cs        CALL INTLOG(JP_ERROR,
-cs     X    'WAVEXX1: Problem setting sign of scale factor',JPQUIET)
-cs        WAVEXX1 = JPROUTINE + 6
-cs        GOTO 900
-cs      ENDIF
-cs      SCALE = 2.0**(FLOAT(ISCALE))
-C
-C     Get the reference value
-C
-cs      CALL INXBIT(OLDWAVE,NLENG,INSPT,NEXP,1,NBIT,8,'D',NRETA)
-cs      CALL INXBIT(OLDWAVE,NLENG,INSPT,NMANT,1,NBIT,24,'D',NRETB)
-cs      IF( (NRETA.NE.0) .OR. (NRETB.NE.0) ) THEN
-cs        CALL INTLOG(JP_ERROR,
-cs     X    'WAVEXX1: Problem getting reference value from GRIB',JPQUIET)
-cs        WAVEXX1 = JPROUTINE + 7
-cs        GOTO 900
-cs      ENDIF
-cs      CALL DECFP2(REFVAL,NEXP,NMANT)
-C
-C     Get number of bits per packed value
-C
-cs      CALL INXBIT(OLDWAVE,NLENG,INSPT,IBITS,1,NBIT,8,'D',NRETA)
-cs      IF( NRETA.NE.0 ) THEN
-cs        CALL INTLOG(JP_ERROR,
-cs     X    'WAVEXX1: Problem getting number of bits per word',JPQUIET)
-cs        WAVEXX1 = JPROUTINE + 8
-cs        GOTO 900
-cs      ENDIF
-cs      NSPT1 = INSPT
-C
-C ---------------------------------------------------------------------
-C*    Section 4. Work through the output subarea.
-C ---------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-C     Fill in the wave spectra values
-C
-      NEXT = 0
-      NEXTWV = 0
-C
-      SOUTH = NOAREA(3)/PPMULT
-      EAST  = NOAREA(4)/PPMULT
-      ISTART = 0
-C
-C     Work down through latitudes from north to south.
-C
-
-          OPEN (UNIT=16,FILE='./mars.txt',STATUS='UNKNOWN',
-     &    FORM='FORMATTED')
-c17            format(i4,1x,i4,4(1x,i6))
-17            format(i4,1x,i4,4(1x,i6),2x,4(f9.2))
-19            format(i4,1x,i4,4(1x,i6),2x,f9.2)
-
-      DO NROW = 1, KNEWNUM
-C
-C       If inside north-south (subarea) boundaries ..
-C
-        IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPQUASI) ) THEN
-          PTLAT = ROGAUSS(NROW)
-        ELSE
-          PTLAT = 90.0 - (NROW-1)*STEPNS
-        ENDIF
-        IF( (PTLAT.LE.NORTH).AND.(ABS(PTLAT-SOUTH).GT.-0.0005) ) THEN
-C
-C         Calculate number of points between west boundary of area and
-C         Greenwich
-C
-          ROWINC = 360.0/NUMNEW(NROW)
-C
-          IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) )
-     X      IWEST = IWEST + 1
-          AWEST = IWEST * ROWINC
-          IWOFSET = NUMPTWE(AWEST,0.0,ROWINC)
-          IEOFSET = NUMPTWE(AWEST,EAST,ROWINC)
-C
-C         Work through subarea longitudes from west to east.
-C
-          DO NCOL = 1, NUMNEW(NROW)
-            PTLONG = AWEST + (NCOL-1)*ROWINC
-            NEXT = NUMPTWE(AWEST,PTLONG,ROWINC)
-            IF( (NEXT.LE.IEOFSET).AND.(NEXT.GE.0) ) THEN
-C
-C             .. and inside west-east (subarea) boundaries
-C
-              NEXT = 1 + NEXT - IWOFSET
-              IF( NEXT.LE.0) NEXT = NEXT + NUMNEW(NROW)
-              NEXT = NEXT + ISTART
-              NEXTWV = NEXTWV + 1
-C
-              INW = NEWIDX(JPNW,NEXT)
-              INE = NEWIDX(JPNE,NEXT)
-              ISW = NEWIDX(JPSW,NEXT)
-              ISE = NEWIDX(JPSE,NEXT)
-C
-C             If there is a bitmap, ...
-C
-cs              IF( IS3.NE.0 ) THEN
-cs                IF(INW.NE.0) JNW = VALPINA(OLDWAVE, IS3+6, INW)
-cs                IF(INE.NE.0) JNE = VALPINA(OLDWAVE, IS3+6, INE)
-cs                IF(ISW.NE.0) JSW = VALPINA(OLDWAVE, IS3+6, ISW)
-cs                IF(ISE.NE.0) JSE = VALPINA(OLDWAVE, IS3+6, ISE)
-cs              ELSE
-cs                JNW = INW
-cs                JNE = INE
-cs                JSW = ISW
-cs                JSE = ISE
-cs              ENDIF
-C
-C             Test if any of the four neighbouring points is missing.
-C
-              IF( (INW.EQ.0) .OR. (OLDWAVE(INW).EQ.PMISS) .OR.
-     X            (ISW.EQ.0) .OR. (OLDWAVE(ISW).EQ.PMISS) .OR.
-     X            (INE.EQ.0) .OR. (OLDWAVE(INE).EQ.PMISS) .OR.
-     X            (ISE.EQ.0) .OR. (OLDWAVE(ISE).EQ.PMISS) ) THEN
-cs
-cs              WRITE (16,17)NROW,NCOL,INW,INE,ISW,ISE
-cs     X           ,OLDWAVE(INW),OLDWAVE(ISW)
-cs     X           ,OLDWAVE(INE),OLDWAVE(ISE)
-C
-C               If so, take nearest grid point value.
-C
-                DISNW = DISTNEW(JPDISNW,NEXT)
-                DISNE = DISTNEW(JPDISNE,NEXT)
-                DISSW = DISTNEW(JPDISSW,NEXT)
-                DISSE = DISTNEW(JPDISSE,NEXT)
-C
-                IF( (DISNW.LE.DISNE).AND.
-     X              (DISNW.LE.DISSW).AND.
-     X              (DISNW.LE.DISSE)) THEN
-                  INDEX = INW
-cs                  ILOCATE  = JNW
-C
-                ELSE IF( (DISNE.LE.DISSW).AND.
-     X                   (DISNE.LE.DISSE) ) THEN
-                  INDEX = INE
-cs                  ILOCATE  = JNE
-C
-                ELSE IF( (DISSW.LE.DISSE) ) THEN
-                  INDEX = ISW
-cs                  ILOCATE  = JSW
-C
-                ELSE
-                  INDEX = ISE
-cs                  ILOCATE  = JSE
-                ENDIF
-C
-                IF(INDEX.EQ.0.OR.(OLDWAVE(INDEX).EQ.PMISS)) THEN
-C
-C                 Nearest point is missing
-C
-                  NEWWAVE(NEXTWV) = PMISS
-C
-                ELSE
-cs                  INSPT = NSPT1 + (ILOCATE - 1)*IBITS
-cs                  CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-cs     X                        NBIT,IBITS,'D',NRETA)
-cs                  IF( NRETA.NE.0 ) THEN
-ccss                    CALL INTLOG(JP_ERROR,
-cs     X              'WAVEXX1: Problem getting nearest neighbour value',
-cs     X              JPQUIET)
-cs                    WAVEXX1 = JPROUTINE + 9
-cs                  GOTO 900
-cs                  ENDIF
-cs                  NEWWAVE(NEXTWV) = REFVAL + FLOAT(ITEMP)*SCALE
-                NEWWAVE(NEXTWV) =  OLDWAVE(INDEX)
-              WRITE (16,19)NROW,NCOL,INW,INE,ISW,ISE,NEWWAVE(NEXTWV)
-                ENDIF
-C
-              ELSE
-C
-C               Use bi-linear interpolation from four
-C               neighbouring sea points.
-C
-cs                INSPT = NSPT1 + (JNW - 1)*IBITS
-cs                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-cs     X                      NBIT,IBITS,'D',NRETA)
-cs                IF( NRETA.NE.0 ) THEN
-cs                  CALL INTLOG(JP_ERROR,
-cs     X            'WAVEXX1: Problem getting NW neighbour value',
-cs     X            JPQUIET)
-cs                  WAVEXX1 = JPROUTINE + 10
-cs                  GOTO 900
-cs                ENDIF
-cs                NW_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-cs                INSPT = NSPT1 + (JNE - 1)*IBITS
-cs                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-cs     X                      NBIT,IBITS,'D',NRETA)
-cs                IF( NRETA.NE.0 ) THEN
-cs                  CALL INTLOG(JP_ERROR,
-cs     X            'WAVEXX1: Problem getting NE neighbour value',
-cs     X            JPQUIET)
-cs                  WAVEXX1 = JPROUTINE + 10
-cs                  GOTO 900
-cs                ENDIF
-cs                NE_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-cs                INSPT = NSPT1 + (JSW - 1)*IBITS
-cs                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-cs     X                      NBIT,IBITS,'D',NRETA)
-cs                IF( NRETA.NE.0 ) THEN
-cs                  CALL INTLOG(JP_ERROR,
-cs     X            'WAVEXX1: Problem getting SW neighbour value',
-cs     X            JPQUIET)
-cs                  WAVEXX1 = JPROUTINE + 10
-cs                  GOTO 900
-cs                ENDIF
-cs                SW_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-cs                INSPT = NSPT1 + (JSE - 1)*IBITS
-cs                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-cs     X                      NBIT,IBITS,'D',NRETA)
-cs                IF( NRETA.NE.0 ) THEN
-cs                  CALL INTLOG(JP_ERROR,
-cs     X            'WAVEXX1: Problem getting SE neighbour value',
-cs     X            JPQUIET)
-cs                  WAVEXX1 = JPROUTINE + 10
-cs                  GOTO 900
-cs                ENDIF
-cs                SE_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-                DI1N = DISTNEW(JPNW,NEXT)
-                DI2N = DISTNEW(JPNE,NEXT)
-                DI1S = DISTNEW(JPSW,NEXT)
-                DI2S = DISTNEW(JPSE,NEXT)
-                DK1  = DISTNEW(JPN,NEXT)
-                DK2  = DISTNEW(JPS,NEXT)
-C
-                IF( .NOT. LDIREC ) THEN
-                  U1 = NW_PT*DI2N + NE_PT*DI1N
-                  U2 = SW_PT*DI2S + SE_PT*DI1S
-                  NEWWAVE(NEXTWV) = U1*DK2 + U2*DK1
-                ELSE
-C
-C                 Fields representing a 'direction': resolve into
-C                 components and interpolate each separately.
-C
-                  CNW_PT = COS(NW_PT*RAD)
-                  CNE_PT = COS(NE_PT*RAD)
-                  CSW_PT = COS(SW_PT*RAD)
-                  CSE_PT = COS(SE_PT*RAD)
-                  SNW_PT = SIN(NW_PT*RAD)
-                  SNE_PT = SIN(NE_PT*RAD)
-                  SSW_PT = SIN(SW_PT*RAD)
-                  SSE_PT = SIN(SE_PT*RAD)
-                  C1 = CNW_PT*DI2N + CNE_PT*DI1N
-                  C2 = CSW_PT*DI2S + CSE_PT*DI1S
-                  CC = C1*DK2 + C2*DK1
-                  S1 = SNW_PT*DI2N + SNE_PT*DI1N
-                  S2 = SSW_PT*DI2S + SSE_PT*DI1S
-                  SS = S1*DK2 + S2*DK1
-                  IF( SS.LT.0.0 ) THEN
-                    NEWWAVE(NEXTWV) = ATAN2(SS,CC)/RAD + 360.0
-                  ELSE
-                    NEWWAVE(NEXTWV) = ATAN2(SS,CC)/RAD
-                  ENDIF
-                ENDIF
-              ENDIF
-            ENDIF
-          ENDDO
-C
-        ENDIF
-        ISTART = ISTART + NUMNEW(NROW)
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
-C
-  900 CONTINUE
-      RETURN
-      END
diff --git a/interpolation/wavexx2.F b/interpolation/wavexx2.F
index 2d8620f..17950c4 100644
--- a/interpolation/wavexx2.F
+++ b/interpolation/wavexx2.F
@@ -1,18 +1,17 @@
 C
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION WAVEXX2(NPARAM, NUMLATS, NPTS,
      X                         NLATS, STEPNS, STEPWE,
-     X                         OLDWAVE,
-     X                         NEWWAVE, NORTH, WEST, PMISS)
+     X                         OLDWAVE, NEWWAVE, NORTH, WEST, PMISS)
 C
 C---->
 C*****WAVEXX2*
@@ -26,23 +25,24 @@ C
 C     INTERFACE
 C     ---------
 C
-C     IRET = WAVEXX2(NPARAM, NUMLATS, NLATS, STEPNS, STEPWE,
-C    X               OLDWAVE, NEWIDX, DISTNEW,
-C    X               NEWWAVE, NORTH, WEST, PMISS)
+C     IRET = WAVEXX2(NPARAM, NUMLATS, NPTS,
+C    X               NLATS, STEPNS, STEPWE,
+C    X               OLDWAVE, NEWWAVE, NORTH, WEST, PMISS)
 C
 C     Input arguments
 C     ---------------
 C
+C     NPARAM  - Parameter ID
 C     NUMLATS - Input lat number north-south
-C     NPTS   - Array giving number of points along each latitude
-C               (empty latitudes have entry 0)
+C     NPTS    - Array giving number of points along each latitude
+C               for input field (empty latitudes have entry 0)
 C     NLATS   - Number of points N-S in new grid
 C     STEPNS  - Output grid north-south resolution (degrees)
 C     STEPWE  - Output grid west-east resolution (degrees)
 C     OLDWAVE - Original wave field
 C     NORTH   - Output grid northernmost latitude (degrees)
 C     WEST    - Output grid westernmost longitude (degrees)
-C     PMISS   - Missing data value 
+C     PMISS   - Missing data value
 C
 C     Output arguments
 C     ----------------
@@ -57,14 +57,14 @@ C     ------
 C
 C     Builds the index of neighbouring points for the output grid.
 C     Then works through the output grid points, checking for subarea
-C     boundaries and looking up neighbouring point values and weights.
-C     (Neighbours may have missing data).
+C     boundaries and looking up neighbouring point values and weights
+C     (which may be missing data).
 C
 C
 C     EXTERNALS
 C     ---------
 C
-C     WAVEIDX - Determines which nearest-neighbour values to use for
+C     WAVEIDX - Determines which nearest neighbour points to use for
 C               interpolating to new output grid point
 C     NUMPTWE - Calculates number of grid points between west/east
 C               area boundaries
@@ -92,58 +92,41 @@ C
 C     Parameters
 C
 #include "parim.h"
+C
+      INTEGER JPROUTINE, JPMXLAT,
+     X        JPNW, JPNE, JPSW, JPSE, JPN, JPS,
+     X        JPDISNW, JPDISNE, JPDISSW, JPDISSE
+      PARAMETER( JPROUTINE = 40100 )
+      PARAMETER( JPMXLAT   =  1801 ) ! allow up to 0.1 degree resolution
+      PARAMETER( JPNW=1, JPNE=2, JPSW=3, JPSE=4, JPN=5, JPS=6,
+     X           JPDISNW=7, JPDISNE=8, JPDISSW=9, JPDISSE=10 )
+C
 #include "nifld.common"
 #include "nofld.common"
 #include "grspace.h"
-      INTEGER JPROUTINE, JPMXLAT
-      PARAMETER (JPROUTINE = 40100)
-      PARAMETER (JPMXLAT = 1801)
-      INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
-      INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
-      PARAMETER (JPNW = 1)
-      PARAMETER (JPNE = 2)
-      PARAMETER (JPSW = 3)
-      PARAMETER (JPSE = 4)
-      PARAMETER (JPN  = 5)
-      PARAMETER (JPS  = 6)
-      PARAMETER (JPDISNW = 7)
-      PARAMETER (JPDISNE = 8)
-      PARAMETER (JPDISSW = 9)
-      PARAMETER (JPDISSE = 10)
-C
-C     Subroutine arguments
-C
-      INTEGER NPTS,NLATS
-      DIMENSION NPTS(*)
-      REAL STEPNS, STEPWE, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-      INTEGER NUMLATS
-C
-C     Local arguments
-C
-      REAL RLATINC, RLATINC2
-      REAL ONORTH,OSOUTH,OWEST, OEAST
-      INTEGER IEOFSET, IWOFSET, ISTART, IWEST
-      REAL SOUTH, PTLAT, AWEST, EAST, PTLONG
-      REAL REFVAL, SCALE
-      INTEGER NSPT1, INSPT, NEXP, NMANT, NRETA, NRETB, NLENG, NBIT
-      INTEGER NPARAM, ISCALE, NSCALE, IBITS, ITEMP
-      INTEGER IRET, IEDITN
-      INTEGER NEXT, NEXTWV, NROW, NCOL, INDEX
-      INTEGER MISSLAT, LOOP, NUMNEW, KOLDNUM, KNEWNUM
-      DIMENSION NUMNEW(JPMXLAT)
-      REAL OLDLATS, NEWLATS, ROWINC
-      DIMENSION OLDLATS(JPMXLAT), NEWLATS(JPMXLAT)
+C
+C     Arguments
+C
+      INTEGER NPARAM
+      INTEGER NUMLATS, NPTS(*), NLATS
+      REAL STEPNS, STEPWE, OLDWAVE(*), NEWWAVE(*), NORTH, WEST, PMISS
+C
+C     Local variables
+C
+      INTEGER IEOFSET, INDEX, ISTART, IWEST, IWOFSET, KNEWNUM,
+     X        KOLDNUM, LOOP, MISSLAT, NCOL, NEXT,
+     X        NEXTWV, NROW, NUMNEW(JPMXLAT)
+      REAL    AWEST, EAST, NEWLATS(JPMXLAT), OLDLATS(JPMXLAT),
+     X        ONORTH, OSOUTH, PTLAT, PTLONG, RLATINC, ROWINC,
+     X        SOUTH, OEAST, OWEST
+      INTEGER INE, INW, ISE, ISW
       LOGICAL LDIREC
-      REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*4 NW_PT, NE_PT, SW_PT, SE_PT
-      REAL*4 RAD
+      REAL*4  C1, C2, CC, CNE_PT, CNW_PT, CSE_PT, CSW_PT, DI1N, DI1S,
+     X        DI2N, DI2S, DISNE, DISNW, DISSE, DISSW, DK1, DK2, NE_PT,
+     X        NW_PT, RAD, S1, S2, SE_PT, SNE_PT, SNW_PT, SS, SSE_PT,
+     X        SSW_PT, SW_PT, U1, U2
+C
       DATA RAD/0.017453293/
-      REAL*4 DI1N, DI1S, DI2N, DI2S, DK1, DK2
-      REAL*4 CNW_PT, CNE_PT, CSW_PT, CSE_PT
-      REAL*4 SNW_PT, SNE_PT, SSW_PT, SSE_PT
-      REAL*4 U1, U2, C1, C2, S1, S2, CC, SS
-      INTEGER INW, INE, ISW, ISE, JNW, JNE, JSW, JSE
 C
 C     Large, resolution-dependent arrays
 C
@@ -151,8 +134,7 @@ C
       DATA    IS_ALLOCATED_LARGEARRAY /.FALSE./
       SAVE    IS_ALLOCATED_LARGEARRAY
 C
-      INTEGER NEWIDX
-      DIMENSION NEWIDX(4,JPARRAYDIM_WAVE)
+      INTEGER NEWIDX(4,JPARRAYDIM_WAVE)
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 P_NEWIDX
@@ -161,8 +143,7 @@ C
       POINTER(P_NEWIDX,NEWIDX)
       SAVE P_NEWIDX
 C
-      REAL*4 DISTNEW
-      DIMENSION DISTNEW(10,JPARRAYDIM_WAVE)
+      REAL*4 DISTNEW(10,JPARRAYDIM_WAVE)
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 P_DISTNEW
@@ -179,11 +160,12 @@ C
 #else
       INTEGER JMALLOC
 #endif
-      EXTERNAL WAVEIDX, NUMPTWE, JMALLOC
+      LOGICAL IS_WAVE_DIRECTION
+      EXTERNAL WAVEIDX, NUMPTWE, JMALLOC, IS_WAVE_DIRECTION
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   100 CONTINUE
 C
@@ -270,10 +252,11 @@ C
         ENDDO
 C
         MISSLAT = (90.0 - ONORTH)/RLATINC
+        KOLDNUM = 1 + NINT((90.0 - OSOUTH)/RLATINC)
+C
         DO LOOP = 1, MISSLAT
           NPTS(LOOP)    = 0
         ENDDO
-        KOLDNUM = 1 + NINT((90.0 - OSOUTH)/RLATINC)
         DO LOOP = 1, (KOLDNUM-MISSLAT)
           NPTS(LOOP+MISSLAT) = NIWE
         ENDDO
@@ -289,10 +272,10 @@ C     Allocate large, resolution-dependent arrays
         IS_ALLOCATED_LARGEARRAY = .TRUE.
       END IF
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 2. Setup number of points at each latitude for the
 C                output latitude/longitude field.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
@@ -335,44 +318,33 @@ C
 C
       ENDIF
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 3. Get the input GRIB field characteristics.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   300 CONTINUE
 C
 C     Calculate the indices of the input grid points to be used for
 C     the output points
 C
-
       OWEST = FLOAT(NIAREA(2))/PPMULT
       OEAST = FLOAT(NIAREA(4))/PPMULT
 
       WAVEXX2 = WAVEIDX(NUMLATS,NPTS,OLDLATS,OWEST,OEAST,
-     X                  KNEWNUM, NUMNEW, NEWLATS,
-     X                  NEWIDX, DISTNEW)
+     X                  KNEWNUM, NUMNEW, NEWLATS, NEWIDX, DISTNEW)
       IF( WAVEXX2.NE.0 ) THEN
         CALL INTLOG(JP_ERROR,
      X    'WAVEXX2: Unable to calculate output grid indices',JPQUIET)
-        WAVEXX2 = JPROUTINE + 2
+        WAVEXX2 = JPROUTINE + 3
         GOTO 900
       ENDIF
 C
 C     Wave direction parameters need special handling
-C     (MWD1, MWD2, MWD3, MWD, MDWW, MDPS, MDWI, DWI)
-C
-      LDIREC = ( (NPARAM.EQ.122) .OR.
-     X           (NPARAM.EQ.125) .OR.
-     X           (NPARAM.EQ.128) .OR.
-     X           (NPARAM.EQ.230) .OR.
-     X           (NPARAM.EQ.235) .OR.
-     X           (NPARAM.EQ.238) .OR.
-     X           (NPARAM.EQ.242) .OR.
-     X           (NPARAM.EQ.249) )
-C
-C ---------------------------------------------------------------------
+      LDIREC = IS_WAVE_DIRECTION(NPARAM)
+C
+C     -----------------------------------------------------------------|
 C*    Section 4. Work through the output subarea.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   400 CONTINUE
 C
@@ -396,6 +368,7 @@ C
         ELSE
           PTLAT = 90.0 - (NROW-1)*STEPNS
         ENDIF
+C
         IF( (PTLAT.LE.NORTH).AND.(ABS(PTLAT-SOUTH).GT.-0.0005) ) THEN
 C
 C         Calculate number of points between west boundary of area and
@@ -404,8 +377,11 @@ C
           ROWINC = 360.0/NUMNEW(NROW)
 C
           IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) )
-     X      IWEST = IWEST + 1
+          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) ) THEN
+            IWEST = IWEST + 1
+          ELSEIF( (WEST.LT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) ) THEN
+            IWEST = IWEST - 1
+          ENDIF
           AWEST = IWEST * ROWINC
           IWOFSET = NUMPTWE(AWEST,0.0,ROWINC)
           IEOFSET = NUMPTWE(AWEST,EAST,ROWINC)
@@ -477,7 +453,6 @@ C
                   NEWWAVE(NEXTWV) = PMISS
 C
                 ELSE
-
                   NEWWAVE(NEXTWV) =  OLDWAVE(INDEX)
                 ENDIF
 C
@@ -535,9 +510,9 @@ C
         ISTART = ISTART + NUMNEW(NROW)
       ENDDO
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   900 CONTINUE
       RETURN
diff --git a/interpolation/wavexxx.F b/interpolation/wavexxx.F
deleted file mode 100644
index 2ed142e..0000000
--- a/interpolation/wavexxx.F
+++ /dev/null
@@ -1,645 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION WAVEXXX(ISEC2, ISEC4, NLATS, STEPNS, STEPWE,
-     X                         OLDWAVE, NEWIDX, DISTNEW,
-     X                         NEWWAVE, NORTH, WEST, PMISS)
-C
-C---->
-C*****WAVEXXX*
-C
-C     PURPOSE
-C     -------
-C
-C     Interpolates wave fields (except 2D spectra).
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     IRET = WAVEXXX(ISEC2, ISEC4, NLATS, STEPNS, STEPWE,
-C    X               OLDWAVE, NEWIDX, DISTNEW,
-C    X               NEWWAVE, NORTH, WEST, PMISS)
-C
-C     Input arguments
-C     ---------------
-C
-C     ISEC2   - Unpacked section 2 header from 2D wave spectra field
-C     ISEC4   - Unpacked section 4 header from 2D wave spectra field
-C     NLATS   - Number of points N-S in new grid
-C     STEPNS  - Output grid north-south resolution (degrees)
-C     STEPWE  - Output grid west-east resolution (degrees)
-C     OLDWAVE - Original wave field
-C     NORTH   - Output grid northernmost latitude (degrees)
-C     WEST    - Output grid westernmost longitude (degrees)
-C     PMISS   - Missing data value 
-C
-C     Output arguments
-C     ----------------
-C
-C     NEWIDX  - Indices of four neighbouring old grid points used for
-C               new grid points
-C     DISTNEW - Distances of surrounding box edges from new grid points
-C     NEWWAVE - New wave field
-C
-C     Function returns 0 if the interpolation was OK.
-C
-C
-C     METHOD
-C     ------
-C
-C     Builds the index of neighbouring points for the output grid.
-C     Then works through the output grid points, checking for subarea
-C     boundaries and looking up neighbouring point values and weights.
-C     (Neighbours may have missing data).
-C
-C
-C     EXTERNALS
-C     ---------
-C
-C     WAVEIDX - determines which nearest-neighbour values to use for
-C               interpolating to new output grid point
-C     NUMPTWE - Calculates number of grid points between west/east
-C               area boundaries
-C     VALPINA - Looks up bitmap value
-C     SOFFSET - Finds the section offsets in GRIB message
-C     INTLOG  - Log error message
-C
-C
-C     REFERENCE
-C     ---------
-C
-C     None.
-C
-C
-C     Author.
-C     -------
-C
-C     J.D.Chambers      ECMWF    January 1998
-C
-C
-C     Modifications
-C     -------------
-C     Handle reduced lat/long grid in 'pseudo-gaussian' layout
-C     J.D.Chambers      ECMWF    November 2003
-C
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMXLAT
-      PARAMETER (JPROUTINE = 40100)
-      PARAMETER (JPMXLAT = 1801)
-      INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
-      INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
-      PARAMETER (JPNW = 1)
-      PARAMETER (JPNE = 2)
-      PARAMETER (JPSW = 3)
-      PARAMETER (JPSE = 4)
-      PARAMETER (JPN  = 5)
-      PARAMETER (JPS  = 6)
-      PARAMETER (JPDISNW = 7)
-      PARAMETER (JPDISNE = 8)
-      PARAMETER (JPDISSW = 9)
-      PARAMETER (JPDISSE = 10)
-C
-C     Subroutine arguments
-C
-      INTEGER ISEC2, ISEC4, NLATS
-      DIMENSION ISEC2(*), ISEC4(*)
-      REAL STEPNS, STEPWE, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      REAL ONORTH
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-      INTEGER NEWIDX
-      DIMENSION NEWIDX(4,*)
-      REAL*4 DISTNEW
-      DIMENSION DISTNEW(10,*)
-C
-C     Local arguments
-C
-      INTEGER IEOFSET, IWOFSET, ISTART, IWEST
-      REAL SOUTH, PTLAT, AWEST, EAST, PTLONG, OLDWEST, OLDEAST
-      REAL REFVAL, SCALE
-      INTEGER NSPT1, INSPT, NEXP, NMANT, NRETA, NRETB, NLENG, NBIT
-      INTEGER NPARAM, ISCALE, NSCALE, IBITS, ITEMP
-      INTEGER IRET, IS0, IS1, IS2, IS3, IS4, IEDITN
-      INTEGER NEXT, NEXTWV, NROW, NCOL, INDEX, ILOCATE
-      INTEGER MISSLAT, LOOP, NPTS, NUMLATS, NUMNEW, KOLDNUM, KNEWNUM
-      DIMENSION NPTS(JPMXLAT), NUMNEW(JPMXLAT)
-      REAL RLATINC, OLDLATS, NEWLATS, ROWINC
-      DIMENSION OLDLATS(JPMXLAT), NEWLATS(JPMXLAT)
-      LOGICAL LDIREC
-      REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*4 NW_PT, NE_PT, SW_PT, SE_PT
-      REAL*4 RAD
-      DATA RAD/0.017453293/
-      REAL*4 DI1N, DI1S, DI2N, DI2S, DK1, DK2
-      REAL*4 CNW_PT, CNE_PT, CSW_PT, CSE_PT
-      REAL*4 SNW_PT, SNE_PT, SSW_PT, SSE_PT
-      REAL*4 U1, U2, C1, C2, S1, S2, CC, SS
-      INTEGER INW, INE, ISW, ISE, JNW, JNE, JSW, JSE
-C
-C     Externals
-C
-      INTEGER WAVEIDX, SOFFSET, VALPINA, NUMPTWE
-      EXTERNAL WAVEIDX, SOFFSET, VALPINA, NUMPTWE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grspace.h"
-C
-C ---------------------------------------------------------------------
-C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WAVEXXX = 0
-
-C
-C     Initialise the bitmap value lookup function
-C
-      IRET = VALPINA(0,0,0)
-C
-      MISSLAT = 0
-C
-C     Calculate number of latitudes if grid had been full from
-C     North pole to South pole
-C
-      NUMLATS = (180000/ISEC2(10)) + 1
-      IF( NUMLATS.GT.JPMXLAT ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Number of latitudes in input grid = ',NUMLATS)
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: And is greater than allowed maximum = ',JPMXLAT)
-        WAVEXXX = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-      RLATINC = FLOAT(ISEC2(10))
-cs      RLATINC = FLOAT(ISEC2(10)/1000)
-C
-C     Fill an array with the number of points at each latitude for the
-C     input field.
-C
-      IF( ISEC2(17).EQ.1 ) THEN
-C
-C       Input field is a reduced latitude/longitude grid
-C
-C       .. but it may be 'pseudo-gaussian' in layout
-C       (ie global, symmetric about the equator but no latitude
-C        at the equator)
-C
-        IF( (ISEC2(4).NE.90000).AND.(MOD(ISEC2(3),2).EQ.0) ) THEN
-C
-          NUMLATS = ISEC2(3)
-cs          RLATINC = FLOAT(ISEC2(10))/1000
-cs          ONORTH = FLOAT(ISEC2(4))/1000
-          ONORTH = FLOAT(ISEC2(4))
-C
-          DO LOOP = 1, NUMLATS
-cs            OLDLATS(LOOP) = ONORTH - (LOOP-1)*RLATINC
-            OLDLATS(LOOP) = (ONORTH - (LOOP-1)*RLATINC)/1000
-          ENDDO
-C
-          DO LOOP = 1, ISEC2(3)
-            NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-          ENDDO
-C
-        ELSE
-C
-          DO LOOP = 1, NUMLATS
-            OLDLATS(LOOP) = (90000.0 - (LOOP-1)*RLATINC)/1000
-cs            OLDLATS(LOOP) = 90.0 - (LOOP-1)*RLATINC
-          ENDDO
-C
-          MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-          DO LOOP = 1, MISSLAT
-            NPTS(LOOP)    = 0
-          ENDDO
-          KOLDNUM = 1 + (90000 - ISEC2(7))/ISEC2(10)
-          DO LOOP = 1, (KOLDNUM-MISSLAT)
-            NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-          ENDDO
-          DO LOOP = (KOLDNUM+1), NUMLATS
-            NPTS(LOOP)    = 0
-          ENDDO
-        ENDIF
-C
-      ELSE
-C
-C       Input field is a regular latitude/longitude grid
-C
-C
-        DO LOOP = 1, NUMLATS
-cs          OLDLATS(LOOP) = 90.0 - (LOOP-1)*RLATINC
-            OLDLATS(LOOP) = (90000.0 - (LOOP-1)*RLATINC)/1000
-        ENDDO
-C
-        MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-        DO LOOP = 1, MISSLAT
-          NPTS(LOOP)    = 0
-        ENDDO
-        KOLDNUM = 1 + (90000 - ISEC2(7))/ISEC2(10)
-        DO LOOP = 1, (KOLDNUM-MISSLAT)
-          NPTS(LOOP+MISSLAT) = ISEC2(2)
-        ENDDO
-        DO LOOP = (KOLDNUM+1), NUMLATS
-          NPTS(LOOP)    = 0
-        ENDDO
-      ENDIF
-C
-C ---------------------------------------------------------------------
-C*    Section 2. Setup number of points at each latitude for the
-C                output latitude/longitude field.
-C ---------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN) ) THEN
-C
-C       Reduced (quasi-regular) gaussian output
-C
-        KNEWNUM = NOGAUSS*2
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROGAUSS(LOOP)
-        ENDDO
-C
-      ELSE IF( NOREPR.EQ.JPREDLL ) THEN
-C
-C       Reduced (quasi-regular) lat/long output
-C
-        KNEWNUM = NOREDLL
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROREDLL(LOOP)
-        ENDDO
-C
-      ELSE
-C
-C       Regular output
-C
-        MISSLAT = NINT((90.0 - NORTH)/STEPNS)
-        DO LOOP = 1, MISSLAT
-          NUMNEW(LOOP)    = 0
-        ENDDO
-        DO LOOP = 1, NLATS
-          NUMNEW(LOOP+MISSLAT) = NINT(360.0/STEPWE)
-        ENDDO
-C
-        KNEWNUM = MISSLAT + NLATS
-        DO LOOP = 1, KNEWNUM
-          NEWLATS(LOOP) = 90.0 - (LOOP-1)*STEPNS
-        ENDDO
-C
-      ENDIF
-C
-C ---------------------------------------------------------------------
-C*    Section 3. Get the input GRIB field characteristics.
-C ---------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Calculate the indices of the input grid points to be used for
-C     the output points
-C
-      OLDWEST = FLOAT(NIAREA(2))/PPMULT
-      OLDEAST = FLOAT(NIAREA(4))/PPMULT
-
-      WAVEXXX = WAVEIDX(NUMLATS,NPTS,OLDLATS,OLDWEST,OLDEAST,
-     X                  KNEWNUM, NUMNEW, NEWLATS,
-     X                  NEWIDX, DISTNEW)
-      IF( WAVEXXX.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Unable to calculate output grid indices',JPQUIET)
-        WAVEXXX = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-C
-C     Find bitmap (section 3) offset the GRIB product
-C
-      IRET = SOFFSET(OLDWAVE, IS0, IS1, IS2, IS3, IS4, IEDITN)
-C
-C     Get the overall length of OLDWAVE
-C
-#ifdef INTEGER_8
-      NBIT = 64
-#else
-      NBIT = 32
-#endif
-      INSPT = (IS0 + 4) * 8
-      CALL INXBIT(OLDWAVE,10,INSPT,NLENG,1,NBIT,24,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Problem extracting overall length of GRIB',JPQUIET)
-        WAVEXXX = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-C
-C     Get parameter identifier
-C
-      INSPT = (IS1 + 8) * 8
-      CALL INXBIT(OLDWAVE,10,INSPT,NPARAM,1,NBIT,8,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Problem getting parameter identifier',JPQUIET)
-        WAVEXXX = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-C     Wave direction parameters need special handling
-C     (MWD, MDWW, MDPS, MDWI)
-C
-      LDIREC = ( (NPARAM.EQ.230) .OR.
-     X           (NPARAM.EQ.235) .OR.
-     X           (NPARAM.EQ.238) .OR.
-     X           (NPARAM.EQ.242) )
-C
-C     Get the scale factor
-C
-      INSPT = (IS4 + 4) * 8
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NSCALE,1,NBIT,16,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Problem extracting scale factor in GRIB',JPQUIET)
-        WAVEXXX = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-      CALL DSGNBT(ISCALE,NSCALE,16,NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Problem setting sign of scale factor',JPQUIET)
-        WAVEXXX = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-      SCALE = 2.0**(FLOAT(ISCALE))
-C
-C     Get the reference value
-C
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NEXP,1,NBIT,8,'D',NRETA)
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NMANT,1,NBIT,24,'D',NRETB)
-      IF( (NRETA.NE.0) .OR. (NRETB.NE.0) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Problem getting reference value from GRIB',JPQUIET)
-        WAVEXXX = JPROUTINE + 7
-        GOTO 900
-      ENDIF
-      CALL DECFP2(REFVAL,NEXP,NMANT)
-C
-C     Get number of bits per packed value
-C
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,IBITS,1,NBIT,8,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WAVEXXX: Problem getting number of bits per word',JPQUIET)
-        WAVEXXX = JPROUTINE + 8
-        GOTO 900
-      ENDIF
-      NSPT1 = INSPT
-C
-C ---------------------------------------------------------------------
-C*    Section 4. Work through the output subarea.
-C ---------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-C     Fill in the wave spectra values
-C
-      NEXT = 0
-      NEXTWV = 0
-C
-      SOUTH = NOAREA(3)/PPMULT
-      EAST  = NOAREA(4)/PPMULT
-      ISTART = 0
-C
-C     Work down through latitudes from north to south.
-C
-
-
-      DO NROW = 1, KNEWNUM
-C
-C       If inside north-south (subarea) boundaries ..
-C
-        IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPQUASI) ) THEN
-          PTLAT = ROGAUSS(NROW)
-        ELSE
-          PTLAT = 90.0 - (NROW-1)*STEPNS
-        ENDIF
-        IF( (PTLAT.LE.NORTH).AND.(ABS(PTLAT-SOUTH).GT.-0.0005) ) THEN
-C
-C         Calculate number of points between west boundary of area and
-C         Greenwich
-C
-          ROWINC = 360.0/NUMNEW(NROW)
-C
-          IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) )
-     X      IWEST = IWEST + 1
-          AWEST = IWEST * ROWINC
-          IWOFSET = NUMPTWE(AWEST,0.0,ROWINC)
-          IEOFSET = NUMPTWE(AWEST,EAST,ROWINC)
-C
-C         Work through subarea longitudes from west to east.
-C
-          DO NCOL = 1, NUMNEW(NROW)
-            PTLONG = AWEST + (NCOL-1)*ROWINC
-            NEXT = NUMPTWE(AWEST,PTLONG,ROWINC)
-            IF( (NEXT.LE.IEOFSET).AND.(NEXT.GE.0) ) THEN
-C
-C             .. and inside west-east (subarea) boundaries
-C
-              NEXT = 1 + NEXT - IWOFSET
-              IF( NEXT.LE.0) NEXT = NEXT + NUMNEW(NROW)
-              NEXT = NEXT + ISTART
-              NEXTWV = NEXTWV + 1
-C
-              INW = NEWIDX(JPNW,NEXT)
-              INE = NEWIDX(JPNE,NEXT)
-              ISW = NEWIDX(JPSW,NEXT)
-              ISE = NEWIDX(JPSE,NEXT)
-C
-C             If there is a bitmap, ...
-C
-              IF( IS3.NE.0 ) THEN
-                IF(INW.NE.0) JNW = VALPINA(OLDWAVE, IS3+6, INW)
-                IF(INE.NE.0) JNE = VALPINA(OLDWAVE, IS3+6, INE)
-                IF(ISW.NE.0) JSW = VALPINA(OLDWAVE, IS3+6, ISW)
-                IF(ISE.NE.0) JSE = VALPINA(OLDWAVE, IS3+6, ISE)
-              ELSE
-                JNW = INW
-                JNE = INE
-                JSW = ISW
-                JSE = ISE
-              ENDIF
-C
-C             Test if any of the four neighbouring points is missing.
-C
-              IF( (INW.EQ.0) .OR. (INE.EQ.0) .OR.
-     X            (ISW.EQ.0) .OR. (ISE.EQ.0) .OR.
-     X            (JNW.EQ.0) .OR. (JNE.EQ.0) .OR.
-     X            (JSW.EQ.0) .OR. (JSE.EQ.0) ) THEN
-c 
-C
-C               If so, take nearest grid point value.
-C
-                DISNW = DISTNEW(JPDISNW,NEXT)
-                DISNE = DISTNEW(JPDISNE,NEXT)
-                DISSW = DISTNEW(JPDISSW,NEXT)
-                DISSE = DISTNEW(JPDISSE,NEXT)
-C
-                IF( (DISNW.LE.DISNE).AND.
-     X              (DISNW.LE.DISSW).AND.
-     X              (DISNW.LE.DISSE)) THEN
-                  INDEX = INW
-                  ILOCATE  = JNW
-C
-                ELSE IF( (DISNE.LE.DISSW).AND.
-     X                   (DISNE.LE.DISSE) ) THEN
-                  INDEX = INE
-                  ILOCATE  = JNE
-C
-                ELSE IF( (DISSW.LE.DISSE) ) THEN
-                  INDEX = ISW
-                  ILOCATE  = JSW
-C
-                ELSE
-                  INDEX = ISE
-                  ILOCATE  = JSE
-                ENDIF
-C
-                IF( (INDEX.EQ.0).OR.(ILOCATE.EQ.0) ) THEN
-C
-C                 Nearest point is missing
-C
-                  NEWWAVE(NEXTWV) = PMISS
-C
-                ELSE
-                  INSPT = NSPT1 + (ILOCATE - 1)*IBITS
-                  CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                        NBIT,IBITS,'D',NRETA)
-                  IF( NRETA.NE.0 ) THEN
-                    CALL INTLOG(JP_ERROR,
-     X              'WAVEXXX: Problem getting nearest neighbour value',
-     X              JPQUIET)
-                    WAVEXXX = JPROUTINE + 9
-                  GOTO 900
-                  ENDIF
-                  NEWWAVE(NEXTWV) = REFVAL + FLOAT(ITEMP)*SCALE
-                ENDIF
-C
-              ELSE
-C
-C               Use bi-linear interpolation from four
-C               neighbouring sea points.
-C
-                INSPT = NSPT1 + (JNW - 1)*IBITS
-                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                      NBIT,IBITS,'D',NRETA)
-                IF( NRETA.NE.0 ) THEN
-                  CALL INTLOG(JP_ERROR,
-     X            'WAVEXXX: Problem getting NW neighbour value',
-     X            JPQUIET)
-                  WAVEXXX = JPROUTINE + 10
-                  GOTO 900
-                ENDIF
-                NW_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-                INSPT = NSPT1 + (JNE - 1)*IBITS
-                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                      NBIT,IBITS,'D',NRETA)
-                IF( NRETA.NE.0 ) THEN
-                  CALL INTLOG(JP_ERROR,
-     X            'WAVEXXX: Problem getting NE neighbour value',
-     X            JPQUIET)
-                  WAVEXXX = JPROUTINE + 10
-                  GOTO 900
-                ENDIF
-                NE_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-                INSPT = NSPT1 + (JSW - 1)*IBITS
-                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                      NBIT,IBITS,'D',NRETA)
-                IF( NRETA.NE.0 ) THEN
-                  CALL INTLOG(JP_ERROR,
-     X            'WAVEXXX: Problem getting SW neighbour value',
-     X            JPQUIET)
-                  WAVEXXX = JPROUTINE + 10
-                  GOTO 900
-                ENDIF
-                SW_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-                INSPT = NSPT1 + (JSE - 1)*IBITS
-                CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                      NBIT,IBITS,'D',NRETA)
-                IF( NRETA.NE.0 ) THEN
-                  CALL INTLOG(JP_ERROR,
-     X            'WAVEXXX: Problem getting SE neighbour value',
-     X            JPQUIET)
-                  WAVEXXX = JPROUTINE + 10
-                  GOTO 900
-                ENDIF
-                SE_PT = REFVAL + FLOAT(ITEMP)*SCALE
-C
-                DI1N = DISTNEW(JPNW,NEXT)
-                DI2N = DISTNEW(JPNE,NEXT)
-                DI1S = DISTNEW(JPSW,NEXT)
-                DI2S = DISTNEW(JPSE,NEXT)
-                DK1  = DISTNEW(JPN,NEXT)
-                DK2  = DISTNEW(JPS,NEXT)
-C
-                IF( .NOT. LDIREC ) THEN
-                  U1 = NW_PT*DI2N + NE_PT*DI1N
-                  U2 = SW_PT*DI2S + SE_PT*DI1S
-                  NEWWAVE(NEXTWV) = U1*DK2 + U2*DK1
-                ELSE
-C
-C                 Fields representing a 'direction': resolve into
-C                 components and interpolate each separately.
-C
-                  CNW_PT = COS(NW_PT*RAD)
-                  CNE_PT = COS(NE_PT*RAD)
-                  CSW_PT = COS(SW_PT*RAD)
-                  CSE_PT = COS(SE_PT*RAD)
-                  SNW_PT = SIN(NW_PT*RAD)
-                  SNE_PT = SIN(NE_PT*RAD)
-                  SSW_PT = SIN(SW_PT*RAD)
-                  SSE_PT = SIN(SE_PT*RAD)
-                  C1 = CNW_PT*DI2N + CNE_PT*DI1N
-                  C2 = CSW_PT*DI2S + CSE_PT*DI1S
-                  CC = C1*DK2 + C2*DK1
-                  S1 = SNW_PT*DI2N + SNE_PT*DI1N
-                  S2 = SSW_PT*DI2S + SSE_PT*DI1S
-                  SS = S1*DK2 + S2*DK1
-                  IF( SS.LT.0.0 ) THEN
-                    NEWWAVE(NEXTWV) = ATAN2(SS,CC)/RAD + 360.0
-                  ELSE
-                    NEWWAVE(NEXTWV) = ATAN2(SS,CC)/RAD
-                  ENDIF
-                ENDIF
-              ENDIF
-            ENDIF
-          ENDDO
-C
-        ENDIF
-        ISTART = ISTART + NUMNEW(NROW)
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
-C
-  900 CONTINUE
-      RETURN
-      END
diff --git a/interpolation/wv2di32.F b/interpolation/wv2di32.F
deleted file mode 100644
index 6e21234..0000000
--- a/interpolation/wv2di32.F
+++ /dev/null
@@ -1,342 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION WV2DI32(KOLDNUM,NUMOLD,OLDLATS,OLDWEST,OLDEAST,
-     X                         KNEWNUM,NUMNEW,NEWLATS,NEWWAVE)
-C
-C---->
-C*****WV2DI32*
-C
-C     PURPOSE
-C     -------
-C
-C     Determines which nearest-neighbour values of an input global wave
-C     2D-spectra grid field to use for an output global wave 2D-spectra
-C     grid field.
-C     (32-bit REALs version)
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     IRET = WV2DI32(KOLDNUM,NUMOLD,OLDLATS,OLDWEST,OLDEAST,
-C    X               KNEWNUM,NUMNEW,NEWLATS,NEWWAVE)
-C
-C     Input arguments
-C     ---------------
-C
-C     KOLDNUM - No. of meridians from North to South pole (input field)
-C     NUMOLD  - Array giving number of points along each latitude
-C               (empty latitudes have entry 0)
-C     OLDLATS - input field latitudes
-C     OLDWEST - western longitude of the input field (degrees)
-C     OLDEAST - eastern longitude of the input field (degrees)
-C
-C     KNEWNUM - No. of meridians from North to South pole (output field)
-C     NUMNEW  - Array giving number of points along each latitude
-C               (empty latitudes have entry 0)
-C     NEWLATS - output field latitudes
-C
-C     Output arguments
-C     ----------------
-C
-C     NEWWAVE - Indices of points to use
-C
-C     Function returns 0 if the interpolation was OK.
-C
-C
-C     METHOD
-C     ------
-C
-C     The index of the nearest neighbouring grid point value of
-C     the input field is assigned to each point of the output
-C     grid.
-C     The index is zero if the output grid point is 'missing'.
-C
-C     The input field can be regular or quasi-regular, and can be
-C     global or a subarea.
-C     The output field can be regular or quasi-regular.
-C
-C
-C     EXTERNALS
-C     ---------
-C
-C     INTLOG  - Log error message.
-C
-C
-C     REFERENCE
-C     ---------
-C
-C     None
-C
-C
-C     Author.
-C     -------
-C
-C     J.D.Chambers      ECMWF    October  1997
-C
-C
-C----<
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Parameters
-C
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 19410 )
-      INTEGER JPLLMAX
-      PARAMETER ( JPLLMAX = 721 )
-C                             `--> allow upto 0.25 degree resolution
-      INTEGER JPNMOUT
-      PARAMETER ( JPNMOUT = 720 )
-C                             `--> allow upto 0.25 degree resolution
-C
-C     Function arguments
-C
-      INTEGER KOLDNUM, NUMOLD, KNEWNUM, NUMNEW
-      DIMENSION NUMOLD(*), NUMNEW(*)
-      REAL*4 OLDWEST, OLDEAST, OLDLATS, NEWLATS
-      DIMENSION OLDLATS(*), NEWLATS(*)
-      INTEGER NEWWAVE
-      DIMENSION NEWWAVE(*)
-C
-C     Local arguments
-C
-      INTEGER K, NEWCOL, NEWROW, INCOL, LOOP, NEXT
-      INTEGER I_NW, I_SW, I_N, I_S, I_NE, I_SE
-      REAL*8 DELONGN, DELONGS, DIFF, RESOL, DINC
-      REAL*8 DIST_NW, DIST_SW, DIST_NE, DIST_SE, DIST_N, DIST_S
-      REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*8 ZXIN, ZXIS, LON, LAT, OWEST, OEAST
-      DIMENSION LON(JPNMOUT*2)
-      LOGICAL LINGNS, LINGWE
-      INTEGER INDEXI
-      DIMENSION INDEXI(JPLLMAX)
-C
-C ---------------------------------------------------------------------
-C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WV2DI32 = 0
-      CALL INTLOG(JP_DEBUG,
-     X   'WV2DI32: Wave interpolation requested.',JPQUIET)
-C
-C     Check latitude/longitude grid specification
-      IF( KOLDNUM.GT.JPLLMAX ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DI32: Number of latitudes in input grid = ',KOLDNUM)
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DI32: And is greater than allowed maximum = ',JPLLMAX)
-        WV2DI32 = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-C     Set up INDEXI for latitude lines in input lat/lon array
-C
-      INDEXI(1) = 0
-      DO LOOP = 2, KOLDNUM
-        INDEXI(LOOP) = INDEXI(LOOP-1) + NUMOLD(LOOP-1)
-      ENDDO
-C
-      OEAST = OLDEAST
-      OWEST = OLDWEST
-C
-C ---------------------------------------------------------------------
-C*    Section 2. Interpolation.
-C ---------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      NEXT = 1
-C
-      DO 220 NEWROW = 1, KNEWNUM
-C
-C       Find old latitude rows to north and south of new latitude and
-C       set up the distance between new row and the old rows to N and S.
-C
-        DO LOOP = 1, KOLDNUM -1
-          IF( (NEWLATS(NEWROW).LE.OLDLATS(LOOP)) .AND.
-     X        (NEWLATS(NEWROW).GT.OLDLATS(LOOP+1)) ) THEN
-            I_N = LOOP
-            I_S = MIN(LOOP+1,KOLDNUM)
-            GOTO 205
-          ENDIF
-        ENDDO
-C
-        IF( NEWLATS(NEWROW).EQ.OLDLATS(KOLDNUM) ) THEN
-          I_N = KOLDNUM
-          I_S = KOLDNUM
-        ELSE
-          I_N = -1
-          I_S = -1
-        ENDIF
-C
-  205   CONTINUE
-        IF( I_N.NE.I_S) THEN
-          DIFF   = OLDLATS(I_N) - OLDLATS(I_S)
-          DIST_N = (OLDLATS(I_N) - NEWLATS(NEWROW)) / DIFF
-        ELSE
-          DIST_N = 1.0
-        ENDIF
-        DIST_S = 1.0 - DIST_N
-C
-C       Check if the new interpolated row lies between 2 old rows which
-C       have data points
-C
-        LINGNS = .FALSE.
-        IF( I_N.GT.0 ) THEN
-          IF( (NUMOLD(I_N).GT.0).AND.(NUMOLD(I_S).GT.0) ) THEN
-C
-C           Yes, so set up the grid increments.
-C
-            DINC = 360.0/DBLE(NUMOLD(I_N))
-            DELONGN = (DMOD((OEAST-OWEST+DBLE(360.0)), DBLE(360.0))
-     X                 +DINC) / DBLE(NUMOLD(I_N))
-            DINC = 360.0/DBLE(NUMOLD(I_S))
-            DELONGS = (DMOD((OEAST-OWEST+DBLE(360.0)), DBLE(360.0))
-     X                 +DINC) / DBLE(NUMOLD(I_S))
-            LINGNS  = .TRUE.
-          ENDIF
-C
-C         The equator is given special treatment so that the northern
-C         and southern hemispheres for the parameter 250 can (later)
-C         be stitched together.
-C
-C         If the input field finishs at the equator and the output
-C         field has a line at the equator, use the input equator for
-C         interpolation.
-C
-          IF( NEWLATS(I_N).EQ.0.0 .AND.
-     x        ((NUMOLD(I_N).GT.0).AND.(NUMOLD(I_S).EQ.0)) ) THEN
-C
-C           Yes, so set up the grid increments.
-C
-            DINC = 360.0/DBLE(NUMOLD(I_N))
-            DELONGN = (DMOD((OEAST-OWEST+DBLE(360.0)), DBLE(360.0))
-     X                 +DINC) / DBLE(NUMOLD(I_N))
-            DELONGS = DELONGN
-            DIST_N = 0.0
-            DIST_S = 1.0
-            LINGNS  = .TRUE.
-          ENDIF
-        ENDIF
-C
-C       Setup longitudes for the current row
-C
-        INCOL = NUMNEW(NEWROW)
-        IF( INCOL.NE.0 ) THEN
-          RESOL = 360.0/DBLE(INCOL)
-          DO LOOP = 1, INCOL
-            LON(LOOP) = DBLE(LOOP-1)*RESOL
-          ENDDO
-C
-          DO 210 NEWCOL = 1, INCOL
-C
-            LINGWE = (LON(NEWCOL).GT.OWEST).OR.(LON(NEWCOL).LT.OEAST)
-C
-            IF( LINGNS .AND. LINGWE ) THEN
-C
-C             If point to be interpolated is inside the input field ,
-C             work out distances from new point to four neighbours.
-C
-              ZXIN = DMOD( (LON(NEWCOL) + (360.0-OWEST) + DBLE(720.0)),
-     X                     DBLE(360.0))
-              ZXIS = ZXIN
-              ZXIN = ZXIN/DELONGN + 1.0
-              ZXIS = ZXIS/DELONGS + 1.0
-              I_NW = INT(ZXIN)
-              I_NE = I_NW + 1
-              I_SW = INT(ZXIS)
-              I_SE = I_SW + 1
-C
-C             Allow wrap-around
-C
-C
-              I_NW = MOD(I_NW,NUMOLD(I_N))
-              I_NE = MOD(I_NE,NUMOLD(I_N))
-              I_SW = MOD(I_SW,NUMOLD(I_S))
-              I_SE = MOD(I_SE,NUMOLD(I_S))
-              IF( I_NW.EQ.0 ) I_NW = NUMOLD(I_N)
-              IF( I_SW.EQ.0 ) I_SW = NUMOLD(I_S)
-              IF( I_NE.EQ.0 ) I_NE = NUMOLD(I_N)
-              IF( I_SE.EQ.0 ) I_SE = NUMOLD(I_S)
-C
-C             Calculate distance from interpolated point to its neighbours
-C
-              DIST_NW = ZXIN - REAL(I_NW)
-              DIST_NE = 1.0 - DIST_NW
-              DIST_SW = ZXIS - REAL(I_SW)
-              DIST_SE = 1.0 - DIST_SW
-C
-C             Take nearest grid point value.
-C
-              DISNW = DIST_NW*DIST_NW + DIST_N*DIST_N
-              DISNE = DIST_NE*DIST_NE + DIST_N*DIST_N
-              DISSW = DIST_SW*DIST_SW + DIST_S*DIST_S
-              DISSE = DIST_SE*DIST_SE + DIST_S*DIST_S
-C
-              IF( (DISNW.LE.DISNE).AND.(DISNW.LE.DISSW).AND.
-     X            (DISNW.LE.DISSE) ) THEN
-C
-C               Use north-west neighbour
-C
-                NEWWAVE(NEXT) = INDEXI(I_N)+I_NW
-C
-              ELSE IF( (DISNE.LE.DISSW).AND.(DISNE.LE.DISSE) ) THEN
-C
-C               Use north-east neighbour
-C
-                NEWWAVE(NEXT) = INDEXI(I_N)+I_NE
-C
-              ELSE IF( DISSW.LE.DISSE ) THEN
-C
-C               Use south-west neighbour
-C
-                NEWWAVE(NEXT) = INDEXI(I_S)+I_SW
-              ELSE
-C
-C               Use south-east neighbour
-C
-                NEWWAVE(NEXT) = INDEXI(I_S)+I_SE
-              ENDIF
-C
-C           If the point to be interpolated is outside the input field,
-C           set it to 'land'.
-C
-            ELSE
-              NEWWAVE(NEXT) = 0
-            ENDIF
-C
-            NEXT = NEXT + 1
-C
-  210     CONTINUE
-C
-        ENDIF
-C
-  220 CONTINUE
-C
-C ---------------------------------------------------------------------
-C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-      IF( WV2DI32.EQ.0 ) THEN
-        CALL INTLOG(JP_DEBUG, 'WV2DI32: successful.',JPQUIET)
-      ELSE
-        CALL INTLOG(JP_ERROR, 'WV2DI32: failed.',JPQUIET)
-      ENDIF
-C
-      RETURN
-      END
diff --git a/interpolation/wv2didx.F b/interpolation/wv2didx.F
index 34db56b..38109cc 100644
--- a/interpolation/wv2didx.F
+++ b/interpolation/wv2didx.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -110,12 +110,12 @@ C
 C
 C     Local arguments
 C
-      INTEGER K, NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
+      INTEGER NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
       INTEGER I_NW, I_SW, I_N, I_S, I_NE, I_SE
       REAL*8 DELONGN, DELONGS, DIFF, RESOL, DINC, DEPS
       REAL*8 DIST_NW, DIST_SW, DIST_NE, DIST_SE, DIST_N, DIST_S
       REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*8 ZXIN, ZXIS, LON, LAT, OWEST, OEAST
+      REAL*8 ZXIN, ZXIS, LON, OWEST, OEAST
       DIMENSION LON(JPNMOUT*2)
       LOGICAL LINGNS, LINGWE
       INTEGER INDEXI
@@ -297,7 +297,7 @@ C             work out distances from new point to four neighbours.
 C
               ZXIN = DMOD( (LON(NEWCOL) + (360.0-OWEST) + DBLE(720.0)),
      X                     DBLE(360.0))
-cs			  ZXIN = LON(NEWCOL)
+cs            ZXIN = LON(NEWCOL)
               ZXIS = ZXIN
               ZXIN = ZXIN/DELONGN + 1.0
               ZXIS = ZXIS/DELONGS + 1.0
diff --git a/interpolation/wv2dint.F b/interpolation/wv2dint.F
index 8552cb7..e4b48ee 100644
--- a/interpolation/wv2dint.F
+++ b/interpolation/wv2dint.F
@@ -118,14 +118,12 @@ C
 C
 C     Local arguments
 C
-      INTEGER NLAT, K, I, NEWCOL, NEWROW,LOOP
-      INTEGER I_NW, I_SW, I_N, I_S, I_NE, I_SE
-      REAL DELONGN, DELONGS, DELAT
-      REAL DIST_NW, DIST_SW, DIST_NE, DIST_SE, DIST_N, DIST_S
-      REAL DISNW, DISNE, DISSW, DISSE
-      REAL ZXIN, ZXIS, LON, LAT
-      DIMENSION LON(JPNMOUT*2),LAT(JPNMOUT+1)
-      LOGICAL INGRID
+      INTEGER NLAT, K, NEWCOL, NEWROW
+      INTEGER I_N, I_S
+      REAL DELAT
+      REAL DIST_N, DIST_S
+      REAL LAT
+      DIMENSION LAT(JPNMOUT+1)
       INTEGER INDEX
       DIMENSION INDEX(JPLLMAX)
 C
diff --git a/interpolation/wv2dppp.F b/interpolation/wv2dppp.F
deleted file mode 100644
index 3426c5b..0000000
--- a/interpolation/wv2dppp.F
+++ /dev/null
@@ -1,156 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION WV2DPPP(ISEC2, ISEC4, NLONS, NLATS, STEP,
-     X                         OLDWAVE, NEWWAVE, NORTH, WEST, PMISS)
-C
-C---->
-C*****WV2DPPP*
-C
-C     PURPOSE
-C     -------
-C
-C     Interface routine to call WV2DINT using (inconsistent)
-C     GRIB headers in 2D wave spectra fields.
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     IRET = WV2DPPP(ISEC2, ISEC4, NLONS, NLATS, STEP,
-C    X               OLDWAVE, NEWWAVE, NORTH, WEST, PMISS)
-C
-C     Input arguments
-C     ---------------
-C
-C     ISEC2   - Unpacked section 2 header from 2D wave spectra field
-C     ISEC4   - Unpacked section 4 header from 2D wave spectra field
-C     NLONS   - Number of points E-W in new grid
-C     NLATS   - Number of points N-S in new grid
-C     STEP    - Output grid resolution (degrees)
-C     OLDWAVE - Original wave field
-C     NORTH   - Output grid northernmost latitude (degrees)
-C     WEST    - Output grid westernmost longitude (degrees)
-C     PMISS   - Missing data value 
-C
-C     Output arguments
-C     ----------------
-
-C     NEWWAVE - New wave field
-C
-C     Function returns 0 if the interpolation was OK.
-C
-C
-C     METHOD
-C     ------
-C
-C     Setes up call to WV2DINT from 2D wave spectra field headers.
-C
-C
-C     EXTERNALS
-C     ---------
-C
-C     None.
-C
-C
-C     REFERENCE
-C     ---------
-C
-C     None.
-C
-C
-C     Author.
-C     -------
-C
-C     J.D.Chambers      ECMWF    November 1996
-C
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Subroutine arguments
-C
-      INTEGER ISEC2, ISEC4, NLONS, NLATS
-      DIMENSION ISEC2(*), ISEC4(*)
-      REAL STEP, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMXLAT
-      PARAMETER (JPROUTINE = 19420)
-      PARAMETER (JPMXLAT = 361)
-C
-C     Local arguments
-C
-      INTEGER NSPEC, MISSLAT, LOOP, NPTS, NUMLATS
-      DIMENSION NPTS(JPMXLAT)
-C
-C     Externals
-C
-      INTEGER WV2DINT
-      EXTERNAL WV2DINT
-C
-C ---------------------------------------------------------------------
-C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WV2DPPP = 0
-C
-C     Setup number of spectra at each point
-C
-      IF( ISEC4(8).EQ.64 ) THEN
-        NSPEC = ISEC4(50)*ISEC4(51)
-      ELSE
-        NSPEC = 1
-      ENDIF
-C
-C     Calculate number of latitudes if grid had been full from
-C     North pole to South pole
-C
-      NUMLATS = (180000/ISEC2(10)) + 1
-      IF( NUMLATS.GT.JPMXLAT ) THEN
-        WV2DPPP = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-C     Fill an array with the number of points at each latitude
-C     (this is a reduced latitude/longitude grid)
-C
-      MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-      DO LOOP = 1, MISSLAT
-        NPTS(LOOP) = 0
-      ENDDO
-      DO LOOP = 1, ISEC2(3)
-        NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-      ENDDO
-      DO LOOP = MISSLAT+ISEC2(3), NUMLATS
-        NPTS(LOOP) = 0
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 2. Do the interpolation.
-C ---------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      WV2DPPP = WV2DINT(NUMLATS,NPTS,NLONS,NLATS,STEP,OLDWAVE,
-     X                  NEWWAVE,NORTH,WEST,NSPEC,PMISS)
-C
-C ---------------------------------------------------------------------
-C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
-C
-  900 CONTINUE
-      RETURN
-      END
diff --git a/interpolation/wv2dx32.F b/interpolation/wv2dx32.F
deleted file mode 100644
index e256f4b..0000000
--- a/interpolation/wv2dx32.F
+++ /dev/null
@@ -1,484 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION WV2DX32(ISEC2,ISEC4,NLATS,STEPNS,STEPWE,
-     X                         OLDWAVE,NEWIDX,NEWWAVE,NORTH,WEST,PMISS)
-C
-C---->
-C*****WV2DX32*
-C
-C     PURPOSE
-C     -------
-C
-C     Interpolates 2D wave spectra fields.
-C     (32-bit REALs version)
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     IRET = WV2DX32(ISEC2,ISEC4,NLATS,STEPNS,STEPWE,
-C    X               OLDWAVE,NEWIDX,NEWWAVE,NORTH,WEST,PMISS)
-C
-C     Input arguments
-C     ---------------
-C
-C     ISEC2   - Unpacked section 2 header from 2D wave spectra field
-C     ISEC4   - Unpacked section 4 header from 2D wave spectra field
-C     NLATS   - Number of points N-S in new grid
-C     STEPNS  - Output grid north-south resolution (degrees) (REAL*4)
-C     STEPWE  - Output grid west-east resolution (degrees) (REAL*4)
-C     OLDWAVE - Original wave field (REAL*4)
-C     NORTH   - Output grid northernmost latitude (degrees) (REAL*4)
-C     WEST    - Output grid westernmost longitude (degrees) (REAL*4)
-C     PMISS   - Missing data value  (REAL*4)
-C
-C     Output arguments
-C     ----------------
-C
-C     NEWIDX  - Indices of old grid points used for new grid points
-C     NEWWAVE - New wave field (REAL*4)
-C
-C     Function returns 0 if the interpolation was OK.
-C
-C
-C     METHOD
-C     ------
-C
-C     Builds the index of nearest neighbour points for the output grid.
-C     Then works through the output grid points, checking for subarea
-C     boundaries and looking up nearset neighbour 2D spectra values
-C     (which may be missing data).
-C
-C
-C     EXTERNALS
-C     ---------
-C
-C     WV2DI32 - builds the index of nearest neighbour points
-C     NPTWE32 - Calculates number of grid points between west/east
-C               area boundaries (32-bit REALs version)
-C     VALPINA - Looks up bitmap value
-C     ONEBITS - Counts number of 1s in a GRIB section 3 bitmap
-C     NUMVALS - Counts the values in the secondary bitmap.
-C     SOFFSET - Finds the section offsets in GRIB message
-C     INTLOG  - Log error message
-C
-C
-C     REFERENCE
-C     ---------
-C
-C     None.
-C
-C
-C     Author.
-C     -------
-C
-C     J.D.Chambers      ECMWF    March 1998
-C
-C
-C     Modifications
-C     -------------
-C
-C     J.D.Chambers      ECMWF    May 1998
-C     Handle parameter 251 as a simple form of wave 2D spectra.
-C     (A field containing one direction and one frequency).
-C
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Subroutine arguments
-C
-      INTEGER ISEC2, ISEC4, NLATS
-      DIMENSION ISEC2(*), ISEC4(*)
-      REAL*4 STEPNS, STEPWE, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-      INTEGER NEWIDX
-      DIMENSION NEWIDX(*)
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMXLAT, JPNSPEC
-      PARAMETER (JPROUTINE = 40000)
-      PARAMETER (JPMXLAT = 721)
-      PARAMETER (JPNSPEC = 600)
-C
-C     Local arguments
-C
-      LOGICAL LSIMPLE
-      INTEGER IEOFSET, IWOFSET, ISTART, IWEST
-      REAL*4 SOUTH, EAST, PTLAT, PTLONG, AWEST, OLDWEST, OLDEAST
-      REAL*4 REFVAL, SCALE
-      INTEGER NPDATA, INSPT, NEXP, NMANT, NRETA, NRETB, NLENG, NBIT
-      INTEGER NVALS
-      INTEGER ISCALE, NSCALE, IBITS, ITEMP, NPBTMP2, IBITMAP, NUNUSED
-      DIMENSION IBITMAP(JPNSPEC)
-      INTEGER IRET, IS0, IS1, IS2, IS3, IS4, IEDITN
-      INTEGER NEXT, NEXTWV, NROW, NCOL, INDEX, ILOCATE
-      INTEGER NSPEC, MISSLAT, LOOP, NPTS, NUMLATS, NUMNEW
-      INTEGER KOLDNUM, KNEWNUM
-      DIMENSION NPTS(JPMXLAT), NUMNEW(JPMXLAT)
-      REAL*4 RLATINC, OLDLATS, NEWLATS, ROWINC
-      DIMENSION OLDLATS(JPMXLAT), NEWLATS(JPMXLAT)
-C
-C     Externals
-C
-      INTEGER WV2DI32, SOFFSET, VALPINA, NUMVALS, ONEBITS, NPTWE32
-      EXTERNAL WV2DI32, SOFFSET, VALPINA, NUMVALS, ONEBITS, NPTWE32
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grspace.h"
-C
-C ---------------------------------------------------------------------
-C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WV2DX32 = 0
-C
-C     Initialise the bitmap value lookup function and function
-C     which counts the values in the secondary bitmap.
-C
-      IRET = VALPINA(0,0,0)
-      IRET = NUMVALS(0,0,0)
-C
-C     Setup number of spectra at each point
-C
-      IF( ISEC4(8).EQ.0 ) THEN
-        LSIMPLE = .TRUE.
-        NSPEC   = 1
-      ELSE
-        LSIMPLE = .FALSE.
-        NSPEC   = ISEC4(50)*ISEC4(51)
-      ENDIF
-C
-      IF( NSPEC.GT.JPNSPEC) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Number of wave spectra at each grid pt = ',NSPEC)
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: And is greater than allowed maximum = ',JPNSPEC)
-        WV2DX32 = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-C     Calculate number of latitudes if grid had been full from
-C     North pole to South pole
-C
-      NUMLATS = (180000/ISEC2(10)) + 1
-      IF( NUMLATS.GT.JPMXLAT ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Number of latitudes in input grid = ',NUMLATS)
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: And is greater than allowed maximum = ',JPMXLAT)
-        WV2DX32 = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-      RLATINC = FLOAT(ISEC2(10))/1000
-      DO LOOP = 1, NUMLATS
-        OLDLATS(LOOP) = 90.0 - (LOOP-1)*RLATINC
-      ENDDO
-C
-C     Fill an array with the number of points at each latitude for the
-C     input field (this is a reduced latitude/longitude grid)
-C
-      MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-      DO LOOP = 1, MISSLAT
-        NPTS(LOOP)    = 0
-      ENDDO
-      KOLDNUM = 1 + (90000 - ISEC2(7))/ISEC2(10)
-      DO LOOP = 1, (KOLDNUM-MISSLAT)
-        NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-      ENDDO
-      DO LOOP = (KOLDNUM+1), NUMLATS
-        NPTS(LOOP)    = 0
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 2. Setup number of points at each latitude for the
-C                output latitude/longitude field.
-C ---------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN) ) THEN
-C
-C       Reduced (quasi-regular) gaussian output
-C
-        KNEWNUM = NOGAUSS*2
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROGAUSS(LOOP)
-        ENDDO
-C
-      ELSE IF( NOREPR.EQ.JPREDLL ) THEN
-C
-C       Reduced (quasi-regular) lat/long output
-C
-        KNEWNUM = NOREDLL
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROREDLL(LOOP)
-        ENDDO
-C
-      ELSE
-C
-C       Regular output
-C
-        MISSLAT = NINT((90.0 - NORTH)/STEPNS)
-        DO LOOP = 1, MISSLAT
-          NUMNEW(LOOP)    = 0
-        ENDDO
-        DO LOOP = 1, NLATS
-          NUMNEW(LOOP+MISSLAT) = NINT(360.0/STEPWE)
-        ENDDO
-C
-        KNEWNUM = MISSLAT + NLATS
-        DO LOOP = 1, KNEWNUM
-          NEWLATS(LOOP) = 90.0 - (LOOP-1)*STEPNS
-        ENDDO
-C
-      ENDIF
-C
-C ---------------------------------------------------------------------
-C*    Section 3. Get the input GRIB field characteristics.
-C ---------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Calculate the indices of the input grid points to be used for
-C     the output points
-C
-      OLDWEST = FLOAT(ISEC2(5))/1000
-      OLDEAST = FLOAT(ISEC2(8))/1000
-      WV2DX32 = WV2DI32(NUMLATS,NPTS,OLDLATS,OLDWEST,OLDEAST,
-     X                  KNEWNUM, NUMNEW, NEWLATS, NEWIDX)
-      IF( WV2DX32.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Unable to calculate output grid indices',JPQUIET)
-        WV2DX32 = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-C
-C     Find section offsets for the GRIB product
-C
-      IRET = SOFFSET(OLDWAVE, IS0, IS1, IS2, IS3, IS4, IEDITN)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Problem finding section offsets for GRIB',JPQUIET)
-        WV2DX32 = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-C     Get the overall length of OLDWAVE
-C
-      NBIT = 32
-      INSPT = (IS0 + 4) * 8
-      CALL INXBIT(OLDWAVE,10,INSPT,NLENG,1,NBIT,24,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Problem extracting overall length of GRIB',JPQUIET)
-        WV2DX32 = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-C
-C     Get the scale factor
-C
-      INSPT = (IS4 + 4) * 8
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NSCALE,1,NBIT,16,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Problem extracting scale factor in GRIB',JPQUIET)
-        WV2DX32 = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-      CALL DSGNBT(ISCALE,NSCALE,16,NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Problem setting sign of scale factor',JPQUIET)
-        WV2DX32 = JPROUTINE + 7
-        GOTO 900
-      ENDIF
-      SCALE = 2.0**(FLOAT(ISCALE))
-C
-C     Get the reference value
-C
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NEXP,1,NBIT,8,'D',NRETA)
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NMANT,1,NBIT,24,'D',NRETB)
-      IF( (NRETA.NE.0) .OR. (NRETB.NE.0) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Problem getting reference value from GRIB',JPQUIET)
-        WV2DX32 = JPROUTINE + 8
-        GOTO 900
-      ENDIF
-      CALL DECFP2(REFVAL,NEXP,NMANT)
-C
-C     Get number of bits per packed value
-C
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,IBITS,1,NBIT,8,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DX32: Problem getting number of bits per word',JPQUIET)
-        WV2DX32 = JPROUTINE + 9
-        GOTO 900
-      ENDIF
-C
-C     (Pointer INSPT is currently at octet 12 in GRIB section 4)
-C
-C     Set up pointers to start of secondary bitmap and start of packed
-C     data values
-C
-      NPBTMP2 = (IS4 + 24)*8 + (ISEC4(53)+ISEC4(55))*32
-C
-      IF( .NOT. LSIMPLE ) THEN
-        NPDATA  = NPBTMP2 + NSPEC*ONEBITS(OLDWAVE,IS3)
-      ELSE
-        NPDATA  = NPBTMP2
-      ENDIF
-      NPDATA  = ((NPDATA + 7)/8)*8
-C
-C ---------------------------------------------------------------------
-C*    Section 4. Work through the output subarea.
-C ---------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-C     Fill in the wave spectra values
-C
-      NEXT = 0
-      NEXTWV = 0
-C
-      SOUTH = NOAREA(3)/PPMULT
-      EAST  = NOAREA(4)/PPMULT
-      ISTART = 0
-C
-C     Work down through latitudes from north to south.
-C
-      DO NROW = 1, KNEWNUM
-C
-C       If inside north-south (subarea) boundaries ..
-C
-        IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPQUASI) ) THEN
-          PTLAT = ROGAUSS(NROW)
-        ELSE
-          PTLAT = 90.0 - (NROW-1)*STEPNS
-        ENDIF
-C
-        IF( (PTLAT.LE.NORTH).AND.(ABS(PTLAT-SOUTH).GT.-0.0005) ) THEN
-C
-C         Calculate number of points between west boundary of area and
-C         Greenwich
-C
-          ROWINC = 360.0/NUMNEW(NROW)
-C
-          IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) )
-     X      IWEST = IWEST + 1
-          AWEST = IWEST * ROWINC
-          IWOFSET = NPTWE32(AWEST,0.0,ROWINC)
-          IEOFSET = NPTWE32(AWEST,EAST,ROWINC)
-C
-C         Work through subarea longitudes from west to east.
-C
-          DO NCOL = 1, NUMNEW(NROW)
-            PTLONG = AWEST + (NCOL-1)*ROWINC
-            NEXT = NPTWE32(AWEST,PTLONG,ROWINC)
-            IF( (NEXT.LE.IEOFSET).AND.(NEXT.GE.0) ) THEN
-C
-C             .. and inside west-east (subarea) boundaries
-C
-              NEXT = 1 + NEXT - IWOFSET
-              IF( NEXT.LE.0) NEXT = NEXT + NUMNEW(NROW)
-              NEXT = NEXT + ISTART
-              INDEX = NEWIDX(NEXT)
-              ILOCATE = VALPINA(OLDWAVE, IS3+6, INDEX)
-C
-              IF( ILOCATE.EQ.0 ) THEN
-C
-C               Nearest neighbour is a 'missing' point
-C
-                DO LOOP = 1, NSPEC
-                  NEXTWV = NEXTWV + 1
-                  NEWWAVE(NEXTWV) = PMISS
-                ENDDO
-C
-              ELSE
-C
-C               Nearest neighbour has values
-C
-                IF( LSIMPLE ) THEN
-                  INSPT = NPDATA + (ILOCATE - 1)*IBITS
-                  NVALS = 1
-                  IBITMAP(1) = 1
-                ELSE
-C
-C                 Count the number of values in the secondary bitmap upto
-C                 the current point and pick up its secondary bitmap.
-C
-                  INSPT = NPBTMP2 + (ILOCATE - 1)*NSPEC
-                  NVALS = NUMVALS(OLDWAVE,NPBTMP2,INSPT)
-                  CALL INXBIT(OLDWAVE,NLENG,INSPT,IBITMAP,NSPEC,
-     X                        NBIT,1,'D',NRETA)
-                  IF( NRETA.NE.0 ) THEN
-                    CALL INTLOG(JP_ERROR,
-     X              'WV2DX32: Problem getting neighbours 2ndary bitmap',
-     X              JPQUIET)
-                    WV2DX32 = JPROUTINE + 10
-                    GOTO 900
-                  ENDIF
-C
-C                 Pick up the values at the current point
-C
-                  INSPT = NPDATA + NVALS*IBITS
-                ENDIF
-C
-                DO LOOP = 1, NSPEC
-                  NEXTWV = NEXTWV + 1
-                  IF( IBITMAP(LOOP).EQ.0 ) THEN
-C
-C                   ..missing
-C
-                    NEWWAVE(NEXTWV) = PMISS
-C
-                  ELSE
-C
-C                   ..retrieve and recreate the packed value
-C
-                    CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                          NBIT,IBITS,'D',NRETA)
-                    IF( NRETA.NE.0 ) THEN
-                      CALL INTLOG(JP_ERROR,
-     X                'WV2DX32: Problem getting nearest neighbour',
-     X                JPQUIET)
-                      WV2DX32 = JPROUTINE + 11
-                      GOTO 900
-                    ENDIF
-                    NEWWAVE(NEXTWV) = REFVAL + FLOAT(ITEMP)*SCALE
-                  ENDIF
-                ENDDO
-C
-              ENDIF
-            ENDIF
-          ENDDO
-C
-        ENDIF
-        ISTART = ISTART + NUMNEW(NROW)
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
-C
-  900 CONTINUE
-      RETURN
-      END
diff --git a/interpolation/wv2dxx2.F b/interpolation/wv2dxx2.F
index ad9b541..7a3dd12 100644
--- a/interpolation/wv2dxx2.F
+++ b/interpolation/wv2dxx2.F
@@ -1,18 +1,17 @@
 C
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
       INTEGER FUNCTION WV2DXX2(KNSPEC, NUMLATS, NPTS,
      X                         NLATS, STEPNS, STEPWE,
-     X                         OLDWAVE, NEWWAVE,
-     X                         NORTH,WEST,PMISS)
+     X                         OLDWAVE, NEWWAVE, NORTH, WEST, PMISS)
 C
 C---->
 C*****WV2DXX2*
@@ -27,24 +26,23 @@ C     INTERFACE
 C     ---------
 C
 C     IRET = WV2DXX2(KNSPEC, NUMLATS, NPTS,
-C    X               NLATS,STEPNS,STEPWE,
-C    X               OLDWAVE,NEWWAVE,
-C    X               NORTH,WEST,PMISS)
+C    X               NLATS, STEPNS, STEPWE,
+C    X               OLDWAVE, NEWWAVE, NORTH, WEST, PMISS)
 C
 C     Input arguments
 C     ---------------
 C
 C     KNSPEC  - Number of 2D spectra values at each wave point
 C     NUMLATS - Input lat number north-south
-C     NPTS   - Array giving number of points along each latitude
-C              for Input field (empty latitudes have entry 0)
+C     NPTS    - Array giving number of points along each latitude
+C               for input field (empty latitudes have entry 0)
 C     NLATS   - Number of points N-S in new grid
 C     STEPNS  - Output grid north-south resolution (degrees)
 C     STEPWE  - Output grid west-east resolution (degrees)
 C     OLDWAVE - Original wave field
 C     NORTH   - Output grid northernmost latitude (degrees)
 C     WEST    - Output grid westernmost longitude (degrees)
-C     PMISS   - Missing data value 
+C     PMISS   - Missing data value
 C
 C     Output arguments
 C     ----------------
@@ -57,9 +55,9 @@ C
 C     METHOD
 C     ------
 C
-C     Builds the index of nearest neighbour points for the output grid.
+C     Builds the index of neighbouring points for the output grid.
 C     Then works through the output grid points, checking for subarea
-C     boundaries and looking up nearset neighbour 2D spectra values
+C     boundaries and looking up neighbouring point 2D spectra values
 C     (which may be missing data).
 C
 C
@@ -83,7 +81,7 @@ C
 C     Author.
 C     -------
 C
-C     S. Curic         ECMWF    Jun 2009 
+C     S. Curic      ECMWF    Jun 2009
 C
 C     Handle parameter 251 as a simple form of wave 2D spectra.
 C     (A field containing one direction and one frequency).
@@ -96,42 +94,31 @@ C
 C     Parameters
 C
 #include "parim.h"
+C
+      INTEGER JPROUTINE, JPMXLAT, JPNSPEC
+      PARAMETER( JPROUTINE = 40000 )
+      PARAMETER( JPMXLAT   =  1801 ) ! allow up to 0.1 degree resolution
+      PARAMETER( JPNSPEC   =   600 )
+C
 #include "nifld.common"
 #include "nofld.common"
 #include "grspace.h"
 C
-C     Subroutine arguments
+C     Arguments
 C
-      INTEGER NPTS,NLATS
-      DIMENSION NPTS(*)
-      REAL STEPNS, STEPWE, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-      INTEGER NUMLATS, KNSPEC
+      INTEGER KNSPEC
+      INTEGER NUMLATS, NPTS(*), NLATS
+      REAL STEPNS, STEPWE, OLDWAVE(*), NEWWAVE(*), NORTH, WEST, PMISS
 C
-C     Parameters
+C     Local variables
 C
-      INTEGER JPROUTINE, JPMXLAT, JPNSPEC
-      PARAMETER (JPROUTINE = 40000)
-      PARAMETER (JPMXLAT = 1801)
-      PARAMETER (JPNSPEC = 600)
-C
-C     Local arguments
-C
-      INTEGER IEOFSET, IWOFSET, ISTART, IWEST
-      REAL SOUTH, EAST, PTLAT, PTLONG, AWEST, OLDWEST, OLDEAST
-      REAL REFVAL, SCALE
-      INTEGER NPDATA, INSPT, NEXP, NMANT, NRETA, NRETB, NLENG, NBIT
-      INTEGER NVALS
-      INTEGER ISCALE, NSCALE, IBITS, ITEMP, NPBTMP2, IBITMAP, NUNUSED
-      DIMENSION IBITMAP(JPNSPEC)
-      INTEGER IRET, IEDITN
-      INTEGER NEXT, NEXTWV, NROW, NCOL, INDEX, ILOCATE
-      INTEGER MISSLAT, LOOP, NUMNEW
-      INTEGER KOLDNUM, KNEWNUM
-      DIMENSION  NUMNEW(JPMXLAT)
-      REAL RLATINC, OLDLATS, NEWLATS, ROWINC
-      REAL ONORTH, OSOUTH
-      DIMENSION OLDLATS(JPMXLAT), NEWLATS(JPMXLAT)
+      INTEGER IEOFSET, INDEX, ISTART, IWEST, IWOFSET, KNEWNUM,
+     X        KOLDNUM, LOOP, MISSLAT, NCOL, NEXT,
+     X        NEXTWV, NROW, NUMNEW(JPMXLAT)
+      REAL    AWEST, EAST, NEWLATS(JPMXLAT), OLDLATS(JPMXLAT),
+     X        ONORTH, OSOUTH, PTLAT, PTLONG, RLATINC, ROWINC,
+     X        SOUTH, OLDEAST, OLDWEST
+      INTEGER IRET
 C
 C     Large, resolution-dependent arrays
 C
@@ -139,8 +126,7 @@ C
       DATA    IS_ALLOCATED_LARGEARRAY /.FALSE./
       SAVE    IS_ALLOCATED_LARGEARRAY
 C
-      INTEGER NEWIDX
-      DIMENSION NEWIDX(JPARRAYDIM_WAVE)
+      INTEGER NEWIDX(JPARRAYDIM_WAVE)
 #ifndef _CRAYFTN
 #ifdef POINTER_64
       INTEGER*8 P_NEWIDX
@@ -159,9 +145,9 @@ C
 #endif
       EXTERNAL WV2DIDX, NUMVALS, NUMPTWE, JMALLOC
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   100 CONTINUE
 C
@@ -209,13 +195,13 @@ C     input field (this is a reduced latitude/longitude grid)
 C
       MISSLAT = (90.0 - ONORTH)/RLATINC
       KOLDNUM = 1 + (90.0 - OSOUTH)/RLATINC
-
+C
       IF( NIREPR.NE.JPREDLL ) THEN
         DO LOOP = 1, MISSLAT
           NPTS(LOOP)    = 0
         ENDDO
         DO LOOP = 1, (KOLDNUM-MISSLAT)
-            NPTS(LOOP+MISSLAT) = NIWE
+          NPTS(LOOP+MISSLAT) = NIWE
         ENDDO
         DO LOOP = (KOLDNUM+1), NUMLATS
           NPTS(LOOP)    = 0
@@ -228,10 +214,10 @@ C     Allocate large, resolution-dependent arrays
         IS_ALLOCATED_LARGEARRAY = .TRUE.
       END IF
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 2. Setup number of points at each latitude for the
 C                output latitude/longitude field.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   200 CONTINUE
 C
@@ -274,9 +260,9 @@ C
 C
       ENDIF
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 3. Get the input GRIB field characteristics.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   300 CONTINUE
 C
@@ -295,10 +281,9 @@ C
         GOTO 900
       ENDIF
 C
-C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 4. Work through the output subarea.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   400 CONTINUE
 C
@@ -331,8 +316,11 @@ C
           ROWINC = 360.0/NUMNEW(NROW)
 C
           IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) )
-     X      IWEST = IWEST + 1
+          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) ) THEN
+            IWEST = IWEST + 1
+          ELSEIF( (WEST.LT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) ) THEN
+            IWEST = IWEST - 1
+          ENDIF
           AWEST = IWEST * ROWINC
           IWOFSET = NUMPTWE(AWEST,0.0,ROWINC)
           IEOFSET = NUMPTWE(AWEST,EAST,ROWINC)
@@ -349,28 +337,29 @@ C
               NEXT = 1 + NEXT - IWOFSET
               IF( NEXT.LE.0) NEXT = NEXT + NUMNEW(NROW)
               NEXT = NEXT + ISTART
-              INDEX = NEWIDX(NEXT)
-
               NEXTWV = NEXTWV + 1
-
+C
+              INDEX = NEWIDX(NEXT)
               IF( OLDWAVE(INDEX).EQ.PMISS.OR.INDEX.EQ.0) THEN
 C
-C               Nearest neighbour is a 'missing' point
+C                 Nearest point is missing
 C
                   NEWWAVE(NEXTWV) = PMISS
+C
               ELSE
                   NEWWAVE(NEXTWV) = OLDWAVE(INDEX)
               ENDIF
-             ENDIF
+C
+            ENDIF
           ENDDO
 C
         ENDIF
         ISTART = ISTART + NUMNEW(NROW)
       ENDDO
 C
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
+C     -----------------------------------------------------------------|
 C
   900 CONTINUE
       RETURN
diff --git a/interpolation/wv2dxxx.F b/interpolation/wv2dxxx.F
deleted file mode 100644
index cae8486..0000000
--- a/interpolation/wv2dxxx.F
+++ /dev/null
@@ -1,496 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      INTEGER FUNCTION WV2DXXX(ISEC2,ISEC4,NLATS,STEPNS,STEPWE,
-     X                         OLDWAVE,NEWIDX,NEWWAVE,NORTH,WEST,PMISS)
-C
-C---->
-C*****WV2DXXX*
-C
-C     PURPOSE
-C     -------
-C
-C     Interpolates 2D wave spectra fields.
-C
-C
-C     INTERFACE
-C     ---------
-C
-C     IRET = WV2DXXX(ISEC2,ISEC4,NLATS,STEPNS,STEPWE,
-C    X               OLDWAVE,NEWIDX,NEWWAVE,NORTH,WEST,PMISS)
-C
-C     Input arguments
-C     ---------------
-C
-C     ISEC2   - Unpacked section 2 header from 2D wave spectra field
-C     ISEC4   - Unpacked section 4 header from 2D wave spectra field
-C     NLATS   - Number of points N-S in new grid
-C     STEPNS  - Output grid north-south resolution (degrees)
-C     STEPWE  - Output grid west-east resolution (degrees)
-C     OLDWAVE - Original wave field
-C     NORTH   - Output grid northernmost latitude (degrees)
-C     WEST    - Output grid westernmost longitude (degrees)
-C     PMISS   - Missing data value 
-C
-C     Output arguments
-C     ----------------
-C
-C     NEWIDX  - Indices of old grid points used for new grid points
-C     NEWWAVE - New wave field
-C
-C     Function returns 0 if the interpolation was OK.
-C
-C
-C     METHOD
-C     ------
-C
-C     Builds the index of nearest neighbour points for the output grid.
-C     Then works through the output grid points, checking for subarea
-C     boundaries and looking up nearset neighbour 2D spectra values
-C     (which may be missing data).
-C
-C
-C     EXTERNALS
-C     ---------
-C
-C     WV2DIDX - builds the index of nearest neighbour points
-C     NUMPTWE - Calculates number of grid points between west/east
-C               area boundaries
-C     VALPINA - Looks up bitmap value
-C     ONEBITS - Counts number of 1s in a GRIB section 3 bitmap
-C     NUMVALS - Counts the values in the secondary bitmap.
-C     SOFFSET - Finds the section offsets in GRIB message
-C     INTLOG  - Log error message
-C
-C
-C     REFERENCE
-C     ---------
-C
-C     None.
-C
-C
-C     Author.
-C     -------
-C
-C     J.D.Chambers      ECMWF    November 1996
-C
-C
-C     Modifications
-C     -------------
-C
-C     J.D.Chambers      ECMWF    April 1998
-C     Handle parameter 251 as a simple form of wave 2D spectra.
-C     (A field containing one direction and one frequency).
-C
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Subroutine arguments
-C
-      INTEGER ISEC2, ISEC4, NLATS
-      DIMENSION ISEC2(*), ISEC4(*)
-      REAL STEPNS, STEPWE, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
-      DIMENSION OLDWAVE(*), NEWWAVE(*)
-      INTEGER NEWIDX
-      DIMENSION NEWIDX(*)
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMXLAT, JPNSPEC
-      PARAMETER (JPROUTINE = 40000)
-      PARAMETER (JPMXLAT = 1801)
-      PARAMETER (JPNSPEC = 600)
-C
-C     Local arguments
-C
-      LOGICAL LSIMPLE
-      INTEGER IEOFSET, IWOFSET, ISTART, IWEST
-      REAL SOUTH, EAST, PTLAT, PTLONG, AWEST, OLDWEST, OLDEAST
-      REAL REFVAL, SCALE
-      INTEGER NPDATA, INSPT, NEXP, NMANT, NRETA, NRETB, NLENG, NBIT
-      INTEGER NVALS
-      INTEGER ISCALE, NSCALE, IBITS, ITEMP, NPBTMP2, IBITMAP, NUNUSED
-      DIMENSION IBITMAP(JPNSPEC)
-      INTEGER IRET, IS0, IS1, IS2, IS3, IS4, IEDITN
-      INTEGER NEXT, NEXTWV, NROW, NCOL, INDEX, ILOCATE
-      INTEGER NSPEC, MISSLAT, LOOP, NPTS, NUMLATS, NUMNEW
-      INTEGER KOLDNUM, KNEWNUM
-      DIMENSION NPTS(JPMXLAT), NUMNEW(JPMXLAT)
-      REAL RLATINC, OLDLATS, NEWLATS, ROWINC
-      DIMENSION OLDLATS(JPMXLAT), NEWLATS(JPMXLAT)
-C
-C     Externals
-C
-      INTEGER WV2DIDX, SOFFSET, VALPINA, NUMVALS, ONEBITS, NUMPTWE
-      EXTERNAL WV2DIDX, SOFFSET, VALPINA, NUMVALS, ONEBITS, NUMPTWE
-C
-#include "parim.h"
-#include "nifld.common"
-#include "nofld.common"
-#include "grspace.h"
-C
-C ---------------------------------------------------------------------
-C*    Section 1. Initalisation.
-C ---------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WV2DXXX = 0
-C
-C     Initialise the bitmap value lookup function and function
-C     which counts the values in the secondary bitmap.
-C
-      IRET = VALPINA(0,0,0)
-      IRET = NUMVALS(0,0,0)
-C
-C     Setup number of spectra at each point
-C
-      IF( ISEC4(8).EQ.0 ) THEN
-        LSIMPLE = .TRUE.
-        NSPEC   = 1
-      ELSE
-        LSIMPLE = .FALSE.
-        NSPEC   = ISEC4(50)*ISEC4(51)
-      ENDIF
-C
-      IF( NSPEC.GT.JPNSPEC) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Number of wave spectra at each grid pt = ',NSPEC)
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: And is greater than allowed maximum = ',JPNSPEC)
-        WV2DXXX = JPROUTINE + 1
-        GOTO 900
-      ENDIF
-C
-C     Calculate number of latitudes if grid had been full from
-C     North pole to South pole
-C
-      NUMLATS = (180000/ISEC2(10)) + 1
-      IF( NUMLATS.GT.JPMXLAT ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Number of latitudes in input grid = ',NUMLATS)
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: And is greater than allowed maximum = ',JPMXLAT)
-        WV2DXXX = JPROUTINE + 2
-        GOTO 900
-      ENDIF
-      RLATINC = FLOAT(ISEC2(10))/1000
-      DO LOOP = 1, NUMLATS
-        OLDLATS(LOOP) = 90.0 - (LOOP-1)*RLATINC
-      ENDDO
-C
-C     Fill an array with the number of points at each latitude for the
-C     input field (this is a reduced latitude/longitude grid)
-C
-      MISSLAT = (90000 - ISEC2(4))/ISEC2(10)
-      DO LOOP = 1, MISSLAT
-        NPTS(LOOP)    = 0
-      ENDDO
-      KOLDNUM = 1 + (90000 - ISEC2(7))/ISEC2(10)
-      DO LOOP = 1, (KOLDNUM-MISSLAT)
-        IF( NIREPR.EQ.JPREDLL ) THEN
-          NPTS(LOOP+MISSLAT) = ISEC2(22+LOOP)
-        ELSE
-          NPTS(LOOP+MISSLAT) = ISEC2(2)
-        ENDIF
-      ENDDO
-      DO LOOP = (KOLDNUM+1), NUMLATS
-        NPTS(LOOP)    = 0
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 2. Setup number of points at each latitude for the
-C                output latitude/longitude field.
-C ---------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      IF( (NOREPR.EQ.JPQUASI) .OR. (NOREPR.EQ.JPGAUSSIAN) ) THEN
-C
-C       Reduced (quasi-regular) gaussian output
-C
-        KNEWNUM = NOGAUSS*2
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROGAUSS(LOOP)
-        ENDDO
-C
-      ELSE IF( NOREPR.EQ.JPREDLL ) THEN
-C
-C       Reduced (quasi-regular) lat/long output
-C
-        KNEWNUM = NOREDLL
-        DO LOOP = 1, KNEWNUM
-          NUMNEW(LOOP)  = NOLPTS(LOOP)
-          NEWLATS(LOOP) = ROREDLL(LOOP)
-        ENDDO
-C
-      ELSE
-C
-C       Regular output
-C
-        MISSLAT = NINT((90.0 - NORTH)/STEPNS)
-        DO LOOP = 1, MISSLAT
-          NUMNEW(LOOP)    = 0
-        ENDDO
-        DO LOOP = 1, NLATS
-          NUMNEW(LOOP+MISSLAT) = NINT(360.0/STEPWE)
-        ENDDO
-C
-        KNEWNUM = MISSLAT + NLATS
-        DO LOOP = 1, KNEWNUM
-          NEWLATS(LOOP) = 90.0 - (LOOP-1)*STEPNS
-        ENDDO
-C
-      ENDIF
-C
-C ---------------------------------------------------------------------
-C*    Section 3. Get the input GRIB field characteristics.
-C ---------------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Calculate the indices of the input grid points to be used for
-C     the output points
-C
-      OLDWEST = FLOAT(ISEC2(5))/1000
-      OLDEAST = FLOAT(ISEC2(8))/1000
-      WV2DXXX = WV2DIDX(NUMLATS,NPTS,OLDLATS,OLDWEST,OLDEAST,
-     X                  KNEWNUM, NUMNEW, NEWLATS, NEWIDX)
-      IF( WV2DXXX.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Unable to calculate output grid indices',JPQUIET)
-        WV2DXXX = JPROUTINE + 3
-        GOTO 900
-      ENDIF
-C
-C     Find section offsets for the GRIB product
-C
-      IRET = SOFFSET(OLDWAVE, IS0, IS1, IS2, IS3, IS4, IEDITN)
-      IF( IRET.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Problem finding section offsets for GRIB',JPQUIET)
-        WV2DXXX = JPROUTINE + 4
-        GOTO 900
-      ENDIF
-C
-C     Get the overall length of OLDWAVE
-C
-#ifdef INTEGER_8
-      NBIT = 64
-#else
-      NBIT = 32
-#endif
-      INSPT = (IS0 + 4) * 8
-      CALL INXBIT(OLDWAVE,10,INSPT,NLENG,1,NBIT,24,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Problem extracting overall length of GRIB',JPQUIET)
-        WV2DXXX = JPROUTINE + 5
-        GOTO 900
-      ENDIF
-C
-C     Get the scale factor
-C
-      INSPT = (IS4 + 4) * 8
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NSCALE,1,NBIT,16,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Problem extracting scale factor in GRIB',JPQUIET)
-        WV2DXXX = JPROUTINE + 6
-        GOTO 900
-      ENDIF
-      CALL DSGNBT(ISCALE,NSCALE,16,NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Problem setting sign of scale factor',JPQUIET)
-        WV2DXXX = JPROUTINE + 7
-        GOTO 900
-      ENDIF
-      SCALE = 2.0**(FLOAT(ISCALE))
-C
-C     Get the reference value
-C
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NEXP,1,NBIT,8,'D',NRETA)
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,NMANT,1,NBIT,24,'D',NRETB)
-      IF( (NRETA.NE.0) .OR. (NRETB.NE.0) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Problem getting reference value from GRIB',JPQUIET)
-        WV2DXXX = JPROUTINE + 8
-        GOTO 900
-      ENDIF
-      CALL DECFP2(REFVAL,NEXP,NMANT)
-C
-C     Get number of bits per packed value
-C
-      CALL INXBIT(OLDWAVE,NLENG,INSPT,IBITS,1,NBIT,8,'D',NRETA)
-      IF( NRETA.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'WV2DXXX: Problem getting number of bits per word',JPQUIET)
-        WV2DXXX = JPROUTINE + 9
-        GOTO 900
-      ENDIF
-C
-C     (Pointer INSPT is currently at octet 12 in GRIB section 4)
-C
-C     Set up pointers to start of secondary bitmap and start of packed
-C     data values
-C
-#ifdef INTEGER_8
-      NBIT = 64
-#else
-      NBIT = 32
-#endif
-      NPBTMP2 = (IS4 + 24)*8 + (ISEC4(53)+ISEC4(55))*32
-C
-      IF( .NOT. LSIMPLE ) THEN
-        NPDATA  = NPBTMP2 + NSPEC*ONEBITS(OLDWAVE,IS3)
-      ELSE
-        NPDATA  = NPBTMP2
-      ENDIF
-      NPDATA  = ((NPDATA + 7)/8)*8
-C
-C ---------------------------------------------------------------------
-C*    Section 4. Work through the output subarea.
-C ---------------------------------------------------------------------
-C
-  400 CONTINUE
-C
-C     Fill in the wave spectra values
-C
-      NEXT = 0
-      NEXTWV = 0
-C
-      SOUTH = NOAREA(3)/PPMULT
-      EAST  = NOAREA(4)/PPMULT
-      ISTART = 0
-C
-C     Work down through latitudes from north to south.
-C
-      DO NROW = 1, KNEWNUM
-C
-C       If inside north-south (subarea) boundaries ..
-C
-        IF( (NOREPR.EQ.JPGAUSSIAN).OR.(NOREPR.EQ.JPQUASI) ) THEN
-          PTLAT = ROGAUSS(NROW)
-        ELSE
-          PTLAT = 90.0 - (NROW-1)*STEPNS
-        ENDIF
-C
-        IF( (PTLAT.LE.NORTH).AND.(ABS(PTLAT-SOUTH).GT.-0.0005) ) THEN
-C
-C         Calculate number of points between west boundary of area and
-C         Greenwich
-C
-          ROWINC = 360.0/NUMNEW(NROW)
-C
-          IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) )
-     X      IWEST = IWEST + 1
-          AWEST = IWEST * ROWINC
-          IWOFSET = NUMPTWE(AWEST,0.0,ROWINC)
-          IEOFSET = NUMPTWE(AWEST,EAST,ROWINC)
-C
-C         Work through subarea longitudes from west to east.
-C
-          DO NCOL = 1, NUMNEW(NROW)
-            PTLONG = AWEST + (NCOL-1)*ROWINC
-            NEXT = NUMPTWE(AWEST,PTLONG,ROWINC)
-            IF( (NEXT.LE.IEOFSET).AND.(NEXT.GE.0) ) THEN
-C
-C             .. and inside west-east (subarea) boundaries
-C
-              NEXT = 1 + NEXT - IWOFSET
-              IF( NEXT.LE.0) NEXT = NEXT + NUMNEW(NROW)
-              NEXT = NEXT + ISTART
-              INDEX = NEWIDX(NEXT)
-              ILOCATE = VALPINA(OLDWAVE, IS3+6, INDEX)
-C
-              IF( ILOCATE.EQ.0 ) THEN
-C
-C               Nearest neighbour is a 'missing' point
-C
-                DO LOOP = 1, NSPEC
-                  NEXTWV = NEXTWV + 1
-                  NEWWAVE(NEXTWV) = PMISS
-                ENDDO
-C
-              ELSE
-C
-C               Nearest neighbour has values
-C
-                IF( LSIMPLE ) THEN
-                  INSPT = NPDATA + (ILOCATE - 1)*IBITS
-                  NVALS = 1
-                  IBITMAP(1) = 1
-                ELSE
-C
-C                 Count the number of values in the secondary bitmap upto
-C                 the current point and pick up its secondary bitmap.
-C
-                  INSPT = NPBTMP2 + (ILOCATE - 1)*NSPEC
-                  NVALS = NUMVALS(OLDWAVE,NPBTMP2,INSPT)
-                  CALL INXBIT(OLDWAVE,NLENG,INSPT,IBITMAP,NSPEC,
-     X                        NBIT,1,'D',NRETA)
-                  IF( NRETA.NE.0 ) THEN
-                    CALL INTLOG(JP_ERROR,
-     X              'WV2DXXX: Problem getting neighbours 2ndary bitmap',
-     X              JPQUIET)
-                    WV2DXXX = JPROUTINE + 10
-                    GOTO 900
-                  ENDIF
-C
-C                 Pick up the values at the current point
-C
-                  INSPT = NPDATA + NVALS*IBITS
-                ENDIF
-C
-                DO LOOP = 1, NSPEC
-                  NEXTWV = NEXTWV + 1
-                  IF( IBITMAP(LOOP).EQ.0 ) THEN
-C
-C                   ..missing
-C
-                    NEWWAVE(NEXTWV) = PMISS
-C
-                  ELSE
-C
-C                   ..retrieve and recreate the packed value
-C
-                    CALL INXBIT(OLDWAVE,NLENG,INSPT,ITEMP,1,
-     X                          NBIT,IBITS,'D',NRETA)
-                    IF( NRETA.NE.0 ) THEN
-                      CALL INTLOG(JP_ERROR,
-     X                'WV2DXXX: Problem getting nearest neighbour',
-     X                JPQUIET)
-                      WV2DXXX = JPROUTINE + 11
-                      GOTO 900
-                    ENDIF
-                    NEWWAVE(NEXTWV) = REFVAL + FLOAT(ITEMP)*SCALE
-                  ENDIF
-                ENDDO
-C
-              ENDIF
-            ENDIF
-          ENDDO
-C
-        ENDIF
-        ISTART = ISTART + NUMNEW(NROW)
-      ENDDO
-C
-C ---------------------------------------------------------------------
-C*    Section 9. Closedown.
-C ---------------------------------------------------------------------
-C
-  900 CONTINUE
-      RETURN
-      END
diff --git a/interpolation/wvqlidx.F b/interpolation/wvqlidx.F
index d22e167..7d22de0 100644
--- a/interpolation/wvqlidx.F
+++ b/interpolation/wvqlidx.F
@@ -1,10 +1,10 @@
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -94,12 +94,9 @@ C     Parameters
 C
       INTEGER JPROUTINE
       PARAMETER ( JPROUTINE = 19410 )
-      INTEGER JPLLMAX
-      PARAMETER ( JPLLMAX = 1801 )
-C                             `--> allow upto 0.1 degree resolution
-      INTEGER JPNMOUT
-      PARAMETER ( JPNMOUT = 1800 )
-C                             `--> allow upto 0.1 degree resolution
+      INTEGER JPLLMAX, JPNMOUT
+      PARAMETER ( JPLLMAX = 1801 ) ! allow up to 0.1 degree resolution
+      PARAMETER ( JPNMOUT = 1800 ) ! allow up to 0.1 degree resolution
 C
       INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
       INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
@@ -127,12 +124,11 @@ C
 C
 C     Local arguments
 C
-      INTEGER K, NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
+      INTEGER NEWCOL, NEWROW, INCOL, LOOP, NEXT, NUMMAX
       INTEGER I_NW, I_SW, I_N, I_S, I_NE, I_SE
-      REAL*8 DELONGN, DELONGS, DIFF, RESOL, DINC, DEPS
+      REAL*8 DELONGN, DELONGS, DIFF, RESOL, DEPS
       REAL*8 DIST_NW, DIST_SW, DIST_NE, DIST_SE, DIST_N, DIST_S
-      REAL*8 DISNW, DISNE, DISSW, DISSE
-      REAL*8 ZXIN, ZXIS, LON, LAT, OWEST, OEAST
+      REAL*8 ZXIN, ZXIS, LON, OWEST, OEAST
       DIMENSION LON(JPNMOUT*2)
       LOGICAL LINGNS, LINGWE
       INTEGER INDEXI
@@ -249,20 +245,21 @@ C
             ENDIF
             LINGNS  = .TRUE.
           ENDIF
+C
         ENDIF
 C
 C       Setup longitudes for the current row
 C
         INCOL = NUMNEW(NEWROW)
         IF( INCOL.NE.0 ) THEN
-            IF( LGLOBAL ) THEN
-             RESOL = 360.0/DBLE(INCOL)
-            ELSE
-             RESOL = (OEAST-OWEST)/(DBLE(INCOL)-1)
-            ENDIF
-             DO LOOP = 1, INCOL
-               LON(LOOP) = OLDWEST + DBLE(LOOP-1)*RESOL
-             ENDDO
+          IF( LGLOBAL ) THEN
+           RESOL = 360.0/DBLE(INCOL)
+          ELSE
+           RESOL = (OEAST-OWEST)/(DBLE(INCOL)-1)
+          ENDIF
+          DO LOOP = 1, INCOL
+            LON(LOOP) = OLDWEST + DBLE(LOOP-1)*RESOL
+          ENDDO
 C
           DO 210 NEWCOL = 1, INCOL
 C
@@ -294,7 +291,7 @@ C
               IF( I_NE.EQ.0 ) I_NE = NUMOLD(I_N)
               IF( I_SE.EQ.0 ) I_SE = NUMOLD(I_S)
 C
-C             Calculate distance from interpolated point to neighbours
+C             Calculate distance from interpolated point to its neighbours
 C
               DIST_NW = ZXIN - REAL(I_NW)
               DIST_NE = 1.0 - DIST_NW
@@ -322,11 +319,6 @@ C           If the point to be interpolated is outside the input field,
 C           set it to 'land'.
 C
             ELSE
-cs             print*,'IDX LINGWE ',LINGWE
-cs              print*,'IDX ',LON(NEWCOL),OWEST
-cs			  print*,'IDX ',LON(NEWCOL),OEAST
-cs             print*,'IDX LINGNS ',LINGNS
-cs             print*,'IDX ',NUMOLD(I_N),NUMOLD(I_S)
 C
               DISTNEW(JPNW,NEXT) = 0
               DISTNEW(JPNE,NEXT) = 0
diff --git a/interpolation/wvqlin2.F b/interpolation/wvqlin2.F
index 640c5cc..a9a5e28 100644
--- a/interpolation/wvqlin2.F
+++ b/interpolation/wvqlin2.F
@@ -1,10 +1,11 @@
+C
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -43,11 +44,10 @@ C     NORTH   - Input and output grid northernmost latitude (degree)
 C     WEST    - Input and output grid westernmost  longitude (degree)
 C     KPARAM  - Field parameter code
 C     PMISS   - Missing value indicator
-C     RNS     - Difference in degrees in NS disrection
 C
 C     Output arguments
 C     ----------------
-
+C
 C     NEWWAVE - New wave field
 C
 C     Function returns 0 if the interpolation was OK.
@@ -84,7 +84,7 @@ C         SUBROUTINE INTERPOLATE
 C         Peter Janssen     ECMWF    September 1995
 C     and:
 C         SUBROUTINE EXPOINT
-C         Heinz Gunther     ECMWF    December  1989 
+C         Heinz Gunther     ECMWF    December  1989
 C
 C
 C     Author.
@@ -102,73 +102,52 @@ C     output grid resolution.
 C
 C----<
 C
-C     -----------------------------------------------------------------|
-C*    Section 0. Arguments and variable
-C     -----------------------------------------------------------------|
-C
-C
       IMPLICIT NONE
 C
 #include "parim.h"
 C
 C     Parameters
 C
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 19400 )
-      INTEGER JPLLMAX
-      PARAMETER ( JPLLMAX = 1801 )
-C                             `--> allow upto 0.1 degree resolution
-      INTEGER JPNMOUT
-      PARAMETER ( JPNMOUT = 1800 )
-C                             `--> allow upto 0.1 degree resolution
-C
-      INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
-      INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
-      PARAMETER (JPNW = 1)
-      PARAMETER (JPNE = 2)
-      PARAMETER (JPSW = 3)
-      PARAMETER (JPSE = 4)
-      PARAMETER (JPN  = 5)
-      PARAMETER (JPS  = 6)
-      PARAMETER (JPDISNW = 7)
-      PARAMETER (JPDISNE = 8)
-      PARAMETER (JPDISSW = 9)
-      PARAMETER (JPDISSE = 10)
-C
-C     Subroutine arguments
-C
-      INTEGER KNUM, NUMPTS, KE_W, KN_S, KPARAM
-      DIMENSION NUMPTS(*)
+      INTEGER JPROUTINE, JPLLMAX, JPNMOUT,
+     X        JPNW, JPNE, JPSW, JPSE, JPN, JPS,
+     X        JPDISNW, JPDISNE, JPDISSW, JPDISSE
+      PARAMETER( JPROUTINE = 19400 )
+      PARAMETER( JPLLMAX   =  1801 ) ! allow up to 0.1 degree resolution
+      PARAMETER( JPNMOUT   =  1800 ) ! allow up to 0.1 degree resolution
+      PARAMETER( JPNW=1, JPNE=2, JPSW=3, JPSE=4, JPN=5, JPS=6,
+     X           JPDISNW=7, JPDISNE=8, JPDISSW=9, JPDISSE=10 )
+C
+C     Arguments
+C
+      INTEGER KNUM, NUMPTS(*), KE_W, KN_S, KPARAM
       REAL RESON, NORTH, WEST, PMISS
-      REAL RNS
-      REAL OLDWAVE, NEWWAVE
-      DIMENSION OLDWAVE(*),  NEWWAVE(*)
+      REAL RNS !FIXME: Unused! Difference in degrees in NS disrection
+      REAL OLDWAVE(*), NEWWAVE(*)
 C
-C     Local arguments
+C     Local variables
 C
       INTEGER NLAT, K, I, NEWROW, NEWCOL, I1N, I1S, I_N, I_S, I2N, I2S
       REAL*4 DELONGN, DELONGS, DELAT, DI1N, DI1S, DI2N, DI2S
       REAL*4 DIST_N, DIST_S
       REAL*4 DISNW, DISNE, DISSW, DISSE
       REAL*4 U1, U2, ZXIN, ZXIS
-      REAL LON, LAT
-      DIMENSION LON(JPNMOUT*2),LAT(JPNMOUT+1)
+      REAL LON(JPNMOUT*2), LAT(JPNMOUT+1)
       LOGICAL INGRID, LDIREC
       INTEGER NW_PT, NE_PT, SW_PT, SE_PT
       REAL*4 NWVALUE, NEVALUE, SWVALUE, SEVALUE
       REAL*4 RAD
-      DATA RAD/0.017453293/
       REAL*4 CNW_PT, CNE_PT, CSW_PT, CSE_PT
       REAL*4 SNW_PT, SNE_PT, SSW_PT, SSE_PT
       REAL*4 C1, C2, S1, S2, CC, SS
 C
+      DATA RAD/0.017453293/
+C
       REAL OLDLATS(JPLLMAX), OLDEAST
       REAL OLDNS
       INTEGER ISTART, IEND
       INTEGER LOCATE
       INTEGER NEXT, NUMNEW(JPLLMAX)
-      INTEGER IRET, WVQLID2
-      EXTERNAL WVQLID2
+      INTEGER IRET
       INTEGER XKNUM,XKE_W,XKN_S
       DATA XKNUM/-1/,XKE_W/-1/,XKN_S/-1/
       REAL XRESON,XNORTH,XWEST
@@ -190,7 +169,12 @@ C     EPS      Tolerance on missing data flag
       LOGICAL LSW,LSE,LNE,LNW,LTEMP
 C
       SAVE IFIRST,XKNUM,XKE_W,XKN_S,XRESON,XNORTH,XWEST,NEWIDX,DISTNEW
-
+C
+C     Externals
+C
+      INTEGER WVQLID2
+      LOGICAL IS_WAVE_DIRECTION
+      EXTERNAL WVQLID2, IS_WAVE_DIRECTION
 C
 C     -----------------------------------------------------------------|
 C*    Section 1. Initalisation.
@@ -285,14 +269,8 @@ C
       ENDDO
 C
 C     Wave direction parameters need special handling
-C     (MWD, MDWW, MDPS, MDWI)
+      LDIREC = IS_WAVE_DIRECTION(KPARAM)
 C
-      LDIREC = ( (KPARAM.EQ.230) .OR.
-     X           (KPARAM.EQ.235) .OR.
-     X           (KPARAM.EQ.238) .OR.
-     X           (KPARAM.EQ.242) )
-C
-cs	  print*,KNUM,KE_W,KN_S,RESON,NORTH,WEST,KPARAM,PMISS,RNS
 C     -----------------------------------------------------------------|
 C*    Section 2. Interpolation.
 C     -----------------------------------------------------------------|
@@ -309,8 +287,6 @@ C
      X    ( NORTH.NE.XNORTH ).OR.
      X    ( WEST.NE.XWEST ) ) THEN
 C
-c        print*,'DISS KNUM ', KNUM,' WEST ',WEST, 'KN_S ',KN_S
-c        print*,'DISS OLDEAST ', OLDEAST
         IRET =  WVQLID2(KNUM,NUMPTS,OLDLATS,WEST,OLDEAST,
      X                  KN_S,NUMNEW,LAT,NEWIDX,DISTNEW)
         IFIRST = 1
@@ -338,13 +314,12 @@ C
 C       Check if the new interpolated row lies between 2 old rows which
 C       have data points
 C
-
         IF( (NUMPTS(I_N).GT.0).AND.(NUMPTS(I_S).GT.0) ) THEN
 C
 C         Yes, use the calculated indices
 C
           DO 210 NEWCOL = 1, KE_W
-
+C
             NEXT = NEXT + 1
 C
             NW_PT = NEWIDX(JPNW,NEXT)
@@ -397,15 +372,15 @@ cs                NEWWAVE(NEXT) = SWVALUE
                 LOCATE = SW_PT
                 LTEMP  = LSW
 C
-              ELSE 
+              ELSE
 cs                NEWWAVE(NEXT) = SEVALUE
                 LOCATE = SE_PT
                 LTEMP  = LSE
 C
               ENDIF
 
-              IF( .NOT.LTEMP.AND.LOCATE.NE.0) THEN 
-c              IF( LOCATE.NE.0) THEN 
+              IF( .NOT.LTEMP.AND.LOCATE.NE.0) THEN
+c              IF( LOCATE.NE.0) THEN
                   NEWWAVE(NEXT) = OLDWAVE(LOCATE)
               ENDIF
 
diff --git a/interpolation/wvqlint.F b/interpolation/wvqlint.F
index b774866..8aee1d9 100644
--- a/interpolation/wvqlint.F
+++ b/interpolation/wvqlint.F
@@ -1,10 +1,11 @@
+C
 C Copyright 1981-2012 ECMWF.
 C
-C This software is licensed under the terms of the Apache Licence 
+C This software is licensed under the terms of the Apache Licence
 C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
 C nor does it submit to any jurisdiction.
 C
 
@@ -25,7 +26,7 @@ C     INTERFACE
 C     ---------
 C
 C     IRET = WVQLINT(KNUM,NUMPTS,KE_W,KN_S,RESON,OLDWAVE,
-C    X               NEWWAVE,NORTH,WEST,KPARAM,PMISS)
+C    X               NEWWAVE,NORTH,WEST,KPARAM,PMISS,RNS)
 C
 C     Input arguments
 C     ---------------
@@ -47,7 +48,7 @@ C     RNS     - Difference in degrees in NS disrection
 C
 C     Output arguments
 C     ----------------
-
+C
 C     NEWWAVE - New wave field
 C
 C     Function returns 0 if the interpolation was OK.
@@ -84,7 +85,7 @@ C         SUBROUTINE INTERPOLATE
 C         Peter Janssen     ECMWF    September 1995
 C     and:
 C         SUBROUTINE EXPOINT
-C         Heinz Gunther     ECMWF    December  1989 
+C         Heinz Gunther     ECMWF    December  1989
 C
 C
 C     Author.
@@ -102,72 +103,50 @@ C     output grid resolution.
 C
 C----<
 C
-C     -----------------------------------------------------------------|
-C*    Section 0. Arguments and variable
-C     -----------------------------------------------------------------|
-C
-C
       IMPLICIT NONE
 C
 #include "parim.h"
 C
 C     Parameters
 C
-      INTEGER JPROUTINE
-      PARAMETER ( JPROUTINE = 19400 )
-      INTEGER JPLLMAX
-      PARAMETER ( JPLLMAX = 1801 )
-C                             `--> allow upto 0.1 degree resolution
-      INTEGER JPNMOUT
-      PARAMETER ( JPNMOUT = 1800 )
-C                             `--> allow upto 0.1 degree resolution
-C
-      INTEGER JPNW, JPNE, JPSW, JPSE, JPN, JPS
-      INTEGER JPDISNW, JPDISNE, JPDISSW, JPDISSE
-      PARAMETER (JPNW = 1)
-      PARAMETER (JPNE = 2)
-      PARAMETER (JPSW = 3)
-      PARAMETER (JPSE = 4)
-      PARAMETER (JPN  = 5)
-      PARAMETER (JPS  = 6)
-      PARAMETER (JPDISNW = 7)
-      PARAMETER (JPDISNE = 8)
-      PARAMETER (JPDISSW = 9)
-      PARAMETER (JPDISSE = 10)
-C
-C     Subroutine arguments
-C
-      INTEGER KNUM, NUMPTS, KE_W, KN_S, KPARAM
-      DIMENSION NUMPTS(*)
-      REAL RESON, OLDWAVE, NEWWAVE, NORTH, WEST, PMISS
+      INTEGER JPROUTINE, JPLLMAX, JPNMOUT,
+     X        JPNW, JPNE, JPSW, JPSE, JPN, JPS,
+     X        JPDISNW, JPDISNE, JPDISSW, JPDISSE
+      PARAMETER( JPROUTINE = 19400 )
+      PARAMETER( JPLLMAX   =  1801 ) ! allow up to 0.1 degree resolution
+      PARAMETER( JPNMOUT   =  1800 ) ! allow up to 0.1 degree resolution
+      PARAMETER( JPNW=1, JPNE=2, JPSW=3, JPSE=4, JPN=5, JPS=6,
+     X           JPDISNW=7, JPDISNE=8, JPDISSW=9, JPDISSE=10 )
+C
+C     Arguments
+C
+      INTEGER KNUM, NUMPTS(*), KE_W, KN_S, KPARAM
+      REAL RESON, OLDWAVE(*), NEWWAVE(KE_W,KN_S), NORTH, WEST, PMISS
       REAL RNS
-      DIMENSION OLDWAVE(*)
-      DIMENSION NEWWAVE(KE_W,KN_S)
 C
-C     Local arguments
+C     Local variables
 C
-      INTEGER NLAT, K, I, NEWROW, NEWCOL, I1N, I1S, I_N, I_S, I2N, I2S
-      REAL*4 DELONGN, DELONGS, DELAT, DI1N, DI1S, DI2N, DI2S
+      INTEGER NLAT, K, I, NEWROW, NEWCOL, I_N, I_S
+      REAL*4 DELAT, DI1N, DI1S, DI2N, DI2S
       REAL*4 DIST_N, DIST_S
       REAL*4 DISNW, DISNE, DISSW, DISSE
-      REAL*4 U1, U2, ZXIN, ZXIS
-      REAL LON, LAT
-      DIMENSION LON(JPNMOUT*2),LAT(JPNMOUT+1)
-      LOGICAL INGRID, LDIREC
+      REAL*4 U1, U2
+      REAL LON(JPNMOUT*2), LAT(JPNMOUT+1)
+      LOGICAL LDIREC
       INTEGER NW_PT, NE_PT, SW_PT, SE_PT
       REAL*4 NWVALUE, NEVALUE, SWVALUE, SEVALUE
       REAL*4 RAD
-      DATA RAD/0.017453293/
       REAL*4 CNW_PT, CNE_PT, CSW_PT, CSE_PT
       REAL*4 SNW_PT, SNE_PT, SSW_PT, SSE_PT
       REAL*4 C1, C2, S1, S2, CC, SS
 C
+      DATA RAD/0.017453293/
+C
       REAL OLDLATS(JPLLMAX), OLDEAST
       REAL OLDNS
       INTEGER ISTART, IEND
       INTEGER NEXT, NUMNEW(JPLLMAX)
-      INTEGER IRET, WVQLIDX
-      EXTERNAL WVQLIDX
+      INTEGER IRET
       INTEGER XKNUM,XKE_W,XKN_S
       DATA XKNUM/-1/,XKE_W/-1/,XKN_S/-1/
       REAL XRESON,XNORTH,XWEST
@@ -184,6 +163,12 @@ C
 C
       SAVE IFIRST,XKNUM,XKE_W,XKN_S,XRESON,XNORTH,XWEST,NEWIDX,DISTNEW
 C
+C     Externals
+C
+      INTEGER WVQLIDX
+      LOGICAL IS_WAVE_DIRECTION
+      EXTERNAL WVQLIDX, IS_WAVE_DIRECTION
+C
 C     -----------------------------------------------------------------|
 C*    Section 1. Initalisation.
 C     -----------------------------------------------------------------|
@@ -275,12 +260,7 @@ C
       ENDDO
 C
 C     Wave direction parameters need special handling
-C     (MWD, MDWW, MDPS, MDWI)
-C
-      LDIREC = ( (KPARAM.EQ.230) .OR.
-     X           (KPARAM.EQ.235) .OR.
-     X           (KPARAM.EQ.238) .OR.
-     X           (KPARAM.EQ.242) )
+      LDIREC = IS_WAVE_DIRECTION(KPARAM)
 C
 C     -----------------------------------------------------------------|
 C*    Section 2. Interpolation.
diff --git a/interpolation/xrotate.F b/interpolation/xrotate.F
deleted file mode 100644
index c75395b..0000000
--- a/interpolation/xrotate.F
+++ /dev/null
@@ -1,84 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE XROTATE(RANGLE,X,Y,Z,RX,RY,RZ,INROW)
-C---->
-C**** XROTATE
-C
-C     Purpose
-C     -------
-C
-C     Rotate an array of (x,y,z) values about the x-axis.
-C
-C
-C     Interface
-C     ---------
-C
-C     CALL XROTATE(RANGLE,X,Y,Z,RX,RY,RZ,INROW)
-C
-C     Input
-C     -----
-C
-C     RANGLE  - The angle of rotation (degrees)
-C     (X,Y,Z) - Arrays of input (x,y,z) values.
-C     INROW   - Number of coordinate values.
-C
-C
-C     Output
-C     ------
-C
-C     (RX,RY,RZ) - Arrays of rotated (x,y,z) values.
-C
-C
-C     Method
-C     ------
-C
-C     X remains unchanged.
-C
-C
-C     Externals
-C     ---------
-C
-C     None.
-C
-C
-C     Author
-C     ------
-C
-C     J.D.Chambers     ECMWF
-C
-C----<
-C
-      IMPLICIT NONE
-C
-C     Subroutine arguments
-C
-      REAL RANGLE,X,Y,Z,RX,RY,RZ
-      DIMENSION X(*),Y(*),Z(*),RX(*),RY(*),RZ(*)
-      INTEGER INROW
-C
-C     Local variables
-C
-      REAL FACTOR, ANGLE, SINA, COSA
-      DATA FACTOR/0.017453293/
-      INTEGER LOOP
-C
-      ANGLE = RANGLE * FACTOR
-      SINA  = SIN(ANGLE)
-      COSA  = COS(ANGLE)
-C
-      DO LOOP = 1, INROW
-        RX(LOOP) = X(LOOP)
-        RY(LOOP) =  Y(LOOP)*COSA + Z(LOOP)*SINA
-        RZ(LOOP) = -Y(LOOP)*SINA + Z(LOOP)*COSA
-      ENDDO
-C
-      RETURN
-      END
diff --git a/land_sea_mask/0-INDEX-0 b/land_sea_mask/0-INDEX-0
deleted file mode 100644
index c1586a8..0000000
--- a/land_sea_mask/0-INDEX-0
+++ /dev/null
@@ -1,30 +0,0 @@
-0-INDEX-0			    
-defaults_for_table_001	  WMO table parameter interpolation options
-defaults_for_table_128	  ECMWF table parameter interpolation options
-lsm_32_lsm0p5deg		  32 bit land-sea mask 0.5 degree resolution
-lsm_32_lsm10m01			  32 bit land-sea mask 10 minute resolution
-lsm_32_lsmn080			  32 bit land-sea mask gaussian N80
-lsm_32_lsmr160*			  32 bit land-sea mask gaussian N160
-lsm_64_lsm0p5deg		  64 bit land-sea mask 0.5 degree resolution
-lsm_64_lsm10m01			  64 bit land-sea mask 10 minute resolution
-lsm_64_lsmn080			  64 bit land-sea mask gaussian N80
-lsm_64_lsmr160			  64 bit land-sea mask gaussian N160
-parameter_processing_defaults	  Not currently used (see rddefs.c)
-r160_32_19790930		  32 bit land-sea mask for N160 from 19790930
-r160_32_19910917		  32 bit land-sea mask for N160 from 19910917
-r160_32_19930804		  32 bit land-sea mask for N160 from 19930804
-r160_32_19940302		  32 bit land-sea mask for N160 from 19940302
-r160_32_19940823		  32 bit land-sea mask for N160 from 19940823
-r160_32_19950404		  32 bit land-sea mask for N160 from 19950404
-r160_64_19790930		  64 bit land-sea mask for N160 from 19790930
-r160_64_19910917		  64 bit land-sea mask for N160 from 19910917
-r160_64_19930804		  64 bit land-sea mask for N160 from 19930804
-r160_64_19940302		  64 bit land-sea mask for N160 from 19940302
-r160_64_19940823		  64 bit land-sea mask for N160 from 19940823
-r160_64_19950404		  64 bit land-sea mask for N160 from 19950404
-LSM_GG_0048			      land-sea mask reduced gaussian N48
-LSM_GG_0080			      land-sea mask reduced gaussian N80
-LSM_GG_0128			      land-sea mask reduced gaussian N128
-LSM_GG_0160			      land-sea mask reduced gaussian N160
-LSM_GG_0256			      land-sea mask reduced gaussian N256
-LSM_GG_0400			      land-sea mask reduced gaussian N400
diff --git a/land_sea_mask/LSM_GG_0048 b/land_sea_mask/LSM_GG_0048
deleted file mode 100644
index 6c9560e..0000000
Binary files a/land_sea_mask/LSM_GG_0048 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0080 b/land_sea_mask/LSM_GG_0080
deleted file mode 100644
index 4a84fb0..0000000
Binary files a/land_sea_mask/LSM_GG_0080 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0128 b/land_sea_mask/LSM_GG_0128
deleted file mode 100644
index ae60fcb..0000000
Binary files a/land_sea_mask/LSM_GG_0128 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0160 b/land_sea_mask/LSM_GG_0160
deleted file mode 100644
index 2b773a1..0000000
Binary files a/land_sea_mask/LSM_GG_0160 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0200 b/land_sea_mask/LSM_GG_0200
deleted file mode 100644
index 733bb99..0000000
Binary files a/land_sea_mask/LSM_GG_0200 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0256 b/land_sea_mask/LSM_GG_0256
deleted file mode 100644
index 21db783..0000000
Binary files a/land_sea_mask/LSM_GG_0256 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0400 b/land_sea_mask/LSM_GG_0400
deleted file mode 100644
index 877aa1f..0000000
Binary files a/land_sea_mask/LSM_GG_0400 and /dev/null differ
diff --git a/land_sea_mask/LSM_GG_0640 b/land_sea_mask/LSM_GG_0640
deleted file mode 100644
index 3b52b69..0000000
Binary files a/land_sea_mask/LSM_GG_0640 and /dev/null differ
diff --git a/land_sea_mask/defaults_for_table_001 b/land_sea_mask/defaults_for_table_001
deleted file mode 100644
index fba24df..0000000
--- a/land_sea_mask/defaults_for_table_001
+++ /dev/null
@@ -1,11 +0,0 @@
-Param  lsm  wind  prec  lsm interp
------  ---  ----  ----  ----------
-002     n     n     n     n       # MSL
-033     y     y     n     n       # U
-034     y     y     n     n       # V
-061     y     n     y     n       # TP
-062     y     n     y     n       # LSP
-063     y     n     y     n       # CP
-064     y     n     y     n       # SF
-065     y     n     y     n       # WESF
-081     n     n     n     y       # LSM
diff --git a/land_sea_mask/defaults_for_table_128 b/land_sea_mask/defaults_for_table_128
deleted file mode 100644
index 76dd6d0..0000000
--- a/land_sea_mask/defaults_for_table_128
+++ /dev/null
@@ -1,14 +0,0 @@
-Param  lsm  wind  prec  lsm interp
------  ---  ----  ----  ----------
-131     y     y     n     n       # U
-132     y     y     n     n       # V
-142     y     n     y     n       # LSP
-143     y     n     y     n       # CP
-144     y     n     y     n       # SF
-151     n     n     n     n       # MSL
-165     y     y     n     n       # 10U
-166     y     y     n     n       # 10V
-172     n     n     n     y       # LSM
-228     y     n     y     n       # TTP
-239     y     n     y     n       # CSF
-240     y     n     y     n       # LSF
diff --git a/land_sea_mask/defaults_for_table_129 b/land_sea_mask/defaults_for_table_129
deleted file mode 100644
index 76dd6d0..0000000
--- a/land_sea_mask/defaults_for_table_129
+++ /dev/null
@@ -1,14 +0,0 @@
-Param  lsm  wind  prec  lsm interp
------  ---  ----  ----  ----------
-131     y     y     n     n       # U
-132     y     y     n     n       # V
-142     y     n     y     n       # LSP
-143     y     n     y     n       # CP
-144     y     n     y     n       # SF
-151     n     n     n     n       # MSL
-165     y     y     n     n       # 10U
-166     y     y     n     n       # 10V
-172     n     n     n     y       # LSM
-228     y     n     y     n       # TTP
-239     y     n     y     n       # CSF
-240     y     n     y     n       # LSF
diff --git a/land_sea_mask/ksm_xx_lsm0p5deg b/land_sea_mask/ksm_xx_lsm0p5deg
deleted file mode 100644
index 38e3019..0000000
Binary files a/land_sea_mask/ksm_xx_lsm0p5deg and /dev/null differ
diff --git a/land_sea_mask/lsm_xx_lsm0p25deg b/land_sea_mask/lsm_xx_lsm0p25deg
deleted file mode 100644
index 432b5fc..0000000
Binary files a/land_sea_mask/lsm_xx_lsm0p25deg and /dev/null differ
diff --git a/land_sea_mask/lsm_xx_lsm0p5deg b/land_sea_mask/lsm_xx_lsm0p5deg
deleted file mode 100644
index d846bcf..0000000
Binary files a/land_sea_mask/lsm_xx_lsm0p5deg and /dev/null differ
diff --git a/land_sea_mask/lsm_xx_lsm10m01 b/land_sea_mask/lsm_xx_lsm10m01
deleted file mode 100644
index 295c080..0000000
Binary files a/land_sea_mask/lsm_xx_lsm10m01 and /dev/null differ
diff --git a/land_sea_mask/lsm_xx_lsmn080 b/land_sea_mask/lsm_xx_lsmn080
deleted file mode 100644
index d1eebf3..0000000
Binary files a/land_sea_mask/lsm_xx_lsmn080 and /dev/null differ
diff --git a/land_sea_mask/lsm_xx_lsmr160 b/land_sea_mask/lsm_xx_lsmr160
deleted file mode 100644
index 116c1a4..0000000
Binary files a/land_sea_mask/lsm_xx_lsmr160 and /dev/null differ
diff --git a/land_sea_mask/parameter_processing_defaults b/land_sea_mask/parameter_processing_defaults
deleted file mode 100644
index dffa9c2..0000000
--- a/land_sea_mask/parameter_processing_defaults
+++ /dev/null
@@ -1,27 +0,0 @@
-Param  lsm  wind  prec  lsm interp
------  ---  ----  ----  ----------
-131     n     y     n     n
-132     n     y     n     n
-140     y     n     n     n
-141     y     n     n     n
-142     n     n     y     n
-143     n     n     y     n
-144     n     n     y     n
-165     n     y     n     n
-166     n     y     n     n
-170     y     n     n     n
-171     y     n     n     n
-172     n     n     n     y
-173     y     n     n     n
-182     y     n     n     n
-183     y     n     n     n
-184     y     n     n     n
-190     y     n     n     n
-191     y     n     n     n
-192     y     n     n     n
-193     y     n     n     n
-199     y     n     n     n
-200     y     n     n     n
-228     n     n     y     n
-239     n     n     y     n
-240     n     n     y     n
diff --git a/land_sea_mask/r160_xx_19790930 b/land_sea_mask/r160_xx_19790930
deleted file mode 120000
index a20af44..0000000
--- a/land_sea_mask/r160_xx_19790930
+++ /dev/null
@@ -1 +0,0 @@
-r160_xx_19910917
\ No newline at end of file
diff --git a/land_sea_mask/r160_xx_19910917 b/land_sea_mask/r160_xx_19910917
deleted file mode 100644
index 7975a70..0000000
Binary files a/land_sea_mask/r160_xx_19910917 and /dev/null differ
diff --git a/land_sea_mask/r160_xx_19930804 b/land_sea_mask/r160_xx_19930804
deleted file mode 120000
index a20af44..0000000
--- a/land_sea_mask/r160_xx_19930804
+++ /dev/null
@@ -1 +0,0 @@
-r160_xx_19910917
\ No newline at end of file
diff --git a/land_sea_mask/r160_xx_19940302 b/land_sea_mask/r160_xx_19940302
deleted file mode 120000
index a20af44..0000000
--- a/land_sea_mask/r160_xx_19940302
+++ /dev/null
@@ -1 +0,0 @@
-r160_xx_19910917
\ No newline at end of file
diff --git a/land_sea_mask/r160_xx_19940823 b/land_sea_mask/r160_xx_19940823
deleted file mode 120000
index a20af44..0000000
--- a/land_sea_mask/r160_xx_19940823
+++ /dev/null
@@ -1 +0,0 @@
-r160_xx_19910917
\ No newline at end of file
diff --git a/land_sea_mask/r160_xx_19950404 b/land_sea_mask/r160_xx_19950404
deleted file mode 120000
index 4e46a22..0000000
--- a/land_sea_mask/r160_xx_19950404
+++ /dev/null
@@ -1 +0,0 @@
-lsm_xx_lsmr160
\ No newline at end of file
diff --git a/libemos-dp/CMakeLists.txt b/libemos-dp/CMakeLists.txt
index 7424869..7e7e2cf 100644
--- a/libemos-dp/CMakeLists.txt
+++ b/libemos-dp/CMakeLists.txt
@@ -7,9 +7,17 @@ endforeach()
 # compiler definitions:
 # - configure Fortran-based targets for double precision (compilation & linking)
 # - allow/disallow GRIBEX with configuration
-set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${emos_double_precision_flags}")
+ecbuild_add_fortran_flags(${emos_double_precision_flags})
 if( HAVE_GRIBEX_ABORT )
-  set_source_files_properties( ../gribex/gribex.F PROPERTIES COMPILE_DEFINITIONS "GRIBEX_ABORT" )
+  set_source_files_properties(
+    "../gribex/gribex.F"
+    PROPERTIES COMPILE_DEFINITIONS "GRIBEX_ABORT" )
+endif()
+if( HAVE_LIBEMOS_INTERPOLATION AND HAVE_FFTW )
+  set_source_files_properties(
+    "../interpolation/jagggp.F"
+    "../interpolation/jsymgg.F"
+    PROPERTIES COMPILE_DEFINITIONS "HAVE_FFTW" )
 endif()
 
 
@@ -21,7 +29,8 @@ ecbuild_add_library(
   TYPE        STATIC
   TARGET      emos
   OUTPUT_NAME "emosR64"
-  DEFINITIONS ${LIBEMOS_DEFINITIONS}
+  DEFINITIONS ${LIBEMOS_DEFINITIONS} ${emos_interpol_tables_def}
+  LIBS        "${GRIB_API_LIBRARIES}" "${FFTW_LIB}" ${FORTRAN_LIBRARIES}
   SOURCES     ../libemos_version.c ${emos_dp_srcs}
   GENERATED   ../libemos_version.c )
 
diff --git a/libemos-sp/CMakeLists.txt b/libemos-sp/CMakeLists.txt
index a98f0a8..231d507 100644
--- a/libemos-sp/CMakeLists.txt
+++ b/libemos-sp/CMakeLists.txt
@@ -14,7 +14,15 @@ endforeach()
 # - allow/disallow GRIBEX with configuration
 list( REMOVE_ITEM LIBEMOS_DEFINITIONS REAL_8 REAL_BIGGER_THAN_INTEGER )
 if( HAVE_GRIBEX_ABORT )
-  set_source_files_properties( ../gribex/gribex.F PROPERTIES COMPILE_DEFINITIONS "GRIBEX_ABORT" )
+  set_source_files_properties(
+    "${CMAKE_CURRENT_BINARY_DIR}/gribex/gribex.F"
+    PROPERTIES COMPILE_DEFINITIONS "GRIBEX_ABORT" )
+endif()
+if( HAVE_LIBEMOS_INTERPOLATION AND HAVE_FFTW )
+  set_source_files_properties(
+    "${CMAKE_CURRENT_BINARY_DIR}/interpolation/jagggp.F"
+    "${CMAKE_CURRENT_BINARY_DIR}/interpolation/jsymgg.F"
+    PROPERTIES COMPILE_DEFINITIONS "HAVE_FFTW" )
 endif()
 
 
@@ -26,16 +34,17 @@ ecbuild_add_library(
   TYPE        STATIC
   TARGET      emos_sp
   OUTPUT_NAME "emos"
-  DEFINITIONS ${LIBEMOS_DEFINITIONS}
+  DEFINITIONS ${LIBEMOS_DEFINITIONS} ${emos_interpol_tables_def}
+  LIBS        "${GRIB_API_LIBRARIES}" "${FFTW_LIB}" "${FORTRAN_LIBRARIES}"
   SOURCES     ../libemos_version.c ${emos_sp_srcs}
   GENERATED   ../libemos_version.c )
 
 
 #if( BUILD_SHARED_LIBS )
-#install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
-#             libemos.so ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/libemos.R32.D64.I32.so)" )
+#  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
+#               libemos.so ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/libemos.R32.D64.I32.so)" )
 #else()
-install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
-             libemos.a ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/libemos.R32.D64.I32.a)" )
+  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
+               libemos.a ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/libemos.R32.D64.I32.a)" )
 #endif()
 
diff --git a/libemos.dox b/libemos.dox
deleted file mode 100644
index 4d27339..0000000
--- a/libemos.dox
+++ /dev/null
@@ -1,2381 +0,0 @@
-# Doxyfile 1.8.9.1
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project.
-#
-# All text after a double hash (##) is considered a comment and is placed in
-# front of the TAG it is preceding.
-#
-# All text after a single hash (#) is considered a comment and will be ignored.
-# The format is:
-# TAG = value [value, ...]
-# For lists, items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (\" \").
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all text
-# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
-# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
-# for the list of possible encodings.
-# The default value is: UTF-8.
-
-DOXYFILE_ENCODING      = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
-# double-quotes, unless you are using Doxywizard) that should identify the
-# project for which the documentation is generated. This name is used in the
-# title of most generated pages and in a few other places.
-# The default value is: My Project.
-
-PROJECT_NAME           = "Emoslib"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
-# could be handy for archiving the generated documentation or if some version
-# control system is used.
-
-PROJECT_NUMBER         =
-
-# Using the PROJECT_BRIEF tag one can provide an optional one line description
-# for a project that appears at the top of each page and should give viewer a
-# quick idea about the purpose of the project. Keep the description short.
-
-PROJECT_BRIEF          =
-
-# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
-# in the documentation. The maximum height of the logo should not exceed 55
-# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
-# the logo to the output directory.
-
-PROJECT_LOGO           =
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
-# into which the generated documentation will be written. If a relative path is
-# entered, it will be relative to the location where doxygen was started. If
-# left blank the current directory will be used.
-
-OUTPUT_DIRECTORY       = /tmp/doxygen/libemos
-
-# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
-# directories (in 2 levels) under the output directory of each output format and
-# will distribute the generated files over these directories. Enabling this
-# option can be useful when feeding doxygen a huge amount of source files, where
-# putting all generated files in the same directory would otherwise causes
-# performance problems for the file system.
-# The default value is: NO.
-
-CREATE_SUBDIRS         = NO
-
-# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
-# characters to appear in the names of generated files. If set to NO, non-ASCII
-# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
-# U+3044.
-# The default value is: NO.
-
-ALLOW_UNICODE_NAMES    = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
-# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
-# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
-# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
-# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
-# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
-# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
-# Ukrainian and Vietnamese.
-# The default value is: English.
-
-OUTPUT_LANGUAGE        = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
-# descriptions after the members that are listed in the file and class
-# documentation (similar to Javadoc). Set to NO to disable this.
-# The default value is: YES.
-
-BRIEF_MEMBER_DESC      = YES
-
-# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
-# description of a member or function before the detailed description
-#
-# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-# The default value is: YES.
-
-REPEAT_BRIEF           = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator that is
-# used to form the text in various listings. Each string in this list, if found
-# as the leading text of the brief description, will be stripped from the text
-# and the result, after processing the whole list, is used as the annotated
-# text. Otherwise, the brief description is used as-is. If left blank, the
-# following values are used ($name is automatically replaced with the name of
-# the entity):The $name class, The $name widget, The $name file, is, provides,
-# specifies, contains, represents, a, an and the.
-
-ABBREVIATE_BRIEF       =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# doxygen will generate a detailed section even if there is only a brief
-# description.
-# The default value is: NO.
-
-ALWAYS_DETAILED_SEC    = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-# The default value is: NO.
-
-INLINE_INHERITED_MEMB  = NO
-
-# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
-# before files name in the file list and in the header files. If set to NO the
-# shortest path that makes the file name unique will be used
-# The default value is: YES.
-
-FULL_PATH_NAMES        = YES
-
-# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
-# Stripping is only done if one of the specified strings matches the left-hand
-# part of the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the path to
-# strip.
-#
-# Note that you can specify absolute paths here, but also relative paths, which
-# will be relative from the directory where doxygen is started.
-# This tag requires that the tag FULL_PATH_NAMES is set to YES.
-
-STRIP_FROM_PATH        =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
-# path mentioned in the documentation of a class, which tells the reader which
-# header file to include in order to use a class. If left blank only the name of
-# the header file containing the class definition is used. Otherwise one should
-# specify the list of include paths that are normally passed to the compiler
-# using the -I flag.
-
-STRIP_FROM_INC_PATH    =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
-# less readable) file names. This can be useful is your file systems doesn't
-# support long names like on DOS, Mac, or CD-ROM.
-# The default value is: NO.
-
-SHORT_NAMES            = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
-# first line (until the first dot) of a Javadoc-style comment as the brief
-# description. If set to NO, the Javadoc-style will behave just like regular Qt-
-# style comments (thus requiring an explicit @brief command for a brief
-# description.)
-# The default value is: NO.
-
-JAVADOC_AUTOBRIEF      = NO
-
-# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
-# line (until the first dot) of a Qt-style comment as the brief description. If
-# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
-# requiring an explicit \brief command for a brief description.)
-# The default value is: NO.
-
-QT_AUTOBRIEF           = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
-# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
-# a brief description. This used to be the default behavior. The new default is
-# to treat a multi-line C++ comment block as a detailed description. Set this
-# tag to YES if you prefer the old behavior instead.
-#
-# Note that setting this tag to YES also means that rational rose comments are
-# not recognized any more.
-# The default value is: NO.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
-# documentation from any documented member that it re-implements.
-# The default value is: YES.
-
-INHERIT_DOCS           = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
-# page for each member. If set to NO, the documentation of a member will be part
-# of the file/class/namespace that contains it.
-# The default value is: NO.
-
-SEPARATE_MEMBER_PAGES  = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
-# uses this value to replace tabs by spaces in code fragments.
-# Minimum value: 1, maximum value: 16, default value: 4.
-
-TAB_SIZE               = 4
-
-# This tag can be used to specify a number of aliases that act as commands in
-# the documentation. An alias has the form:
-# name=value
-# For example adding
-# "sideeffect=@par Side Effects:\n"
-# will allow you to put the command \sideeffect (or @sideeffect) in the
-# documentation, which will result in a user-defined paragraph with heading
-# "Side Effects:". You can put \n's in the value part of an alias to insert
-# newlines.
-
-ALIASES                =
-
-# This tag can be used to specify a number of word-keyword mappings (TCL only).
-# A mapping has the form "name=value". For example adding "class=itcl::class"
-# will allow you to use the command class in the itcl::class meaning.
-
-TCL_SUBST              =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
-# only. Doxygen will then generate output that is more tailored for C. For
-# instance, some of the names that are used will be different. The list of all
-# members will be omitted, etc.
-# The default value is: NO.
-
-OPTIMIZE_OUTPUT_FOR_C  = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
-# Python sources only. Doxygen will then generate output that is more tailored
-# for that language. For instance, namespaces will be presented as packages,
-# qualified scopes will look different, etc.
-# The default value is: NO.
-
-OPTIMIZE_OUTPUT_JAVA   = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources. Doxygen will then generate output that is tailored for Fortran.
-# The default value is: NO.
-
-OPTIMIZE_FOR_FORTRAN   = YES
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for VHDL.
-# The default value is: NO.
-
-OPTIMIZE_OUTPUT_VHDL   = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it
-# parses. With this tag you can assign which parser to use for a given
-# extension. Doxygen has a built-in mapping, but you can override or extend it
-# using this tag. The format is ext=language, where ext is a file extension, and
-# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
-# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
-# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
-# Fortran. In the later case the parser tries to guess whether the code is fixed
-# or free formatted code, this is the default for Fortran type files), VHDL. For
-# instance to make doxygen treat .inc files as Fortran files (default is PHP),
-# and .f files as C (default is Fortran), use: inc=Fortran f=C.
-#
-# Note: For files without extension you can use no_extension as a placeholder.
-#
-# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
-# the files are not read by doxygen.
-
-EXTENSION_MAPPING      = "F=FortranFixed"
-
-# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
-# according to the Markdown format, which allows for more readable
-# documentation. See http://daringfireball.net/projects/markdown/ for details.
-# The output of markdown processing is further processed by doxygen, so you can
-# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
-# case of backward compatibilities issues.
-# The default value is: YES.
-
-MARKDOWN_SUPPORT       = YES
-
-# When enabled doxygen tries to link words that correspond to documented
-# classes, or namespaces to their corresponding documentation. Such a link can
-# be prevented in individual cases by putting a % sign in front of the word or
-# globally by setting AUTOLINK_SUPPORT to NO.
-# The default value is: YES.
-
-AUTOLINK_SUPPORT       = YES
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should set this
-# tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string);
-# versus func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-# The default value is: NO.
-
-BUILTIN_STL_SUPPORT    = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-# The default value is: NO.
-
-CPP_CLI_SUPPORT        = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
-# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
-# will parse them like normal C++ but will assume all classes use public instead
-# of private inheritance when no explicit protection keyword is present.
-# The default value is: NO.
-
-SIP_SUPPORT            = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate
-# getter and setter methods for a property. Setting this option to YES will make
-# doxygen to replace the get and set methods by a property in the documentation.
-# This will only work if the methods are indeed getting or setting a simple
-# type. If this is not the case, or you want to show the methods anyway, you
-# should set this option to NO.
-# The default value is: YES.
-
-IDL_PROPERTY_SUPPORT   = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-# The default value is: NO.
-
-DISTRIBUTE_GROUP_DOC   = NO
-
-# Set the SUBGROUPING tag to YES to allow class member groups of the same type
-# (for instance a group of public functions) to be put as a subgroup of that
-# type (e.g. under the Public Functions section). Set it to NO to prevent
-# subgrouping. Alternatively, this can be done per class using the
-# \nosubgrouping command.
-# The default value is: YES.
-
-SUBGROUPING            = YES
-
-# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
-# are shown inside the group in which they are included (e.g. using \ingroup)
-# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
-# and RTF).
-#
-# Note that this feature does not work in combination with
-# SEPARATE_MEMBER_PAGES.
-# The default value is: NO.
-
-INLINE_GROUPED_CLASSES = NO
-
-# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
-# with only public data fields or simple typedef fields will be shown inline in
-# the documentation of the scope in which they are defined (i.e. file,
-# namespace, or group documentation), provided this scope is documented. If set
-# to NO, structs, classes, and unions are shown on a separate page (for HTML and
-# Man pages) or section (for LaTeX and RTF).
-# The default value is: NO.
-
-INLINE_SIMPLE_STRUCTS  = NO
-
-# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
-# enum is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically be
-# useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-# The default value is: NO.
-
-TYPEDEF_HIDES_STRUCT   = NO
-
-# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
-# cache is used to resolve symbols given their name and scope. Since this can be
-# an expensive process and often the same symbol appears multiple times in the
-# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
-# doxygen will become slower. If the cache is too large, memory is wasted. The
-# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
-# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
-# symbols. At the end of a run doxygen will report the cache usage and suggest
-# the optimal cache size from a speed point of view.
-# Minimum value: 0, maximum value: 9, default value: 0.
-
-LOOKUP_CACHE_SIZE      = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
-# documentation are documented, even if no documentation was available. Private
-# class members and static file members will be hidden unless the
-# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
-# Note: This will also disable the warnings about undocumented members that are
-# normally produced when WARNINGS is set to YES.
-# The default value is: NO.
-
-EXTRACT_ALL            = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
-# be included in the documentation.
-# The default value is: NO.
-
-EXTRACT_PRIVATE        = NO
-
-# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
-# scope will be included in the documentation.
-# The default value is: NO.
-
-EXTRACT_PACKAGE        = NO
-
-# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
-# included in the documentation.
-# The default value is: NO.
-
-EXTRACT_STATIC         = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
-# locally in source files will be included in the documentation. If set to NO,
-# only classes defined in header files are included. Does not have any effect
-# for Java sources.
-# The default value is: YES.
-
-EXTRACT_LOCAL_CLASSES  = YES
-
-# This flag is only useful for Objective-C code. If set to YES, local methods,
-# which are defined in the implementation section but not in the interface are
-# included in the documentation. If set to NO, only methods in the interface are
-# included.
-# The default value is: NO.
-
-EXTRACT_LOCAL_METHODS  = YES
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base name of
-# the file that contains the anonymous namespace. By default anonymous namespace
-# are hidden.
-# The default value is: NO.
-
-EXTRACT_ANON_NSPACES   = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
-# undocumented members inside documented classes or files. If set to NO these
-# members will be included in the various overviews, but no documentation
-# section is generated. This option has no effect if EXTRACT_ALL is enabled.
-# The default value is: NO.
-
-HIDE_UNDOC_MEMBERS     = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy. If set
-# to NO, these classes will be included in the various overviews. This option
-# has no effect if EXTRACT_ALL is enabled.
-# The default value is: NO.
-
-HIDE_UNDOC_CLASSES     = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
-# (class|struct|union) declarations. If set to NO, these declarations will be
-# included in the documentation.
-# The default value is: NO.
-
-HIDE_FRIEND_COMPOUNDS  = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
-# documentation blocks found inside the body of a function. If set to NO, these
-# blocks will be appended to the function's detailed documentation block.
-# The default value is: NO.
-
-HIDE_IN_BODY_DOCS      = NO
-
-# The INTERNAL_DOCS tag determines if documentation that is typed after a
-# \internal command is included. If the tag is set to NO then the documentation
-# will be excluded. Set it to YES to include the internal documentation.
-# The default value is: NO.
-
-INTERNAL_DOCS          = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
-# names in lower-case letters. If set to YES, upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-# The default value is: system dependent.
-
-CASE_SENSE_NAMES       = NO
-
-# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
-# their full class and namespace scopes in the documentation. If set to YES, the
-# scope will be hidden.
-# The default value is: NO.
-
-HIDE_SCOPE_NAMES       = NO
-
-# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
-# append additional text to a page's title, such as Class Reference. If set to
-# YES the compound reference will be hidden.
-# The default value is: NO.
-
-HIDE_COMPOUND_REFERENCE= NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
-# the files that are included by a file in the documentation of that file.
-# The default value is: YES.
-
-SHOW_INCLUDE_FILES     = YES
-
-# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
-# grouped member an include statement to the documentation, telling the reader
-# which file to include in order to use the member.
-# The default value is: NO.
-
-SHOW_GROUPED_MEMB_INC  = NO
-
-# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
-# files with double quotes in the documentation rather than with sharp brackets.
-# The default value is: NO.
-
-FORCE_LOCAL_INCLUDES   = NO
-
-# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
-# documentation for inline members.
-# The default value is: YES.
-
-INLINE_INFO            = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
-# (detailed) documentation of file and class members alphabetically by member
-# name. If set to NO, the members will appear in declaration order.
-# The default value is: YES.
-
-SORT_MEMBER_DOCS       = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
-# descriptions of file, namespace and class members alphabetically by member
-# name. If set to NO, the members will appear in declaration order. Note that
-# this will also influence the order of the classes in the class list.
-# The default value is: NO.
-
-SORT_BRIEF_DOCS        = NO
-
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
-# (brief and detailed) documentation of class members so that constructors and
-# destructors are listed first. If set to NO the constructors will appear in the
-# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
-# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
-# member documentation.
-# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
-# detailed member documentation.
-# The default value is: NO.
-
-SORT_MEMBERS_CTORS_1ST = NO
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
-# of group names into alphabetical order. If set to NO the group names will
-# appear in their defined order.
-# The default value is: NO.
-
-SORT_GROUP_NAMES       = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
-# fully-qualified names, including namespaces. If set to NO, the class list will
-# be sorted only by class name, not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the alphabetical
-# list.
-# The default value is: NO.
-
-SORT_BY_SCOPE_NAME     = NO
-
-# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
-# type resolution of all parameters of a function it will reject a match between
-# the prototype and the implementation of a member function even if there is
-# only one candidate or it is obvious which candidate to choose by doing a
-# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
-# accept a match between prototype and implementation in such cases.
-# The default value is: NO.
-
-STRICT_PROTO_MATCHING  = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
-# list. This list is created by putting \todo commands in the documentation.
-# The default value is: YES.
-
-GENERATE_TODOLIST      = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
-# list. This list is created by putting \test commands in the documentation.
-# The default value is: YES.
-
-GENERATE_TESTLIST      = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
-# list. This list is created by putting \bug commands in the documentation.
-# The default value is: YES.
-
-GENERATE_BUGLIST       = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
-# the deprecated list. This list is created by putting \deprecated commands in
-# the documentation.
-# The default value is: YES.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional documentation
-# sections, marked by \if <section_label> ... \endif and \cond <section_label>
-# ... \endcond blocks.
-
-ENABLED_SECTIONS       =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
-# initial value of a variable or macro / define can have for it to appear in the
-# documentation. If the initializer consists of more lines than specified here
-# it will be hidden. Use a value of 0 to hide initializers completely. The
-# appearance of the value of individual variables and macros / defines can be
-# controlled using \showinitializer or \hideinitializer command in the
-# documentation regardless of this setting.
-# Minimum value: 0, maximum value: 10000, default value: 30.
-
-MAX_INITIALIZER_LINES  = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
-# the bottom of the documentation of classes and structs. If set to YES, the
-# list will mention the files that were used to generate the documentation.
-# The default value is: YES.
-
-SHOW_USED_FILES        = YES
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
-# will remove the Files entry from the Quick Index and from the Folder Tree View
-# (if specified).
-# The default value is: YES.
-
-SHOW_FILES             = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
-# page. This will remove the Namespaces entry from the Quick Index and from the
-# Folder Tree View (if specified).
-# The default value is: YES.
-
-SHOW_NAMESPACES        = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command command input-file, where command is the value of the
-# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
-# by doxygen. Whatever the program writes to standard output is used as the file
-# version. For an example see the documentation.
-
-FILE_VERSION_FILTER    =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
-# by doxygen. The layout file controls the global structure of the generated
-# output files in an output format independent way. To create the layout file
-# that represents doxygen's defaults, run doxygen with the -l option. You can
-# optionally specify a file name after the option, if omitted DoxygenLayout.xml
-# will be used as the name of the layout file.
-#
-# Note that if you run doxygen from a directory containing a file called
-# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
-# tag is left empty.
-
-LAYOUT_FILE            =
-
-# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
-# the reference definitions. This must be a list of .bib files. The .bib
-# extension is automatically appended if omitted. This requires the bibtex tool
-# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
-# For LaTeX the style of the bibliography can be controlled using
-# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
-# search path. See also \cite for info how to create references.
-
-CITE_BIB_FILES         =
-
-#---------------------------------------------------------------------------
-# Configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated to
-# standard output by doxygen. If QUIET is set to YES this implies that the
-# messages are off.
-# The default value is: NO.
-
-QUIET                  = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
-# this implies that the warnings are on.
-#
-# Tip: Turn warnings on while writing the documentation.
-# The default value is: YES.
-
-WARNINGS               = YES
-
-# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
-# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
-# will automatically be disabled.
-# The default value is: YES.
-
-WARN_IF_UNDOCUMENTED   = YES
-
-# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some parameters
-# in a documented function, or documenting parameters that don't exist or using
-# markup commands wrongly.
-# The default value is: YES.
-
-WARN_IF_DOC_ERROR      = YES
-
-# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
-# are documented, but have no documentation for their parameters or return
-# value. If set to NO, doxygen will only warn about wrong or incomplete
-# parameter documentation, but not about the absence of documentation.
-# The default value is: NO.
-
-WARN_NO_PARAMDOC       = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that doxygen
-# can produce. The string should contain the $file, $line, and $text tags, which
-# will be replaced by the file and line number from which the warning originated
-# and the warning text. Optionally the format may contain $version, which will
-# be replaced by the version of the file (if it could be obtained via
-# FILE_VERSION_FILTER)
-# The default value is: $file:$line: $text.
-
-WARN_FORMAT            = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning and error
-# messages should be written. If left blank the output is written to standard
-# error (stderr).
-
-WARN_LOGFILE           =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag is used to specify the files and/or directories that contain
-# documented source files. You may enter file names like myfile.cpp or
-# directories like /usr/src/myproject. Separate the files or directories with
-# spaces.
-# Note: If this tag is empty the current directory is searched.
-
-INPUT                  = .
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
-# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
-# documentation (see: http://www.gnu.org/software/libiconv) for the list of
-# possible encodings.
-# The default value is: UTF-8.
-
-INPUT_ENCODING         = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
-# *.h) to filter out the source-files in the directories. If left blank the
-# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
-# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
-# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
-# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
-# *.qsf, *.as and *.js.
-
-FILE_PATTERNS          = *.F *.c *.h
-
-# The RECURSIVE tag can be used to specify whether or not subdirectories should
-# be searched for input files as well.
-# The default value is: NO.
-
-RECURSIVE              = YES
-
-# The EXCLUDE tag can be used to specify files and/or directories that should be
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-#
-# Note that relative paths are relative to the directory from which doxygen is
-# run.
-
-EXCLUDE                = grib_api_merging/example.c
-
-# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
-# directories that are symbolic links (a Unix file system feature) are excluded
-# from the input.
-# The default value is: NO.
-
-EXCLUDE_SYMLINKS       = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories.
-#
-# Note that the wildcards are matched against the file with absolute path, so to
-# exclude all test directories for example use the pattern */test/*
-
-EXCLUDE_PATTERNS       =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-#
-# Note that the wildcards are matched against the file with absolute path, so to
-# exclude all test directories use the pattern */test/*
-
-EXCLUDE_SYMBOLS        =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or directories
-# that contain example code fragments that are included (see the \include
-# command).
-
-EXAMPLE_PATH           =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
-# *.h) to filter out the source-files in the directories. If left blank all
-# files are included.
-
-EXAMPLE_PATTERNS       =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude commands
-# irrespective of the value of the RECURSIVE tag.
-# The default value is: NO.
-
-EXAMPLE_RECURSIVE      = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or directories
-# that contain images that are to be included in the documentation (see the
-# \image command).
-
-IMAGE_PATH             =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command:
-#
-# <filter> <input-file>
-#
-# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
-# name of an input file. Doxygen will then use the output that the filter
-# program writes to standard output. If FILTER_PATTERNS is specified, this tag
-# will be ignored.
-#
-# Note that the filter must not add or remove lines; it is applied before the
-# code is scanned, but not when the output code is generated. If lines are added
-# or removed, the anchors will not be placed correctly.
-
-INPUT_FILTER           =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form: pattern=filter
-# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
-# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
-# patterns match the file name, INPUT_FILTER is applied.
-
-FILTER_PATTERNS        =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will also be used to filter the input files that are used for
-# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
-# The default value is: NO.
-
-FILTER_SOURCE_FILES    = NO
-
-# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
-# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
-# it is also possible to disable source filtering for a specific pattern using
-# *.ext= (so without naming a filter).
-# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
-
-FILTER_SOURCE_PATTERNS =
-
-# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
-# is part of the input, its contents will be placed on the main page
-# (index.html). This can be useful if you have a project on for instance GitHub
-# and want to reuse the introduction page also for the doxygen output.
-
-USE_MDFILE_AS_MAINPAGE =
-
-#---------------------------------------------------------------------------
-# Configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
-# generated. Documented entities will be cross-referenced with these sources.
-#
-# Note: To get rid of all source code in the generated output, make sure that
-# also VERBATIM_HEADERS is set to NO.
-# The default value is: NO.
-
-SOURCE_BROWSER         = YES
-
-# Setting the INLINE_SOURCES tag to YES will include the body of functions,
-# classes and enums directly into the documentation.
-# The default value is: NO.
-
-INLINE_SOURCES         = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
-# special comment blocks from generated source code fragments. Normal C, C++ and
-# Fortran comments will always remain visible.
-# The default value is: YES.
-
-STRIP_CODE_COMMENTS    = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
-# function all documented functions referencing it will be listed.
-# The default value is: NO.
-
-REFERENCED_BY_RELATION = NO
-
-# If the REFERENCES_RELATION tag is set to YES then for each documented function
-# all documented entities called/used by that function will be listed.
-# The default value is: NO.
-
-REFERENCES_RELATION    = NO
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
-# to YES then the hyperlinks from functions in REFERENCES_RELATION and
-# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
-# link to the documentation.
-# The default value is: YES.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
-# source code will show a tooltip with additional information such as prototype,
-# brief description and links to the definition and documentation. Since this
-# will make the HTML file larger and loading of large files a bit slower, you
-# can opt to disable this feature.
-# The default value is: YES.
-# This tag requires that the tag SOURCE_BROWSER is set to YES.
-
-SOURCE_TOOLTIPS        = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code will
-# point to the HTML generated by the htags(1) tool instead of doxygen built-in
-# source browser. The htags tool is part of GNU's global source tagging system
-# (see http://www.gnu.org/software/global/global.html). You will need version
-# 4.8.6 or higher.
-#
-# To use it do the following:
-# - Install the latest version of global
-# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
-# - Make sure the INPUT points to the root of the source tree
-# - Run doxygen as normal
-#
-# Doxygen will invoke htags (and that will in turn invoke gtags), so these
-# tools must be available from the command line (i.e. in the search path).
-#
-# The result: instead of the source browser generated by doxygen, the links to
-# source code will now point to the output of htags.
-# The default value is: NO.
-# This tag requires that the tag SOURCE_BROWSER is set to YES.
-
-USE_HTAGS              = NO
-
-# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
-# verbatim copy of the header file for each class for which an include is
-# specified. Set to NO to disable this.
-# See also: Section \class.
-# The default value is: YES.
-
-VERBATIM_HEADERS       = YES
-
-# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
-# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
-# cost of reduced performance. This can be particularly helpful with template
-# rich C++ code for which doxygen's built-in parser lacks the necessary type
-# information.
-# Note: The availability of this option depends on whether or not doxygen was
-# compiled with the --with-libclang option.
-# The default value is: NO.
-
-CLANG_ASSISTED_PARSING = YES
-
-# If clang assisted parsing is enabled you can provide the compiler with command
-# line options that you would normally use when invoking the compiler. Note that
-# the include paths will already be set by doxygen for the files and directories
-# specified with INPUT and INCLUDE_PATH.
-# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
-
-CLANG_OPTIONS          =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
-# compounds will be generated. Enable this if the project contains a lot of
-# classes, structs, unions or interfaces.
-# The default value is: YES.
-
-ALPHABETICAL_INDEX     = YES
-
-# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
-# which the alphabetical index list will be split.
-# Minimum value: 1, maximum value: 20, default value: 5.
-# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
-
-COLS_IN_ALPHA_INDEX    = 5
-
-# In case all classes in a project start with a common prefix, all classes will
-# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
-# can be used to specify a prefix (or a list of prefixes) that should be ignored
-# while generating the index headers.
-# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
-
-IGNORE_PREFIX          =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
-# The default value is: YES.
-
-GENERATE_HTML          = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: html.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_OUTPUT            = 
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
-# generated HTML page (for example: .htm, .php, .asp).
-# The default value is: .html.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_FILE_EXTENSION    = .html
-
-# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
-# each generated HTML page. If the tag is left blank doxygen will generate a
-# standard header.
-#
-# To get valid HTML the header file that includes any scripts and style sheets
-# that doxygen needs, which is dependent on the configuration options used (e.g.
-# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
-# default header using
-# doxygen -w html new_header.html new_footer.html new_stylesheet.css
-# YourConfigFile
-# and then modify the file new_header.html. See also section "Doxygen usage"
-# for information on how to generate the default header that doxygen normally
-# uses.
-# Note: The header is subject to change so you typically have to regenerate the
-# default header when upgrading to a newer version of doxygen. For a description
-# of the possible markers and block names see the documentation.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_HEADER            =
-
-# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
-# generated HTML page. If the tag is left blank doxygen will generate a standard
-# footer. See HTML_HEADER for more information on how to generate a default
-# footer and what special commands can be used inside the footer. See also
-# section "Doxygen usage" for information on how to generate the default footer
-# that doxygen normally uses.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_FOOTER            =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
-# sheet that is used by each HTML page. It can be used to fine-tune the look of
-# the HTML output. If left blank doxygen will generate a default style sheet.
-# See also section "Doxygen usage" for information on how to generate the style
-# sheet that doxygen normally uses.
-# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
-# it is more robust and this tag (HTML_STYLESHEET) will in the future become
-# obsolete.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_STYLESHEET        =
-
-# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
-# cascading style sheets that are included after the standard style sheets
-# created by doxygen. Using this option one can overrule certain style aspects.
-# This is preferred over using HTML_STYLESHEET since it does not replace the
-# standard style sheet and is therefore more robust against future updates.
-# Doxygen will copy the style sheet files to the output directory.
-# Note: The order of the extra style sheet files is of importance (e.g. the last
-# style sheet in the list overrules the setting of the previous ones in the
-# list). For an example see the documentation.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_EXTRA_STYLESHEET  =
-
-# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
-# other source files which should be copied to the HTML output directory. Note
-# that these files will be copied to the base HTML output directory. Use the
-# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
-# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
-# files will be copied as-is; there are no commands or markers available.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_EXTRA_FILES       =
-
-# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
-# will adjust the colors in the style sheet and background images according to
-# this color. Hue is specified as an angle on a colorwheel, see
-# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
-# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
-# purple, and 360 is red again.
-# Minimum value: 0, maximum value: 359, default value: 220.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_COLORSTYLE_HUE    = 220
-
-# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
-# in the HTML output. For a value of 0 the output will use grayscales only. A
-# value of 255 will produce the most vivid colors.
-# Minimum value: 0, maximum value: 255, default value: 100.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_COLORSTYLE_SAT    = 100
-
-# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
-# luminance component of the colors in the HTML output. Values below 100
-# gradually make the output lighter, whereas values above 100 make the output
-# darker. The value divided by 100 is the actual gamma applied, so 80 represents
-# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
-# change the gamma.
-# Minimum value: 40, maximum value: 240, default value: 80.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_COLORSTYLE_GAMMA  = 80
-
-# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
-# page will contain the date and time when the page was generated. Setting this
-# to NO can help when comparing the output of multiple runs.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_TIMESTAMP         = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_DYNAMIC_SECTIONS  = NO
-
-# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
-# shown in the various tree structured indices initially; the user can expand
-# and collapse entries dynamically later on. Doxygen will expand the tree to
-# such a level that at most the specified number of entries are visible (unless
-# a fully collapsed tree already exceeds this amount). So setting the number of
-# entries 1 will produce a full collapsed tree by default. 0 is a special value
-# representing an infinite number of entries and will result in a full expanded
-# tree by default.
-# Minimum value: 0, maximum value: 9999, default value: 100.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_INDEX_NUM_ENTRIES = 100
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files will be
-# generated that can be used as input for Apple's Xcode 3 integrated development
-# environment (see: http://developer.apple.com/tools/xcode/), introduced with
-# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
-# Makefile in the HTML output directory. Running make will produce the docset in
-# that directory and running make install will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
-# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
-# for more information.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_DOCSET        = NO
-
-# This tag determines the name of the docset feed. A documentation feed provides
-# an umbrella under which multiple documentation sets from a single provider
-# (such as a company or product suite) can be grouped.
-# The default value is: Doxygen generated docs.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_FEEDNAME        = "Doxygen generated docs"
-
-# This tag specifies a string that should uniquely identify the documentation
-# set bundle. This should be a reverse domain-name style string, e.g.
-# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
-# The default value is: org.doxygen.Project.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_BUNDLE_ID       = org.doxygen.Project
-
-# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
-# the documentation publisher. This should be a reverse domain-name style
-# string, e.g. com.mycompany.MyDocSet.documentation.
-# The default value is: org.doxygen.Publisher.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
-
-# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
-# The default value is: Publisher.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_PUBLISHER_NAME  = Publisher
-
-# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
-# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
-# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
-# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
-# Windows.
-#
-# The HTML Help Workshop contains a compiler that can convert all HTML output
-# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
-# files are now used as the Windows 98 help format, and will replace the old
-# Windows help format (.hlp) on all Windows platforms in the future. Compressed
-# HTML files also contain an index, a table of contents, and you can search for
-# words in the documentation. The HTML workshop also contains a viewer for
-# compressed HTML files.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_HTMLHELP      = NO
-
-# The CHM_FILE tag can be used to specify the file name of the resulting .chm
-# file. You can add a path in front of the file if the result should not be
-# written to the html output directory.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-CHM_FILE               =
-
-# The HHC_LOCATION tag can be used to specify the location (absolute path
-# including file name) of the HTML help compiler (hhc.exe). If non-empty,
-# doxygen will try to run the HTML help compiler on the generated index.hhp.
-# The file has to be specified with full path.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-HHC_LOCATION           =
-
-# The GENERATE_CHI flag controls if a separate .chi index file is generated
-# (YES) or that it should be included in the master .chm file (NO).
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-GENERATE_CHI           = NO
-
-# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
-# and project file content.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-CHM_INDEX_ENCODING     =
-
-# The BINARY_TOC flag controls whether a binary table of contents is generated
-# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
-# enables the Previous and Next buttons.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-BINARY_TOC             = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members to
-# the table of contents of the HTML help documentation and to the tree view.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-TOC_EXPAND             = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
-# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
-# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
-# (.qch) of the generated HTML documentation.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_QHP           = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
-# the file name of the resulting .qch file. The path specified is relative to
-# the HTML output folder.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QCH_FILE               =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
-# Project output. For more information please see Qt Help Project / Namespace
-# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
-# The default value is: org.doxygen.Project.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_NAMESPACE          = org.doxygen.Project
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
-# Help Project output. For more information please see Qt Help Project / Virtual
-# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
-# folders).
-# The default value is: doc.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_VIRTUAL_FOLDER     = doc
-
-# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
-# filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
-# filters).
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_CUST_FILTER_NAME   =
-
-# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
-# custom filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
-# filters).
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_CUST_FILTER_ATTRS  =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
-# project's filter section matches. Qt Help Project / Filter Attributes (see:
-# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_SECT_FILTER_ATTRS  =
-
-# The QHG_LOCATION tag can be used to specify the location of Qt's
-# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
-# generated .qhp file.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHG_LOCATION           =
-
-# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
-# generated, together with the HTML files, they form an Eclipse help plugin. To
-# install this plugin and make it available under the help contents menu in
-# Eclipse, the contents of the directory containing the HTML and XML files needs
-# to be copied into the plugins directory of eclipse. The name of the directory
-# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
-# After copying Eclipse needs to be restarted before the help appears.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_ECLIPSEHELP   = NO
-
-# A unique identifier for the Eclipse help plugin. When installing the plugin
-# the directory name containing the HTML and XML files should also have this
-# name. Each documentation set should have its own identifier.
-# The default value is: org.doxygen.Project.
-# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
-
-ECLIPSE_DOC_ID         = org.doxygen.Project
-
-# If you want full control over the layout of the generated HTML pages it might
-# be necessary to disable the index and replace it with your own. The
-# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
-# of each HTML page. A value of NO enables the index and the value YES disables
-# it. Since the tabs in the index contain the same information as the navigation
-# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-DISABLE_INDEX          = NO
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information. If the tag
-# value is set to YES, a side panel will be generated containing a tree-like
-# index structure (just like the one that is generated for HTML Help). For this
-# to work a browser that supports JavaScript, DHTML, CSS and frames is required
-# (i.e. any modern browser). Windows users are probably better off using the
-# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
-# further fine-tune the look of the index. As an example, the default style
-# sheet generated by doxygen has an example that shows how to put an image at
-# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
-# the same information as the tab index, you could consider setting
-# DISABLE_INDEX to YES when enabling this option.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_TREEVIEW      = NO
-
-# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
-# doxygen will group on one line in the generated HTML documentation.
-#
-# Note that a value of 0 will completely suppress the enum values from appearing
-# in the overview section.
-# Minimum value: 0, maximum value: 20, default value: 4.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-ENUM_VALUES_PER_LINE   = 4
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
-# to set the initial width (in pixels) of the frame in which the tree is shown.
-# Minimum value: 0, maximum value: 1500, default value: 250.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-TREEVIEW_WIDTH         = 250
-
-# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
-# external symbols imported via tag files in a separate window.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-EXT_LINKS_IN_WINDOW    = NO
-
-# Use this tag to change the font size of LaTeX formulas included as images in
-# the HTML documentation. When you change the font size after a successful
-# doxygen run you need to manually remove any form_*.png images from the HTML
-# output directory to force them to be regenerated.
-# Minimum value: 8, maximum value: 50, default value: 10.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-FORMULA_FONTSIZE       = 10
-
-# Use the FORMULA_TRANPARENT tag to determine whether or not the images
-# generated for formulas are transparent PNGs. Transparent PNGs are not
-# supported properly for IE 6.0, but are supported on all modern browsers.
-#
-# Note that when changing this option you need to delete any form_*.png files in
-# the HTML output directory before the changes have effect.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-FORMULA_TRANSPARENT    = YES
-
-# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
-# http://www.mathjax.org) which uses client side Javascript for the rendering
-# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
-# installed or if you want to formulas look prettier in the HTML output. When
-# enabled you may also need to install MathJax separately and configure the path
-# to it using the MATHJAX_RELPATH option.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-USE_MATHJAX            = NO
-
-# When MathJax is enabled you can set the default output format to be used for
-# the MathJax output. See the MathJax site (see:
-# http://docs.mathjax.org/en/latest/output.html) for more details.
-# Possible values are: HTML-CSS (which is slower, but has the best
-# compatibility), NativeMML (i.e. MathML) and SVG.
-# The default value is: HTML-CSS.
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_FORMAT         = HTML-CSS
-
-# When MathJax is enabled you need to specify the location relative to the HTML
-# output directory using the MATHJAX_RELPATH option. The destination directory
-# should contain the MathJax.js script. For instance, if the mathjax directory
-# is located at the same level as the HTML output directory, then
-# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
-# Content Delivery Network so you can quickly see the result without installing
-# MathJax. However, it is strongly recommended to install a local copy of
-# MathJax from http://www.mathjax.org before deployment.
-# The default value is: http://cdn.mathjax.org/mathjax/latest.
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
-
-# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
-# extension names that should be enabled during MathJax rendering. For example
-# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_EXTENSIONS     =
-
-# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
-# of code that will be used on startup of the MathJax code. See the MathJax site
-# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
-# example see the documentation.
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_CODEFILE       =
-
-# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
-# the HTML output. The underlying search engine uses javascript and DHTML and
-# should work on any modern browser. Note that when using HTML help
-# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
-# there is already a search function so this one should typically be disabled.
-# For large projects the javascript based search engine can be slow, then
-# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
-# search using the keyboard; to jump to the search box use <access key> + S
-# (what the <access key> is depends on the OS and browser, but it is typically
-# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
-# key> to jump into the search results window, the results can be navigated
-# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
-# the search. The filter options can be selected when the cursor is inside the
-# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
-# to select a filter and <Enter> or <escape> to activate or cancel the filter
-# option.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-SEARCHENGINE           = YES
-
-# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
-# implemented using a web server instead of a web client using Javascript. There
-# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
-# setting. When disabled, doxygen will generate a PHP script for searching and
-# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
-# and searching needs to be provided by external tools. See the section
-# "External Indexing and Searching" for details.
-# The default value is: NO.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-SERVER_BASED_SEARCH    = NO
-
-# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
-# script for searching. Instead the search results are written to an XML file
-# which needs to be processed by an external indexer. Doxygen will invoke an
-# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
-# search results.
-#
-# Doxygen ships with an example indexer (doxyindexer) and search engine
-# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: http://xapian.org/).
-#
-# See the section "External Indexing and Searching" for details.
-# The default value is: NO.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-EXTERNAL_SEARCH        = NO
-
-# The SEARCHENGINE_URL should point to a search engine hosted by a web server
-# which will return the search results when EXTERNAL_SEARCH is enabled.
-#
-# Doxygen ships with an example indexer (doxyindexer) and search engine
-# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: http://xapian.org/). See the section "External Indexing and
-# Searching" for details.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-SEARCHENGINE_URL       =
-
-# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
-# search data is written to a file for indexing by an external tool. With the
-# SEARCHDATA_FILE tag the name of this file can be specified.
-# The default file is: searchdata.xml.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-SEARCHDATA_FILE        = searchdata.xml
-
-# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
-# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
-# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
-# projects and redirect the results back to the right project.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-EXTERNAL_SEARCH_ID     =
-
-# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
-# projects other than the one defined by this configuration file, but that are
-# all added to the same external search index. Each project needs to have a
-# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
-# to a relative location where the documentation can be found. The format is:
-# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-EXTRA_SEARCH_MAPPINGS  =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
-# The default value is: YES.
-
-GENERATE_LATEX         = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: latex.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_OUTPUT           = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked.
-#
-# Note that when enabling USE_PDFLATEX this option is only used for generating
-# bitmaps for formulas in the HTML output, but not in the Makefile that is
-# written to the output directory.
-# The default file is: latex.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_CMD_NAME         = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
-# index for LaTeX.
-# The default file is: makeindex.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-MAKEINDEX_CMD_NAME     = makeindex
-
-# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
-# documents. This may be useful for small projects and may help to save some
-# trees in general.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-COMPACT_LATEX          = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used by the
-# printer.
-# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
-# 14 inches) and executive (7.25 x 10.5 inches).
-# The default value is: a4.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-PAPER_TYPE             = a4
-
-# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
-# that should be included in the LaTeX output. To get the times font for
-# instance you can specify
-# EXTRA_PACKAGES=times
-# If left blank no extra packages will be included.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-EXTRA_PACKAGES         =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
-# generated LaTeX document. The header should contain everything until the first
-# chapter. If it is left blank doxygen will generate a standard header. See
-# section "Doxygen usage" for information on how to let doxygen write the
-# default header to a separate file.
-#
-# Note: Only use a user-defined header if you know what you are doing! The
-# following commands have a special meaning inside the header: $title,
-# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
-# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
-# string, for the replacement values of the other commands the user is referred
-# to HTML_HEADER.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_HEADER           =
-
-# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
-# generated LaTeX document. The footer should contain everything after the last
-# chapter. If it is left blank doxygen will generate a standard footer. See
-# LATEX_HEADER for more information on how to generate a default footer and what
-# special commands can be used inside the footer.
-#
-# Note: Only use a user-defined footer if you know what you are doing!
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_FOOTER           =
-
-# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
-# LaTeX style sheets that are included after the standard style sheets created
-# by doxygen. Using this option one can overrule certain style aspects. Doxygen
-# will copy the style sheet files to the output directory.
-# Note: The order of the extra style sheet files is of importance (e.g. the last
-# style sheet in the list overrules the setting of the previous ones in the
-# list).
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_EXTRA_STYLESHEET =
-
-# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
-# other source files which should be copied to the LATEX_OUTPUT output
-# directory. Note that the files will be copied as-is; there are no commands or
-# markers available.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_EXTRA_FILES      =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
-# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
-# contain links (just like the HTML output) instead of page references. This
-# makes the output suitable for online browsing using a PDF viewer.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-PDF_HYPERLINKS         = YES
-
-# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
-# the PDF file directly from the LaTeX files. Set this option to YES, to get a
-# higher quality PDF documentation.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-USE_PDFLATEX           = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
-# command to the generated LaTeX files. This will instruct LaTeX to keep running
-# if errors occur, instead of asking the user for help. This option is also used
-# when generating formulas in HTML.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_BATCHMODE        = NO
-
-# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
-# index chapters (such as File Index, Compound Index, etc.) in the output.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_HIDE_INDICES     = NO
-
-# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
-# code with syntax highlighting in the LaTeX output.
-#
-# Note that which sources are shown also depends on other settings such as
-# SOURCE_BROWSER.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_SOURCE_CODE      = NO
-
-# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
-# bibliography, e.g. plainnat, or ieeetr. See
-# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
-# The default value is: plain.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_BIB_STYLE        = plain
-
-#---------------------------------------------------------------------------
-# Configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
-# RTF output is optimized for Word 97 and may not look too pretty with other RTF
-# readers/editors.
-# The default value is: NO.
-
-GENERATE_RTF           = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: rtf.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_OUTPUT             = rtf
-
-# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
-# documents. This may be useful for small projects and may help to save some
-# trees in general.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-COMPACT_RTF            = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
-# contain hyperlink fields. The RTF file will contain links (just like the HTML
-# output) instead of page references. This makes the output suitable for online
-# browsing using Word or some other Word compatible readers that support those
-# fields.
-#
-# Note: WordPad (write) and others do not support links.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_HYPERLINKS         = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's config
-# file, i.e. a series of assignments. You only have to provide replacements,
-# missing definitions are set to their default value.
-#
-# See also section "Doxygen usage" for information on how to generate the
-# default style sheet that doxygen normally uses.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_STYLESHEET_FILE    =
-
-# Set optional variables used in the generation of an RTF document. Syntax is
-# similar to doxygen's config file. A template extensions file can be generated
-# using doxygen -e rtf extensionFile.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_EXTENSIONS_FILE    =
-
-# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
-# with syntax highlighting in the RTF output.
-#
-# Note that which sources are shown also depends on other settings such as
-# SOURCE_BROWSER.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_SOURCE_CODE        = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
-# classes and files.
-# The default value is: NO.
-
-GENERATE_MAN           = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it. A directory man3 will be created inside the directory specified by
-# MAN_OUTPUT.
-# The default directory is: man.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_OUTPUT             = man
-
-# The MAN_EXTENSION tag determines the extension that is added to the generated
-# man pages. In case the manual section does not start with a number, the number
-# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
-# optional.
-# The default value is: .3.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_EXTENSION          = .3
-
-# The MAN_SUBDIR tag determines the name of the directory created within
-# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
-# MAN_EXTENSION with the initial . removed.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_SUBDIR             =
-
-# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
-# will generate one additional man file for each entity documented in the real
-# man page(s). These additional files only source the real man page, but without
-# them the man command would be unable to find the correct page.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_LINKS              = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
-# captures the structure of the code including all documentation.
-# The default value is: NO.
-
-GENERATE_XML           = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: xml.
-# This tag requires that the tag GENERATE_XML is set to YES.
-
-XML_OUTPUT             = xml
-
-# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
-# listings (including syntax highlighting and cross-referencing information) to
-# the XML output. Note that enabling this will significantly increase the size
-# of the XML output.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_XML is set to YES.
-
-XML_PROGRAMLISTING     = YES
-
-#---------------------------------------------------------------------------
-# Configuration options related to the DOCBOOK output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
-# that can be used to generate PDF.
-# The default value is: NO.
-
-GENERATE_DOCBOOK       = NO
-
-# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
-# front of it.
-# The default directory is: docbook.
-# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
-
-DOCBOOK_OUTPUT         = docbook
-
-# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
-# program listings (including syntax highlighting and cross-referencing
-# information) to the DOCBOOK output. Note that enabling this will significantly
-# increase the size of the DOCBOOK output.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
-
-DOCBOOK_PROGRAMLISTING = NO
-
-#---------------------------------------------------------------------------
-# Configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
-# AutoGen Definitions (see http://autogen.sf.net) file that captures the
-# structure of the code including all documentation. Note that this feature is
-# still experimental and incomplete at the moment.
-# The default value is: NO.
-
-GENERATE_AUTOGEN_DEF   = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
-# file that captures the structure of the code including all documentation.
-#
-# Note that this feature is still experimental and incomplete at the moment.
-# The default value is: NO.
-
-GENERATE_PERLMOD       = NO
-
-# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
-# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
-# output from the Perl module output.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_PERLMOD is set to YES.
-
-PERLMOD_LATEX          = NO
-
-# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
-# formatted so it can be parsed by a human reader. This is useful if you want to
-# understand what is going on. On the other hand, if this tag is set to NO, the
-# size of the Perl module output will be much smaller and Perl will parse it
-# just the same.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_PERLMOD is set to YES.
-
-PERLMOD_PRETTY         = YES
-
-# The names of the make variables in the generated doxyrules.make file are
-# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
-# so different doxyrules.make files included by the same Makefile don't
-# overwrite each other's variables.
-# This tag requires that the tag GENERATE_PERLMOD is set to YES.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
-# C-preprocessor directives found in the sources and include files.
-# The default value is: YES.
-
-ENABLE_PREPROCESSING   = YES
-
-# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
-# in the source code. If set to NO, only conditional compilation will be
-# performed. Macro expansion can be done in a controlled way by setting
-# EXPAND_ONLY_PREDEF to YES.
-# The default value is: NO.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-MACRO_EXPANSION        = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
-# the macro expansion is limited to the macros specified with the PREDEFINED and
-# EXPAND_AS_DEFINED tags.
-# The default value is: NO.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-EXPAND_ONLY_PREDEF     = NO
-
-# If the SEARCH_INCLUDES tag is set to YES, the include files in the
-# INCLUDE_PATH will be searched if a #include is found.
-# The default value is: YES.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-SEARCH_INCLUDES        = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by the
-# preprocessor.
-# This tag requires that the tag SEARCH_INCLUDES is set to YES.
-
-INCLUDE_PATH           =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will be
-# used.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-INCLUDE_FILE_PATTERNS  =
-
-# The PREDEFINED tag can be used to specify one or more macro names that are
-# defined before the preprocessor is started (similar to the -D option of e.g.
-# gcc). The argument of the tag is a list of macros of the form: name or
-# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
-# is assumed. To prevent a macro definition from being undefined via #undef or
-# recursively expanded use the := operator instead of the = operator.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-PREDEFINED             =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
-# tag can be used to specify a list of macro names that should be expanded. The
-# macro definition that is found in the sources will be used. Use the PREDEFINED
-# tag if you want to use a different macro definition that overrules the
-# definition found in the source code.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-EXPAND_AS_DEFINED      =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
-# remove all references to function-like macros that are alone on a line, have
-# an all uppercase name, and do not end with a semicolon. Such function macros
-# are typically used for boiler-plate code, and will confuse the parser if not
-# removed.
-# The default value is: YES.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-SKIP_FUNCTION_MACROS   = YES
-
-#---------------------------------------------------------------------------
-# Configuration options related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES tag can be used to specify one or more tag files. For each tag
-# file the location of the external documentation should be added. The format of
-# a tag file without this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where loc1 and loc2 can be relative or absolute paths or URLs. See the
-# section "Linking to external documentation" for more information about the use
-# of tag files.
-# Note: Each tag file must have a unique name (where the name does NOT include
-# the path). If a tag file is not located in the directory in which doxygen is
-# run, you must also specify the path to the tagfile here.
-
-TAGFILES               =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
-# tag file that is based on the input files it reads. See section "Linking to
-# external documentation" for more information about the usage of tag files.
-
-GENERATE_TAGFILE       =
-
-# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
-# the class index. If set to NO, only the inherited external classes will be
-# listed.
-# The default value is: NO.
-
-ALLEXTERNALS           = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will be
-# listed.
-# The default value is: YES.
-
-EXTERNAL_GROUPS        = YES
-
-# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
-# the related pages index. If set to NO, only the current project's pages will
-# be listed.
-# The default value is: YES.
-
-EXTERNAL_PAGES         = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of 'which perl').
-# The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH              = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
-# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
-# NO turns the diagrams off. Note that this option also works with HAVE_DOT
-# disabled, but it is recommended to install and use dot, since it yields more
-# powerful graphs.
-# The default value is: YES.
-
-CLASS_DIAGRAMS         = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see:
-# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH            =
-
-# You can include diagrams made with dia in doxygen documentation. Doxygen will
-# then run dia to produce the diagram and insert it in the documentation. The
-# DIA_PATH tag allows you to specify the directory where the dia binary resides.
-# If left empty dia is assumed to be found in the default search path.
-
-DIA_PATH               =
-
-# If set to YES the inheritance and collaboration graphs will hide inheritance
-# and usage relations if the target is undocumented or is not a class.
-# The default value is: YES.
-
-HIDE_UNDOC_RELATIONS   = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz (see:
-# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
-# Bell Labs. The other options in this section have no effect if this option is
-# set to NO
-# The default value is: NO.
-
-HAVE_DOT               = YES
-
-# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
-# to run in parallel. When set to 0 doxygen will base this on the number of
-# processors available in the system. You can set it explicitly to a value
-# larger than 0 to get control over the balance between CPU load and processing
-# speed.
-# Minimum value: 0, maximum value: 32, default value: 0.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_NUM_THREADS        = 0
-
-# When you want a differently looking font in the dot files that doxygen
-# generates you can specify the font name using DOT_FONTNAME. You need to make
-# sure dot is able to find the font, which can be done by putting it in a
-# standard location or by setting the DOTFONTPATH environment variable or by
-# setting DOT_FONTPATH to the directory containing the font.
-# The default value is: Helvetica.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_FONTNAME           = Helvetica
-
-# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
-# dot graphs.
-# Minimum value: 4, maximum value: 24, default value: 10.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_FONTSIZE           = 10
-
-# By default doxygen will tell dot to use the default font as specified with
-# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
-# the path where dot can find it using this tag.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_FONTPATH           =
-
-# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
-# each documented class showing the direct and indirect inheritance relations.
-# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-CLASS_GRAPH            = YES
-
-# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
-# graph for each documented class showing the direct and indirect implementation
-# dependencies (inheritance, containment, and class references variables) of the
-# class with other documented classes.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-COLLABORATION_GRAPH    = YES
-
-# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
-# groups, showing the direct groups dependencies.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-GROUP_GRAPHS           = YES
-
-# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-UML_LOOK               = NO
-
-# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
-# class node. If there are many fields or methods and many nodes the graph may
-# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
-# number of items for each type to make the size more manageable. Set this to 0
-# for no limit. Note that the threshold may be exceeded by 50% before the limit
-# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
-# but if the number exceeds 15, the total amount of fields shown is limited to
-# 10.
-# Minimum value: 0, maximum value: 100, default value: 10.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-UML_LIMIT_NUM_FIELDS   = 10
-
-# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
-# collaboration graphs will show the relations between templates and their
-# instances.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-TEMPLATE_RELATIONS     = NO
-
-# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
-# YES then doxygen will generate a graph for each documented file showing the
-# direct and indirect include dependencies of the file with other documented
-# files.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-INCLUDE_GRAPH          = YES
-
-# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
-# set to YES then doxygen will generate a graph for each documented file showing
-# the direct and indirect include dependencies of the file with other documented
-# files.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-INCLUDED_BY_GRAPH      = YES
-
-# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
-# dependency graph for every global function or class method.
-#
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-CALL_GRAPH             = YES
-
-# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
-# dependency graph for every global function or class method.
-#
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable caller graphs for selected
-# functions only using the \callergraph command.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-CALLER_GRAPH           = YES
-
-# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
-# hierarchy of all classes instead of a textual one.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-GRAPHICAL_HIERARCHY    = YES
-
-# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
-# dependencies a directory has on other directories in a graphical way. The
-# dependency relations are determined by the #include relations between the
-# files in the directories.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DIRECTORY_GRAPH        = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot.
-# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
-# to make the SVG files visible in IE 9+ (other browsers do not have this
-# requirement).
-# Possible values are: png, jpg, gif and svg.
-# The default value is: png.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_IMAGE_FORMAT       = png
-
-# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
-# enable generation of interactive SVG images that allow zooming and panning.
-#
-# Note that this requires a modern browser other than Internet Explorer. Tested
-# and working are Firefox, Chrome, Safari, and Opera.
-# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
-# the SVG files visible. Older versions of IE do not have SVG support.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-INTERACTIVE_SVG        = NO
-
-# The DOT_PATH tag can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_PATH               =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the \dotfile
-# command).
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOTFILE_DIRS           =
-
-# The MSCFILE_DIRS tag can be used to specify one or more directories that
-# contain msc files that are included in the documentation (see the \mscfile
-# command).
-
-MSCFILE_DIRS           =
-
-# The DIAFILE_DIRS tag can be used to specify one or more directories that
-# contain dia files that are included in the documentation (see the \diafile
-# command).
-
-DIAFILE_DIRS           =
-
-# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
-# path where java can find the plantuml.jar file. If left blank, it is assumed
-# PlantUML is not used or called during a preprocessing step. Doxygen will
-# generate a warning when it encounters a \startuml command in this case and
-# will not generate output for the diagram.
-
-PLANTUML_JAR_PATH      =
-
-# When using plantuml, the specified paths are searched for files specified by
-# the !include statement in a plantuml block.
-
-PLANTUML_INCLUDE_PATH  =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
-# that will be shown in the graph. If the number of nodes in a graph becomes
-# larger than this value, doxygen will truncate the graph, which is visualized
-# by representing a node as a red box. Note that doxygen if the number of direct
-# children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
-# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-# Minimum value: 0, maximum value: 10000, default value: 50.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_GRAPH_MAX_NODES    = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
-# generated by dot. A depth value of 3 means that only nodes reachable from the
-# root by following a path via at most 3 edges will be shown. Nodes that lay
-# further from the root node will be omitted. Note that setting this option to 1
-# or 2 may greatly reduce the computation time needed for large code bases. Also
-# note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-# Minimum value: 0, maximum value: 1000, default value: 0.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-MAX_DOT_GRAPH_DEPTH    = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not seem
-# to support this out of the box.
-#
-# Warning: Depending on the platform used, enabling this option may lead to
-# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
-# read).
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_TRANSPARENT        = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10) support
-# this, this feature is disabled by default.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_MULTI_TARGETS      = NO
-
-# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
-# explaining the meaning of the various boxes and arrows in the dot generated
-# graphs.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-GENERATE_LEGEND        = YES
-
-# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
-# files that are used to generate the various graphs.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_CLEANUP            = YES
diff --git a/pbio/CMakeLists.txt b/pbio/CMakeLists.txt
index e0dead6..ed5952c 100644
--- a/pbio/CMakeLists.txt
+++ b/pbio/CMakeLists.txt
@@ -26,7 +26,6 @@ list( APPEND pbio_src_files
   # this is not a complete list of headers, but they seem to be sufficient
   PBGroutines.h
   fileRead.h
-  fortint.h
   sizeRoutines.h
 )
 
diff --git a/pbio/PBGroutines.c b/pbio/PBGroutines.c
old mode 100755
new mode 100644
diff --git a/pbio/PBGroutines.h b/pbio/PBGroutines.h
old mode 100755
new mode 100644
diff --git a/pbio/blokex.F b/pbio/blokex.F
old mode 100755
new mode 100644
diff --git a/pbio/bufrgrib.h b/pbio/bufrgrib.h
old mode 100755
new mode 100644
diff --git a/pbio/emosnum.F b/pbio/emosnum.F
index 7abea50..abfef8a 100644
--- a/pbio/emosnum.F
+++ b/pbio/emosnum.F
@@ -75,7 +75,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
@@ -88,7 +88,7 @@ C
       CHARACTER*35 CMESS
       CHARACTER*20 YNUMBER
 C
-      DATA INUMBER/000411/, ICOUNT/0/
+      DATA INUMBER/000433/, ICOUNT/0/
       DATA CMESS/'* EMOSLIB version number = ****** *'/
 C
 C ------------------------------------------------------------------
diff --git a/pbio/extras.c b/pbio/extras.c
old mode 100755
new mode 100644
diff --git a/pbio/fileRead.h b/pbio/fileRead.h
old mode 100755
new mode 100644
diff --git a/pbio/fort2c.c b/pbio/fort2c.c
old mode 100755
new mode 100644
diff --git a/pbio/fort2c.h b/pbio/fort2c.h
old mode 100755
new mode 100644
diff --git a/pbio/fortint.h b/pbio/fortint.h
deleted file mode 100644
index 8c8f70e..0000000
--- a/pbio/fortint.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-#ifndef FORTINT_H
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#if defined hpR64 || defined hpiaR64
-#define fortint long long
-#else
-#define fortint long
-#endif
-#endif
-
-#endif /* end of  FORTINT_H */
diff --git a/pbio/fortran.h b/pbio/fortran.h
new file mode 100644
index 0000000..cc82ee6
--- /dev/null
+++ b/pbio/fortran.h
@@ -0,0 +1,44 @@
+/**
+* Copyright 1981-2012 ECMWF.
+*
+* This software is licensed under the terms of the Apache Licence
+* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+*
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
+* nor does it submit to any jurisdiction.
+*/
+#ifndef fortran_H
+#define fortran_H
+
+#include "common/fortint.h"
+
+
+fortint outrep_();
+fortint estima_();
+fortint gettru_();
+fortint setrep_(fortint*);
+fortint chkout_();
+fortint global_();
+fortint intf_(const char*, fortint*, fortfloat[], const char*, fortint*, fortfloat[]);
+fortint intout_(const char*, fortint[], fortfloat[], const char*, fortint, fortint);
+fortint intin_(const char*, fortint[], fortfloat[], const char*, fortint, fortint);
+fortint gasetup_( fortint isec1[], fortint isec2[], fortint isec3[], fortint isec4[], fortfloat rsec2[], fortfloat zsec3[]);
+fortint intuvy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+fortint intuvu_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+fortint intvecy_(fortfloat[], fortfloat[], fortint*, fortfloat[], fortfloat[], fortint*);
+
+fortint csect4_(fortfloat*,fortint*,fortint*,fortint*,fortint*,fortint*, fortint*,fortint*,fortint*);
+fortint iainit_(fortint*, fortint*);
+fortint igglat_(fortint*,fortfloat*,fortint*,fortint*);
+fortint ref2grb_(fortfloat*,fortint*,fortint*,fortint*);
+void clear_c_();
+void gbyte_(void*,void*,fortint*,fortint*);
+void grsmkp_(fortint*);
+void inscal_(fortfloat*,fortint*,fortint*,fortfloat*,fortfloat*,fortint*);
+void inxbit_(fortint*,fortint*,fortint*,fortint*,fortint*,fortint*,fortint*, char*,fortint*,long);
+void jgetgg_(fortint*,unsigned char*,fortfloat*,fortint*,fortint*,long);
+void jmakgg_(fortint*, fortint*, fortint*, fortfloat*, fortfloat*, fortint*);
+void jmakll_(fortint*, fortint*, fortfloat*, fortfloat*, fortfloat*, fortint*);
+
+#endif
diff --git a/pbio/gbyte.c b/pbio/gbyte.c
old mode 100755
new mode 100644
index 10f8103..796fa44
--- a/pbio/gbyte.c
+++ b/pbio/gbyte.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -15,9 +15,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
-#include "fortint.h"
+#include "common/fortint.h"
 
-/* 
+/*
 //  Retrieve or store arbitrary bit-size values from or to SWORD-bit words
 //
 //  Rewritten April 2000, J.D.Chambers, ECMWF.
@@ -64,7 +64,7 @@ void gbytes_(
   fortint *skipBetweenValues,
   fortint *numberOfValues) {
 /*
-//  GBYTES: 
+//  GBYTES:
 //
 //   Unpacks values from source to destination.
 //
@@ -112,7 +112,7 @@ void gbyte_(
   fortint *nextValueFirstBit,
   fortint *bitsPerValue) {
 /*
-//  GBYTE: 
+//  GBYTE:
 //
 //   Unpacks one value from source to destination.
 //
@@ -177,7 +177,7 @@ void sbytes_(
   fortint *skipBetweenValues,
   fortint *numberOfValues) {
 /*
-//  SBYTES: 
+//  SBYTES:
 //
 //   Packs values from source to destination.
 //
@@ -225,7 +225,7 @@ void sbyte_(
   fortint *nextValueFirstBit,
   fortint *bitsPerValue) {
 /*
-//  SBYTE: 
+//  SBYTE:
 //
 //   Packs one value from source to destination.
 //
diff --git a/pbio/grprs.h b/pbio/grprs.h
deleted file mode 100644
index dc4e010..0000000
--- a/pbio/grprs.h
+++ /dev/null
@@ -1,16 +0,0 @@
-C
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-C     Common blocks holding default or user supplied values for printing.
-C
-      LOGICAL GRPRSET
-      INTEGER GRPRSM
-C
-      COMMON /GRPRSCM/ GRPRSM, GRPRSET
diff --git a/pbio/lwsize.c b/pbio/lwsize.c
index 89b1229..45d7703 100644
--- a/pbio/lwsize.c
+++ b/pbio/lwsize.c
@@ -1,17 +1,17 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "fortint.h"
+#include "common/fortint.h"
 #include "fileRead.h"
 
 #define BUFFLEN 4096
diff --git a/pbio/mvchars.c b/pbio/mvchars.c
index d62b5ba..d0f2a8f 100644
--- a/pbio/mvchars.c
+++ b/pbio/mvchars.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "fortint.h"
+#include "common/fortint.h"
 
 fortint mvchars_(fortint * k, char * s, long ls) {
 /*
@@ -45,7 +45,7 @@ char * p = (char *) k;
 */
     for( loop = 0; loop <= last ; loop++ )
       *p++ = *(s+loop);
-  
+
     return (fortint) (last+1);
 }
 
diff --git a/pbio/newpbio.c b/pbio/newpbio.c
old mode 100755
new mode 100644
index d20e3ab..d6ff266
--- a/pbio/newpbio.c
+++ b/pbio/newpbio.c
@@ -1,20 +1,20 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 /*
-	newpbio.c
+  newpbio.c
 */
 #include "bufrgrib.h"
 #include "fort2c.h"
-#include "fortint.h"
+#include "common/fortint.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -45,19 +45,20 @@
 */
 void PBOPEN(FILE ** unit, _fcd name, _fcd mode, fortint * iret,
 if defined hpR64 || defined hpiaR64
-            long l1, long l2)
+            long l1, long l2
 #else
-            fortint l1, fortint l2)
+            fortint l1, fortint l2
 #endif
+        )
 /*
-* Purpose:	Opens file, return UNIX FILE pointer.
+* Purpose:               Opens file, return UNIX FILE pointer.
 *
 * Function returns:      iret:  -1 = Could not open file.
 *                               -2 = Invalid file name.
 *                               -3 = Invalid open mode specified
 *                                0 = OK.
 *
-*    Note: l1 and l2 are the lengths of the character strings in 
+*    Note: l1 and l2 are the lengths of the character strings in
 *          name and mode on SGI.
 */
 {
@@ -101,11 +102,11 @@ char namebuff[NAMEBUFFLEN], modebuff[MODEBUFFLEN];
     while(*p == ' ')
     {
         *p = 0;
-	p--;
+        p--;
     }
-		
+
     /* convert fortran to c string : open modes  */
-	
+
 #if (!defined CRAY) && (!defined VAX)
     if(!(modes = fcd2char(modebuff)))
 #else
@@ -176,15 +177,15 @@ char namebuff[NAMEBUFFLEN], modebuff[MODEBUFFLEN];
 void PBSEEK(FILE ** unit, fortint * offset, fortint * whence, fortint * iret)
 /*
 *
-* Purpose:	Seeks to specified location in file.
+* Purpose:              Seeks to specified location in file.
 *
-* Function returns:	status : 	-2 = error in handling file,
-*					-1 = end-of-file
+* Function returns:     status :        -2 = error in handling file,
+*                                       -1 = end-of-file
 *                       otherwise,         = byte offset from start of file.
 *
-*	whence	= 0, from start of file
-*		= 1, from current position
-*		= 2, from end of file.	
+*       whence  = 0, from start of file
+*               = 1, from current position
+*               = 2, from end of file.
 */
 {
 int my_offset = (int) *offset;
@@ -192,8 +193,8 @@ int my_whence = (int) *whence;
 int my_iret;
 
     if ( my_whence == 2) my_offset = - abs(my_offset);
-				/* must use negative offset if working
-				   from end-of-file	*/
+    /* must use negative offset if working
+       from end-of-file */
 
     my_iret = fseek(*unit, my_offset, my_whence);
 
@@ -201,24 +202,24 @@ int my_iret;
     {
         if ( ! feof(*unit) )
         {
-            my_iret = -2;		/* error in file-handling */
+            my_iret = -2;               /* error in file-handling */
             perror("pbseek");
         }
         else
-            my_iret = -1;		/* end-of-file	*/
+            my_iret = -1;               /* end-of-file */
 
         clearerr(*unit);
         *iret = (fortint) my_iret;
         return;
     }
 
-    my_iret = ftell(*unit);		/* byte offset from start of file */
+    my_iret = ftell(*unit);             /* byte offset from start of file */
     *iret = (fortint) my_iret;
     return;
 
 }
-		
- 
+
+
 /*************************************************************************
 *  FUNCTION:  pbread - Read (from FORTRAN)
 **************************************************************************
@@ -235,7 +236,7 @@ void PBREAD(FILE ** unit, char * buffer, fortint * nbytes, fortint * iret)
 {
 int my_nbytes = (int) *nbytes;
 int my_iret;
- 
+
     if ( (my_iret = fread(buffer, 1, my_nbytes, *unit) ) != my_nbytes)
     {
                                                 /*      Read problem */
@@ -253,9 +254,9 @@ int my_iret;
     }
     *iret = my_iret;
     return;
- 
+
 }
- 
+
 
 /*************************************************************************
 *  FUNCTION:  pbread2 - Read (from FORTRAN)
@@ -264,9 +265,9 @@ int my_iret;
 void PBREAD2(FILE ** unit, char * buffer, fortint * nbytes, fortint * iret)
 /*
 *
-* Purpose:	Reads a block of bytes from a file.
+* Purpose:      Reads a block of bytes from a file.
 *
-* Function returns:	      status : 	-2 = error in reading file,
+* Function returns:           status :  -2 = error in reading file,
 *                               otherwise, = number of bytes read.
 */
 {
@@ -275,17 +276,17 @@ int my_iret;
 
     if ( (my_iret = fread(buffer, 1, my_nbytes, *unit) ) != my_nbytes)
     {
-						/*	Read problem */
+                                      /* Read problem */
         if ( ! feof(*unit) )
         {
-            my_iret = -2;             /*  error in file-handling  */
+            my_iret = -2;             /* error in file-handling */
             perror("pbread");
             clearerr(*unit);
         }
     }
     *iret = my_iret;
     return;
- 
+
 }
 
 /*************************************************************************
@@ -294,9 +295,9 @@ int my_iret;
 */
 void PBWRITE( FILE ** unit, char * buffer, fortint * nbytes, fortint *iret)
 /*
-* Purpose:	Writes a block of bytes to a file.
+* Purpose:      Writes a block of bytes to a file.
 *
-* Function returns:	     status : -1 = Could not write to file.
+* Function returns:          status : -1 = Could not write to file.
 *                                    >=0 = Number of bytes written.
 */
 {
@@ -304,13 +305,14 @@ int my_nbytes = (int) *nbytes;
 int my_iret;
 
     if ( (my_iret = fwrite(buffer, 1, my_nbytes, *unit) ) != my_nbytes)
-    {				/* Problem with write */   
+    {
+        /* Problem with write */
         perror("pbwrite");
         my_iret = -1;
     }
     *iret = my_iret;
     return;
-    
+
 }
 
 
@@ -322,10 +324,10 @@ int my_iret;
 void PBCLOSE( FILE ** unit, fortint * iret)
 /*
 *
-* Purpose:	Closes file.
+* Purpose:      Closes file.
 *
-* Function returns:	     status : non-0 = error in handling file.
-*                                     	  0 = OK.
+* Function returns:          status : non-0 = error in handling file.
+*                                         0 = OK.
 */
 {
 int my_iret;
@@ -346,7 +348,7 @@ int my_iret;
 void PBFLUSH( FILE ** unit)
 /*
 *
-* Purpose:	Flushes file.
+* Purpose:      Flushes file.
 *
 */
 {
@@ -365,7 +367,7 @@ void PBREAD3(fortint  *unit, char * buffer, fortint * nbytes, fortint * iret)
 *                               otherwise, = number of bytes read.
 */
 {
- 
+
     *iret = read(*unit, buffer, *nbytes);
 
                                                 /*      Read problem */
@@ -382,9 +384,9 @@ void PBREAD3(fortint  *unit, char * buffer, fortint * nbytes, fortint * iret)
         *nbytes,*iret);
         return;
     }
- 
+
 }
- 
+
 static oct_bin3(int onum)
 {
    char tmp[20];
@@ -392,7 +394,7 @@ static oct_bin3(int onum)
 
    sprintf(tmp,"%d",onum);
    sscanf(tmp,"%o",&rc);
-   return rc; 
+   return rc;
 }
 void PBOPEN3(fortint *unit, _fcd name, _fcd mode, fortint * iret,
             fortint l1, fortint l2)
@@ -404,7 +406,7 @@ void PBOPEN3(fortint *unit, _fcd name, _fcd mode, fortint * iret,
 *                               -3 = Invalid open mode specified
 *                                0 = OK.
 *
-*    Note: l1 and l2 are the lengths of the character strings in 
+*    Note: l1 and l2 are the lengths of the character strings in
 *          name and mode on SGI.
 */
 {
@@ -451,9 +453,9 @@ char namebuff[NAMEBUFFLEN], modebuff[MODEBUFFLEN];
         *p = 0;
     p--;
     }
-            
+
     /* convert fortran to c string : open modes  */
-    
+
 #if (!defined CRAY) && (!defined VAX)
     if(!(modes = fcd2char(modebuff)))
 #else
@@ -543,7 +545,7 @@ void PBSEEK3(fortint * unit, fortint * offset, fortint * whence, fortint * iret)
 *
 *   whence  = 0, from start of file
 *           = 1, from current position
-*           = 2, from end of file.  
+*           = 2, from end of file.
 */
 {
 fortint my_offset = *offset;
@@ -562,7 +564,7 @@ int my_whence;
     {
          my_whence = 1;
     }
-     
+
                             /* must use negative offset if working
                                from end-of-file     */
 
@@ -573,7 +575,7 @@ int my_whence;
    }
 
 }
-            
+
 void PBWRITE3( fortint * unit, char * buffer, fortint * nbytes, fortint *iret)
 /*
 * Purpose:  Writes a block of bytes to a file.
diff --git a/pbio/pbbufr.F b/pbio/pbbufr.F
old mode 100755
new mode 100644
diff --git a/pbio/pbcrex.F b/pbio/pbcrex.F
old mode 100755
new mode 100644
diff --git a/pbio/pbgrib.F b/pbio/pbgrib.F
old mode 100755
new mode 100644
diff --git a/pbio/pbio.c b/pbio/pbio.c
old mode 100755
new mode 100644
index ad29eed..c5b6704
--- a/pbio/pbio.c
+++ b/pbio/pbio.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -58,7 +58,7 @@ static int debugSet = 0;
 
 #include "bufrgrib.h"
 #include "fort2c.h"
-#include "fortint.h"
+#include "common/fortint.h"
 #include "fileRead.h"
 
 #define NAMEBUFFLEN 256
@@ -85,7 +85,7 @@ void pbopen_(fortint* unit,_fcd name,_fcd mode,fortint* iret,fortint l1,fortint
 #endif
 /*
 // Purpose:
-//  Opens file, returns the index of a UNIX FILE pointer held in 
+//  Opens file, returns the index of a UNIX FILE pointer held in
 //  an internal table (fptable).
 //
 // First time through, reads value in environment variable PBIO_BUFSIZE
@@ -149,7 +149,7 @@ char * namebuff, * modebuff;
 
       n1 = (l1>NAMEBUFFLEN) ? NAMEBUFFLEN : l1;
       n2 = (l2>MODEBUFFLEN) ? MODEBUFFLEN : l2;
-   
+
       strncpy( namebuff, name, n1);
       strncpy( modebuff, mode, n2);
       namebuff[n1] = '\0';
@@ -381,7 +381,7 @@ void pbseek_(fortint* unit,fortint* offset,fortint* whence,fortint* iret) {
 //
 //    whence  = 0, from start of file
 //            = 1, from current position
-//            = 2, from end of file.  
+//            = 2, from end of file.
 //
 //  Returns:
 //    iret:
@@ -395,7 +395,7 @@ int my_whence = (int) *whence;
 /*
 // Must use negative offset if working from end-of-file
 */
-    if( DEBUG ) { 
+    if( DEBUG ) {
       printf("PBIO_PBSEEK: fptable slot = %d\n", *unit);
       printf("PBIO_PBSEEK: Offset = %d\n", my_offset);
       printf("PBIO_PBSEEK: Type of offset = %d\n", my_whence);
@@ -661,7 +661,7 @@ void pbread_(fortint* unit,char* buffer,fortint* nbytes,fortint* iret) {
 
     return;
 }
- 
+
 void pbread(fortint* unit,char* buffer,fortint* nbytes,fortint* iret) {
 
   pbread_(unit,buffer,nbytes,iret);
@@ -796,7 +796,7 @@ void pbclose(fortint* unit,fortint* iret) {
 */
 void pbflush_(fortint * unit) {
 /*
-// Purpose:	Flushes file.
+// Purpose:     Flushes file.
 */
     if( DEBUG )
       printf("PBIO_FLUSH: fptable slot = %d\n", *unit);
@@ -848,9 +848,9 @@ void pbread3_(fortint* unit,char* buffer,fortint* nbytes,fortint* iret) {
       *iret = -1;
       return;
     }
- 
+
 }
- 
+
 void pbread3(fortint* unit,char* buffer,fortint* nbytes,fortint* iret) {
 
   pbread3_(unit,buffer,nbytes,iret);
@@ -878,15 +878,15 @@ size_t pos    = 0;
 
    while((left > 0) && (len = read(*unit,(buffer+pos),chunk)) > 0)
    {
-	left -= len;
-	pos += len;
-	if(left < chunk)
-		chunk = left;
+       left -= len;
+       pos += len;
+       if(left < chunk)
+           chunk = left;
    }
    if(len>0)
-	*iret = pos;
+       *iret = pos;
    else
-	*iret = len;
+       *iret = len;
 
     if( DEBUG )
          printf("PBIO_READ4: number of bytes READ = %ld\n", pos);
@@ -907,7 +907,7 @@ size_t pos    = 0;
     }
       printf("PBIO_READ4: number of bytes read = %ld\n", pos);
       printf("PBIO_READ4: return code *iret = %ld\n", *iret);
- 
+
 }
 
 void pbread4(fortint* unit,char* buffer,size_t* nbytes,size_t* iret) {
@@ -948,9 +948,9 @@ void pbread5_(fortint* unit,char* buffer,size_t* nbytes,size_t* iret) {
       *iret = -1;
       return;
     }
- 
+
 }
- 
+
 void pbread5(fortint* unit,char* buffer,size_t* nbytes,size_t* iret) {
   pbread5_(unit,buffer,nbytes,iret);
 }
@@ -969,7 +969,7 @@ static int oct_bin3(int onum) {
 
    sprintf(tmp,"%d",onum);
    sscanf(tmp,"%o",&rc);
-   return rc; 
+   return rc;
 }
 
 /*
@@ -988,7 +988,7 @@ void pbopen3_(fortint* unit,_fcd name,_fcd mode,fortint* iret,fortint l1,fortint
 //          -3 = Invalid open mode specified
 //           0 = OK.
 //
-// Note: l1 and l2 are the lengths of the character strings in 
+// Note: l1 and l2 are the lengths of the character strings in
 //       name and mode on SGI.
 */
 char *p;
@@ -1035,7 +1035,7 @@ char * namebuff, * modebuff;
 
       n1 = (l1>NAMEBUFFLEN) ? NAMEBUFFLEN : l1;
       n2 = (l2>MODEBUFFLEN) ? MODEBUFFLEN : l2;
-   
+
       strncpy( namebuff, name, n1);
       strncpy( modebuff, mode, n2);
       namebuff[n1] = '\0';
@@ -1068,7 +1068,7 @@ char * namebuff, * modebuff;
       p--;
     }
     if( DEBUG ) printf("PBIO_PBOPEN: filename = %s\n", namebuff);
-            
+
 /*
 // Build open flags from "modes"
 */
@@ -1077,14 +1077,14 @@ char * namebuff, * modebuff;
     switch(*p) {
 
       case 'a':
-      case 'A': oflag = 0x100 | 2 | 0x08;
+      case 'A': oflag = 0x100 | O_CREAT | 2 | 0x08;
                 filemode = 766;
                 break;
 
       case 'c':
       case 'C':
       case 'w':
-      case 'W': oflag = 0x100 | 1;
+      case 'W': oflag = 0x100 | O_CREAT | 1;
                 filemode = 766;
                 break;
 
@@ -1167,11 +1167,11 @@ void pbseek3_(fortint* unit,fortint* offset,fortint* whence,fortint* iret) {
 //
 //   whence  = 0, from start of file
 //           = 1, from current position
-//           = 2, from end of file.  
+//           = 2, from end of file.
 */
 fortint my_offset = *offset;
 int my_whence;
-	
+
     if( DEBUG ) {
       printf("PBIO_PBSEEK3: file pointer = %0x\n", *unit);
       printf("PBIO_PBSEEK3: offset = %d\n", my_offset);
@@ -1203,7 +1203,7 @@ int my_whence;
       printf("PBIO_PBSEEK3: byte offset from start of file = %d\n",*iret);
 
 }
-            
+
 void pbseek3(fortint* unit,fortint* offset,fortint* whence,fortint* iret) {
 
   pbseek3_(unit,offset,whence,iret);
@@ -1397,7 +1397,7 @@ long offset, loop = 1;
       return;
     }
 /*
-//  If the smallish buffer is too small, progressively increase it until 
+//  If the smallish buffer is too small, progressively increase it until
 //  big enough
 */
     while ( iret == -4 ) {
@@ -1513,7 +1513,7 @@ char PlPlCrCrLf7777[10] = {0x2b,0x2b,0x0d,0x0d,0x0a,0x37,0x37,0x37,0x37,0x00};
     return;
   }
   endBuffer = buffer + number + 3;
-    
+
 /*
 // Look for ++CrCrLf7777 at end of product
 */
@@ -1535,7 +1535,7 @@ char PlPlCrCrLf7777[10] = {0x2b,0x2b,0x0d,0x0d,0x0a,0x37,0x37,0x37,0x37,0x00};
   }
 
   if( !endFound ) {
-    if( feof(CURRENT_FILE) ) 
+    if( feof(CURRENT_FILE) )
       *status = END_OF_FILE;
     else
       *status = USER_BUFFER_TOO_SMALL;
diff --git a/pbio/pbio_alpha.c b/pbio/pbio_alpha.c
index 52a98c4..3be7a52 100644
--- a/pbio/pbio_alpha.c
+++ b/pbio/pbio_alpha.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -17,7 +17,7 @@ static FILE** fptable = NULL;
 static int fptableSize = 0;
 #define BUFFLEN 4096
 
-#include "fortint.h"
+#include "common/fortint.h"
 #include "fileRead.h"
 
 /*
@@ -25,7 +25,7 @@ static int fptableSize = 0;
 */
 #include "fort2c.h"
 #include "bufrgrib.h"
- 
+
 #define NAMEBUFFLEN 256
 #define MODEBUFFLEN 10
 
@@ -36,7 +36,7 @@ static int fptableSize = 0;
 void PBOPEN(fortint* unit, _fcd name, _fcd mode, fortint* iret, int l1, int l2){
 /*
 // Purpose:
-//  Opens file, returns the index of a UNIX FILE pointer held in 
+//  Opens file, returns the index of a UNIX FILE pointer held in
 //  an internal table (fptable).
 //
 //  Function  accepts:
@@ -92,7 +92,7 @@ int n;
       if(*p == ' ') *p = 0;
       p++;
     }
-                
+
 /*
 // Convert Fortran to C string: open modes.
 */
@@ -204,7 +204,7 @@ void PBSEEK(fortint* unit, fortint* offset, fortint* whence, fortint* iret) {
 //
 //    whence  = 0, from start of file
 //            = 1, from current position
-//            = 2, from end of file.  
+//            = 2, from end of file.
 //
 //  Returns:
 //    iret:
@@ -248,7 +248,7 @@ fortint my_whence;
 
     return;
 }
- 
+
 /*************************************************************************
 *  FUNCTION:  pbread_ - Read (from FORTRAN)
 **************************************************************************
@@ -285,7 +285,7 @@ void PBREAD(fortint* unit, char * buffer, fortint* nbytes, fortint* iret) {
 
     return;
 }
- 
+
 /*************************************************************************
 *  FUNCTION:  pbread2_ - Read (from FORTRAN)
 **************************************************************************
@@ -480,7 +480,7 @@ FILE *in = fptable[*unit];
       return;
     }
 /*
-// If the smallish buffer is too small, progressively increase it until 
+// If the smallish buffer is too small, progressively increase it until
 // big enough */
 
   while ( iret == -4 ) {
@@ -527,7 +527,7 @@ void PBREAD3(fortint  *unit, char * buffer, fortint * nbytes, fortint * iret)
 *                               otherwise, = number of bytes read.
 */
 {
- 
+
     *iret = read(*unit, buffer, *nbytes);
 
                                                 /*      Read problem */
@@ -544,9 +544,9 @@ void PBREAD3(fortint  *unit, char * buffer, fortint * nbytes, fortint * iret)
         *nbytes,*iret);
         return;
     }
- 
+
 }
- 
+
 static oct_bin3(int onum)
 {
    char tmp[20];
@@ -554,7 +554,7 @@ static oct_bin3(int onum)
 
    sprintf(tmp,"%d",onum);
    sscanf(tmp,"%o",&rc);
-   return rc; 
+   return rc;
 }
 void PBOPEN3(fortint *unit, _fcd name, _fcd mode, fortint * iret,
             fortint l1, fortint l2)
@@ -566,7 +566,7 @@ void PBOPEN3(fortint *unit, _fcd name, _fcd mode, fortint * iret,
 *                               -3 = Invalid open mode specified
 *                                0 = OK.
 *
-*    Note: l1 and l2 are the lengths of the character strings in 
+*    Note: l1 and l2 are the lengths of the character strings in
 *          name and mode on SGI.
 */
 {
@@ -613,9 +613,9 @@ char namebuff[NAMEBUFFLEN], modebuff[MODEBUFFLEN];
         *p = 0;
     p--;
     }
-            
+
     /* convert fortran to c string : open modes  */
-    
+
 #if (!defined CRAY) && (!defined VAX)
     if(!(modes = fcd2char(modebuff)))
 #else
@@ -705,7 +705,7 @@ void PBSEEK3(fortint * unit, fortint * offset, fortint * whence, fortint * iret)
 *
 *   whence  = 0, from start of file
 *           = 1, from current position
-*           = 2, from end of file.  
+*           = 2, from end of file.
 */
 {
 fortint my_offset = *offset;
@@ -724,7 +724,7 @@ int my_whence;
     {
          my_whence = 1;
     }
-     
+
                             /* must use negative offset if working
                                from end-of-file     */
 
@@ -735,7 +735,7 @@ int my_whence;
    }
 
 }
-            
+
 void PBWRITE3( fortint * unit, char * buffer, fortint * nbytes, fortint *iret)
 /*
 * Purpose:  Writes a block of bytes to a file.
diff --git a/pbio/pbionum.F b/pbio/pbionum.F
index 388e094..30572f2 100644
--- a/pbio/pbionum.F
+++ b/pbio/pbionum.F
@@ -75,7 +75,7 @@ C
 C
       IMPLICIT NONE
 C
-#include "grprs.h"
+#include "common/grprs.h"
 C
 C     Function arguments
 C
diff --git a/pbio/pbpseu.F b/pbio/pbpseu.F
old mode 100755
new mode 100644
diff --git a/pbio/pbsize.c b/pbio/pbsize.c
index 57722c0..48a07d0 100644
--- a/pbio/pbsize.c
+++ b/pbio/pbsize.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -15,7 +15,7 @@
 #include <unistd.h>
 #endif
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 
 #define BUFFLEN 4096
 
@@ -54,14 +54,14 @@ long offset, loop = 1;
         return;
     }
 
-/*  If the smallish buffer is too small, progressively increase it until 
+/*  If the smallish buffer is too small, progressively increase it until
     big enough */
 
     while ( iret == -4 )
     {
         loop++;
         buff = (char *) malloc( BUFFLEN*loop);
-        if( buff == NULL) 
+        if( buff == NULL)
         {
             perror("malloc failed in PBSIZE");
             *plen = -2;
@@ -79,7 +79,7 @@ long offset, loop = 1;
         printf("readprod error %d\n", iret);
         *plen = -2;
     }
-        
+
 /*  Put the file pointer back where it started */
 
     offset = (fortint) fileSeek( *in, offset, SEEK_SET);
diff --git a/pbio/readany.c b/pbio/readany.c
index dcd2ba2..a1ed176 100644
--- a/pbio/readany.c
+++ b/pbio/readany.c
@@ -1,19 +1,19 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 /*
-	readany.c
+  readany.c
 */
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 
 #ifndef NULL
 #define NULL 0
@@ -29,7 +29,7 @@ fortint readany(FILE * file, char * buffer, fortint * prod_len)
 
     buffer        = buffer big enough to hold the product
 
-    prod_len      = size of the buffer on input, becomes size in BYTES of 
+    prod_len      = size of the buffer on input, becomes size in BYTES of
                     the product read.  If the end-of-file is hit, the
                     value is returned unchanged (ie. when the function return
                     code is -1).
@@ -40,8 +40,8 @@ fortint readany(FILE * file, char * buffer, fortint * prod_len)
 
        -1  if end-of-file is hit before a product is read
 
-       -2  if there is an error in the file-handling 
-	   (eg. if the file contains a truncated product)
+       -2  if there is an error in the file-handling
+           (eg. if the file contains a truncated product)
 
        -3  if the size of buffer is not sufficient for the product
 
diff --git a/pbio/readbufr.c b/pbio/readbufr.c
old mode 100755
new mode 100644
index 39bac41..ea0790b
--- a/pbio/readbufr.c
+++ b/pbio/readbufr.c
@@ -1,19 +1,19 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 /*
-	readbufr.c
+  readbufr.c
 */
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 
 #include "fileRead.h"
 
@@ -25,7 +25,7 @@ fortint readbufr(FILE * file, char * buffer, fortint * bufr_prod_len)
 
     buffer        = buffer big enough to hold the BUFR product
 
-    bufr_prod_len = size of the buffer on input, becomes size in BYTES of 
+    bufr_prod_len = size of the buffer on input, becomes size in BYTES of
                     the BUFR product read.  If the end-of-file is hit, the
                     value is returned unchanged (ie. when the function return
                     code is -1).
@@ -36,8 +36,8 @@ fortint readbufr(FILE * file, char * buffer, fortint * bufr_prod_len)
 
        -1  if end-of-file is hit before a BUFR product is read
 
-       -2  if there is an error in the file-handling 
-	   (eg. if the file contains a truncated BUFR product)
+       -2  if there is an error in the file-handling
+           (eg. if the file contains a truncated BUFR product)
 
        -3  if the size of buffer is not sufficient for the BUFR product
 
diff --git a/pbio/readcrex.c b/pbio/readcrex.c
old mode 100755
new mode 100644
index a3f4431..a8cc24e
--- a/pbio/readcrex.c
+++ b/pbio/readcrex.c
@@ -1,19 +1,19 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 /*
-	readcrex.c
+  readcrex.c
 */
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 #include "fileRead.h"
 #include "sizeRoutines.h"
 
@@ -24,7 +24,7 @@ fortint readcrex(FILE * file, char * buffer, fortint * crex_prod_len)
 
     buffer        = buffer big enough to hold the CREX product
 
-    crex_prod_len = size of the buffer on input, becomes size in BYTES of 
+    crex_prod_len = size of the buffer on input, becomes size in BYTES of
                     the CREX product read.  If the end-of-file is hit, the
                     value is returned unchanged (ie. when the function return
                     code is -1).
@@ -35,8 +35,8 @@ fortint readcrex(FILE * file, char * buffer, fortint * crex_prod_len)
 
        -1  if end-of-file is hit before a CREX product is read
 
-       -2  if there is an error in the file-handling 
-	   (eg. if the file contains a truncated CREX product)
+       -2  if there is an error in the file-handling
+           (eg. if the file contains a truncated CREX product)
 
        -3  if the size of buffer is not sufficient for the CREX product
 
diff --git a/pbio/readgrib.c b/pbio/readgrib.c
old mode 100755
new mode 100644
index 91ad249..57107e8
--- a/pbio/readgrib.c
+++ b/pbio/readgrib.c
@@ -1,19 +1,19 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 /*
-	readgrib.c
+  readgrib.c
 */
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 
 #include "fileRead.h"
 
@@ -27,7 +27,7 @@ fortint readgrib(FILE * file, char * buffer, fortint * grib_prod_len)
 
     buffer        = buffer big enough to hold the GRIB product
 
-    grib_prod_len = size of the buffer on input, becomes size in BYTES of 
+    grib_prod_len = size of the buffer on input, becomes size in BYTES of
                     the GRIB product read.  If the end-of-file is hit, the
                     value is returned unchanged (ie. when the function return
                     code is -1).
@@ -38,8 +38,8 @@ fortint readgrib(FILE * file, char * buffer, fortint * grib_prod_len)
 
        -1  if end-of-file is hit before a GRIB product is read
 
-       -2  if there is an error in the file-handling 
-	   (eg. if the file contains a truncated GRIB product)
+       -2  if there is an error in the file-handling
+           (eg. if the file contains a truncated GRIB product)
 
        -3  if the size of buffer is not sufficient for the GRIB product
 
diff --git a/pbio/readnext.c b/pbio/readnext.c
old mode 100755
new mode 100644
index 761dea0..46e2104
--- a/pbio/readnext.c
+++ b/pbio/readnext.c
@@ -1,19 +1,19 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
 /*
-	readnext.c
+  readnext.c
 */
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 
 #ifndef NULL
 #define NULL 0
@@ -22,22 +22,22 @@
 #include "fileRead.h"
 
 
-fortint readnext(char * buffer, fortint * grib_prod_len, 
+fortint readnext(char * buffer, fortint * grib_prod_len,
               fortint (*read_func)(char *, fortint , void *), void * stream)
 /*
 
     buffer        = buffer big enough to hold the next product.
-                    If buffer = NULL, the function will return the 
+                    If buffer = NULL, the function will return the
                     length of the product, but not the product itself.
 
-    grib_prod_len = size of the buffer on input, becomes size in BYTES of 
+    grib_prod_len = size of the buffer on input, becomes size in BYTES of
                     the next product read.  If the end-of-file is hit, the
                     value is returned unchanged (ie. when the function return
                     code is -1).
 
     read_func     = function to read input stream
 
-    stream        = data for read_function, eg. file pointer returned 
+    stream        = data for read_function, eg. file pointer returned
                     from PBOPEN
 
     Function returns:
@@ -46,8 +46,8 @@ fortint readnext(char * buffer, fortint * grib_prod_len,
 
        -1  if end-of-file is hit before a product is read
 
-       -2  if there is an error in the file-handling 
-	   (eg. if the file contains a truncated product)
+       -2  if there is an error in the file-handling
+           (eg. if the file contains a truncated product)
 
        -3  if the size of buffer is not sufficient for the product
 
diff --git a/pbio/readprod.c b/pbio/readprod.c
old mode 100755
new mode 100644
index 5ca4f5e..b946893
--- a/pbio/readprod.c
+++ b/pbio/readprod.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -28,7 +28,7 @@
 #endif
 
 #include "bufrgrib.h"
-#include "fortint.h"
+#include "common/fortint.h"
 #include "fileRead.h"
 #include "sizeRoutines.h"
 
@@ -63,13 +63,13 @@ static int grab(char * , char * , long ,long ,long * );
 static fortint waveLength(char * );
 
 #ifdef FOPEN64
-fortint readprod( char * prod_id, char * buffer, fortint * size, 
+fortint readprod( char * prod_id, char * buffer, fortint * size,
               fortint (*fileRead)(char *, fortint , void *),
               OFF_T (*fileSeek)(void *, OFF_T, fortint),
               OFF_T (*fileTell)(void *),
               void * stream)
 #else
-fortint readprod( char * prod_id, char * buffer, fortint * size, 
+fortint readprod( char * prod_id, char * buffer, fortint * size,
               fortint (*fileRead)(char *, fortint , void *),
               fortint (*fileSeek)(void *, fortint, fortint),
               fortint (*fileTell)(void *),
@@ -88,7 +88,7 @@ fortint readprod( char * prod_id, char * buffer, fortint * size,
 //             the product byte stream,
 //  stream = data describing the input stream (eg. FILE *).
 //
-//  Returns 
+//  Returns
 //    -1 if can't find product  (eg. end-of-file)
 //    -2 if internal processing error (malloc fail, file seek error)
 //    -3 if buffer too small for whole product.
@@ -163,7 +163,7 @@ fortint one = 1;
   if( prodlen == -4 ) return USER_BUFFER_TINY;
 
   if( prodlen < -4 ) {           /* special case for very large wave products */
-    fortint estimate; 
+    fortint estimate;
 
     estimate = -prodlen;
     prodlen = estimate - 128;
@@ -315,7 +315,7 @@ const char* big_prod_flag = NULL;
 /* See if the GRIB version is 0 ...
 */
   if ( THREE_BYTE_LONG(phold+4) == 24 ) {
-    length = 28;		     /* GRIB + section 1 */
+    length = 28;                   /* GRIB + section 1 */
 
 /* Check for presence of sections 2 and 3
 */
@@ -324,11 +324,11 @@ const char* big_prod_flag = NULL;
 
 /* Add up all lengths of sections
 */
-    return lentotal(hold, holdsize, leng, length, section2, section3, 
+    return lentotal(hold, holdsize, leng, length, section2, section3,
                     fileRead, stream);
   }
 
-  
+
 /* ... or version 2 ...
 */
 if ( hold[7] == 2 ){
@@ -340,13 +340,13 @@ if ( hold[7] == 2 ){
   if ( ( hold[21] != 0 ) || ( hold[22] != 0 ) ) {
 
 /* Nightmare fixup for very large GRIB products (eg 2D wave spectra).
-  
+
    If the most-significant of the 24 bits is set, this indicates a
    very large product; the size has to be rescaled by a factor of 120.
    This is a fixup to get round the GRIB code practice of representing
    a product length by 24 bits. It is only possible because the
    (default) rounding for GRIB products is 120 bytes.
-  
+
 */
     fortint fixlen;
 
@@ -357,15 +357,15 @@ if ( hold[7] == 2 ){
     {
       fortint largeLen;
       unsigned long code = 0;
-      
-	  big_prod_flag = getenv("ECMWF_CODED_BIG_PRODUCT");  
+
+      big_prod_flag = getenv("ECMWF_CODED_BIG_PRODUCT");
       if(big_prod_flag)
          if(strcmp(big_prod_flag,"OFF") == 0) return fixlen;
-      
+
       fixlen = (fixlen & 0x7fffff)*120;  /* first guess at length */
-     
+
       num = fixlen;
-    
+
       if( leng < num ) { /* -unsure - apparently test is given buffer is too small */
         num = fixlen - 128;
         numread = fileRead( hold + hsize, leng - hsize, stream);
@@ -377,28 +377,30 @@ if ( hold[7] == 2 ){
         return (-fixlen);
       }
       else {
-		  fortint fileReadResult =0;
+        fortint fileReadResult =0;
         if ( hsize < num) { /* buffer is big enough */
-	  /* go to the estimate minus 128 bytes to look after the 7777*/
+
+          /* go to the estimate minus 128 bytes to look after the 7777*/
           numread = fileRead( hold + hsize, num - hsize - 128, stream);
 
           if ( numread <= 0 ) {          /* eg. on END_OF_FILE */
             *holdsize -= numread;
             return *holdsize;
           }
-        	  /* search byte after byte for the 7777 in the stream and stop when found*/
-  		  do {
-		     if (num<numread) return MISPLACED_7777;
-		     fileReadResult = fileRead( hold + numread + hsize, 1, stream);
-		      
-		      if ( fileReadResult <= 0 ) {          /* eg. on END_OF_FILE ---should not happen*/
- 		           *holdsize += numread;
-			   *holdsize -= fileReadResult;
- 		           return *holdsize; /*returns the number of bytes actually read */
- 		      }     
- 		     numread += fileReadResult;
- 		     code = ( (code << 8) + hold[hsize + numread-1] ) & 0xFFFFFFFF;
-		    } while ( code != CODE_7777 );
+
+          /* search byte after byte for the 7777 in the stream and stop when found*/
+          do {
+            if (num<numread) return MISPLACED_7777;
+            fileReadResult = fileRead( hold + numread + hsize, 1, stream);
+
+            if ( fileReadResult <= 0 ) {          /* eg. on END_OF_FILE ---should not happen*/
+                 *holdsize += numread;
+                 *holdsize -= fileReadResult;
+                 return *holdsize; /*returns the number of bytes actually read */
+            }
+            numread += fileReadResult;
+            code = ( (code << 8) + hold[hsize + numread-1] ) & 0xFFFFFFFF;
+          } while ( code != CODE_7777 );
           hsize = numread;
         }
         *holdsize = hsize;
@@ -412,7 +414,7 @@ if ( hold[7] == 2 ){
 
   }
 
-  length = 24;		     /* GRIB + section 1 */
+  length = 24;                     /* GRIB + section 1 */
 
 /* Check for presence of sections 2 and 3
 */
@@ -421,7 +423,7 @@ if ( hold[7] == 2 ){
 
 /* Add up all lengths of sections
 */
-  return lentotal(hold, holdsize, leng, length, section2, section3, 
+  return lentotal(hold, holdsize, leng, length, section2, section3,
                     fileRead, stream);
 
 }
@@ -464,7 +466,7 @@ fortint next, next_sec = 4;
       return *holdsize;
     }
     hsize = length;
-  } 
+  }
   *holdsize = hsize;
 
 /* Get the size of remaining sections
@@ -478,7 +480,7 @@ fortint next, next_sec = 4;
         return *holdsize;
       }
       hsize = length + 4;
-    } 
+    }
     *holdsize = hsize;
     length += THREE_BYTE_LONG(phold+length);
   }
@@ -532,7 +534,7 @@ fortint next, next_sec = 3;
    adding up the lengths
 */
 
-/* Add on the length of section 1 and ensure enough of product is in 
+/* Add on the length of section 1 and ensure enough of product is in
    memory to continue
 */
   length = SECT_0_LEN + THREE_BYTE_LONG(phold+4);
@@ -545,7 +547,7 @@ fortint next, next_sec = 3;
     }
     hsize = length + 4;
     *holdsize = hsize;
-  } 
+  }
 
 /* Check for presence of section 2
 */
@@ -564,7 +566,7 @@ fortint next, next_sec = 3;
       }
       hsize = length + 4;
       *holdsize = hsize;
-    } 
+    }
   }
 
 /* Add on the size of section 5
@@ -610,7 +612,7 @@ fortint num, length;
 /* Have to step through individual sections adding up the lengths
 */
 
-/* Add on the length of section 1 and ensure enough of product is in 
+/* Add on the length of section 1 and ensure enough of product is in
    memory to continue
 */
   length = SECT_0_LEN + THREE_BYTE_LONG(phold+4);
@@ -623,7 +625,7 @@ fortint num, length;
     }
     hsize = length + 4;
     *holdsize = hsize;
-  } 
+  }
 
 /* Get the size of remaining section
 */
@@ -637,7 +639,7 @@ fortint num, length;
   return length;
 }
 
-static fortint prodsize(fortint code, char * hold, fortint leng, fortint * holdsize, 
+static fortint prodsize(fortint code, char * hold, fortint leng, fortint * holdsize,
                      fortint (*fileRead)(), void * stream)
 /*
 //  Returns size of BUFR, GRIB, BUDG, TIDE, DIAG product in bytes.
@@ -652,7 +654,7 @@ static fortint prodsize(fortint code, char * hold, fortint leng, fortint * holds
 long lcode = code;
 
   *holdsize = 4;
-  switch( lcode ) 
+  switch( lcode )
   {
      case BUFR: memcpy(hold,"BUFR",4);
                 return bufrsize( hold, leng, holdsize, fileRead, stream);
@@ -775,9 +777,9 @@ long s0;
     if( grab(buffer, size, 3, 1, &bytes_read) != 0) return (-1);
     section4 = THREE_BYTE_LONG(size);
     /*  If it happens that the section 2 is not the difference of bytes
-        between the real message length and the coded message length, that mean that 
-        the 120 trick is not used, if so return the real length   */ 
-     if(section4 > 120 ) 
+        between the real message length and the coded message length, that mean that
+        the 120 trick is not used, if so return the real length   */
+     if(section4 > 120 )
        return rtotal;
     section4 = total + 3 - bytes_read - section4;
 
diff --git a/pbio/readprod_alpha.c b/pbio/readprod_alpha.c
old mode 100755
new mode 100644
index 0a92c2b..92d02a3
--- a/pbio/readprod_alpha.c
+++ b/pbio/readprod_alpha.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -44,13 +44,13 @@
 #define TIDE 0x54494445
 #define DIAG 0x44494147
 
-#include "fortint.h"
+#include "common/fortint.h"
 #include "fileRead.h"
 
 #include "sizeRoutines.h"
 
 
-fortint readprod( char * prod_id, char * buffer, fortint * size, 
+fortint readprod( char * prod_id, char * buffer, fortint * size,
               fortint (*fileRead)(char *, fortint , void *),
               fortint (*fileSeek)(void *, fortint, fortint),
               fortint (*fileTell)(void *),
@@ -68,7 +68,7 @@ fortint readprod( char * prod_id, char * buffer, fortint * size,
 //             the product byte stream,
 //  stream = data describing the input stream (eg. FILE *).
 //
-//  Returns 
+//  Returns
 //    -1 if can't find product  (eg. end-of-file)
 //    -2 if internal processing error (malloc fail, file seek error)
 //    -3 if buffer too small for whole product.
@@ -225,7 +225,7 @@ unsigned char * phold = (unsigned char *) hold;
 /* See if the GRIB version is 0 ...
 */
   if ( THREE_BYTE_LONG(phold+4) == 24 ) {
-    length = 28;		     /* GRIB + section 1 */
+    length = 28;                   /* GRIB + section 1 */
 
 /* Check for presence of sections 2 and 3
 */
@@ -234,7 +234,7 @@ unsigned char * phold = (unsigned char *) hold;
 
 /* Add up all lengths of sections
 */
-    return lentotal(hold, holdsize, leng, length, section2, section3, 
+    return lentotal(hold, holdsize, leng, length, section2, section3,
                     fileRead, stream);
   }
 
@@ -244,13 +244,13 @@ unsigned char * phold = (unsigned char *) hold;
   if ( ( hold[21] != 0 ) || ( hold[22] != 0 ) ) {
 
 /* Nightmare fixup for very large GRIB products (eg 2D wave spectra).
-  
+
    If the most-significant of the 24 bits is set, this indicates a
    very large product; the size has to be rescaled by a factor of 120.
    This is a fixup to get round the GRIB code practice of representing
    a product length by 24 bits. It is only possible because the
    (default) rounding for GRIB products is 120 bytes.
-  
+
 */
     fortint fixlen;
 
@@ -261,7 +261,7 @@ unsigned char * phold = (unsigned char *) hold;
       return fixlen;
   }
 
-  length = 24;		     /* GRIB + section 1 */
+  length = 24;                     /* GRIB + section 1 */
 
 /* Check for presence of sections 2 and 3
 */
@@ -270,7 +270,7 @@ unsigned char * phold = (unsigned char *) hold;
 
 /* Add up all lengths of sections
 */
-  return lentotal(hold, holdsize, leng, length, section2, section3, 
+  return lentotal(hold, holdsize, leng, length, section2, section3,
                     fileRead, stream);
 
 }
@@ -313,7 +313,7 @@ fortint next, next_sec = 4;
       return *holdsize;
     }
     hsize = length;
-  } 
+  }
   *holdsize = hsize;
 
 /* Get the size of remaining sections
@@ -327,7 +327,7 @@ fortint next, next_sec = 4;
         return *holdsize;
       }
       hsize = length + 4;
-    } 
+    }
     *holdsize = hsize;
     length += THREE_BYTE_LONG(phold+length);
   }
@@ -381,7 +381,7 @@ fortint next, next_len, next_sec = 3;
    adding up the lengths
 */
 
-/* Add on the length of section 1 and ensure enough of product is in 
+/* Add on the length of section 1 and ensure enough of product is in
    memory to continue
 */
   length = SECT_0_LEN + THREE_BYTE_LONG(phold+4);
@@ -394,7 +394,7 @@ fortint next, next_len, next_sec = 3;
     }
     hsize = length + 4;
     *holdsize = hsize;
-  } 
+  }
 
 /* Check for presence of section 2
 */
@@ -413,7 +413,7 @@ fortint next, next_len, next_sec = 3;
       }
       hsize = length + 4;
       *holdsize = hsize;
-    } 
+    }
   }
 
 /* Add on the size of section 5
@@ -461,7 +461,7 @@ fortint next, next_len, next_sec = 3;
 /* Have to step through individual sections adding up the lengths
 */
 
-/* Add on the length of section 1 and ensure enough of product is in 
+/* Add on the length of section 1 and ensure enough of product is in
    memory to continue
 */
   length = SECT_0_LEN + THREE_BYTE_LONG(phold+4);
@@ -474,7 +474,7 @@ fortint next, next_len, next_sec = 3;
     }
     hsize = length + 4;
     *holdsize = hsize;
-  } 
+  }
 
 /* Get the size of remaining section
 */
@@ -488,7 +488,7 @@ fortint next, next_len, next_sec = 3;
   return length;
 }
 
-static fortint prodsize(fortint code, char * hold, fortint leng, fortint * holdsize, 
+static fortint prodsize(fortint code, char * hold, fortint leng, fortint * holdsize,
                      fortint (*fileRead)(), void * stream)
 /*
 //  Returns size of BUFR, GRIB, BUDG, TIDE, DIAG product in bytes.
@@ -501,7 +501,7 @@ static fortint prodsize(fortint code, char * hold, fortint leng, fortint * holds
 */
 {
   *holdsize = 4;
-  switch( code ) 
+  switch( code )
   {
      case BUFR: memcpy(hold,"BUFR",4);
                 return bufrsize( hold, leng, holdsize, fileRead, stream);
diff --git a/pbio/setpar.c b/pbio/setpar.c
index 0abedab..694528b 100644
--- a/pbio/setpar.c
+++ b/pbio/setpar.c
@@ -1,11 +1,11 @@
 /**
 * Copyright 1981-2012 ECMWF.
 *
-* This software is licensed under the terms of the Apache Licence 
+* This software is licensed under the terms of the Apache Licence
 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
+* In applying this licence, ECMWF does not waive the privileges and immunities
+* granted to it by virtue of its status as an intergovernmental organisation
 * nor does it submit to any jurisdiction.
 */
 
@@ -13,13 +13,13 @@
 //  setpar.c
 //
 //  This is a replacement for the SETPAR.f FORTRAN-callable subroutine.
-//  It sets the number of bits per word (kbit), 
+//  It sets the number of bits per word (kbit),
 //  and the largest negative number (kneg).
 //  The diagnostic print option is no longer supported (kpar).
 //
 */
 #include <limits.h>
-#include "fortint.h"
+#include "common/fortint.h"
 
 void setpar_(fortint * kbit, fortint * kneg, fortint * kpar)
 {
diff --git a/sandbox/CMakeLists.txt b/sandbox/CMakeLists.txt
new file mode 100644
index 0000000..fc00553
--- /dev/null
+++ b/sandbox/CMakeLists.txt
@@ -0,0 +1,21 @@
+if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" )
+
+  set_source_files_properties( emos_tool.c PROPERTIES COMPILE_DEFINITIONS "FORTRAN_LINKER_PGI" )
+  ecbuild_add_executable(
+    TARGET    emos_tool
+    SOURCES   emos_tool.c
+    CONDITION HAVE_LIBEMOS_INTERPOLATION
+    INCLUDES  ${GRIB_API_INCLUDE_DIRS}
+    LIBS      emos
+    LINKER_LANGUAGE Fortran )
+
+else()
+
+  ecbuild_add_executable(
+    TARGET    emos_tool
+    SOURCES   emos_tool.c
+    CONDITION HAVE_LIBEMOS_INTERPOLATION
+    INCLUDES  ${GRIB_API_INCLUDE_DIRS}
+    LIBS      emos )
+
+endif()
diff --git a/sandbox/emos_tool.c b/sandbox/emos_tool.c
new file mode 100644
index 0000000..d9592b2
--- /dev/null
+++ b/sandbox/emos_tool.c
@@ -0,0 +1,1062 @@
+/*
+ * (C) Copyright 1996-2015 ECMWF.
+ *
+ * This software is licensed under the terms of the Apache Licence Version 2.0
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+ * In applying this licence, ECMWF does not waive the privileges and immunities
+ * granted to it by virtue of its status as an intergovernmental organisation nor
+ * does it submit to any jurisdiction.
+ */
+
+/// @author Baudouin Raoult
+/// @date Apr 2015
+
+#include <stdio.h>
+#include <grib_api.h>
+
+typedef int fortint;
+typedef double fortfloat;
+typedef void (*emos_cb_proc)(char *);
+
+extern fortint intout_(const char *name,
+                       const fortint ints[],
+                       const fortfloat reals[],
+                       const char *value,
+                       const fortint name_len,
+                       const fortint value_len);
+
+extern fortint intin_(const char *name,
+                      const fortint ints[],
+                      const fortfloat reals[],
+                      const char *value,
+                      const fortint name_len,
+                      const fortint value_len);
+
+extern fortint intf_(const void *grib_in,
+                     const fortint *length_in,
+                     const fortfloat values_in[],
+                     void *grib_out,
+                     fortint *length_out,
+                     fortfloat values_out[]);
+
+extern fortint intf2(const void *grib_in,
+                     const fortint *length_in,
+                     void *grib_out,
+                     fortint *length_out);
+
+extern fortint intuvs2_(char *vort_grib_in,
+                        char *div_grib_in,
+                        const fortint *length_in,
+                        char *u_grib_out,
+                        char *v_grib_out,
+                        const fortint *length_out);
+
+extern fortint intuvp2_(const void *vort_grib_in,
+                        const void *div_grib_in,
+                        const fortint *length_in,
+                        void *u_grib_out,
+                        void *v_grib_out,
+                        fortint *length_out);
+
+extern fortint intvect2_(const void *u_grib_in,
+                         const void *v_grib_in,
+                         const fortint *length_in,
+                         void *u_grib_out,
+                         void *v_grib_out,
+                         fortint *length_out);
+
+extern fortint intuvs_(const void *vort_grib_in,
+                       const void *div_grib_in,
+                       const fortint *length_in,
+                       void *u_grib_out,
+                       void *v_grib_out,
+                       fortint *length_out);
+
+extern fortint intuvp_(const void *vort_grib_in,
+                       const void *div_grib_in,
+                       const fortint *length_in,
+                       void *u_grib_out,
+                       void *v_grib_out,
+                       fortint *length_out);
+
+extern fortint intvect_(const void *u_grib_in,
+                        const void *v_grib_in,
+                        const fortint *length_in,
+                        void *u_grib_out,
+                        void *v_grib_out,
+                        fortint *length_out);
+
+extern fortint iscrsz_();
+
+extern fortint ibasini_(const fortint *force);
+
+extern void intlogm_(fortint (*)(char *, fortint));
+
+extern void intlogs(emos_cb_proc proc);
+
+extern fortint areachk_(const fortfloat *we,
+                        const fortfloat *ns,
+                        fortfloat *north,
+                        fortfloat *west,
+                        fortfloat *south,
+                        fortfloat *east);
+
+extern fortint emosnum_(fortint *value);
+
+extern void freecf_(const fortint *flag);
+
+extern void jvod2uv_(const fortfloat vor[],
+                     const fortfloat div[],
+                     const fortint *ktin,
+                     fortfloat u[],
+                     fortfloat v[],
+                     const fortint *ktout);
+
+
+extern fortint jgglat_(const fortint *KLAT, fortfloat PGAUSS[]);
+
+extern void jnumgg_(const fortint *knum,
+                    const char *htype,
+                    fortint kpts[],
+                    fortint *kret,
+                    fortint htype_len);
+
+extern fortint wvqlint_(const fortint *knum,
+                        const fortint numpts[],
+                        const fortint *ke_w,
+                        const fortint *kn_s,
+                        const fortfloat *reson,
+                        const fortfloat oldwave[],
+                        fortfloat newwave[],
+                        const fortfloat *north,
+                        const fortfloat *west,
+                        const fortint *kparam,
+                        const fortfloat *pmiss,
+                        const fortfloat *rns);
+
+extern void wv2dint_(const fortint *knum,
+                     const fortint numpts[],
+                     const fortint *ke_w,
+                     const fortint *kn_s,
+                     const fortfloat *reson,
+                     const fortfloat oldwave[],
+                     fortfloat newwave[],
+                     const fortfloat *north,
+                     const fortfloat *west,
+                     const fortint *knspec, // <== What is that?
+                     const fortfloat *pmiss,
+                     const fortfloat *rns);
+
+extern fortint hirlam_(const fortint *l12pnt,
+                       const fortfloat oldfld[],
+                       const fortint *kount,
+                       const fortint *kgauss,
+                       const fortfloat area[],
+                       const fortfloat pole[],
+                       const fortfloat grid[],
+                       fortfloat newfld[],
+                       const fortint *ksize,
+                       fortint *nlon,
+                       fortint *nlat);
+
+extern fortint hirlsm_(const fortint *l12pnt,
+                       const fortfloat oldfld[],
+                       const fortint *kount,
+                       const fortint *kgauss,
+                       const fortfloat area[],
+                       const fortfloat pole[],
+                       const fortfloat grid[],
+                       fortfloat newfld[],
+                       const fortint *ksize,
+                       fortint *nlon,
+                       fortint *nlat);
+
+extern fortint hirlamw_(const fortint *l12pnt,
+                        const fortfloat oldfldu[],
+                        const fortfloat oldfldv[],
+                        const fortint *kount,
+                        const fortint *kgauss,
+                        const fortfloat area[],
+                        const fortfloat pole[],
+                        const fortfloat grid[],
+                        fortfloat newfldu[],
+                        fortfloat newfldv[],
+                        const fortint *ksize,
+                        fortint *nlon,
+                        fortint *nlat);
+
+#define MAX 20
+
+#define OPTION_STR 0
+#define OPTION_INT 1
+#define OPTION_REAL 2
+#define OPTION_BOOL 3
+
+const char *types[] = { "string", "integer", "real", "boolean"};
+
+
+typedef struct value {
+    const char *name;
+    const char *intout;
+} value;
+
+typedef struct option {
+    const char *name;
+    const char *intout;
+    const char *description;
+
+    int type;
+    int count;
+
+    value *values;
+
+    int set;
+    char *arg;
+    fortint ints[MAX];
+    fortfloat reals[MAX];
+
+
+} option;
+
+static value styles[] = {
+    {"dissemination", "dissemination",},
+    {0,}
+};
+
+
+static value interpolation[] = {
+    {"bilinear", "bilinear",},
+    {"nlsm", "nearest lsm",},
+    {"nn", "nearest neighbour",},
+    {"off", "off",},
+    {0,}
+};
+
+
+static value packings[] = {
+    {"so", "second",},
+    {"simple", "simple",},
+    {"av", "archive",},
+    {"complex", "complex",},
+    {0,}
+};
+
+
+
+
+static option options[] = {
+    {"accuracy", "accuracy", "Accuracy", OPTION_INT, 1, },
+    {"area", "area", "Area north/west/south/east", OPTION_REAL, 4, },
+    {"autoresol", "autoresol", "Auto resolution", OPTION_BOOL, 1, },
+    {"bitmap", "bitmap", "Bitmap", OPTION_STR, 1, },
+    {"frame", "frame", "Frame", OPTION_INT, 1, },
+    {"grid", "grid", "Grid west-east/south-north increments", OPTION_REAL, 2, },
+    {"hirlam12", NULL, "Use 12 points hirlam routines", OPTION_BOOL, 1, },
+    {"hirlam4", NULL, "Use 4 points hirlam routines", OPTION_BOOL, 1, },
+    {"intermediate_gaussian", "intermediate_gaussian", "Intermediate gaussian", OPTION_INT, 1, },
+    {"interpolation", "interpolation", "Interpolation method", OPTION_STR, 1, interpolation},
+    {"packing", "packing", "Packing", OPTION_STR, 1, packings},
+    {"reduced", "reduced", "Reduced gaussian", OPTION_INT, 1, },
+    {"regular", "regular", "Regular gaussian", OPTION_INT, 1, },
+    {"rotation", "rotation", "Pole of rotation", OPTION_REAL, 2, },
+    {"style", "style", "Style", OPTION_STR, 1, styles},
+    {"truncation", "truncation", "Truncation", OPTION_INT, 1, },
+    {"vod2uv", NULL, "Interpolate winds", OPTION_BOOL, 1, },
+    {"wind", NULL, "Input is wind", OPTION_BOOL, 1, },
+    {0,}
+};
+
+
+option *find_option(const char *name) {
+    int j = 0;
+    while (options[j].name) {
+        if (strcmp(name, options[j].name) == 0) {
+            return &options[j];
+        }
+        j++;
+    }
+    return NULL;
+}
+
+option *is_set(const char *name) {
+    int j = 0;
+    while (options[j].name) {
+        if (strcmp(name, options[j].name) == 0 && options[j].set) {
+            printf("%s is set\n", name);
+            return &options[j];
+        }
+        j++;
+    }
+    printf("%s is not set\n", name);
+    return NULL;
+}
+
+#define GRIB_CALL(a) if(a) { fprintf(stderr, "%s %s\n", #a, grib_get_error_message(a)); err=-1; goto cleanup;}
+fortint hirlam(const char *ingrib, fortint inlen, char *outgrib, fortint *outlen, int twelve) {
+
+    int err = 0;
+    double *values = 0;
+    grib_handle *h = 0;
+    size_t count, size;
+    long N;
+    double *result;
+    option *area = 0;
+    option *grid = 0;
+    option *pole = 0;
+    const void *message;
+    grib_handle *g;
+
+    fortint l12pnt;
+    fortint kount;
+    fortint kgauss;
+    fortint ksize;
+    fortint nlon;
+    fortint nlat;
+
+    grib_util_grid_spec grid_spec = {0, };
+    grib_util_packing_spec packing_spec = {0, };
+
+    h  = grib_handle_new_from_message(NULL, (void *)ingrib, inlen);
+
+    GRIB_CALL(grib_get_size(h, "values", &count));
+
+    values = malloc(count * sizeof(double));
+    GRIB_CALL(grib_get_double_array(h, "values", &values[0], &size));
+
+    GRIB_CALL(grib_get_long(h, "N", &N));
+
+    grid = find_option("grid");
+    if (!grid->set) {
+        fprintf(stderr, "HIRLAM: grid not specified\n");
+        err = -1;
+        goto cleanup;
+    }
+
+    pole = find_option("rotation");
+    if (!pole->set) {
+        fprintf(stderr, "HIRLAM: rotation not specified\n");
+        err = -1;
+        goto cleanup;
+    }
+
+    area = find_option("area");
+    if (!area->set) {
+        fprintf(stderr, "HIRLAM: area not specified, using global\n");
+        area->reals[0] = 90;
+        area->reals[1] = 0;
+        area->reals[2] = -90;
+        area->reals[3] = 360;
+    }
+
+
+    // long bitmap;
+    // GRIB_CALL(grib_get_long(grib_, "bitmapPresent", &bitmap));
+
+    // double missing;
+    // GRIB_CALL(grib_get_double(grib_, "missingValue", &missing));
+    l12pnt = twelve;
+    kount = count;
+    kgauss = N;
+    ksize = count * 4;
+    result = malloc(ksize * sizeof(double));
+
+    err = hirlam_(&l12pnt,
+                  values,
+                  &kount,
+                  &kgauss,
+                  area->reals,
+                  pole->reals,
+                  grid->reals,
+                  result,
+                  &ksize,
+                  &nlon,
+                  &nlat);
+
+    if (err) {
+        fprintf(stderr, "hirlam_ returns %d\n", err);
+        goto cleanup;
+    }
+
+    if (nlon *  nlat > ksize) {
+        fprintf(stderr, "HIRLAM: array too small %d <  %d\n", ksize, nlon *  nlat);
+        err = -1;
+        goto cleanup;
+    }
+
+
+    packing_spec.packing = GRIB_UTIL_PACKING_SAME_AS_INPUT;
+    packing_spec.accuracy = GRIB_UTIL_ACCURACY_SAME_BITS_PER_VALUES_AS_INPUT;
+
+    grid_spec.grid_type = GRIB_UTIL_GRID_SPEC_ROTATED_LL;
+
+    grid_spec.Ni = nlon;
+    grid_spec.Nj = nlat;
+    grid_spec.iDirectionIncrementInDegrees = grid->reals[0];
+    grid_spec.jDirectionIncrementInDegrees = grid->reals[1];
+
+    grid_spec.longitudeOfFirstGridPointInDegrees = area->reals[1];
+    grid_spec.longitudeOfLastGridPointInDegrees = area->reals[3];
+
+    grid_spec.latitudeOfFirstGridPointInDegrees = area->reals[0];
+    grid_spec.latitudeOfLastGridPointInDegrees = area->reals[2];
+
+    grid_spec.latitudeOfSouthernPoleInDegrees = pole->reals[0];
+    grid_spec.longitudeOfSouthernPoleInDegrees = pole->reals[1];
+
+
+    g = grib_util_set_spec(h, &grid_spec, &packing_spec, 0, result, nlon * nlat, &err);
+    GRIB_CALL(err);
+
+    GRIB_CALL(grib_get_message(g, &message, &size));
+    if (*outlen < size) {
+        fprintf(stderr, "HIRLAM: buffer too small %d <  %d\n", *outlen, (int)size);
+        err = -1;
+        goto cleanup;
+    }
+
+    memcpy(outgrib, message, size);
+    *outlen = size;
+
+cleanup:
+
+    if (h) grib_handle_delete(h);
+    if (g) grib_handle_delete(g);
+    if (values) free(values);
+    if (result) free(result);
+
+    return err;
+}
+
+fortint hirlamw(const char *u_ingrib, const char *v_ingrib, fortint inlen, char *u_outgrib, char *v_outgrib, fortint *outlen, int twelve) {
+
+    int err = 0;
+    double *u_values = 0;
+    grib_handle *u = 0;
+    grib_handle *v = 0;
+    grib_handle *g = 0;
+    size_t u_count, u_size;
+    long u_N;
+    double *u_result;
+    option *area = 0;
+    option *grid = 0;
+    option *pole = 0;
+    const void *u_message;
+
+    double *v_values = 0;
+    size_t v_count, v_size;
+    long v_N;
+    double *v_result;
+    const void *v_message;
+
+    fortint l12pnt;
+    fortint kount;
+    fortint kgauss;
+    fortint ksize;
+    fortint nlon;
+    fortint nlat;
+
+    grib_util_grid_spec grid_spec = {0, };
+    grib_util_packing_spec packing_spec = {0, };
+
+    u  = grib_handle_new_from_message(NULL, (void *)u_ingrib, inlen);
+
+    GRIB_CALL(grib_get_size(u, "values", &u_count));
+
+    u_values = malloc(u_count * sizeof(double));
+    GRIB_CALL(grib_get_double_array(u, "values", &u_values[0], &u_size));
+
+    GRIB_CALL(grib_get_long(u, "N", &u_N));
+
+    v  = grib_handle_new_from_message(NULL, (void *)v_ingrib, inlen);
+
+    GRIB_CALL(grib_get_size(v, "values", &v_count));
+
+    v_values = malloc(v_count * sizeof(double));
+    GRIB_CALL(grib_get_double_array(v, "values", &v_values[0], &v_size));
+
+    GRIB_CALL(grib_get_long(v, "N", &v_N));
+
+    if (u_N != v_N) {
+        fprintf(stderr, "HIRLAM: grid mismatch %ld %ld\n", u_N, v_N);
+        err = -1;
+        goto cleanup;
+    }
+
+    if (u_count != v_count) {
+        fprintf(stderr, "HIRLAM: count mismatch %ld %ld\n", u_count, v_count);
+        err = -1;
+        goto cleanup;
+    }
+
+
+    grid = find_option("grid");
+    if (!grid->set) {
+        fprintf(stderr, "HIRLAM: grid not specified\n");
+        err = -1;
+        goto cleanup;
+    }
+
+    pole = find_option("rotation");
+    if (!pole->set) {
+        fprintf(stderr, "HIRLAM: rotation not specified\n");
+        err = -1;
+        goto cleanup;
+    }
+
+    area = find_option("area");
+    if (!area->set) {
+        fprintf(stderr, "HIRLAM: area not specified, using global\n");
+        area->reals[0] = 90;
+        area->reals[1] = 0;
+        area->reals[2] = -90;
+        area->reals[3] = 360;
+    }
+
+
+    // long bitmap;
+    // GRIB_CALL(grib_get_long(grib_, "bitmapPresent", &bitmap));
+
+    // double missing;
+    // GRIB_CALL(grib_get_double(grib_, "missingValue", &missing));
+    l12pnt = twelve;
+    kount = u_count;
+    kgauss = u_N;
+    ksize = u_count * 4;
+    u_result = malloc(ksize * sizeof(double));
+    v_result = malloc(ksize * sizeof(double));
+
+    err = hirlamw_(&l12pnt,
+                   u_values,
+                   v_values,
+                   &kount,
+                   &kgauss,
+                   area->reals,
+                   pole->reals,
+                   grid->reals,
+                   u_result,
+                   v_result,
+                   &ksize,
+                   &nlon,
+                   &nlat);
+
+    if (err) {
+        fprintf(stderr, "hirlamw_ returns %d\n", err);
+        goto cleanup;
+    }
+
+    if (nlon *  nlat > ksize) {
+        fprintf(stderr, "HIRLAMW: array too small %d <  %d\n", ksize, nlon *  nlat);
+        err = -1;
+        goto cleanup;
+    }
+
+
+    packing_spec.packing = GRIB_UTIL_PACKING_SAME_AS_INPUT;
+    packing_spec.accuracy = GRIB_UTIL_ACCURACY_SAME_BITS_PER_VALUES_AS_INPUT;
+
+    grid_spec.grid_type = GRIB_UTIL_GRID_SPEC_ROTATED_LL;
+
+    grid_spec.Ni = nlon;
+    grid_spec.Nj = nlat;
+    grid_spec.iDirectionIncrementInDegrees = grid->reals[0];
+    grid_spec.jDirectionIncrementInDegrees = grid->reals[1];
+
+    grid_spec.longitudeOfFirstGridPointInDegrees = area->reals[1];
+    grid_spec.longitudeOfLastGridPointInDegrees = area->reals[3];
+
+    grid_spec.latitudeOfFirstGridPointInDegrees = area->reals[0];
+    grid_spec.latitudeOfLastGridPointInDegrees = area->reals[2];
+
+    grid_spec.latitudeOfSouthernPoleInDegrees = pole->reals[0];
+    grid_spec.longitudeOfSouthernPoleInDegrees = pole->reals[1];
+
+    grid_spec.uvRelativeToGrid = 1; // Check if hirlam does it
+
+
+    g = grib_util_set_spec(u, &grid_spec, &packing_spec, 0, u_result, nlon * nlat, &err);
+    GRIB_CALL(err);
+
+    GRIB_CALL(grib_get_message(g, &u_message, &u_size));
+    if (*outlen < u_size) {
+        fprintf(stderr, "HIRLAMW: buffer too small %d <  %d\n", *outlen, (int)u_size);
+        err = -1;
+        goto cleanup;
+    }
+
+    memcpy(u_outgrib, u_message, u_size);
+    grib_handle_delete(g);
+    g = 0;
+
+    g = grib_util_set_spec(v, &grid_spec, &packing_spec, 0, v_result, nlon * nlat, &err);
+    GRIB_CALL(err);
+
+    GRIB_CALL(grib_get_message(g, &v_message, &v_size));
+    if (*outlen < v_size) {
+        fprintf(stderr, "HIRLAMW: buffer too small %d <  %d\n", *outlen, (int)v_size);
+        err = -1;
+        goto cleanup;
+    }
+
+    memcpy(v_outgrib, v_message, v_size);
+    if (u_size != v_size) {
+        fprintf(stderr, "HIRLAMW: output size mismatch %ld %ld\n", u_size, v_size);
+        err = -1;
+        goto cleanup;
+    }
+
+
+
+    *outlen = u_size;
+
+cleanup:
+
+    if (u) grib_handle_delete(u);
+    if (v) grib_handle_delete(v);
+    if (g)grib_handle_delete(g);
+    if (u_values) free(u_values);
+    if (v_values) free(v_values);
+    if (u_result) free(u_result);
+    if (v_result) free(v_result);
+
+    return err;
+}
+
+void usage(const char *prog) {
+    int i, j;
+    fprintf(stderr, "\nUsage: %s [options] in.grib out.grib\n", prog);
+    fprintf(stderr, "\nOptions are:\n\n");
+    j = 0;
+    while (options[j].name) {
+        const char *sep = "=";
+        int l = 0;
+        l += fprintf(stderr, " --%s", options[j].name);
+        for (i = 0; i < options[j].count; i++) {
+            l += fprintf(stderr, "%s%s", sep, types[options[j].type]);
+            sep = "/";
+        }
+        while (l < 40) {
+            l += fprintf(stderr, " ");
+        }
+        fprintf(stderr, "%s\n", options[j].description);
+        j++;
+    }
+    fprintf(stderr, "\n");
+    exit(1);
+}
+
+
+#ifdef FORTRAN_LINKER_PGI
+#define main_ MAIN_
+#else
+#define main_ main
+#endif
+
+
+int main_( int argc, const char **argv ) {
+    fortint dummy = 0;
+    printf("WARNING: this tool if for debugging purposes only!!!\n");
+    printf("EMOSNUM is %d\n", emosnum_(&dummy));
+    option *o = NULL;
+    const char *paths[2];
+    FILE *f;
+    FILE *g;
+
+    int err = 0;
+    const char *func = "NONE";
+    int n = 0;
+
+
+    int i, j, k, e;
+    char *p;
+    char *q;
+
+
+    for (i = 1; i < argc; i++) {
+
+        if (argv[i][0] == '-' && argv[i][1] == '-') {
+            const char *a = argv[i];
+            a += 2;
+
+            j = 0;
+            o = NULL;
+            while (options[j].name && !o) {
+                int len = strlen(options[j].name);
+                if (strncmp(a, options[j].name, len) == 0 && (a[len] == '=' || a[len] == 0)) {
+                    o = &options[j];
+                    if (o->arg) {
+                        free(o->arg);
+                    }
+
+                    if (a[len] == '=') {
+                        o->arg = strdup(a + len + 1);
+                    } else {
+                        o->arg = strdup("1");
+                    }
+                }
+                j++;
+            }
+
+            if (!o) {
+                fprintf(stderr, "%s: invalid option [%s]\n", argv[0], a);
+                usage(argv[0]);
+            }
+
+            printf("SET %s\n", o->name);
+            o->set = 1;
+
+            switch (o->type) {
+            case OPTION_STR:
+
+
+                if (o->values) {
+                    int v = 0;
+                    int ok = 0;
+                    while (o->values[v].name) {
+                        if (strncmp(o->values[v].name, o->arg, strlen(o->arg)) == 0 ||
+                                strncmp(o->values[v].intout, o->arg, strlen(o->arg)) == 0) {
+                            free(o->arg);
+                            o->arg = strdup(o->values[v].intout);
+                            ok = 1;
+                            break;
+                        }
+                        v++;
+                    }
+
+                    if (!ok) {
+                        fprintf(stderr, "Values for '%s' are:\n", o->name);
+                        v = 0;
+                        while (o->values[v].name) {
+                            fprintf(stderr, "   %s\n", o->values[v].name);
+                            if (strcmp(o->values[v].name, o->values[v].intout) != 0) {
+                                fprintf(stderr, "   %s\n", o->values[v].intout);
+                            }
+                            v++;
+                        }
+                        exit(1);
+                    }
+                }
+                if (o->intout) {
+                    printf("INTOUT %s => %s\n", o->intout, o->arg);
+                }
+                break;
+
+            case OPTION_REAL:
+
+                k = 0;
+                q = p = o->arg;
+                while (*p) {
+                    if (*p == '/') {
+                        *p = 0;
+                        if (k < MAX) {
+                            o->reals[k++] = atof(q);
+                        }
+                        *p = '/';
+                        q = p + 1;
+                    }
+                    p++;
+                }
+
+                if (k < MAX && q != p) {
+                    o->reals[k++] = atof(q);
+                }
+
+                if (k != o->count) {
+                    usage(argv[0]);
+                }
+                if (o->intout) {
+                    printf("INTOUT %s =>", o->intout);
+                    for (k = 0; k < o->count; k++) {
+                        printf(" %g", o->reals[k]);
+                    }
+                    printf("\n");
+                }
+
+                break;
+
+            case OPTION_INT:
+                k = 0;
+                q = p = o->arg;
+                while (*p) {
+                    if (*p == '/') {
+                        *p = 0;
+                        if (k < MAX) {
+                            o->ints[k++] = atol(q);
+                        }
+                        *p = '/';
+                        q = p + 1;
+                    }
+                    p++;
+                }
+
+                if (k < MAX && q != p) {
+                    o->ints[k++] = atol(q);
+                }
+
+                if (k != o->count) {
+                    usage(argv[0]);
+                }
+                if (o->intout) {
+                    printf("INTOUT %s =>", o->intout);
+                    for (k = 0; k < o->count; k++) {
+                        printf(" %d", o->ints[k]);
+                    }
+                    printf("\n");
+                }
+
+                break;
+
+            case OPTION_BOOL:
+                o->ints[0] = atof(o->arg) ? 1 : 0;
+                if (o->intout) {
+                    printf("INTOUT %s => %d\n", o->intout, o->ints[0]);
+                }
+                break;
+            }
+
+            if (o->intout) {
+                e = intout_(o->intout, o->ints, o->reals, o->arg, strlen(o->intout), strlen(o->arg));
+                if (e) {
+                    fprintf(stderr, "INTOUT returns %d\n", e);
+                    exit(1);
+                }
+            }
+
+        } else {
+            if ( n < 2) {
+                paths[n++] = argv[i];
+            } else {
+                usage(argv[0]);
+            }
+        }
+
+    }
+
+    if (n != 2) {
+        usage(argv[0]);
+    }
+
+    f = fopen(paths[0], "r");
+    if (!f) {
+        perror(paths[0]);
+        exit(1);
+    }
+
+    g = fopen(paths[1], "w");
+    if (!g) {
+        perror(paths[1]);
+        exit(1);
+    }
+
+    if (is_set("vod2uv")) {
+        fprintf(stderr, "%s: wind not yet supported\n", argv[0]);
+        exit(1);
+    }
+
+    if (is_set("wind")) {
+        grib_handle *u, *v;
+        int u_buflen = 0;
+        char *u_buffer = NULL;
+        int v_buflen = 0;
+        char *v_buffer = NULL;
+        n = 0;
+        printf("%s: wind interpolation\n", argv[0]);
+        while ( (u = grib_handle_new_from_file(0,  f, &err)) != 0) {
+
+            v = grib_handle_new_from_file(0,  f, &err);
+            if (err) {
+                break;
+            }
+
+            if (!v) {
+                fprintf(stderr, "%s: cannot read V field\n", argv[0]);
+                exit(1);
+            }
+
+            int e;
+            const void *u_message = 0;
+            size_t u_message_length = 0;
+            fortint u_inlen, u_outlen;
+
+            if ( (err = grib_get_message(u , &u_message, &u_message_length) ) != 0) {
+                fprintf(stderr, "%s: %s\n", paths[0], grib_get_error_message(err));
+                exit(1);
+            }
+
+            const void *v_message = 0;
+            size_t v_message_length = 0;
+            fortint v_inlen, v_outlen;
+
+            if ( (err = grib_get_message(v , &v_message, &v_message_length) ) != 0) {
+                fprintf(stderr, "%s: %s\n", paths[0], grib_get_error_message(err));
+                exit(1);
+            }
+
+            if (u_buflen < u_message_length * 4) {
+                if (u_buffer) {
+                    free(u_buffer);
+                }
+                u_buflen = u_message_length * 4;
+                u_buffer = malloc(u_buflen);
+                if (u_buffer == NULL) {
+                    fprintf(stderr, "%s: failed to allocate %d bytes\n", argv[0], u_buflen);
+                    exit(1);
+                }
+            }
+
+            if (v_buflen < v_message_length * 4) {
+                if (v_buffer) {
+                    free(v_buffer);
+                }
+                v_buflen = v_message_length * 4;
+                v_buffer = malloc(v_buflen);
+                if (v_buffer == NULL) {
+                    fprintf(stderr, "%s: failed to allocate %d bytes\n", argv[0], v_buflen);
+                    exit(1);
+                }
+            }
+
+            u_inlen = u_message_length;
+            u_outlen = u_buflen;
+            v_inlen = v_message_length;
+            v_outlen = v_buflen;
+
+            if (is_set("hirlam12")) {
+                func = "HIRLAMW12";
+                e = hirlamw(u_message, v_message, u_inlen, u_buffer, v_buffer, &u_outlen, 1);
+            }  else if (is_set("hirlam4")) {
+                func = "HIRLAM4W";
+                e = hirlamw(u_message, v_message, u_inlen, u_buffer, v_buffer, &u_outlen, 0);
+            } else  {
+                func = "INTVECT2";
+                e = intvect2_(u_message, v_message, &u_inlen, u_buffer, v_buffer, &u_outlen);
+                v_outlen = u_outlen;
+            }
+            if (e != 0) {
+                fprintf(stderr, "%s: %s returns %d\n", argv[0], func, e);
+                exit(1);
+            }
+
+            if (u_outlen == 0) {
+                /* No iterpolation */
+                printf("%s: no interpolation\n", argv[0]);
+                if (fwrite(u_message, 1, u_inlen, g) != u_inlen) {
+                    perror(paths[1]);
+                    exit(1);
+                }
+                if (fwrite(v_message, 1, v_inlen, g) != v_inlen) {
+                    perror(paths[1]);
+                    exit(1);
+                }
+            } else {
+                if (fwrite(u_buffer, 1, u_outlen, g) != u_outlen) {
+                    perror(paths[1]);
+                    exit(1);
+                }
+                if (fwrite(v_buffer, 1, v_outlen, g) != v_outlen) {
+                    perror(paths[1]);
+                    exit(1);
+                }
+            }
+
+            n++;
+            n++;
+            grib_handle_delete(u);
+            grib_handle_delete(v);
+        }
+
+    } else {
+        grib_handle *h;
+        int buflen = 0;
+        char *buffer = NULL;
+
+
+        n = 0;
+        while ( (h = grib_handle_new_from_file(0,  f, &err)) != 0) {
+
+            int e;
+            const void *message = 0;
+            size_t message_length = 0;
+            fortint inlen, outlen;
+
+            if ( (err = grib_get_message(h , &message, &message_length) ) != 0) {
+                fprintf(stderr, "%s: %s\n", paths[0], grib_get_error_message(err));
+                exit(1);
+            }
+
+
+            if (buflen < message_length * 4) {
+                if (buffer) {
+                    free(buffer);
+                }
+                buflen = message_length * 4;
+                buffer = malloc(buflen);
+                if (buffer == NULL) {
+                    fprintf(stderr, "%s: failed to allocate %d bytes\n", argv[0], buflen);
+                    exit(1);
+                }
+            }
+
+            inlen = message_length;
+            outlen = buflen;
+
+            if (is_set("hirlam12")) {
+                func = "HIRLAM12";
+                e = hirlam(message, inlen, buffer, &outlen, 1);
+            }  else if (is_set("hirlam4")) {
+                func = "HIRLAM4";
+                e = hirlam(message, inlen, buffer, &outlen, 0);
+            } else  {
+                func = "INTF2";
+                e = intf2(message, &inlen, buffer, &outlen);
+            }
+            if (e != 0) {
+                fprintf(stderr, "%s: %s returns %d\n", argv[0], func, e);
+                exit(1);
+            }
+
+            if (outlen == 0) {
+                /* No iterpolation */
+                printf("%s: no interpolation\n", argv[0]);
+                if (fwrite(message, 1, inlen, g) != inlen) {
+                    perror(paths[1]);
+                    exit(1);
+                }
+            } else {
+                if (fwrite(buffer, 1, outlen, g) != outlen) {
+                    perror(paths[1]);
+                    exit(1);
+                }
+            }
+
+            n++;
+            grib_handle_delete(h);
+        }
+
+
+    }
+
+    if (err) {
+        fprintf(stderr, "%s: %s\n", paths[0], grib_get_error_message(err));
+        exit(1);
+    }
+
+
+    if (fclose(f)) {
+        perror(paths[0]);
+        exit(1);
+    }
+
+    if (fclose(g)) {
+        perror(paths[1]);
+        exit(1);
+    }
+    if (n == 0) {
+        fprintf(stderr, "%s: No GRIB found\n", paths[0]);
+        exit(1);
+    }
+
+    printf("%d GRIB(s) written to %s\n", n, paths[1]);
+
+    return 0;
+}
+
diff --git a/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake b/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake
new file mode 100644
index 0000000..341b894
--- /dev/null
+++ b/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake
@@ -0,0 +1,81 @@
+####################################################################
+# COMPILER
+####################################################################
+
+include(CMakeForceCompiler)
+
+CMAKE_FORCE_C_COMPILER       ( cc  Cray )
+CMAKE_FORCE_CXX_COMPILER     ( CC  Cray )
+CMAKE_FORCE_Fortran_COMPILER ( ftn Cray )
+
+link_libraries("$ENV{CC_X86_64}/lib/x86-64/libcray-c++-rts.so")
+link_libraries("$ENV{MPICH_DIR}/lib/libmpichf90_cray.so")
+link_libraries("$ENV{MPICH_DIR}/lib/libmpichcxx_cray.so")
+
+set( ECBUILD_FIND_MPI OFF )
+set( ECBUILD_TRUST_FLAGS ON )
+
+####################################################################
+# FLAGS COMMON TO ALL BUILD TYPES
+####################################################################
+
+set( OMP_C_FLAGS             "-homp" )
+set( OMP_CXX_FLAGS           "-homp" )
+set( OMP_Fortran_FLAGS       "-homp" )
+
+set( OMPSTUBS_C_FLAGS        "-hnoomp" )
+set( OMPSTUBS_CXX_FLAGS      "-hnoomp" )
+set( OMPSTUBS_Fortran_FLAGS  "-hnoomp" )
+
+set( CMAKE_C_FLAGS       "" CACHE STRING "" FORCE )
+set( CMAKE_CXX_FLAGS     "" CACHE STRING "" FORCE )
+set( CMAKE_Fortran_FLAGS "-emf -rmoid" CACHE STRING "" FORCE )   # -emf activates .mods and uses lower case -rmoid produces a listing file
+
+####################################################################
+# RELEASE FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_RELEASE       "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" )
+set( ECBUILD_CXX_FLAGS_RELEASE     "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" )
+set( ECBUILD_Fortran_FLAGS_RELEASE "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" )
+
+####################################################################
+# BIT REPRODUCIBLE FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_BIT        "-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1 -DNDEBUG" )
+set( ECBUILD_CXX_FLAGS_BIT      "-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1 -DNDEBUG" )
+set( ECBUILD_Fortran_FLAGS_BIT  "-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1 -DNDEBUG" )
+
+####################################################################
+# RELWITHDEBINFO FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_RELWITHDEBINFO        "-O2 -hfp1 -Gfast -DNDEBUG" )
+set( ECBUILD_CXX_FLAGS_RELWITHDEBINFO      "-O2 -hfp1 -Gfast -DNDEBUG" )
+set( ECBUILD_Fortran_FLAGS_RELWITHDEBINFO  "-O2 -hfp1 -Gfast -DNDEBUG" )
+
+####################################################################
+# DEBUG FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_DEBUG        "-O0 -G0" )
+set( ECBUILD_CXX_FLAGS_DEBUG      "-O0 -G0" )
+set( ECBUILD_Fortran_FLAGS_DEBUG  "-O0 -G0" )
+
+####################################################################
+# PRODUCTION FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_PRODUCTION        "-O2 -hfp1 -G2" )
+set( ECBUILD_CXX_FLAGS_PRODUCTION      "-O2 -hfp1 -G2" )
+set( ECBUILD_Fortran_FLAGS_PRODUCTION  "-O2 -hfp1 -G2" )
+
+####################################################################
+# LINK FLAGS
+####################################################################
+
+set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,loadmap -Wl,--as-needed -Ktrap=fp" )
+set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,loadmap -Wl,--as-needed -Ktrap=fp" )
+set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,loadmap -Wl,--as-needed -Ktrap=fp" )
+
diff --git a/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake b/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake
new file mode 100644
index 0000000..3c890d5
--- /dev/null
+++ b/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake
@@ -0,0 +1,73 @@
+####################################################################
+# COMPILER
+####################################################################
+
+include(CMakeForceCompiler)
+
+CMAKE_FORCE_C_COMPILER       ( cc  GNU )
+CMAKE_FORCE_CXX_COMPILER     ( CC  GNU )
+CMAKE_FORCE_Fortran_COMPILER ( ftn GNU )
+
+set( ECBUILD_FIND_MPI OFF )
+set( ECBUILD_TRUST_FLAGS ON )
+
+####################################################################
+# FLAGS COMMON TO ALL BUILD TYPES
+####################################################################
+
+set( OMP_C_FLAGS             "-fopenmp" )
+set( OMP_CXX_FLAGS           "-fopenmp" )
+set( OMP_Fortran_FLAGS       "-fopenmp" )
+
+set( CMAKE_C_FLAGS       "" CACHE STRING "" FORCE )
+set( CMAKE_CXX_FLAGS     "" CACHE STRING "" FORCE )
+set( CMAKE_Fortran_FLAGS "" CACHE STRING "" FORCE )
+
+####################################################################
+# RELEASE FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_RELEASE       "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" )
+#set( ECBUILD_CXX_FLAGS_RELEASE     "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" )
+#set( ECBUILD_Fortran_FLAGS_RELEASE "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" )
+
+####################################################################
+# BIT REPRODUCIBLE FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_BIT        "-g -O2 -m64 -march=native -DNDEBUG" )
+set( ECBUILD_CXX_FLAGS_BIT      "-g -O2 -m64 -march=native -DNDEBUG" )
+set( ECBUILD_Fortran_FLAGS_BIT  "-g -O2 -m64 -march=native -DNDEBUG -fno-range-check -ffree-line-length-300 -fconvert=big-endian" )
+
+####################################################################
+# RELWITHDEBINFO FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_RELWITHDEBINFO        "-O2 -hfp1 -Gfast -DNDEBUG" )
+#set( ECBUILD_CXX_FLAGS_RELWITHDEBINFO      "-O2 -hfp1 -Gfast -DNDEBUG" )
+#set( ECBUILD_Fortran_FLAGS_RELWITHDEBINFO  "-O2 -hfp1 -Gfast -DNDEBUG" )
+
+####################################################################
+# DEBUG FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_DEBUG        "-O0 -G0" )
+#set( ECBUILD_CXX_FLAGS_DEBUG      "-O0 -G0" )
+#set( ECBUILD_Fortran_FLAGS_DEBUG  "-O0 -G0" )
+
+####################################################################
+# PRODUCTION FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_PRODUCTION        "-O2 -hfp1 -G2" )
+#set( ECBUILD_CXX_FLAGS_PRODUCTION      "-O2 -hfp1 -G2" )
+#set( ECBUILD_Fortran_FLAGS_PRODUCTION  "-O2 -hfp1 -G2" )
+
+####################################################################
+# LINK FLAGS
+####################################################################
+
+set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,load.map -Wl,--as-needed" )
+set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,load.map -Wl,--as-needed" )
+set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,load.map -Wl,--as-needed" )
+
diff --git a/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake b/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake
new file mode 100644
index 0000000..485b122
--- /dev/null
+++ b/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake
@@ -0,0 +1,76 @@
+####################################################################
+# COMPILER
+####################################################################
+
+include(CMakeForceCompiler)
+
+CMAKE_FORCE_C_COMPILER       ( cc  Intel )
+CMAKE_FORCE_CXX_COMPILER     ( CC  Intel )
+CMAKE_FORCE_Fortran_COMPILER ( ftn Intel )
+
+set( ECBUILD_FIND_MPI OFF )
+set( ECBUILD_TRUST_FLAGS ON )
+
+####################################################################
+# FLAGS COMMON TO ALL BUILD TYPES
+####################################################################
+
+set( OMP_C_FLAGS             "-qopenmp -qopenmp-threadprivate=compat -qopenmp-report=2 -qopt-report-phase=vec,openmp" )
+set( OMP_CXX_FLAGS           "-qopenmp -qopenmp-threadprivate=compat -qopenmp-report=2 -qopt-report-phase=vec,openmp" )
+set( OMP_Fortran_FLAGS       " -openmp  -openmp-threadprivate=compat  -openmp-report=2  -opt-report-phase=vec,openmp" ) # -[q] is missing on purpose, ifort does not take -q as flag
+
+# for diagnostics:
+#  -diag-enable=vec -diag-file -Winline
+
+set( CMAKE_C_FLAGS       "-fp-speculation=strict -fp-model precise -traceback" CACHE STRING "" FORCE )
+set( CMAKE_CXX_FLAGS     "-fp-speculation=strict -fp-model precise -traceback" CACHE STRING "" FORCE )
+set( CMAKE_Fortran_FLAGS "-fp-speculation=strict -fp-model precise -convert big_endian -assume byterecl -traceback -fpe0" CACHE STRING "" FORCE )
+
+####################################################################
+# RELEASE FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_RELEASE       "not implemented" )
+#set( ECBUILD_CXX_FLAGS_RELEASE     "not implemented" )
+#set( ECBUILD_Fortran_FLAGS_RELEASE "not implemented" )
+
+####################################################################
+# BIT REPRODUCIBLE FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_BIT        "-O2 -xAVX -finline-function -finline-limit=500" )
+set( ECBUILD_CXX_FLAGS_BIT      "-O2 -xAVX -finline-function -finline-limit=500" )
+set( ECBUILD_Fortran_FLAGS_BIT  "-O2 -xAVX -finline-function -finline-limit=500 -align array64byte" )
+
+####################################################################
+# RELWITHDEBINFO FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_RELWITHDEBINFO        "not implemented" )
+#set( ECBUILD_CXX_FLAGS_RELWITHDEBINFO      "not implemented" )
+#set( ECBUILD_Fortran_FLAGS_RELWITHDEBINFO  "not implemented" )
+
+####################################################################
+# DEBUG FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_DEBUG        "-g -O0" )
+set( ECBUILD_CXX_FLAGS_DEBUG      "-g -O0" )
+set( ECBUILD_Fortran_FLAGS_DEBUG  "-g -O0" ) # ??? -align array64byte
+
+####################################################################
+# PRODUCTION FLAGS
+####################################################################
+
+#set( ECBUILD_C_FLAGS_PRODUCTION        "not implemented" )
+#set( ECBUILD_CXX_FLAGS_PRODUCTION      "not implemented" )
+#set( ECBUILD_Fortran_FLAGS_PRODUCTION  "not implemented" )
+
+####################################################################
+# LINK FLAGS
+####################################################################
+
+set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,load.map -Wl,--as-needed" )
+set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,load.map -Wl,--as-needed" )
+set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,load.map -Wl,--as-needed" )
+
diff --git a/tables/interpol/0-INDEX-0 b/tables/interpol/0-INDEX-0
index d6d855b..7f62225 100644
--- a/tables/interpol/0-INDEX-0
+++ b/tables/interpol/0-INDEX-0
@@ -1,49 +1,91 @@
-0-INDEX-0
-defaults_for_table_001	  WMO table parameter interpolation options
-defaults_for_table_128	  ECMWF table parameter interpolation options
-defaults_for_table_129
-lsm_32_lsm0p5deg		  32 bit land-sea mask 0.5 degree resolution
-lsm_32_lsm10m01			  32 bit land-sea mask 10 minute resolution
-lsm_32_lsmn080			  32 bit land-sea mask gaussian N80
-lsm_32_lsmr160*			  32 bit land-sea mask gaussian N160
-lsm_64_lsm0p5deg		  64 bit land-sea mask 0.5 degree resolution
-lsm_64_lsm10m01			  64 bit land-sea mask 10 minute resolution
-lsm_64_lsmn080			  64 bit land-sea mask gaussian N80
-lsm_64_lsmr160			  64 bit land-sea mask gaussian N160
-parameter_processing_defaults	  Not currently used (see rddefs.c)
-r160_32_19790930		  32 bit land-sea mask for N160 from 19790930
-r160_32_19910917		  32 bit land-sea mask for N160 from 19910917
-r160_32_19930804		  32 bit land-sea mask for N160 from 19930804
-r160_32_19940302		  32 bit land-sea mask for N160 from 19940302
-r160_32_19940823		  32 bit land-sea mask for N160 from 19940823
-r160_32_19950404		  32 bit land-sea mask for N160 from 19950404
-r160_64_19790930		  64 bit land-sea mask for N160 from 19790930
-r160_64_19910917		  64 bit land-sea mask for N160 from 19910917
-r160_64_19930804		  64 bit land-sea mask for N160 from 19930804
-r160_64_19940302		  64 bit land-sea mask for N160 from 19940302
-r160_64_19940823		  64 bit land-sea mask for N160 from 19940823
-r160_64_19950404		  64 bit land-sea mask for N160 from 19950404
-
-LSM_GG_0048			      land-sea mask reduced gaussian N48
-LSM_GG_0080			      land-sea mask reduced gaussian N80
-LSM_GG_0128			      land-sea mask reduced gaussian N128
-LSM_GG_0160			      land-sea mask reduced gaussian N160
-LSM_GG_0200
-LSM_GG_0256			      land-sea mask reduced gaussian N256
-LSM_GG_0320
-LSM_GG_0400			      land-sea mask reduced gaussian N400
-LSM_GG_0400.lxab
-LSM_GG_0640
-LSM_GG_1024
-ksm_xx_lsm0p5deg
+0-INDEX-0                              This file!
+LSM_GG_0032                            land-sea mask (LSM) for reduced Gaussian N32
+LSM_GG_0032_CY41R1                     LSM for reduced Gaussian N32, for cycle 41r1
+LSM_GG_0048                            LSM for reduced Gaussian N48
+LSM_GG_0048_CY41R1                     LSM for reduced Gaussian N48, for cycle 41r1
+LSM_GG_0080                            LSM for reduced Gaussian N80
+LSM_GG_0080_CY41R1                     LSM for reduced Gaussian N80, for cycle 41r1
+LSM_GG_0096                            LSM for reduced Gaussian N96
+LSM_GG_0096_CY41R1                     LSM for reduced Gaussian N96, for cycle 41r1
+LSM_GG_0128                            LSM for reduced Gaussian N128
+LSM_GG_0128_CY41R1                     LSM for reduced Gaussian N128, for cycle 41r1
+LSM_GG_0160                            LSM for reduced Gaussian N160
+LSM_GG_0160_CY41R1                     LSM for reduced Gaussian N160, for cycle 41r1
+LSM_GG_0200                            LSM for reduced Gaussian N200
+LSM_GG_0200_CY41R1                     LSM for reduced Gaussian N200, for cycle 41r1
+LSM_GG_0256                            LSM for reduced Gaussian N256
+LSM_GG_0256_CY41R1                     LSM for reduced Gaussian N256, for cycle 41r1
+LSM_GG_0320                            LSM for reduced Gaussian N320
+LSM_GG_0320_CY41R1                     LSM for reduced Gaussian N320, for cycle 41r1
+LSM_GG_0400                            LSM for reduced Gaussian N400
+LSM_GG_0400_CY41R1                     LSM for reduced Gaussian N400, for cycle 41r1
+LSM_GG_0512                            LSM for reduced Gaussian N512
+LSM_GG_0512_CY41R1                     LSM for reduced Gaussian N512, for cycle 41r1
+LSM_GG_0640                            LSM for reduced Gaussian N640
+LSM_GG_0640_CY41R1                     LSM for reduced Gaussian N640, for cycle 41r1
+LSM_GG_1024                            LSM for reduced Gaussian N1024
+LSM_GG_1024_CY41R1                     LSM for reduced Gaussian N1024, for cycle 41r1
+LSM_GG_1280                            LSM for reduced Gaussian N1280
+LSM_GG_1280_CY41R1                     LSM for reduced Gaussian N1280, for cycle 41r1
+LSM_O64                                LSM for reduced Gaussian O64 (octahedral)
+LSM_O64_CY41R1                         LSM for reduced Gaussian O64 (octahedral), for cycle 41r1
+LSM_O80                                LSM for reduced Gaussian O80 (octahedral)
+LSM_O80_CY41R1                         LSM for reduced Gaussian O80 (octahedral), for cycle 41r1
+LSM_O96                                LSM for reduced Gaussian O96 (octahedral)
+LSM_O96_CY41R1                         LSM for reduced Gaussian O96 (octahedral), for cycle 41r1
+LSM_O128                               LSM for reduced Gaussian O128 (octahedral)
+LSM_O128_CY41R1                        LSM for reduced Gaussian O128 (octahedral), for cycle 41r1
+LSM_O160                               LSM for reduced Gaussian O160 (octahedral)
+LSM_O160_CY41R1                        LSM for reduced Gaussian O160 (octahedral), for cycle 41r1
+LSM_O200                               LSM for reduced Gaussian O200 (octahedral)
+LSM_O200_CY41R1                        LSM for reduced Gaussian O200 (octahedral), for cycle 41r1
+LSM_O256                               LSM for reduced Gaussian O256 (octahedral)
+LSM_O256_CY41R1                        LSM for reduced Gaussian O256 (octahedral), for cycle 41r1
+LSM_O320                               LSM for reduced Gaussian O320 (octahedral)
+LSM_O320_CY41R1                        LSM for reduced Gaussian O320 (octahedral), for cycle 41r1
+LSM_O400                               LSM for reduced Gaussian O400 (octahedral)
+LSM_O400_CY41R1                        LSM for reduced Gaussian O400 (octahedral), for cycle 41r1
+LSM_O512                               LSM for reduced Gaussian O512 (octahedral)
+LSM_O512_CY41R1                        LSM for reduced Gaussian O512 (octahedral), for cycle 41r1
+LSM_O640                               LSM for reduced Gaussian O640 (octahedral)
+LSM_O640_CY41R1                        LSM for reduced Gaussian O640 (octahedral), for cycle 41r1
+LSM_O1024                              LSM for reduced Gaussian O1024 (octahedral)
+LSM_O1024_CY41R1                       LSM for reduced Gaussian O1024 (octahedral), for cycle 41r1
+LSM_O1280                              LSM for reduced Gaussian O1280 (octahedral)
+LSM_O1280_CY41R1                       LSM for reduced Gaussian O1280 (octahedral), for cycle 41r1
+climate.v014                           Set of climate land-sea mask files, version 014
+defaults_for_table_001                 table parameter interpolation options (WMO)
+defaults_for_table_128                 table parameter interpolation options (ECMWF)
+defaults_for_table_129                 table parameter interpolation options (ECMWF)
+lsm_32_lsm0p5deg                       LSM 0.5 degree resolution (32-bit)
+lsm_32_lsm10m01                        LSM 10 minute resolution (32-bit)
+lsm_32_lsmn080                         LSM for reduced Gaussian N80 (32-bit)
+lsm_32_lsmr160                         LSM for reduced Gaussian N160 (32-bit)
+lsm_64_lsm0p5deg                       LSM 0.5 degree resolution (64-bit)
+lsm_64_lsm10m01                        LSM 10 minute resolution (64-bit)
+lsm_64_lsmn080                         LSM for reduced Gaussian N80 (64-bit)
+lsm_64_lsmr160                         LSM for reduced Gaussian N160 (64-bit)
 lsm_xx_lsm0p25deg
 lsm_xx_lsm0p5deg
 lsm_xx_lsm10m01
 lsm_xx_lsmn080
 lsm_xx_lsmr160
-r160_xx_19790930
-r160_xx_19910917
-r160_xx_19930804
-r160_xx_19940302
-r160_xx_19940823
-r160_xx_19950404
+parameter_processing_defaults          not currently used (see rddefs.c)
+r160_32_19790930                       LSM for reduced Gaussian N160 from 1979-09-30 (32-bit)
+r160_32_19910917                       LSM for reduced Gaussian N160 from 1991-09-17 (32-bit)
+r160_32_19930804                       LSM for reduced Gaussian N160 from 1993-08-04 (32-bit)
+r160_32_19940302                       LSM for reduced Gaussian N160 from 1994-03-02 (32-bit)
+r160_32_19940823                       LSM for reduced Gaussian N160 from 1994-08-23 (32-bit)
+r160_32_19950404                       LSM for reduced Gaussian N160 from 1995-04-04 (32-bit)
+r160_64_19790930                       LSM for reduced Gaussian N160 from 1979-09-30 (64-bit)
+r160_64_19910917                       LSM for reduced Gaussian N160 from 1991-09-17 (64-bit)
+r160_64_19930804                       LSM for reduced Gaussian N160 from 1993-08-04 (64-bit)
+r160_64_19940302                       LSM for reduced Gaussian N160 from 1994-03-02 (64-bit)
+r160_64_19940823                       LSM for reduced Gaussian N160 from 1994-08-23 (64-bit)
+r160_64_19950404                       LSM for reduced Gaussian N160 from 1995-04-04 (64-bit)
+r160_xx_19790930                       LSM for reduced Gaussian N160 from 1979-09-30
+r160_xx_19910917                       LSM for reduced Gaussian N160 from 1991-09-17
+r160_xx_19930804                       LSM for reduced Gaussian N160 from 1993-08-04
+r160_xx_19940302                       LSM for reduced Gaussian N160 from 1994-03-02
+r160_xx_19940823                       LSM for reduced Gaussian N160 from 1994-08-23
+r160_xx_19950404                       LSM for reduced Gaussian N160 from 1995-04-04
diff --git a/tables/interpol/LSM_GG_0032 b/tables/interpol/LSM_GG_0032
new file mode 120000
index 0000000..5640151
--- /dev/null
+++ b/tables/interpol/LSM_GG_0032
@@ -0,0 +1 @@
+climate.v014/N32
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0032_CY41R1 b/tables/interpol/LSM_GG_0032_CY41R1
new file mode 120000
index 0000000..5640151
--- /dev/null
+++ b/tables/interpol/LSM_GG_0032_CY41R1
@@ -0,0 +1 @@
+climate.v014/N32
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0048 b/tables/interpol/LSM_GG_0048
deleted file mode 100644
index 6c9560e..0000000
Binary files a/tables/interpol/LSM_GG_0048 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0048 b/tables/interpol/LSM_GG_0048
new file mode 120000
index 0000000..5c853b7
--- /dev/null
+++ b/tables/interpol/LSM_GG_0048
@@ -0,0 +1 @@
+climate.v014/N48
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0048_CY41R1 b/tables/interpol/LSM_GG_0048_CY41R1
deleted file mode 100644
index c00fb25..0000000
Binary files a/tables/interpol/LSM_GG_0048_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0048_CY41R1 b/tables/interpol/LSM_GG_0048_CY41R1
new file mode 120000
index 0000000..5c853b7
--- /dev/null
+++ b/tables/interpol/LSM_GG_0048_CY41R1
@@ -0,0 +1 @@
+climate.v014/N48
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0080 b/tables/interpol/LSM_GG_0080
deleted file mode 100644
index 4a84fb0..0000000
Binary files a/tables/interpol/LSM_GG_0080 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0080 b/tables/interpol/LSM_GG_0080
new file mode 120000
index 0000000..36de911
--- /dev/null
+++ b/tables/interpol/LSM_GG_0080
@@ -0,0 +1 @@
+climate.v014/N80
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0080_CY41R1 b/tables/interpol/LSM_GG_0080_CY41R1
deleted file mode 100644
index 82dcd06..0000000
Binary files a/tables/interpol/LSM_GG_0080_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0080_CY41R1 b/tables/interpol/LSM_GG_0080_CY41R1
new file mode 120000
index 0000000..36de911
--- /dev/null
+++ b/tables/interpol/LSM_GG_0080_CY41R1
@@ -0,0 +1 @@
+climate.v014/N80
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0096 b/tables/interpol/LSM_GG_0096
new file mode 120000
index 0000000..299e423
--- /dev/null
+++ b/tables/interpol/LSM_GG_0096
@@ -0,0 +1 @@
+climate.v014/N96
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0096_CY41R1 b/tables/interpol/LSM_GG_0096_CY41R1
new file mode 120000
index 0000000..299e423
--- /dev/null
+++ b/tables/interpol/LSM_GG_0096_CY41R1
@@ -0,0 +1 @@
+climate.v014/N96
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0128 b/tables/interpol/LSM_GG_0128
deleted file mode 100644
index ae60fcb..0000000
Binary files a/tables/interpol/LSM_GG_0128 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0128 b/tables/interpol/LSM_GG_0128
new file mode 120000
index 0000000..1c4c114
--- /dev/null
+++ b/tables/interpol/LSM_GG_0128
@@ -0,0 +1 @@
+climate.v014/N128
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0128_CY41R1 b/tables/interpol/LSM_GG_0128_CY41R1
deleted file mode 100644
index d0ff22a..0000000
Binary files a/tables/interpol/LSM_GG_0128_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0128_CY41R1 b/tables/interpol/LSM_GG_0128_CY41R1
new file mode 120000
index 0000000..1c4c114
--- /dev/null
+++ b/tables/interpol/LSM_GG_0128_CY41R1
@@ -0,0 +1 @@
+climate.v014/N128
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0160 b/tables/interpol/LSM_GG_0160
deleted file mode 100644
index 2b773a1..0000000
Binary files a/tables/interpol/LSM_GG_0160 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0160 b/tables/interpol/LSM_GG_0160
new file mode 120000
index 0000000..202dd3f
--- /dev/null
+++ b/tables/interpol/LSM_GG_0160
@@ -0,0 +1 @@
+climate.v014/N160
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0160_CY41R1 b/tables/interpol/LSM_GG_0160_CY41R1
deleted file mode 100644
index 67e4e48..0000000
Binary files a/tables/interpol/LSM_GG_0160_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0160_CY41R1 b/tables/interpol/LSM_GG_0160_CY41R1
new file mode 120000
index 0000000..202dd3f
--- /dev/null
+++ b/tables/interpol/LSM_GG_0160_CY41R1
@@ -0,0 +1 @@
+climate.v014/N160
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0200 b/tables/interpol/LSM_GG_0200
deleted file mode 100644
index 733bb99..0000000
Binary files a/tables/interpol/LSM_GG_0200 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0200 b/tables/interpol/LSM_GG_0200
new file mode 120000
index 0000000..478a7b4
--- /dev/null
+++ b/tables/interpol/LSM_GG_0200
@@ -0,0 +1 @@
+climate.v014/N200
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0200_CY41R1 b/tables/interpol/LSM_GG_0200_CY41R1
deleted file mode 100644
index eac29a1..0000000
Binary files a/tables/interpol/LSM_GG_0200_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0200_CY41R1 b/tables/interpol/LSM_GG_0200_CY41R1
new file mode 120000
index 0000000..478a7b4
--- /dev/null
+++ b/tables/interpol/LSM_GG_0200_CY41R1
@@ -0,0 +1 @@
+climate.v014/N200
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0256 b/tables/interpol/LSM_GG_0256
deleted file mode 100644
index 21db783..0000000
Binary files a/tables/interpol/LSM_GG_0256 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0256 b/tables/interpol/LSM_GG_0256
new file mode 120000
index 0000000..3f1eb5f
--- /dev/null
+++ b/tables/interpol/LSM_GG_0256
@@ -0,0 +1 @@
+climate.v014/N256
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0256_CY41R1 b/tables/interpol/LSM_GG_0256_CY41R1
deleted file mode 100644
index 3f07d41..0000000
Binary files a/tables/interpol/LSM_GG_0256_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0256_CY41R1 b/tables/interpol/LSM_GG_0256_CY41R1
new file mode 120000
index 0000000..3f1eb5f
--- /dev/null
+++ b/tables/interpol/LSM_GG_0256_CY41R1
@@ -0,0 +1 @@
+climate.v014/N256
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0320 b/tables/interpol/LSM_GG_0320
deleted file mode 100644
index 2c7346a..0000000
Binary files a/tables/interpol/LSM_GG_0320 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0320 b/tables/interpol/LSM_GG_0320
new file mode 120000
index 0000000..464c1da
--- /dev/null
+++ b/tables/interpol/LSM_GG_0320
@@ -0,0 +1 @@
+climate.v014/N320
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0320_CY41R1 b/tables/interpol/LSM_GG_0320_CY41R1
deleted file mode 100644
index 252f69e..0000000
Binary files a/tables/interpol/LSM_GG_0320_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0320_CY41R1 b/tables/interpol/LSM_GG_0320_CY41R1
new file mode 120000
index 0000000..464c1da
--- /dev/null
+++ b/tables/interpol/LSM_GG_0320_CY41R1
@@ -0,0 +1 @@
+climate.v014/N320
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0400 b/tables/interpol/LSM_GG_0400
deleted file mode 100644
index 877aa1f..0000000
Binary files a/tables/interpol/LSM_GG_0400 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0400 b/tables/interpol/LSM_GG_0400
new file mode 120000
index 0000000..b134330
--- /dev/null
+++ b/tables/interpol/LSM_GG_0400
@@ -0,0 +1 @@
+climate.v014/N400
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0400.lxab b/tables/interpol/LSM_GG_0400.lxab
deleted file mode 100644
index 37f976d..0000000
Binary files a/tables/interpol/LSM_GG_0400.lxab and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0400_CY41R1 b/tables/interpol/LSM_GG_0400_CY41R1
deleted file mode 100644
index ced2a20..0000000
Binary files a/tables/interpol/LSM_GG_0400_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0400_CY41R1 b/tables/interpol/LSM_GG_0400_CY41R1
new file mode 120000
index 0000000..b134330
--- /dev/null
+++ b/tables/interpol/LSM_GG_0400_CY41R1
@@ -0,0 +1 @@
+climate.v014/N400
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0512 b/tables/interpol/LSM_GG_0512
new file mode 120000
index 0000000..63c5cd5
--- /dev/null
+++ b/tables/interpol/LSM_GG_0512
@@ -0,0 +1 @@
+climate.v014/N512
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0512_CY41R1 b/tables/interpol/LSM_GG_0512_CY41R1
new file mode 120000
index 0000000..63c5cd5
--- /dev/null
+++ b/tables/interpol/LSM_GG_0512_CY41R1
@@ -0,0 +1 @@
+climate.v014/N512
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0640 b/tables/interpol/LSM_GG_0640
deleted file mode 100644
index 3b52b69..0000000
Binary files a/tables/interpol/LSM_GG_0640 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0640 b/tables/interpol/LSM_GG_0640
new file mode 120000
index 0000000..ac13a51
--- /dev/null
+++ b/tables/interpol/LSM_GG_0640
@@ -0,0 +1 @@
+climate.v014/N640
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_0640_CY41R1 b/tables/interpol/LSM_GG_0640_CY41R1
deleted file mode 100644
index 454ca93..0000000
Binary files a/tables/interpol/LSM_GG_0640_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_0640_CY41R1 b/tables/interpol/LSM_GG_0640_CY41R1
new file mode 120000
index 0000000..ac13a51
--- /dev/null
+++ b/tables/interpol/LSM_GG_0640_CY41R1
@@ -0,0 +1 @@
+climate.v014/N640
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_1024 b/tables/interpol/LSM_GG_1024
deleted file mode 100644
index b7483af..0000000
Binary files a/tables/interpol/LSM_GG_1024 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_1024 b/tables/interpol/LSM_GG_1024
new file mode 120000
index 0000000..1951370
--- /dev/null
+++ b/tables/interpol/LSM_GG_1024
@@ -0,0 +1 @@
+climate.v014/N1024
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_1024_CY41R1 b/tables/interpol/LSM_GG_1024_CY41R1
deleted file mode 100644
index e118117..0000000
Binary files a/tables/interpol/LSM_GG_1024_CY41R1 and /dev/null differ
diff --git a/tables/interpol/LSM_GG_1024_CY41R1 b/tables/interpol/LSM_GG_1024_CY41R1
new file mode 120000
index 0000000..1951370
--- /dev/null
+++ b/tables/interpol/LSM_GG_1024_CY41R1
@@ -0,0 +1 @@
+climate.v014/N1024
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_1280 b/tables/interpol/LSM_GG_1280
new file mode 120000
index 0000000..a3d1768
--- /dev/null
+++ b/tables/interpol/LSM_GG_1280
@@ -0,0 +1 @@
+climate.v014/N1280
\ No newline at end of file
diff --git a/tables/interpol/LSM_GG_1280_CY41R1 b/tables/interpol/LSM_GG_1280_CY41R1
new file mode 120000
index 0000000..a3d1768
--- /dev/null
+++ b/tables/interpol/LSM_GG_1280_CY41R1
@@ -0,0 +1 @@
+climate.v014/N1280
\ No newline at end of file
diff --git a/tables/interpol/LSM_O1024 b/tables/interpol/LSM_O1024
new file mode 120000
index 0000000..3cb484b
--- /dev/null
+++ b/tables/interpol/LSM_O1024
@@ -0,0 +1 @@
+climate.v014/O1024
\ No newline at end of file
diff --git a/tables/interpol/LSM_O1024_CY41R1 b/tables/interpol/LSM_O1024_CY41R1
new file mode 120000
index 0000000..3cb484b
--- /dev/null
+++ b/tables/interpol/LSM_O1024_CY41R1
@@ -0,0 +1 @@
+climate.v014/O1024
\ No newline at end of file
diff --git a/tables/interpol/LSM_O128 b/tables/interpol/LSM_O128
new file mode 120000
index 0000000..e1ea89b
--- /dev/null
+++ b/tables/interpol/LSM_O128
@@ -0,0 +1 @@
+climate.v014/O128
\ No newline at end of file
diff --git a/tables/interpol/LSM_O1280 b/tables/interpol/LSM_O1280
new file mode 120000
index 0000000..c4bcf0e
--- /dev/null
+++ b/tables/interpol/LSM_O1280
@@ -0,0 +1 @@
+climate.v014/O1280
\ No newline at end of file
diff --git a/tables/interpol/LSM_O1280_CY41R1 b/tables/interpol/LSM_O1280_CY41R1
new file mode 120000
index 0000000..c4bcf0e
--- /dev/null
+++ b/tables/interpol/LSM_O1280_CY41R1
@@ -0,0 +1 @@
+climate.v014/O1280
\ No newline at end of file
diff --git a/tables/interpol/LSM_O128_CY41R1 b/tables/interpol/LSM_O128_CY41R1
new file mode 120000
index 0000000..e1ea89b
--- /dev/null
+++ b/tables/interpol/LSM_O128_CY41R1
@@ -0,0 +1 @@
+climate.v014/O128
\ No newline at end of file
diff --git a/tables/interpol/LSM_O160 b/tables/interpol/LSM_O160
new file mode 120000
index 0000000..2e6a1fb
--- /dev/null
+++ b/tables/interpol/LSM_O160
@@ -0,0 +1 @@
+climate.v014/O160
\ No newline at end of file
diff --git a/tables/interpol/LSM_O160_CY41R1 b/tables/interpol/LSM_O160_CY41R1
new file mode 120000
index 0000000..2e6a1fb
--- /dev/null
+++ b/tables/interpol/LSM_O160_CY41R1
@@ -0,0 +1 @@
+climate.v014/O160
\ No newline at end of file
diff --git a/tables/interpol/LSM_O200 b/tables/interpol/LSM_O200
new file mode 120000
index 0000000..a5444a8
--- /dev/null
+++ b/tables/interpol/LSM_O200
@@ -0,0 +1 @@
+climate.v014/O200
\ No newline at end of file
diff --git a/tables/interpol/LSM_O200_CY41R1 b/tables/interpol/LSM_O200_CY41R1
new file mode 120000
index 0000000..a5444a8
--- /dev/null
+++ b/tables/interpol/LSM_O200_CY41R1
@@ -0,0 +1 @@
+climate.v014/O200
\ No newline at end of file
diff --git a/tables/interpol/LSM_O256 b/tables/interpol/LSM_O256
new file mode 120000
index 0000000..66c4713
--- /dev/null
+++ b/tables/interpol/LSM_O256
@@ -0,0 +1 @@
+climate.v014/O256
\ No newline at end of file
diff --git a/tables/interpol/LSM_O256_CY41R1 b/tables/interpol/LSM_O256_CY41R1
new file mode 120000
index 0000000..66c4713
--- /dev/null
+++ b/tables/interpol/LSM_O256_CY41R1
@@ -0,0 +1 @@
+climate.v014/O256
\ No newline at end of file
diff --git a/tables/interpol/LSM_O320 b/tables/interpol/LSM_O320
new file mode 120000
index 0000000..935af79
--- /dev/null
+++ b/tables/interpol/LSM_O320
@@ -0,0 +1 @@
+climate.v014/O320
\ No newline at end of file
diff --git a/tables/interpol/LSM_O320_CY41R1 b/tables/interpol/LSM_O320_CY41R1
new file mode 120000
index 0000000..935af79
--- /dev/null
+++ b/tables/interpol/LSM_O320_CY41R1
@@ -0,0 +1 @@
+climate.v014/O320
\ No newline at end of file
diff --git a/tables/interpol/LSM_O400 b/tables/interpol/LSM_O400
new file mode 120000
index 0000000..d4d812b
--- /dev/null
+++ b/tables/interpol/LSM_O400
@@ -0,0 +1 @@
+climate.v014/O400
\ No newline at end of file
diff --git a/tables/interpol/LSM_O400_CY41R1 b/tables/interpol/LSM_O400_CY41R1
new file mode 120000
index 0000000..d4d812b
--- /dev/null
+++ b/tables/interpol/LSM_O400_CY41R1
@@ -0,0 +1 @@
+climate.v014/O400
\ No newline at end of file
diff --git a/tables/interpol/LSM_O512 b/tables/interpol/LSM_O512
new file mode 120000
index 0000000..0295dfe
--- /dev/null
+++ b/tables/interpol/LSM_O512
@@ -0,0 +1 @@
+climate.v014/O512
\ No newline at end of file
diff --git a/tables/interpol/LSM_O512_CY41R1 b/tables/interpol/LSM_O512_CY41R1
new file mode 120000
index 0000000..0295dfe
--- /dev/null
+++ b/tables/interpol/LSM_O512_CY41R1
@@ -0,0 +1 @@
+climate.v014/O512
\ No newline at end of file
diff --git a/tables/interpol/LSM_O64 b/tables/interpol/LSM_O64
new file mode 120000
index 0000000..8ece54c
--- /dev/null
+++ b/tables/interpol/LSM_O64
@@ -0,0 +1 @@
+climate.v014/O64
\ No newline at end of file
diff --git a/tables/interpol/LSM_O640 b/tables/interpol/LSM_O640
new file mode 120000
index 0000000..d5a9c05
--- /dev/null
+++ b/tables/interpol/LSM_O640
@@ -0,0 +1 @@
+climate.v014/O640
\ No newline at end of file
diff --git a/tables/interpol/LSM_O640_CY41R1 b/tables/interpol/LSM_O640_CY41R1
new file mode 120000
index 0000000..d5a9c05
--- /dev/null
+++ b/tables/interpol/LSM_O640_CY41R1
@@ -0,0 +1 @@
+climate.v014/O640
\ No newline at end of file
diff --git a/tables/interpol/LSM_O64_CY41R1 b/tables/interpol/LSM_O64_CY41R1
new file mode 120000
index 0000000..8ece54c
--- /dev/null
+++ b/tables/interpol/LSM_O64_CY41R1
@@ -0,0 +1 @@
+climate.v014/O64
\ No newline at end of file
diff --git a/tables/interpol/LSM_O80 b/tables/interpol/LSM_O80
new file mode 120000
index 0000000..a898a04
--- /dev/null
+++ b/tables/interpol/LSM_O80
@@ -0,0 +1 @@
+climate.v014/O80
\ No newline at end of file
diff --git a/tables/interpol/LSM_O80_CY41R1 b/tables/interpol/LSM_O80_CY41R1
new file mode 120000
index 0000000..a898a04
--- /dev/null
+++ b/tables/interpol/LSM_O80_CY41R1
@@ -0,0 +1 @@
+climate.v014/O80
\ No newline at end of file
diff --git a/tables/interpol/LSM_O96 b/tables/interpol/LSM_O96
new file mode 120000
index 0000000..5b55930
--- /dev/null
+++ b/tables/interpol/LSM_O96
@@ -0,0 +1 @@
+climate.v014/O96
\ No newline at end of file
diff --git a/tables/interpol/LSM_O96_CY41R1 b/tables/interpol/LSM_O96_CY41R1
new file mode 120000
index 0000000..5b55930
--- /dev/null
+++ b/tables/interpol/LSM_O96_CY41R1
@@ -0,0 +1 @@
+climate.v014/O96
\ No newline at end of file
diff --git a/tables/interpol/climate.v014/N1024 b/tables/interpol/climate.v014/N1024
new file mode 100644
index 0000000..ef96413
Binary files /dev/null and b/tables/interpol/climate.v014/N1024 differ
diff --git a/tables/interpol/climate.v014/N128 b/tables/interpol/climate.v014/N128
new file mode 100644
index 0000000..48528d7
Binary files /dev/null and b/tables/interpol/climate.v014/N128 differ
diff --git a/tables/interpol/climate.v014/N1280 b/tables/interpol/climate.v014/N1280
new file mode 100644
index 0000000..6508f98
Binary files /dev/null and b/tables/interpol/climate.v014/N1280 differ
diff --git a/tables/interpol/climate.v014/N160 b/tables/interpol/climate.v014/N160
new file mode 100644
index 0000000..2c73f97
Binary files /dev/null and b/tables/interpol/climate.v014/N160 differ
diff --git a/tables/interpol/climate.v014/N200 b/tables/interpol/climate.v014/N200
new file mode 100644
index 0000000..f108f2a
Binary files /dev/null and b/tables/interpol/climate.v014/N200 differ
diff --git a/tables/interpol/climate.v014/N256 b/tables/interpol/climate.v014/N256
new file mode 100644
index 0000000..314e2d8
Binary files /dev/null and b/tables/interpol/climate.v014/N256 differ
diff --git a/tables/interpol/climate.v014/N32 b/tables/interpol/climate.v014/N32
new file mode 100644
index 0000000..5bbe1c4
Binary files /dev/null and b/tables/interpol/climate.v014/N32 differ
diff --git a/tables/interpol/climate.v014/N320 b/tables/interpol/climate.v014/N320
new file mode 100644
index 0000000..ee86aaf
Binary files /dev/null and b/tables/interpol/climate.v014/N320 differ
diff --git a/tables/interpol/climate.v014/N400 b/tables/interpol/climate.v014/N400
new file mode 100644
index 0000000..77965b6
Binary files /dev/null and b/tables/interpol/climate.v014/N400 differ
diff --git a/tables/interpol/climate.v014/N48 b/tables/interpol/climate.v014/N48
new file mode 100644
index 0000000..83feb94
Binary files /dev/null and b/tables/interpol/climate.v014/N48 differ
diff --git a/tables/interpol/climate.v014/N512 b/tables/interpol/climate.v014/N512
new file mode 100644
index 0000000..0ed222e
Binary files /dev/null and b/tables/interpol/climate.v014/N512 differ
diff --git a/tables/interpol/climate.v014/N640 b/tables/interpol/climate.v014/N640
new file mode 100644
index 0000000..ff3b7a7
Binary files /dev/null and b/tables/interpol/climate.v014/N640 differ
diff --git a/tables/interpol/climate.v014/N80 b/tables/interpol/climate.v014/N80
new file mode 100644
index 0000000..d0aba50
Binary files /dev/null and b/tables/interpol/climate.v014/N80 differ
diff --git a/tables/interpol/climate.v014/N96 b/tables/interpol/climate.v014/N96
new file mode 100644
index 0000000..1985724
Binary files /dev/null and b/tables/interpol/climate.v014/N96 differ
diff --git a/tables/interpol/climate.v014/O1024 b/tables/interpol/climate.v014/O1024
new file mode 100644
index 0000000..a498378
Binary files /dev/null and b/tables/interpol/climate.v014/O1024 differ
diff --git a/tables/interpol/climate.v014/O128 b/tables/interpol/climate.v014/O128
new file mode 100644
index 0000000..da0c4f5
Binary files /dev/null and b/tables/interpol/climate.v014/O128 differ
diff --git a/tables/interpol/climate.v014/O1280 b/tables/interpol/climate.v014/O1280
new file mode 100644
index 0000000..d1c12b3
Binary files /dev/null and b/tables/interpol/climate.v014/O1280 differ
diff --git a/tables/interpol/climate.v014/O160 b/tables/interpol/climate.v014/O160
new file mode 100644
index 0000000..e24d222
Binary files /dev/null and b/tables/interpol/climate.v014/O160 differ
diff --git a/tables/interpol/climate.v014/O200 b/tables/interpol/climate.v014/O200
new file mode 100644
index 0000000..b6cd94d
Binary files /dev/null and b/tables/interpol/climate.v014/O200 differ
diff --git a/tables/interpol/climate.v014/O256 b/tables/interpol/climate.v014/O256
new file mode 100644
index 0000000..0db23ae
Binary files /dev/null and b/tables/interpol/climate.v014/O256 differ
diff --git a/tables/interpol/climate.v014/O320 b/tables/interpol/climate.v014/O320
new file mode 100644
index 0000000..07dc387
Binary files /dev/null and b/tables/interpol/climate.v014/O320 differ
diff --git a/tables/interpol/climate.v014/O400 b/tables/interpol/climate.v014/O400
new file mode 100644
index 0000000..3ae5be5
Binary files /dev/null and b/tables/interpol/climate.v014/O400 differ
diff --git a/tables/interpol/climate.v014/O512 b/tables/interpol/climate.v014/O512
new file mode 100644
index 0000000..bbdbabb
Binary files /dev/null and b/tables/interpol/climate.v014/O512 differ
diff --git a/tables/interpol/climate.v014/O64 b/tables/interpol/climate.v014/O64
new file mode 100644
index 0000000..a55730c
Binary files /dev/null and b/tables/interpol/climate.v014/O64 differ
diff --git a/tables/interpol/climate.v014/O640 b/tables/interpol/climate.v014/O640
new file mode 100644
index 0000000..a168335
Binary files /dev/null and b/tables/interpol/climate.v014/O640 differ
diff --git a/tables/interpol/climate.v014/O80 b/tables/interpol/climate.v014/O80
new file mode 100644
index 0000000..62273e9
Binary files /dev/null and b/tables/interpol/climate.v014/O80 differ
diff --git a/tables/interpol/climate.v014/O96 b/tables/interpol/climate.v014/O96
new file mode 100644
index 0000000..8ee563e
Binary files /dev/null and b/tables/interpol/climate.v014/O96 differ
diff --git a/tables/interpol/ksm_xx_lsm0p5deg b/tables/interpol/ksm_xx_lsm0p5deg
deleted file mode 100644
index 38e3019..0000000
Binary files a/tables/interpol/ksm_xx_lsm0p5deg and /dev/null differ
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f32eecd..3faf2e1 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,192 +1,469 @@
-find_program( GRIB_COMPARE grib_compare )
 
-if( NOT GRIB_COMPARE AND TARGET grib_compare )
-  get_target_property( GRIB_COMPARE grib_compare LOCATION )
+# tools to help testing:
+# - int (internal)
+# - gg_gridname (internal)
+# - grib_compare (bundle, on provided path, or on system path)
+# - cmp (strict binary comparison)
+get_target_property( CMD_INT int LOCATION )
+if( ENABLE_INSTALL_TOOLS )
+  get_target_property( CMD_GG_GRIDNAME gg_gridname LOCATION )
 endif()
 
-if( NOT grib_api_BASE_DIR AND GRIB_COMPARE )
-  get_filename_component( _grib_compare_dir "${GRIB_COMPARE}" PATH )
+if( TARGET grib_compare )
+  get_target_property( CMD_GRIB_COMPARE grib_compare LOCATION )
+endif()
+if( NOT CMD_GRIB_COMPARE )
+  find_program( CMD_GRIB_COMPARE grib_compare NO_DEFAULT_PATH HINTS "${grib_api_BASE_DIR}" PATH_SUFFIXES "bin" )
+endif()
+if( NOT CMD_GRIB_COMPARE )
+  find_program( CMD_GRIB_COMPARE grib_compare )
+endif()
+if( NOT CMD_GRIB_COMPARE )
+  set( CMD_GRIB_COMPARE_MSG "(some tests disabled!)" )
+endif()
+
+find_program( CMD_CMP cmp )
+
+
+# define the grib & emos runtime environment
+if( NOT grib_api_BASE_DIR AND CMD_GRIB_COMPARE )
+  get_filename_component( _grib_compare_dir "${CMD_GRIB_COMPARE}" PATH )
   get_filename_component( grib_api_BASE_DIR "${_grib_compare_dir}" ABSOLUTE )
   set( grib_api_BASE_DIR "${grib_api_BASE_DIR}/../" )
 endif()
 
-if( NOT GRIB_COMPARE )
-    message( WARNING "Could not find grib_compare executable -- turning off some tests!\nTo enable them place 'grib_compare' on the PATH and re-run cmake" )
-else()
-    message( STATUS "Testing with grib_api: ${grib_api_BASE_DIR}" )
-    message( STATUS "Testing with grib_compare: ${GRIB_COMPARE}" )
+message( STATUS "Testing with grib_api:                 ${grib_api_BASE_DIR}" )
+message( STATUS "Testing with grib_compare:             ${CMD_GRIB_COMPARE} ${CMD_GRIB_COMPARE_MSG}" )
+message( STATUS "Testing with cmp:                      ${CMD_CMP}" )
+if( NOT CMD_GRIB_COMPARE OR NOT CMD_CMP )
+  message( WARNING "Some tools not found in PATH: turning off some tests." )
 endif()
 
-# define the grib environment
 if( grib_api_BASE_DIR )
   set( _grib_environment
-    GRIB_DEFINITION_PATH=${grib_api_BASE_DIR}/share/grib_api/definitions/
+    GRIB_DEFINITION_PATH=${grib_api_BASE_DIR}/share/grib_api/definitions/:${grib_api_BASE_DIR}/share/grib_api/definitions/grib1/
     GRIB_SAMPLES_PATH=${grib_api_BASE_DIR}/share/grib_api/samples/ )
 endif()
+set( _emos_environment
+  "${_grib_environment}"
+# JDCNDBG=2
+# INTF2_DEBUG=1
+  CONFIG_INTERP=ON_FLY
+  MARS_LSM_PATH=${PROJECT_SOURCE_DIR}/tables/interpol
+  ECMWF_LOCAL_TABLE_PATH=${PROJECT_SOURCE_DIR}/gribtables
+  LOCAL_DEFINITION_TEMPLATES=${PROJECT_SOURCE_DIR}/gribtemplates )
+
 
 # configure Fortran-based targets for double precision (compilation & linking)
-set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${emos_double_precision_flags}")
-
-configure_file( include.sh.in include.sh @ONLY )
-
-##################### INTERPOLATION #######################
-
-ecbuild_add_test(
-  TARGET  interpolation_example_grib_api
-  SOURCES interpolation_example_grib_api.F
-  LIBS    emos ${GRIB_API_LIBRARIES}
-  ARGS    -i ${PROJECT_SOURCE_DIR}/data/latlon.grib -o interpolation_example_grib_api.grib
-  LINKER_LANGUAGE Fortran
-  ENVIRONMENT
-    "${_grib_environment}"
-    MARS_LSM_PATH=${CMAKE_BINARY_DIR}/${INSTALL_DATA_DIR}/tables/interpol/
-    ECMWF_LOCAL_TABLE_PATH=${PROJECT_SOURCE_DIR}/gribtables/
-    LOCAL_DEFINITION_TEMPLATES=${PROJECT_SOURCE_DIR}/gribtemplates/ )
-
-ecbuild_add_test(
-  TARGET  interpolation_example_wind
-  SOURCES interpolation_example_wind.F
-  LIBS    emos ${GRIB_API_LIBRARIES}
-  ARGS    -i ${PROJECT_SOURCE_DIR}/data/latlon.grib -o interpolation_example_wind.grib
-  LINKER_LANGUAGE Fortran
-  ENVIRONMENT
-    "${_grib_environment}"
-    MARS_LSM_PATH=${CMAKE_BINARY_DIR}/${INSTALL_DATA_DIR}/tables/interpol/
-    ECMWF_LOCAL_TABLE_PATH=${PROJECT_SOURCE_DIR}/gribtables/
-    LOCAL_DEFINITION_TEMPLATES=${PROJECT_SOURCE_DIR}/gribtemplates/ )
+ecbuild_add_fortran_flags(${emos_double_precision_flags})
+
+
+################ I N T E R P O L A T I O N ################
+
+if( HAVE_TESTS AND HAVE_LIBEMOS_INTERPOLATION )
+
+  # intuvp2: interpolation to different formats
+  foreach( out "regular_ll" "F80" "N80" "O80" )
+    set( in "sh_vod" )
+    set( test "${in}_to_${out}" )
+    if( NOT (test MATCHES "^sh_.*_to_O" AND NOT HAVE_FFTW) )
+      set( input  "${PROJECT_SOURCE_DIR}/data/${in}.grib" )
+      set( output "intuvp2_${test}.grib" )
+      if( out MATCHES "^regular_ll" )
+        set( grid "--grid=3.0/3.0" )
+      else()
+        set( grid "--gridname=${out}" )
+      endif()
+
+      # interpolate
+      ecbuild_add_test(
+        TARGET       intuvp2_${test}_interpol
+        DEPENDS      int
+        COMMAND      ${CMD_INT}
+        ARGS         ${grid} --input=${input} --output=${output} --int=intuvp2
+        ENVIRONMENT  ${_emos_environment} )
+
+      # compare results to reference data
+      ecbuild_add_test(
+        TARGET       intuvp2_${test}_compare
+        TEST_DEPENDS intuvp2_${test}_interpol
+        CONDITION    CMD_GRIB_COMPARE
+        COMMAND      ${CMD_GRIB_COMPARE}
+        ARGS         ${PROJECT_SOURCE_DIR}/data/${output} ${output}
+        ENVIRONMENT  ${_grib_environment} )
+
+      unset( grid )
+      unset( output )
+      unset( input )
+    endif()
+    unset( test )
+    unset( in )
+  endforeach()
+
+  # intf2: interpolation to different formats
+  # not possible:
+  # - regular_ll to reduced Gaussian (G) (but regular_ll to regular G is possible)
+  # - regular G to reduced G
+  # - any to rotated reduced/regular G
+  # - regular_ll to rotated regular_ll
+  foreach( rotated "" "rotated_" )
+    foreach( in "sh_vod" "sh_z" "regular_ll" "N640" "O640" "F640" )
+      foreach( out "regular_ll" "F80" "N80" "O80" "F48" )
+        set( test "${in}_to_${rotated}${out}" )
+        set( rot "--rotation=30/30" )
+        if( "${rotated}" STREQUAL "" )
+          set( rot "" )
+        endif()
+        if(     NOT  test MATCHES "^regular_ll_to_[NO]"
+            AND NOT  test MATCHES "^F.*_to_[NO]"
+            AND NOT  test MATCHES "^.*_to_rotated_[NOF]"
+            AND NOT  test MATCHES "^regular_ll_to_rotated_regular_ll$"
+            AND NOT (test MATCHES "^sh_.*_to_O" AND NOT HAVE_FFTW) )
+          set( input  "${PROJECT_SOURCE_DIR}/data/${in}.grib" )
+          set( output "intf2_${test}.grib" )
+          if( out MATCHES "^regular_ll" )
+            set( grid "--grid=0.5/0.5" )
+          else()
+            set( grid "--gridname=${out}" )
+          endif()
+
+          # interpolate
+          ecbuild_add_test(
+            TARGET       intf2_${test}_interpol
+            DEPENDS      int
+            COMMAND      ${CMD_INT}
+            ARGS         ${grid} --autoresol=1 --area=0/0/0/0 ${rot} --input=${input} --output=${output} --int=intf2
+            ENVIRONMENT  ${_emos_environment} )
+
+          # check gridname is expected and is a valid Gaussian grid
+          if( out MATCHES "^[FNO]" )
+            ecbuild_add_test(
+              TARGET       intf2_${test}_gridname
+              TEST_DEPENDS intf2_${test}_interpol
+              CONDITION    CMD_GG_GRIDNAME
+              COMMAND      ${CMD_GG_GRIDNAME}
+              ARGS         --eq=${out} ${output}
+              ENVIRONMENT  ${_grib_environment} )
+          endif()
+
+          # compare results to reference data, strict comparison except:
+          # - for PGI Fortran (lxab, opensuse113, lxc/pgi, opensuse131/pgi)
+          # - for N640_to_O80 (minor numeric issues, within 2x packing error)
+          if( NOT CMD_CMP
+              OR test MATCHES  "^(regular_ll|N640)_to_regular_ll$"
+              OR test MATCHES  "^N640_to_O80$" )
+            ecbuild_add_test(
+              TARGET       intf2_${test}_compare
+              TEST_DEPENDS intf2_${test}_interpol
+              CONDITION    CMD_GRIB_COMPARE
+              COMMAND      ${CMD_GRIB_COMPARE}
+              ARGS         -P -T 2 ${PROJECT_SOURCE_DIR}/data/${output} ${output}
+              ENVIRONMENT  ${_grib_environment} )
+          else()
+            ecbuild_add_test(
+              TARGET       intf2_${test}_compare
+              TEST_DEPENDS intf2_${test}_interpol
+              CONDITION    CMD_GRIB_COMPARE
+              COMMAND      ${CMD_GRIB_COMPARE}
+              ARGS         ${PROJECT_SOURCE_DIR}/data/${output} ${output}
+              ENVIRONMENT  ${_grib_environment} )
+          endif()
+
+          unset( grid )
+          unset( output )
+          unset( input )
+        endif()
+        unset( rot )
+        unset( test )
+      endforeach()
+    endforeach()
+  endforeach()
+
+
+  # intf2: interpolate to N/O grids with the same N
+  # (distinguish between N640 <> O640)
+  foreach( in "N640" "O640" )
+    foreach( out "N640" "O640" )
+      set( test "${in}_to_${out}" )
+      set( input  "${PROJECT_SOURCE_DIR}/data/${in}.grib" )
+      set( output "intf2_${test}.grib" )
+
+      # interpolate
+      ecbuild_add_test(
+        TARGET       intf2_${test}_interpol
+        DEPENDS      int
+        COMMAND      ${CMD_INT}
+        ARGS         --gridname=${out} --autoresol=1 --area=0/0/0/0 --input=${input} --output=${output} --int=intf2
+        ENVIRONMENT  ${_emos_environment} )
+
+      # compare results to reference data
+      if( in STREQUAL out )
+        ecbuild_add_test(
+          TARGET       intf2_${test}_compare_same
+          TEST_DEPENDS intf2_${test}_interpol
+          CONDITION    CMD_GRIB_COMPARE
+          COMMAND      ${CMD_GRIB_COMPARE}
+          ARGS         ${input} ${output}
+          ENVIRONMENT  ${_grib_environment} )
+      else()
+        ecbuild_add_test(
+          TARGET       intf2_${test}_compare_diff
+          TEST_DEPENDS intf2_${test}_interpol
+          CONDITION    CMD_GRIB_COMPARE
+          COMMAND      ${CMD_GRIB_COMPARE}
+          ARGS         ${input} ${output}
+          ENVIRONMENT  ${_grib_environment} )
+        set_tests_properties( intf2_${test}_compare_diff PROPERTIES WILL_FAIL TRUE )
+      endif()
+
+      # expect a gridname
+      ecbuild_add_test(
+        TARGET       intf2_${test}_gridname
+        TEST_DEPENDS intf2_${test}_interpol
+        CONDITION    CMD_GG_GRIDNAME
+        COMMAND      ${CMD_GG_GRIDNAME}
+        ARGS         --eq=${out} ${output}
+        ENVIRONMENT  ${_grib_environment} )
+
+      unset( output )
+      unset( input )
+      unset( test )
+    endforeach()
+  endforeach()
+
+
+  # intf2: interpolate to regular_ll corresponding to O1280 = 1/16 degree
+  if( FALSE )
+  foreach( in "O640" )
+    set( test "${in}_to_regular_ll_1-16" )
+    set( input  "${PROJECT_SOURCE_DIR}/data/${in}.grib" )
+    set( output "intf2_${test}.grib" )
+
+    # interpolate
+    ecbuild_add_test(
+      TARGET       intf2_${test}_interpol
+      DEPENDS      int
+      COMMAND      ${CMD_INT}
+      ARGS         --grid=0.0625/0.0625 --input=${input} --output=${output} --int=intf2
+      ENVIRONMENT  ${_emos_environment} )
+
+    # compare results to reference data
+    ecbuild_add_test(
+      TARGET       intf2_${test}_compare
+      TEST_DEPENDS intf2_${test}_interpol
+      CONDITION    CMD_GRIB_COMPARE
+      COMMAND      ${CMD_GRIB_COMPARE}
+      ARGS         ${PROJECT_SOURCE_DIR}/data/${output} ${output}
+      ENVIRONMENT  ${_grib_environment} )
+
+    unset( output )
+    unset( input )
+    unset( test )
+  endforeach()
+  endif()
+
+
+  # intf2: test GRIB edition 1 encoding limits
+  # snap-milli-degree:     snaps to 0.001 because grid is 0.00025/0.00025, and is GRIB1-encodable
+  # snap-sub-milli-degree: snaps to 0.0005, not GRIB1-encodable (failure expected)
+  if( FALSE )
+  foreach( snap "snap-milli-degree" "snap-sub-milli-degree_bad" )
+    set( test "N640_to_regular_ll_${snap}" )
+    if( snap MATCHES "^snap-milli-degree" )
+      set( eps "0.00076" )
+    elseif( snap MATCHES "^snap-sub-milli-degree" )
+      set( eps "0.00074" )
+    endif()
+    ecbuild_add_test(
+      TARGET       intf2_${test}_interpol
+      DEPENDS      int
+      COMMAND      ${CMD_INT}
+      ARGS         --grid=0.00025/0.00025 --area=${eps}/0/0/${eps} --input=${PROJECT_SOURCE_DIR}/data/N640.grib --output="intf2_${test}.grib" --int=intf2
+      ENVIRONMENT  ${_emos_environment} )
+    unset( eps )
+    unset( test )
+  endforeach()
+  set_tests_properties( intf2_N640_to_regular_ll_snap-sub-milli-degree_bad_interpol PROPERTIES WILL_FAIL TRUE )
+
+  set( snap "snap-sub-milli-degree_sub-area_bad" )
+  set( test "N640_to_regular_ll_${snap}" )
+  ecbuild_add_test(
+    TARGET       intf2_${test}_interpol
+    DEPENDS      int
+    COMMAND      ${CMD_INT}
+    ARGS         --grid=0.0625/0.0625 --area=1/0.0625/0/0.5625 --input=${PROJECT_SOURCE_DIR}/data/N640.grib --output="intf2_${test}.grib" --int=intf2
+    ENVIRONMENT  ${_emos_environment} )
+  set_tests_properties( intf2_${test}_interpol PROPERTIES WILL_FAIL TRUE )
+  unset( test )
+  unset( snap )
+  endif()
+
+
+  # intf2: compare FFT99 vs FFTW exactly (no tolerance!)
+  foreach( in "sh_vod" "sh_z" )
+    set( output_fftw  "intf2_${in}_to_N80-fftw.grib" )
+    set( output_fft99 "intf2_${in}_to_N80.grib" )
+
+    # interpolate forcing FFTW
+    ecbuild_add_test(
+      TARGET       intf2_${in}_to_N80_fft99_vs_fftw_interpol_fftw
+      TEST_DEPENDS intf2_${in}_to_N80_interpol
+      DEPENDS      int
+      COMMAND      ${CMD_INT}
+      CONDITION    HAVE_FFTW
+      ARGS         --gridname=N80 --autoresol=1 --area=0/0/0/0 --input=${PROJECT_SOURCE_DIR}/data/${in}.grib --output=${output_fftw} --int=intf2
+      ENVIRONMENT  EMOSLIB_FORCED_FFTW=1 ${_emos_environment} )
+
+    # compare results to already interpolated results (exactly)
+    ecbuild_add_test(
+      TARGET       intf2_${in}_to_N80_fft99_vs_fftw_compare
+      TEST_DEPENDS intf2_${in}_to_N80_fft99_vs_fftw_interpol_fftw
+      CONDITION    HAVE_FFTW AND CMD_GRIB_COMPARE
+      COMMAND      ${CMD_GRIB_COMPARE}
+      ARGS         ${output_fft99} ${output_fftw}
+      ENVIRONMENT  ${_grib_environment} )
+
+    unset( output_fft99 )
+    unset( output_fftw )
+  endforeach()
+
+
+  # intf2: test SH
+  set( in  "sh_vod" )
+  set( test "${in}_to_${in}_trunc" )
+  set( input  "${PROJECT_SOURCE_DIR}/data/${in}.grib" )
+  set( output "intf2_${test}.grib" )
+  ecbuild_add_test(
+    TARGET       intf2_${test}_interpol
+    DEPENDS      int
+    COMMAND      ${CMD_INT}
+    ARGS         --input=${input} --output=${output} --out:truncation=63 --int=intf2
+    ENVIRONMENT  ${_emos_environment} )
+  unset( output )
+  unset( input )
+  unset( test )
+  unset( in )
 
-ecbuild_add_executable(
-  TARGET  interpolation NOINSTALL
-  SOURCES interpolation.F
-  LIBS    emos ${GRIB_API_LIBRARIES} )
 
-ecbuild_add_test(
-  TARGET      interpolation
-  TYPE        SCRIPT
-  CONDITION   GRIB_COMPARE
-  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/interpolation.sh
-  RESOURCES   data_ref/spectral-ll.grib data_ref/spectral-rg.grib
-  ENVIRONMENT "${_grib_environment}"
-)
+  # FFTW/FFT990
+  ecbuild_add_test( TARGET fft99  SOURCES fft99.F  LIBS emos )
+  ecbuild_add_test( TARGET fftw   SOURCES fftw.F   LIBS emos  CONDITION HAVE_FFTW )
 
-##################### G R I B E X #########################
 
-if( HAVE_GRIBEX_ABORT )
+endif( HAVE_TESTS AND HAVE_LIBEMOS_INTERPOLATION )
 
-  ecbuild_add_test(
-    TARGET  gribex_abort
-    SOURCES gribex_abort.F
-    LIBS    emos ${GRIB_API_LIBRARIES}
-    LINKER_LANGUAGE Fortran )
-  set_tests_properties( gribex_abort PROPERTIES WILL_FAIL TRUE )
 
-else()
+####################### G R I B E X #######################
 
-  ecbuild_add_test(
-    TARGET  interpolation_example_gribex
-    SOURCES interpolation_example_gribex.F
-    LIBS    emos ${GRIB_API_LIBRARIES}
-    ARGS    -i ${PROJECT_SOURCE_DIR}/data/latlon.grib -o interpolation_example_gribex.grib
-    LINKER_LANGUAGE Fortran
-    ENVIRONMENT
-      "${_grib_environment}"
-      MARS_LSM_PATH=${CMAKE_BINARY_DIR}/${INSTALL_DATA_DIR}/tables/interpol/
-      ECMWF_LOCAL_TABLE_PATH=${PROJECT_SOURCE_DIR}/gribtables/
-      LOCAL_DEFINITION_TEMPLATES=${PROJECT_SOURCE_DIR}/gribtemplates/ )
+if( HAVE_TESTS AND HAVE_LIBEMOS_GRIBEX )
 
-endif()
+  foreach( test "gribex_demo" "gribex_abort" )
+    ecbuild_add_test(
+      TARGET      ${test}
+      SOURCES     ${test}.F
+      LIBS        emos
+      ARGS        -i ${PROJECT_SOURCE_DIR}/data/test_latlon.grib  # (only for gribex_demo)
+      ENVIRONMENT ${_emos_environment} )
+    set_tests_properties( ${test} PROPERTIES WILL_FAIL ${HAVE_GRIBEX_ABORT} )
+  endforeach()
 
-##################### B U F R #############################
+endif( HAVE_TESTS AND HAVE_LIBEMOS_GRIBEX )
 
-# set bufr tables path (for testing):
-# (check if bufrtables/ is bundled, otherwise set to best guess)
-if( NOT TEST_BUFR_TABLES_PATH AND EXISTS "${PROJECT_SOURCE_DIR}/bufrtables/B0000000000000000000.TXT" )
-  set( TEST_BUFR_TABLES_PATH "${PROJECT_SOURCE_DIR}/bufrtables" )
-elseif ( NOT TEST_BUFR_TABLES_PATH )
-  set( TEST_BUFR_TABLES_PATH "${BUFR_TABLES_PATH}" )
-endif()
-message( STATUS "TEST_BUFR_TABLES_PATH: ${TEST_BUFR_TABLES_PATH}" )
-if( EXISTS "${TEST_BUFR_TABLES_PATH}" )
-  set( TEST_BUFR_TABLES_PATH_EXISTS TRUE )
-else()
-  set( TEST_BUFR_TABLES_PATH_EXISTS FALSE )
-  message( WARNING "Could not find bufr tables path for testing -- turning off some tests!\nTo enable them set a valid TEST_BUFR_TABLES_PATH (alternatively, BUFR_TABLES_PATH) and re-run cmake" )
-endif()
 
-# download bufr test files
-file(READ "bufr_data_files.txt" bufr_files)
-string(REGEX REPLACE "\n" ";" bufr_files "${bufr_files}")
-ecbuild_get_test_multidata( TARGET download_bufrs NOCHECK NAMES ${bufr_files} )
+######################### B U F R #########################
 
-# add F90 tests
-if( ENABLE_FORTRAN90 )
+if( HAVE_TESTS AND HAVE_LIBEMOS_BUFRDC )
 
-  ecbuild_add_test(
-    TARGET       bufr_demo
-    SOURCES      bufr_demo.f90
-    LIBS         emos ${GRIB_API_LIBRARIES}
-    LINKER_LANGUAGE Fortran
-    CONDITION    TEST_BUFR_TABLES_PATH_EXISTS
-    ARGS         ${PROJECT_SOURCE_DIR}/data/temp_101.bufr
-    ENVIRONMENT  BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+  # set bufr tables path (for testing):
+  # (check if bufrtables/ is bundled, otherwise set to best guess)
+  if( NOT TEST_BUFR_TABLES_PATH AND EXISTS "${PROJECT_SOURCE_DIR}/bufrtables/B0000000000000000000.TXT" )
+    set( TEST_BUFR_TABLES_PATH "${PROJECT_SOURCE_DIR}/bufrtables" )
+  elseif ( NOT TEST_BUFR_TABLES_PATH )
+    set( TEST_BUFR_TABLES_PATH "${BUFR_TABLES_PATH}" )
+  endif()
 
-  ecbuild_add_test(
-    TARGET       bufr_demo_NotFoundTestFile
-    COMMAND      bufr_demo
-    CONDITION    TEST_BUFR_TABLES_PATH_EXISTS
-    ARGS         NotFoundTestFile.bufr
-    ENVIRONMENT  BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
-  set_tests_properties( bufr_demo_NotFoundTestFile PROPERTIES WILL_FAIL TRUE )
+  message( STATUS "TEST_BUFR_TABLES_PATH: ${TEST_BUFR_TABLES_PATH}" )
+
+  if( EXISTS "${TEST_BUFR_TABLES_PATH}" )
+    set( TEST_BUFR_TABLES_PATH_EXISTS TRUE )
+  else()
+    set( TEST_BUFR_TABLES_PATH_EXISTS FALSE )
+    message( WARNING "Could not find bufr tables path for testing -- turning off some tests!\nTo enable them set a valid TEST_BUFR_TABLES_PATH (alternatively, BUFR_TABLES_PATH) and re-run cmake" )
+  endif()
+
+  # download bufr test files
+  file(READ "bufr_data_files.txt" bufr_files)
+  string(REGEX REPLACE "\n" ";" bufr_files "${bufr_files}")
+  ecbuild_get_test_multidata( TARGET download_bufrs NOCHECK NAMES ${bufr_files} )
+
+  # This must be here or set_tests_properties() may fail
+  # FIXME: add PROPERTIES to ecbuild_add_test()
+  if( TEST_BUFR_TABLES_PATH_EXISTS )
+    ecbuild_add_test(
+      TARGET       bufr_decode_all_NotFoundTestFile
+      COMMAND      ${CMAKE_BINARY_DIR}/bin/bufr_decode_all
+      CONDITION    TEST_BUFR_TABLES_PATH_EXISTS
+      ARGS         -i NotFoundTestFile.bufr
+      ENVIRONMENT  BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+    set_tests_properties( bufr_decode_all_NotFoundTestFile PROPERTIES WILL_FAIL TRUE )
+  endif( TEST_BUFR_TABLES_PATH_EXISTS )
 
   ecbuild_add_test(
-    TARGET       bufr_demo_NotFoundTablesPath
-    COMMAND      bufr_demo
-    ARGS         ${PROJECT_SOURCE_DIR}/data/temp_101.bufr
-    ENVIRONMENT  BUFR_TABLES="NotFoundTablesPath/" )
-  set_tests_properties( bufr_demo_NotFoundTablesPath PROPERTIES WILL_FAIL TRUE )
-
-endif( ENABLE_FORTRAN90 )
-
-# add F77 tests
-ecbuild_add_test(
-  TARGET       bufr_decode_all_NotFoundTestFile
-  COMMAND      ${CMAKE_BINARY_DIR}/bin/bufr_decode_all
-  CONDITION    TEST_BUFR_TABLES_PATH_EXISTS
-  ARGS         -i NotFoundTestFile.bufr
-  ENVIRONMENT  BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
-set_tests_properties( bufr_decode_all_NotFoundTestFile PROPERTIES WILL_FAIL TRUE )
-
-ecbuild_add_test(
-  TARGET      bufr_decode_all_NotFoundTablesPath
-  COMMAND     ${CMAKE_BINARY_DIR}/bin/bufr_decode_all
-  ARGS        -i ${PROJECT_SOURCE_DIR}/data/temp_101.bufr
-  ENVIRONMENT BUFR_TABLES="NotFoundTablesPath/" )
-set_tests_properties( bufr_decode_all_NotFoundTablesPath PROPERTIES WILL_FAIL TRUE )
-
-foreach( bufr_file ${bufr_files} )
-  ecbuild_add_test(
-    TARGET       bufr_decode_all_${bufr_file}
+    TARGET       bufr_decode_all_NotFoundTablesPath
     COMMAND      ${CMAKE_BINARY_DIR}/bin/bufr_decode_all
-    CONDITION    TEST_BUFR_TABLES_PATH_EXISTS
-    ARGS         -i ${bufr_file}
-    TEST_DEPENDS download_bufrs
-    ENVIRONMENT  BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
-endforeach()
-
-
-#if( ENABLE_INSTALL_TOOLS )
-#  ecbuild_add_test(
-#    TARGET  tc_tracks
-#    TYPE    SCRIPT
-#    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tc_tracks.sh
-#    ENVIRONMENT BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
-#endif( ENABLE_INSTALL_TOOLS )
-
-##################### F F T ###############################
-
-ecbuild_add_test(
-  TARGET       fft
-  SOURCES      fft.F
-  LIBS         emos ${GRIB_API_LIBRARIES}
-  LINKER_LANGUAGE Fortran )
+    ARGS         -i ${PROJECT_SOURCE_DIR}/data/temp_101.bufr
+    ENVIRONMENT  BUFR_TABLES="NotFoundTablesPath/" )
+  set_tests_properties( bufr_decode_all_NotFoundTablesPath PROPERTIES WILL_FAIL TRUE )
+
+  foreach( bufr_file ${bufr_files} )
+    ecbuild_add_test(
+      TARGET       bufr_decode_all_${bufr_file}
+      COMMAND      ${CMAKE_BINARY_DIR}/bin/bufr_decode_all
+      CONDITION    TEST_BUFR_TABLES_PATH_EXISTS
+      ARGS         -i ${bufr_file}
+      TEST_DEPENDS download_bufrs
+      ENVIRONMENT  BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+  endforeach()
+
+  # tc_tracks series of tests:
+  # FIXME: problems with the compare tests, so not running yet (as before)
+  if( FALSE AND ENABLE_INSTALL_TOOLS )
+
+    set( in  "${PROJECT_SOURCE_DIR}/data/tracks_05W_PEIPAH_2014041000.fm" )
+    set( ref "${PROJECT_SOURCE_DIR}/data/tracks_05W_PEIPAH_2014041000.eps.bufr" )
+    set( out                            "tracks_05W_PEIPAH_2014041000.eps.bufr" )
+    ecbuild_add_test( TARGET tc_tracks_eps_${out}  DEPENDS tc_tracks_eps COMMAND ${CMAKE_BINARY_DIR}/bin/tc_tracks_eps ARGS    -i "${in}" -o "${out}"  ENVIRONMENT BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+    ecbuild_add_test( TARGET tc_tracks_eps_${out}4 DEPENDS tc_tracks_eps COMMAND ${CMAKE_BINARY_DIR}/bin/tc_tracks_eps ARGS -4 -i "${in}" -o "${out}4" ENVIRONMENT BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+    ecbuild_add_test( TARGET tc_tracks_eps_${out}_cmp  TEST_DEPENDS tc_tracks_eps_${out}  CONDITION CMD_CMP COMMAND ${CMD_CMP} ARGS "${ref}" "${out}"  )
+    ecbuild_add_test( TARGET tc_tracks_eps_${out}4_cmp TEST_DEPENDS tc_tracks_eps_${out}4 CONDITION CMD_CMP COMMAND ${CMD_CMP} ARGS "${ref}" "${out}4" )
+
+    set( in  "${PROJECT_SOURCE_DIR}/data/tracks_15U_ITA_2014041012.fm" )
+    set( ref "${PROJECT_SOURCE_DIR}/data/tracks_15U_ITA_2014041012.det.bufr" )
+    set( out                            "tracks_15U_ITA_2014041012.det.bufr" )
+    ecbuild_add_test( TARGET tc_tracks_det_${out}  DEPENDS tc_tracks_det COMMAND ${CMAKE_BINARY_DIR}/bin/tc_tracks_det ARGS    -i "${in}" -o "${out}"  ENVIRONMENT BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+    ecbuild_add_test( TARGET tc_tracks_det_${out}4 DEPENDS tc_tracks_det COMMAND ${CMAKE_BINARY_DIR}/bin/tc_tracks_det ARGS -4 -i "${in}" -o "${out}4" ENVIRONMENT BUFR_TABLES=${TEST_BUFR_TABLES_PATH} )
+    ecbuild_add_test( TARGET tc_tracks_det_${out}_cmp  TEST_DEPENDS tc_tracks_det_${out}  CONDITION CMD_CMP COMMAND ${CMD_CMP} ARGS "${ref}" "${out}"  )
+    ecbuild_add_test( TARGET tc_tracks_det_${out}4_cmp TEST_DEPENDS tc_tracks_det_${out}4 CONDITION CMD_CMP COMMAND ${CMD_CMP} ARGS "${ref}" "${out}4" )
+
+  endif()
+
+endif( HAVE_TESTS AND HAVE_LIBEMOS_BUFRDC )
+
+
+################ L I N K I N G   T E S T S ################
+
+# these are build-time (not runtime!) tests
+# (they are here to guarantee in which platforms link can fail)
+
+ecbuild_add_executable(
+  TARGET    link_mars NOINSTALL
+  SOURCES   link_mars.F
+  CONDITION HAVE_LIBEMOS_INTERPOLATION
+  LIBS      emos )
+
+ecbuild_add_executable(
+  TARGET    link_prodgen NOINSTALL
+  SOURCES   link_prodgen.F
+  CONDITION HAVE_LIBEMOS_INTERPOLATION
+  LIBS      emos )
 
diff --git a/tests/bufr/README b/tests/bufr/README
deleted file mode 100644
index b91c019..0000000
--- a/tests/bufr/README
+++ /dev/null
@@ -1,74 +0,0 @@
-    This directory contains example for the BUFR decoding and programs
-for conversion between BUFR and CREX
-
-Note:
-Conversion programs can be compiled only if you have installed both
-crex and bufr libraries!!!
-
-Compilation of C program for decoding bufr_decode.c is optional
-and if you want to compile it please type:
-
-make bufr_decode
-
-This is available only on Linux platform for Gnu compilers g77 and gcc,
-for pgf77 and pgfcc.
-
-    Relevant data in BUFR format are in data directory.
-
-decode_bufr.f :
-
-
-make
- 
-will compile examples
-
-If you want to run example programs before instal library and Bufr tables
-just run small script:
-
-./test.sh
-
-that will set temporary environment variable: BUFR_TABLES
-and run: 
-
-./decode_bufr -i  data/input_bufr 
-
-Answer the prompts as in the Bufr User's Manual example
-
-
-y
-n
-n
-1
-press return 
-press return 
-press return 
-press return 
-y
-1
-1
-
-
-where:
-     input_bufr - file name containing BUFR data
-
-	The result will be description of data and its values.
-    bufr_example can be run  for different sort of observation data:
-synop.buf, amdar.bufr, atovs.bufr, satob.bufr, synop_ship.bufr, temp.bufr
-
-bufr2crex.f :
-
-    It very useful if there is need for automatic conversion between BUFR and
-CREX data formats, when some centres can not handle meteorogical binary data
-
-./bufr2crex -i input_bufr -o out_crex
-
-where:
-     out_crex - file name containing CREX data
-
-
-
-crex2bufr.f :
-
-    CREX to BUFR conversion program.
-
-./crex2bufr -i input_crex -o out_bufr 
diff --git a/tests/bufr/bufr2crex.F b/tests/bufr/bufr2crex.F
deleted file mode 100755
index bf427b2..0000000
--- a/tests/bufr/bufr2crex.F
+++ /dev/null
@@ -1,605 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      PROGRAM BUFR2CREX
-C
-C**** *BUFRCREX*
-C
-C
-C     PURPOSE.
-C     --------
-C         Bufr to CREX conversion.
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          MILAN DRAGOSAVAC    *ECMWF*       07/01/2004
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =   9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=    4,
-     1       JSEC4=   2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=512000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#else 
-     2          JBPW =  32,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#endif
-     3          JWORK=4096000,JKEY=46,JBYTE=80000)
-C
-      PARAMETER (KELEM=20000)
-      PARAMETER (KVALS=360000)
-C 
-      DIMENSION KBUFF(JBUFL)
-      DIMENSION KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-      DIMENSION KEY  (JKEY),KREQ(2)
-C
-      REAL*8 VALUES(KVALS)
-      REAL*8 RQV(KELEM)
-C
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM),KRQ(KELEM)
-      DIMENSION KDATA(2000)
-C
-      CHARACTER*256    COUT,CARG(4),CFIN
-      CHARACTER*64     CNAMES(KELEM)
-      CHARACTER*24     CUNITS(KELEM)
-      CHARACTER*80     CVALS(KVALS)
-      CHARACTER*80     YENC
-      CHARACTER*160000 YOUT
-      CHARACTER*3      CRCRLF
-C
-C     Common block containing bufr tables
-C
-      COMMON /BCOMTAB/ NTABBTR(JTAB),NTABBS (JTAB),NTABBRV(JTAB),
-     1                 NTABBDW(JTAB),NTABDTR(JTAB),NTABDST(JTAB),
-     2                 NTABDL (JTAB),NTABDSQ(JTAB*20),NTABP(64,255)
-C
-C             NTABBTR    - table B,  table reference              array
-C             NTABBS     - table B,  scale                        array
-C             NTABBRF    - table B,  reference value              array
-C             NTABBDW    - table B,  data width                   array
-C             NTABDTR    - table D,  table reference              array
-C             NTABDST    - table D,  starting pointers            array
-C             NTABDL     - table D,  lengths                      array
-C             NTABDSQ    - table D,  list of sequence descriptors array
-C
-      COMMON /BCOMWT/ NDWINC,NSCAM,NAFDW,NWT ,ODREPF,
-     1                N221,MREL,NFCM,NFUCM,MBMP,OMARKER,M0,
-     2                MBMPL,NSTACK(JELEM),NWTEN(JELEM),
-     3                NWTR (JELEM),NWTS (JELEM),NWTRV (JELEM),
-     4                NWTDW(JELEM)
-C
-C             NDWINC   -  data width increment
-C             NSCAM    -  scale multiplier
-C             NAFDW    -  augmented field data width
-C             NWT      -  pointer to working table
-C             NSTACK   -  list of data descriptors
-C             ODREPF   -  replication (logical)
-C             N221     -  data not present for n221 elements
-C             MREL     -  pointer to the last data element
-C             NFCM     -  first compressed message
-C             MBMP     -  pointer to the begining of bit map
-C             NWTR     -  working table reference
-C             NWTS     -  working scale
-C             NWTRV    -  working reference value
-C             NWTDW    -  working data width
-C
-      COMMON /BCOMWTC/ CWTEN(JELEM),CWTU (JELEM)
-C
-C             CWTEN    -  working table element naame
-C             CWTU     -  working table units
-C
-c
-      PARAMETER(JP=3000)
-C
-      CHARACTER*120 YENTRY
-      CHARACTER*15  YFNAME
-      CHARACTER*15  FMT
-      CHARACTER*6   CREXKTDLST(KELEM),CREXKTDLST0
-C
-      INTEGER IVALUE(KELEM)
-C
-C     Logical switch to use check digit indicator
-C
-      CHARACTER*4 YUSE_E
-C
-      INTEGER IVAL,IIVAL
-c
-      REAL*8 EPS
-      REAL*8 RVIND
-      REAL*8 VAL
-C
-      EQUIVALENCE (YOUT,KBUFR(1))
-C
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C 
-      NBYTPW=JBPW/8
-      RVIND=1.7E38
-      NVIND=2147483647
-      IOBS=0
-      EPS=1.0E-8
-      NPACK=0
-      N=0
-      OO=.FALSE.
-C
-      CRCRLF=CHAR(13)//CHAR(13)//CHAR(10)
-C
-C     Get input and output file name.
-C
-      NARG=IARGC()
-c
-      IF(NARG.LT.4) THEN
-         print*,'Usage -- bufr2crex -i infile -o outfile' 
-         STOP
-      END IF
-c
-      COUT=' '
-      CFIN=' '
-c
-      DO 101 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-c
-      DO 102 J=1,NARG,2
-        IF(CARG(J).EQ.'-i') THEN
-           CFIN=CARG(J+1)
-        ELSEIF(CARG(J).EQ.'-o') THEN
-           COUT=CARG(J+1)
-        ELSE
-            print*,'Usage -- bufr2crex -i infile -o outfile'
-            STOP
-        END IF
- 102  CONTINUE
-C
-      II=INDEX(CFIN,' ')
-      II=II-1
-      JJ=INDEX(COUT,' ')
-      JJ=JJ-1
-C
-      KRQL=0
-      NR=0
-      KREQ(1)=0
-      KREQ(2)=0
-C
-C
-C*          1.2 OPEN FILE CONTAINING BUFR DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CFIN(1:ii),'r',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-      CALL PBOPEN(IUNIT1,cout(1:jj),'w',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on bufr.dat'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-C     ----------------------------------------------------------------- 
-C*          2. SET REQUEST FOR EXPANSION.
-C              --------------------------
- 200  CONTINUE
-C
-      KREQ(1)=1
-      KREQ(2)=0
-C
-      OSEC3=.FALSE.
-      OPRT=.FALSE.
-      OENC=.TRUE.
-      ICODE=0
-      OCOMP=.FALSE.
-C
-C*          2.1 SET REQUEST FOR PARTIAL EXPANSION.
-C               ----------------------------------
- 210  CONTINUE
-C
-      KERR=0
-      CALL BUSRQ(KREQ,KRQL,KRQ,RQV,KERR)
-C
-C     -----------------------------------------------------------------
-C*          3.  READ BUFR MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      KBUFL=0
-C
-      IRET=0
-      CALL PBBUFR(IUNIT,KBUFF,JBYTE,KBUFL,IRET) 
-      IF(IRET.EQ.-1) THEN
-c         IF(N.NE.0) GO TO 600
-         print*,'Number of subsets     ',iobs
-         print*,'Number of messages    ',n
-         STOP 'EOF'
-      END IF
-      IF(IRET.EQ.-2) STOP 'File handling problem' 
-      IF(IRET.EQ.-3) STOP 'Array too small for product'
-C
-      N=N+1
-      KBUFL=KBUFL/nbytpw+1
-      IF(N.LT.NR) GO TO 300
-      print*,'----------------------',n
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND BUFR MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-      CALL BUS012(KBUFL,KBUFF,KSUP,KSEC0,KSEC1,KSEC2,KERR)
-      IF(KERR.NE.0) THEN
-         PRINT*,'Error in BUS012: ',KERR
-         PRINT*,' BUFR MESSAGE NUMBER ',N,' CORRUPTED.'
-         KERR=0
-         GO TO 300
-      END IF
-C
-      KEL=KELEM
-      IF(KSUP(6).GT.1) THEN
-         KEL=KVALS/KSUP(6)
-         IF(KEL.GT.KELEM) KEL=KELEM
-      END IF
-C
-      CALL BUFREX(KBUFL,KBUFF,KSUP,KSEC0 ,KSEC1,KSEC2 ,KSEC3 ,KSEC4,
-     1            KEL,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) THEN
-         IF(IERR.EQ.45) GO TO 300
-         IF(IERR.EQ.2) THEN
-            IERR=0
-            GO TO 300
-         END IF
-         CALL EXIT(2)
-      END IF
-c
-      IOBS=IOBS+KSEC3(3)
-c
-      NPACK=NPACK+1 
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-C*          4.1 PRINT CONTENT OF EXPANDED DATA.
-C               -------------------------------
- 410  CONTINUE
-C
-      IF(.NOT.OPRT) GO TO 500
-      IF(.NOT.OSEC3) GO TO 450
-C
-C*          4.2 PRINT SECTION ZERO OF BUFR MESSAGE.
-C               -----------------------------------
- 420  CONTINUE
-C
-
-      CALL BUPRS0(KSEC0)
-C
-C*          4.3 PRINT SECTION ONE OF BUFR MESSAGE.
-C               -----------------------------------
- 430  CONTINUE
-C
-      CALL BUPRS1(KSEC1)
-C
-C
-C*          4.4 PRINT SECTION TWO OF BUFR MESSAGE.
-C               -----------------------------------
- 440  CONTINUE
-c
-C              AT ECMWF SECTION 2 CONTAINS RDB KEY.
-C              SO UNPACK KEY
-C
-      CALL BUUKEY(KSEC1,KSEC2,KEY,KSUP,KERR)
-C
-C              PRINT KEY
-C
-      CALL BUPRS2(KSUP ,KEY)
-C
-C*          4.5 PRINT SECTION 3 OF BUFR MESSAGE.
-C               -----------------------------------
- 450  CONTINUE
-C
-C               FIRST GET DATA DESCRIPTORS
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-C               PRINT  CONTENT
-C
-      IF(OSEC3) THEN
-         CALL BUPRS3(KSEC3,KTDLEN,KTDLST,KTDEXL,KTDEXP,KEL,CNAMES)
-      END IF
-c
-C
-C*         4.6 PRINT SECTION 4 (DATA).
-C              -----------------------
- 460  CONTINUE
-C
-C          IN THE CASE OF MANY SUBSETS DEFINE RANGE OF SUBSETS
-C
-      IF(.NOT.OO) THEN
-      WRITE(*,'(a,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IST
-      WRITE(*,'(a,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IEND
-      OO=.FALSE.
-      END IF
-C
-C              PRINT DATA
-C
-      ICODE=0
-      CALL BUPRT(ICODE,IST,IEND,KEL,CNAMES,CUNITS,CVALS,
-     1           KVALS,VALUES,KSUP,KSEC1,IERR)
-C
-C
-C     -----------------------------------------------------------------
-C*          5. COLLECT DATA FOR REPACKING.
-C              ---------------------------
- 500  CONTINUE
-C      
-C               FIRST GET DATA DESCRIPTORS
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-C     -----------------------------------------------------------------
-C*          6. PACK CREX MESSAGE.
-C              ------------------
- 600  CONTINUE
-C
-C     Modify BUFR operators
-C
-      J=0
-      DO 602 I=1,KTDLEN
-      IF(KTDLST(I).EQ.222000) GO TO 603
-      IF(KTDLST(I).EQ.201000) GO TO 602 
-      IF(KTDLST(I).EQ.202000) GO TO 602
-      IF(KTDLST(I).EQ.204000) GO TO 602
-      IF(KTDLST(I).EQ.031000) GO TO 602
-      IF(KTDLST(I).EQ.031001) GO TO 602
-      IF(KTDLST(I).EQ.031002) GO TO 602
-C
-      CREXKTDLST0=' '
-      WRITE(CREXKTDLST0,'(I6.6)',IOSTAT=IOS) KTDLST(I)
-      IF(IOS.NE.0) THEN
-         print*,'Internal write error.'
-         CALL EXIT(2)
-      END IF
-      J=J+1
-      CREXKTDLST(J)(1:6)=CREXKTDLST0
-C
-      IF(CREXKTDLST(J)(1:1).EQ.'3') THEN
-         CREXKTDLST(J)(1:1)='D'
-      ELSEIF(CREXKTDLST(J)(1:1).EQ.'0') THEN
-         CREXKTDLST(J)(1:1)='B'
-      ELSEIF(CREXKTDLST(J)(1:1).EQ.'1') THEN
-         CREXKTDLST(J)(1:1)='R'
-c        scan for any 201000,202000 or 201y,202y followed by 206y
-         READ(CREXKTDLST(J)(2:3),'(I2.2)',IOSTAT=IOS) IELEMENTS
-         IF(IOS.NE.0) THEN
-            print*,'Internal read error.'
-            CALL EXIT(2)
-         END IF
-         IEL=IELEMENTS
-         DO IN=I,I+IELEMENTS-1
-         IF(KTDLST(IN).EQ.201000) IEL=IEL-1
-         IF(KTDLST(IN).EQ.202000) IEL=IEL-1
-         IF(KTDLST(IN).GE.201001.AND.KTDLST(IN).LE.201999.AND.
-     1      KTDLST(IN+1)/1000.EQ.206) IEL=IEL-1
-         IF(KTDLST(IN).GE.202001.AND.KTDLST(IN).LE.202999.AND.         
-     1      KTDLST(IN+1)/1000.EQ.206) IEL=IEL-1
-         END DO
-         WRITE(CREXKTDLST(J)(2:3),'(I2.2)',IOSTAT=IOS) IEl
-         IF(IOS.NE.0) THEN
-            print*,'Internal write error.'
-            CALL EXIT(2)
-         END IF
-      ELSEIF(CREXKTDLST(J)(1:3).EQ.'201') THEN
-         IF(KTDLST(I+1)/1000.EQ.206) THEN
-            J=J-1
-            GO TO 602
-         END IF
-         READ(CREXKTDLST(J)(4:6),'(I3.3)',IOSTAT=IOS) IY
-         IF(IOS.NE.0) THEN
-            print*,'Internal read error.'
-            CALL EXIT(2)
-         END IF
-         IBITS=IY-128
-         ICLASS=KTDLST(I+1)/1000
-         IYYY  =KTDLST(I+1)-ICLASS*1000+1
-         ICLASS=ICLASS+1
-         III=NTABP(ICLASS,IYYY)
-         IDW=NTABBDW(III)+IBITS
-         IRES=2.**IDW-1
-         JZ=0
-         DO WHILE(IRES.GT.0)
-         JZ=JZ+1
-         IRES=IRES/10
-         END DO
-         CREXKTDLST(J)(1:3)='C01'
-         WRITE(CREXKTDLST(J)(4:6),'(I3.3)',IOSTAT=IOS) JZ
-         IF(IOS.NE.0) THEN
-            print*,'Internal write error.'
-            CALL EXIT(2)
-         END IF
-      ELSEIF(CREXKTDLST(J)(1:3).EQ.'202') THEN
-         GO TO 602
-      ELSEIF(CREXKTDLST(J)(1:3).EQ.'205') THEN
-          CREXKTDLST(J)(1:3)='C05'
-      ELSE
-         print*,'Wrong data descriptor ',crexktdlst(j)
-         print*,'Data containing above descriptor can',
-     1          ' not be converted'
-         go to 300
-      END IF
- 602  CONTINUE
-c
- 603  CONTINUE
-C
-      ICREXLEN=J
-c
-C     Find delayed replications
-c
-      KDLEN=0
-C
-      IST=1
-      IEND=1
-      OMULTI=.FALSE.
-      IF(IAND(KSEC3(4),64).NE.0.AND.KSEC3(3).GT.1) THEN
-         IEND=KSEC3(3)
-         OMULTI=.TRUE.
-      END IF
-C
-      DO ISUBSET=IST, IEND
-
-      JJ=(ISUBSET-1)*KEL
-C
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-C
-      DO I=1,KTDEXL
-C
-        II=I+JJ
-C
-        IF(KTDEXP(I).EQ.031001.OR.
-     1     KTDEXP(I).EQ.031000.OR.
-     2     KTDEXP(I).EQ.031002) THEN
-           KDLEN=KDLEN+1
-           KDATA(KDLEN)=NINT(VALUES(II))
-        END IF
-      END DO
-C
-C*   Make unit conversion from K to Celsius
-C
-      DO I=1,KTDEXL
-        IF(CUNITS(I)(1:2).EQ.'K '.AND.
-     1     KTDEXP(I)/1000.EQ.12) THEN
-           IF(KTDEXP(I).NE.012064.AND.
-     1        KTDEXP(I).NE.012065.AND.
-     2        KTDEXP(I).NE.012070.AND.
-     2        KTDEXP(I).NE.012071.AND.
-     4        KTDEXP(I).NE.012164.AND.
-     5        KTDEXP(I).NE.012151.AND.
-     6        KTDEXP(I).NE.012051.AND.
-     7        KTDEXP(I).NE.022050.AND.
-     8        KTDEXP(I).NE.012171) THEN
-              IF(OMULTI) THEN
-              IJ=I+JJ
-              IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps) 
-     1           VALUES(IJ)=VALUES(IJ)-273.15 
-              ELSE
-              DO J=1,KSEC3(3)
-              IJ=I+(J-1)*KEL
-              IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps)
-     1           VALUES(IJ)=VALUES(IJ)-273.15
-              END DO
-              END IF
-           END IF
-        END IF
-        IF(CUNITS(I)(1:2).EQ.'PA'.AND.
-     1     KTDEXP(I).EQ.015003) THEN
-           IF(OMULTI) THEN
-           IJ=I+JJ
-           IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps)
-     1        VALUES(IJ)=VALUES(IJ)*10000.
-           ELSE
-           DO J=1,KSEC3(3)
-           IJ=I+(J-1)*KEL
-           IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps) 
-     1        VALUES(IJ)=VALUES(IJ)*10000.
-           END DO
-           END IF
-        END IF
-      END DO
-C
-      END DO
-
-C
-C*          6.2 ENCODE DATA INTO CREX MESSAGE.
-C               ------------------------------
- 620  CONTINUE
-C
-      IF(KSEC1(2).EQ.4) THEN         ! Bufr edition number
-         KSEC1(2)=2                  ! Crex edition number
-         KSEC1(5)=KSEC3(3)           ! Number of subsets
-         KSEC1( 7)=KSEC1(17)         ! International sub category
-         KSEC1(17)=KSEC1(15)            ! Bufr master table version number
-         KSEC1(15)=3                    ! Crex version number used
-         KSEC1(18)=KSEC1(8)             ! Bufr version number of local tables
-      ELSE
-         KSEC1(17)=KSEC1(15)            ! Bufr master table version number
-         KSEC1(2)=1                  ! Crex edition number
-         KSEC1(15)=3                    ! Crex version number used
-         KSEC1(18)=KSEC1(8)             ! Bufr version number of local tables
-      END IF
-c
-      CALL CREXEN(KSEC0,KSEC1,KSEC3,
-     1            ICREXLEN,CREXKTDLST,KDLEN,KDATA,KEL,KVALS,
-     2            VALUES,CVALS,KBUFL,KBUFR,KERR)
-      IF(KERR.GT.0) THEN
-         print*,'CREXEN error:',KERR
-         go to 300
-      END IF
-C
-C           6.3 WRITE CREX MESSAGE INTO FILE.
-C               -----------------------------
- 630  CONTINUE
-C
-      ILEN=KBUFL
-C     
-      IERR=0
-      CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-      IF(IERR.LT.0) THEN
-         print*,'Error writing into target file.'
-         CALL EXIT(2)
-      END IF
-C
-      GO TO 300
-C
-      END
diff --git a/tests/bufr/bufr_decode.c b/tests/bufr/bufr_decode.c
deleted file mode 100644
index ca6a221..0000000
--- a/tests/bufr/bufr_decode.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
-* Copyright 1981-2012 ECMWF.
-*
-* This software is licensed under the terms of the Apache Licence 
-* Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-*
-* In applying this licence, ECMWF does not waive the privileges and immunities 
-* granted to it by virtue of its status as an intergovernmental organisation 
-* nor does it submit to any jurisdiction.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-
-int main(int argc, char *argv[])
-/*******************************************************************
-*                                                                 
-* Program : Bufr_decode
-*                                                              
-*                                                             
-* Author: Milan Dragosavac    ECMWF    July 1996
-*  
-* Purpose: Decode bufr message
-* 
-*
-*
-* Usage:
-* 
-*
-*
-* References:
-*  
-*
-*
-*
-* File formats:
-* 
-*
-*
-* Restrictions:
-*  
-* 
-* Error handling:
-* 
-*
-*
-* Notes:
-* 
-*
-*
-*******************************************************************/
-{
-#define KVALS 4096000
-#define KELEM 160000
-
-  FILE *fp; 
-  char bufr_message[512000];
-  char filename[256];
-  long int length=512000;
-  long int status = 0;
-  int  Nbpw;
-
-  unsigned long int *kbuff;
-  long int ksup[9];
-  long int ksec0[3];
-  long int ksec1[40];
-  long int ksec2[4096];
-  long int ksec3[4]; 
-  long int ksec4[2];
-  long int key[46];
-  long int kerr;
-
-
- 
-  int i;
-  long kelem = KELEM,kvals = KVALS;
-
-  static char cnames[KELEM][64],cunits[KELEM][24];
-  
-
-  char cvals[KVALS][80];
-
-  double values[KVALS],vals[KVALS];
-  long icode = 0;
-  long ktdlst[KELEM],ktdexp[KELEM],ktdlen,ktdexl;
-
- if(sizeof(long) == 4) Nbpw=32;
-  else if(sizeof(long) == 8) Nbpw=64;
-  else{
-    printf("Abort.....\n");
-  }
-
-  printf("%d\n",Nbpw);
-
-/*     Get input and output file name.  */
-/*     -------------------------------  */  
-
-  if(argc != 3) {
-    printf("Usage: bufr_decode -i infile \n");
-    printf("Please try again. \n");
-    exit(1);
-  }
-
-  printf("%c",argc);
-
-  if(!strcmp(argv[1],"-i")) strcpy(filename,argv[2]);
-  else {
-    printf("Usage: bufr_decode -i infile \n");
-    exit(1);
-  }
-
-/*     Open input file       */
-/*     ---------------       */  
-
-  if((fp = fopen(filename,"r")) == NULL) {
-    printf("cannot open file\n");
-    exit(1);
-  }
-  
-/*     Read in bufr messages */
-/*     --------------------- */  
-
-  while(status >= 0){
-      long current_ss;
-     status = readbufr( fp,&bufr_message,&length);
-
-     if(     status == -1 ) printf("End of file.\n");
-     else if(status == -2 ) printf("Error in file handling\n");
-     else if(status == -3 ) printf("Too small input array.\n");
-     else if(status == -4 ) printf("Too small input array.\n");
-     else {
-       printf("It is OK.\n");
-       printf("message read ");
-       printf("%d\n",length);
-       printf("%s\n",&bufr_message[0]);
-     }
-     status=-1;
-
-/*    Expand bufr message calling fortran program */
-       kbuff = (unsigned long *) bufr_message;
-      length /= 4;
-
-      bus012_(&length, kbuff , ksup, ksec0, ksec1, ksec2,  &kerr) ;
-      buprs0_(ksec0);
-      buprs1_(ksec1);
-
-      if (ksup[5] > 1)
-        kelem = kvals/ksup[5];
-      else
-        kelem = KELEM;
-
-      if ( kelem > KELEM ) kelem = KELEM;
-      kerr = 0;
-      bufrex_(&length,(long *)kbuff,ksup,ksec0,ksec1,ksec2,ksec3,ksec4,
-              &kelem,(char **)cnames,(char **)cunits,&kvals,
-              values,(char **)cvals,&kerr);
-      if ( kerr )
-        {
-          kerr = 0;
-        }
-
-      buukey_(ksec1,ksec2,key,ksup,&kerr);
-
-      busel_(&ktdlen,ktdlst,&ktdexl,ktdexp,&kerr);
-      buprs3_(ksec3,&ktdlen,ktdlst,&ktdexl,ktdexp,&kelem,(char **)cnames);
-
-      icode = 0;
-      current_ss = 1;
-      buprt_(&icode,&current_ss,&current_ss,&kelem,(char **)cnames,
-                         (char **)cunits,(char **)cvals,
-                         &kvals,values,ksup,ksec1,&kerr);
-
-      
-  }
-
-  return kerr;
-
-}
-
diff --git a/tests/bufr/create_bufr.F b/tests/bufr/create_bufr.F
deleted file mode 100755
index 6524f3b..0000000
--- a/tests/bufr/create_bufr.F
+++ /dev/null
@@ -1,417 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM BUFR
-C
-C**** *BUFR*
-C
-C
-C     PURPOSE.
-C     --------
-C         An example of using Bufr packing/unpacking software.
-C         It will create synop data in bufr edition 4 
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          M. DRAGOSAVAC    *ECMWF*       05/04/2005.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(O,G), CHARACTER*8(C,H,Y)
-C
-C
-      PARAMETER(JSUP =  9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=    4,
-     1          JSEC4=2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=512000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT= 200,
-#else
-     2          JBPW =  32,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT= 200,
-#endif
-     3          JWORK=4096000,JKEY=46)
-
-C
-      PARAMETER (KDLEN=200,KELEM=4000)
-      parameter (KVALS=4000,KVALS1=4000)
-C 
-      DIMENSION KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-      DIMENSION KEY  (JKEY)
-      DIMENSION ISUP(JSUP)  ,ISEC0(JSEC0),ISEC1(JSEC1)
-      DIMENSION ISEC2(JSEC2),ISEC3(JSEC3),ISEC4(JSEC4)
-C
-#ifndef R_4
-      REAL*8  VALUES(KVALS),VALUE(KVALS1)
-      REAL*8  RQV(KELEM)
-      REAL*8  RVIND
-#else
-      REAL    VALUES(KVALS),VALUE(KVALS1)
-      REAL    RQV(KELEM)
-      REAL    RVIND
-#endif
-
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM),KRQ(KELEM)
-      DIMENSION ITDLST(KELEM),ITDEXP(KELEM)
-      DIMENSION KDATA(KDLEN),IDATA(KDLEN)
-C
-      CHARACTER*8  CF
-      CHARACTER*64 CNAMES(KELEM),CNAME(KELEM)
-      CHARACTER*24 CUNITS(KELEM),CUNIT(KELEM)
-      CHARACTER*80 CVALS(KVALS)
-      CHARACTER*80 CVAL (KVALS1)
-      CHARACTER*80 YENC
-C
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C
-      RVIND=1.7D38
-C
- 
-      CALL PBOPEN(IUNIT1,'synop.bufr','W',IRET)
-      IF(IRET.EQ.-1) STOP 'OPEN FAILED ON synop.dat'
-      IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-      IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-C
-
-C
-C     INITIALIZE DELAYED REPLICATION FACTORS OR REFERENCE VALUES ETD.
-C
-      DO 101 I=1,KDLEN
-      KDATA(I)=1
-      VALUES(I)=RVIND
- 101  CONTINUE
-C
-c
-      KDLENG=3
-C
-C
-C     SET DATA DECSRIPTORS
-C
-
- 
-      ktdlst(    1)=  307080
- 
-      ktdlen=1
-
-      values(  1)=11.        !001001  WMO BLOCK NUMBER
-      values(  2)=423.       !001002  WMO STATION NUMBER
-      values(  3)=1020.      !001015  STATION OR SITE NAME
-      values(  4)=1.         !002001  TYPE OF STATION
-      values(  5)=2007.      !004001  YEAR
-      values(  6)=11.        !004002  MONTH
-      values(  7)=21.        !004003  DAY
-      values(  8)=12.        !004004  HOUR
-      values(  9)=0.         !004005  MINUTE
-      values( 10)=49.66944   !005001  LATITUDE (HIGH ACCURACY)
-      values( 11)=12.67778   !006001  LONGITUDE (HIGH ACCURACY)
-      values( 12)=742.2      !007030  HEIGHT OF STATION GROUND ABOVE MEAN SEA LEVEL (SEE NOTE 3)
-      values( 13)=747.       !007031  HEIGHT OF BAROMETER ABOVE MEAN SEA LEVEL (SEE NOTE 4)
-      values( 14)=92520.     !010004  PRESSURE
-      values( 15)=rvind      !010051  PRESSURE REDUCED TO MEAN SEA LEVEL
-      values( 16)=-60.       !010061  3-HOUR PRESSURE CHANGE
-      values( 17)=5.         !010063  CHARACTERISTIC OF PRESSURE TENDENCY
-      values( 18)=rvind      !010062  24-HOUR PRESSURE CHANGE
-      values( 19)=92500.     !007004  PRESSURE
-      values( 20)=749.       !010009  GEOPOTENTIAL HEIGHT
-      values( 21)=1.95       !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 22)=270.85     !012101  TEMPERATURE/DRY-BULB TEMPERATURE
-      values( 23)=270.45     !012103  DEW-POINT TEMPERATURE
-      values( 24)=97.        !013003  RELATIVE HUMIDITY
-      values( 25)=4.8        !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 26)=200.       !020001  HORIZONTAL VISIBILITY
-      values( 27)=1.12       !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 28)=rvind      !013023  TOTAL PRECIPITATION PAST 24 HOURS
-      values( 29)=rvind      !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 30)=100.       !020010  CLOUD COVER (TOTAL)
-      values( 31)=5.         !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 32)=9.         !020011  CLOUD AMOUNT
-      values( 33)=0.         !020013  HEIGHT OF BASE OF CLOUD
-      values( 34)=62.        !020012  CLOUD TYPE
-      values( 35)=61.        !020012  CLOUD TYPE
-      values( 36)=60.        !020012  CLOUD TYPE
-      values( 37)=1.         !031001  DELAYED DESCRIPTOR REPLICATION FACTOR
-      values( 38)=5.         !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 39)=9.         !020011  CLOUD AMOUNT
-      values( 40)=59.        !020012  CLOUD TYPE
-      values( 41)=0.         !020013  HEIGHT OF BASE OF CLOUD
-      values( 42)=1.         !031001  DELAYED DESCRIPTOR REPLICATION FACTOR
-      values( 43)=11.        !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 44)=rvind      !020011  CLOUD AMOUNT
-      values( 45)=rvind      !020012  CLOUD TYPE
-      values( 46)=rvind      !020014  HEIGHT OF TOP OF CLOUD
-      values( 47)=rvind      !020017  CLOUD TOP DESCRIPTION
-      values( 48)=7.         !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 49)=rvind      !020054  TRUE DIRECTION FROM WHICH CLOUDS ARE MOVING
-      values( 50)=8.         !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 51)=rvind      !020054  TRUE DIRECTION FROM WHICH CLOUDS ARE MOVING
-      values( 52)=9.         !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 53)=rvind      !020054  TRUE DIRECTION FROM WHICH CLOUDS ARE MOVING
-      values( 54)=rvind      !008002  VERTICAL SIGNIFICANCE (SURFACE OBSERVATIONS)
-      values( 55)=rvind      !005021  BEARING OR AZIMUTH
-      values( 56)=rvind      !007021  ELEVATION (SEE NOTE 2)
-      values( 57)=rvind      !020012  CLOUD TYPE
-      values( 58)=rvind      !005021  BEARING OR AZIMUTH
-      values( 59)=rvind      !007021  ELEVATION (SEE NOTE 2)
-      values( 60)=rvind      !020062  STATE OF THE GROUND (WITH OR WITHOUT SNOW)
-      values( 61)=rvind      !013013  TOTAL SNOW DEPTH
-      values( 62)=rvind      !012113  GROUND MINIMUM TEMPERATURE, PAST 12 HOURS
-      values( 63)=49.        !020003  PRESENT WEATHER (SEE NOTE 1)
-      values( 64)=-6.        !004024  TIME PERIOD OR DISPLACEMENT
-      values( 65)=4.         !020004  PAST WEATHER (1) (SEE NOTE 2)
-      values( 66)=4.         !020005  PAST WEATHER (2) (SEE NOTE 2)
-      values( 67)=-1.        !004024  TIME PERIOD OR DISPLACEMENT
-      values( 68)=rvind      !014031  TOTAL SUNSHINE
-      values( 69)=-24.       !004024  TIME PERIOD OR DISPLACEMENT
-      values( 70)=rvind      !014031  TOTAL SUNSHINE
-      values( 71)=1.12       !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 72)=-6.        !004024  TIME PERIOD OR DISPLACEMENT
-      values( 73)=0.         !013011  TOTAL PRECIPITATION/TOTAL WATER EQUIVALENT
-      values( 74)=-1.        !004024  TIME PERIOD OR DISPLACEMENT
-      values( 75)=0.         !013011  TOTAL PRECIPITATION/TOTAL WATER EQUIVALENT
-      values( 76)=1.95       !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 77)=-12.       !004024  TIME PERIOD OR DISPLACEMENT
-      values( 78)=0.         !004024  TIME PERIOD OR DISPLACEMENT
-      values( 79)=rvind      !012111  MAXIMUM TEMPERATURE, AT HEIGHT AND OVER PERIOD SPECIFIED
-      values( 80)=-12.       !004024  TIME PERIOD OR DISPLACEMENT
-      values( 81)=0.         !004024  TIME PERIOD OR DISPLACEMENT
-      values( 82)=rvind      !012112  MINIMUM TEMPERATURE, AT HEIGHT AND OVER PERIOD SPECIFIED
-      values( 83)=10.25      !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 84)=8.         !002002  TYPE OF INSTRUMENTATION FOR WIND MEASUREMENT
-      values( 85)=2.         !008021  TIME SIGNIFICANCE
-      values( 86)=-10.       !004025  TIME PERIOD OR DISPLACEMENT
-      values( 87)=110.       !011001  WIND DIRECTION
-      values( 88)=5.         !011002  WIND SPEED
-      values( 89)=rvind      !008021  TIME SIGNIFICANCE
-      values( 90)=-10.       !004025  TIME PERIOD OR DISPLACEMENT
-      values( 91)=rvind      !011043  MAXIMUM WIND GUST DIRECTION
-      values( 92)=rvind      !011041  MAXIMUM WIND GUST SPEED
-      values( 93)=-360.      !004025  TIME PERIOD OR DISPLACEMENT
-      values( 94)=rvind      !011043  MAXIMUM WIND GUST DIRECTION
-      values( 95)=12.        !011041  MAXIMUM WIND GUST SPEED
-      values( 96)=rvind      !007032  HEIGHT OF SENSOR ABOVE LOCAL GROUND (OR DECK OF MARINE PLATFORM)
-      values( 97)=-24.       !004024  TIME PERIOD OR DISPLACEMENT
-      values( 98)=rvind      !002004  TYPE OF INSTRUMENTATION FOR EVAPORATION MEASUREMENT OR TYPE OF C
-      values( 99)=rvind      !013033  EVAPORATION/EVAPOTRANSPIRATION
-      values(100)=-1.        !004024  TIME PERIOD OR DISPLACEMENT
-      values(101)=rvind      !014002  LONG-WAVE RADIATION, INTEGRATED OVER PERIOD SPECIFIED
-      values(102)=rvind      !014004  SHORT-WAVE RADIATION, INTEGRATED OVER PERIOD SPECIFIED
-      values(103)=rvind      !014016  NET RADIATION, INTEGRATED OVER PERIOD SPECIFIED
-      values(104)=rvind      !014028  GLOBAL SOLAR RADIATION (HIGH ACCURACY), INTEGRATED OVER PERIOD S
-      values(105)=rvind      !014029  DIFFUSE SOLAR RADIATION (HIGH ACCURACY), INTEGRATED OVER PERIOD
-      values(106)=rvind      !014030  DIRECT SOLAR RADIATION (HIGH ACCURACY), INTEGRATED OVER PERIOD S
-      values(107)=-24.       !004024  TIME PERIOD OR DISPLACEMENT
-      values(108)=rvind      !014002  LONG-WAVE RADIATION, INTEGRATED OVER PERIOD SPECIFIED
-      values(109)=rvind      !014004  SHORT-WAVE RADIATION, INTEGRATED OVER PERIOD SPECIFIED
-      values(110)=rvind      !014016  NET RADIATION, INTEGRATED OVER PERIOD SPECIFIED
-      values(111)=rvind      !014028  GLOBAL SOLAR RADIATION (HIGH ACCURACY), INTEGRATED OVER PERIOD S
-      values(112)=rvind      !014029  DIFFUSE SOLAR RADIATION (HIGH ACCURACY), INTEGRATED OVER PERIOD
-      values(113)=rvind      !014030  DIRECT SOLAR RADIATION (HIGH ACCURACY), INTEGRATED OVER PERIOD S
-      values(114)=rvind      !004024  TIME PERIOD OR DISPLACEMENT
-      values(115)=rvind      !004024  TIME PERIOD OR DISPLACEMENT
-      values(116)=rvind      !012049  TEMPERATURE CHANGE OVER SPECIFIED PERIOD
-
- 
-C     SET CCITTIA5 STATION OR SITE NAME
-
-      cvals(1)='PRIMDA'
-C
-C
-C     SECTION 0 CONTENT
-C
-      KSEC0(1)=0      ! TOTAL LENGTH OF SECTION 0
-      KSEC0(2)=0      ! TOTAL LENGTH OF BUFR MESSAGE
-      KSEC0(3)=4      ! BUFR EDITION NUMBER
-C
-C     SECTION 1 CONTENT
-C
-      KSEC1(1)=22    ! TOTTAL LENGTH OF SECTION 1 (  set to 18 for edition <= 3)
-      KSEC1(2)=4     ! BUFR EDITION NUMBER
-      KSEC1(3)=89    ! ORIGINATING CENTRE
-      KSEC1(4)=1     ! UPDATE SEQUENCE NUMBER
-      KSEC1(5)=0     ! FLAG (PRESENCE OF SECTION 2)
-      KSEC1(6)=0     ! DATA CATEGORY
-      KSEC1(7)=0     ! LOCAL DATA SUB-CATEGORY
-      KSEC1(8)=0     ! VERSION NUMBER OF LOCAL TABLE USED
-      KSEC1(9)=nint(values(5)) 
-      if(KSEC1(2).le.3) then
-        if(ksec1(9).gt.2000) then
-           ksec1(9)=ksec1(9)-2000
-        else
-           ksec1(9)=ksec1(9)-1900
-        end if
-      end if
-      KSEC1(10)=nint(values(6))
-      KSEC1(11)=nint(values(7))   ! DAY
-      KSEC1(12)=nint(values(8))   ! HOUR
-      KSEC1(13)=nint(values(9))   ! MINUTE
-      KSEC1(14)=0    ! BUFR MASTER TABLE( ZERO) FOR METEOROLOGICAL DATA)
-      KSEC1(15)=13   ! VERSION NUMBER OF MASTER TABLE USED
-      KSEC1(16)=255  ! ORIGINATING SUB-CENTRE
-      KSEC1(17)=2    ! INTERNATIONAL SUB-CATEGORY
-      KSEC1(18)=0    ! SECOND
-      
-C
-C     SECTION 2 CONTENT
-C
-      KSEC2(1)=52
-C
-      DO 110 I=2,JSEC2
-      KSEC2(I)=0
- 110  CONTINUE
-C
-C     SECTION 3 CONTENT
-C
-      KSEC3(1)=0     ! TOTAL LENGTH OF SECTION 3
-      KSEC3(2)=0     ! RESERVED
-      KSEC3(3)=1
-      KSEC3(4)=0     ! 64 FOR COMPRESSION/ 0 MANY SUBSETS
-      if(KSEC3(3).GT.1) KSEC3(4)=64
-C
-      IREP=0
-C
-C
-C*          6. PACK BUFR MESSAGE
-C              -----------------
- 600  CONTINUE
-C
-C---------------------------------------------------------------
-C              This call is not needed for packing. It just 
-C              prints expanded list corresponding to ktdlst sequence
-C              and delayed replications in kdata array. This four
-C              lines can be deleted or commented out.
-      K=1
-      CALL BUXDES(K,KSEC1,KTDLEN,KTDLST,KDLENG,KDATA,KELEM,
-     1            KTDEXL,KTDEXP,CNAMES,CUNITS,KERR)
-C
-      IF(KERR.NE.0) CALL EXIT(2)
-C---------------------------------------------------------------
-C
-C
-C*          6.2 ENCODE DATA INTO BUFR MESSAGE.
-C               ------------------------------
- 620  CONTINUE
-C
-      KBUFL=3000
-      KPMISS=1
-      KPRUS=1
-      NOKEY=0
-      CALL BUPRQ(KPMISS,KPRUS,NOKEY)
-C
-      KERR=0
-      CALL BUFREN( KSEC0,KSEC1,KSEC2,KSEC3,KSEC4,
-     1             KTDLEN,KTDLST,KDLENG,KDATA,KELEM,
-     2             KVALS,VALUES,CVALS,KBUFL,KBUFR,KERR)
-C
-
-      IF(KERR.GT.0) THEN
-         CALL EXIT(2)
-      ELSEIF(KERR.lt.0) then
-         print*,'Encoding return_code=',kerr
-      END IF 
-c
-C     ILEN=KBUFL*JBPW/8
-      ILEN=KSEC0(2)
-C
-      IERR=0
-      CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-      IF(IERR.LT.0) THEN
-         PRINT*,'ERROR WRITING INTO TARGET FILE.'
-         CALL EXIT(2)
-      END IF
-
-C
-C     -----------------------------------------------------------------
-C*          7. UNPACK MESSAGE.
-C              -------------
- 700  CONTINUE
-C
-      DO 702 I=1,KVALS1
-      VALUE(I)=RVIND
- 702  CONTINUE
-c
- 701  CONTINUE
-C
-      CALL BUFREX(KBUFL,KBUFR,ISUP,ISEC0 ,ISEC1,ISEC2 ,ISEC3 ,ISEC4,
-     1            KELEM,CNAME,CUNIT,KVALS1,VALUE,CVAL,IERR)
-c
-      IF(IERR.NE.0) CALL EXIT(2)
-C
-      CALL BUPRS0(ISEC0)
-      CALL BUPRS1(ISEC1)
-      CALL BUUKEY(ISEC1,ISEC2,KEY,ISUP,KERR)
-      CALL BUPRS2(ISUP ,KEY)
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KELEM,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      CALL BUPRS3(ISEC3,KTDLEN,KTDLST,KTDEXL,KTDEXP,KELEM,CNAME)
-C
-      WRITE(*,'(a,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(I5)')   IST
-      WRITE(*,'(a,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(I6)')   IEND
-C
-      ICODE=0
-      CALL BUPRT(ICODE,IST,IEND,KELEM,CNAME,CUNIT,CVAL,
-     1           KVALS1,VALUE,ISUP,ISEC1,IERR)
-C
-C      
-      IREP=IREP+1
-C   
-      IF(IREP.GT.3) GO TO 900 
-      GO TO 900
-C
- 810  CONTINUE
-C
-      WRITE(*,'(1H ,A)') 'OPEN ERROR ON INPUT FILE'
-      GO TO 900
-C      
- 800  CONTINUE
-C
-      IF(IERR.EQ.-1) THEN
-         print*,'Number of records processed ',IREP
-      ELSE
-         print*,' BUFR : error= ',ierr
-      END IF
-C
- 900  CONTINUE
-C
-      STOP
-      END
diff --git a/tests/bufr/crex2bufr.F b/tests/bufr/crex2bufr.F
deleted file mode 100755
index 15c0ad3..0000000
--- a/tests/bufr/crex2bufr.F
+++ /dev/null
@@ -1,499 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM CREX2BUFR
-C
-C**** *CREX2BUFR*
-C
-C
-C     PURPOSE.
-C     --------
-C         Decode CREX coded data into BUFR format
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          MILAN DRAGOSAVAC    *ECMWF*       07/01/2004.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =  9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=    4,
-     1       JSEC4=   2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=40000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#else
-     2          JBPW =  32,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#endif
-     3          JWORK=4096000,JKEY=46,JBYTE=80000)
-C
-      PARAMETER (KELEM=40000)
-      PARAMETER (KVALS=360000)
-C 
-      DIMENSION KBUFF(JBUFL),KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-      DIMENSION KEY  (JKEY),KREQ(2)
-C
-      REAL*8 VALUES(KVALS), VALUE(KVALS)
-      REAL*8 RVIND
-      REAL*8 EPS
-C
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM),KTDLST1(KELEM)
-      DIMENSION KDATA(2000)
-C
-      CHARACTER*256 CF,COUT,CARG(4)
-      CHARACTER*64 CNAMES(KELEM)
-      CHARACTER*24 CUNITS(KELEM)
-      CHARACTER*80 CVALS(KVALS)
-      CHARACTER*80 CVAL(KVALS),CV
-      CHARACTER*80 YENC
-      CHARACTER*160000 YBUFF
-c
-      EQUIVALENCE(YBUFF,KBUFF(1))
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-      NBYTPW=JBPW/8
-      RVIND=1.7D38
-      NVIND=2147483647
-      IOBS=0
-      EPS=10.D-8
-      N=0
-      OCOMP=.FALSE.
-      OO=.FALSE.
-      CF=' '
-      COUT=' '
-      KKK=0
-C
-C     GET INPUT AND OUTPUT FILE NAME.
-C
-      NARG=IARGC()
-c
-      IF(NARG.NE.4) THEN
-         print*,'Usage -- crex2bufr -i infile -o outfile' 
-         STOP
-      END IF
-c
-      DO 101 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-c
-      IF(CARG(1).NE.'-i'.AND.CARG(1).NE.'-I'.OR.
-     1   CARG(2).EQ.' ') THEN
-         print*,'Usage -- crex2bufr -i inpfile -o outfile'
-         STOP
-      END IF
-      IF(CARG(3).NE.'-o'.AND.CARG(3).NE.'-O'.OR.
-     1   CARG(4).EQ.' ') THEN
-         print*,'Usage -- crex2bufr -i inpfile -o outfile'
-         STOP
-      END IF
-c
-      CF=CARG(2)
-      II=INDEX(CF,' ')
-      II=II-1
-      COUT=CARG(4)
-      I=INDEX(COUT,' ')
-      I=I-1
-C
-C*          1.2 OPEN FILE CONTAINING CREX DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CF(1:II),'r',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on input file'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-c
-C
-C*          1.2.1 OPEN OUTPUT FILE.
-C               ------------------
- 121  CONTINUE
-C
-
-      CALL PBOPEN(IUNIT1,COUT(1:I),'w',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on output file'
-      IF(IRET.EQ.-2) STOP 'Invalid output file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-C     ----------------------------------------------------------------- 
-C*          2. SET REQUEST FOR EXPANSION.
-C              --------------------------
- 200  CONTINUE
-C
-      NR=1
-      OPRT=.TRUE.
-      OENC=.FALSE.
-C
-      OENC=.TRUE.
-
- 210  CONTINUE
-C
-C
-C     -----------------------------------------------------------------
-C*          3.  READ CREX MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      IRET=0
-c
-      CALL PBCREX(IUNIT,KBUFF,JBUFL,KBUFL,IRET)
-      IF(IRET.LT.0) THEN
-         if(iret.eq.-1) stop 'End of file '
-         if(iret.eq.-2) stop 'Error in handling the file'
-         if(iret.eq.-3) stop 'Error during read CREX file.'
-      END IF
-c
-      N=N+1
-      print*,'----------------------------------',n
-      IF(N.LT.NR) GO TO 300
-      KEL=KELEM
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND CREX MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-      IERR=0
-      CALL CREXEX(KBUFL,YBUFF,KSUP,KSEC0 ,KSEC1,KSEC3 ,
-     1            KEL,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) then
-         print*,'CREX error ', ierr
-         IF(IERR.EQ.20.or.IERR.EQ.14) THEN
-            KEL=KVALS/KSUP(6)
-            GO TO 400
-         ELSE
-            CALL EXIT(2)
-         END IF
-      END IF
-C
-      
-      IOBS=IOBS+KSEC3(3)
-C
-      ISUBSET=1
-      CALL CREXSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,
-     1              CNAMES,CUNITS,KERR)
-      IF(KERR.NE.0) then
-         print*,'CREXSEL: error.'
-         CALL EXIT(2)
-      END IF
-C
-C*          4.1 PRINT CONTENT OF EXPANDED DATA.
-C               -------------------------------
- 410  CONTINUE
-C
-      IF(.NOT.OPRT) GO TO 500
-C
-C*          4.2 PRINT SECTION ZERO OF CREX MESSAGE.
-C               -----------------------------------
- 420  CONTINUE
-C
-
-      CALL CREXPRS0(KSEC0)
-C
-C*          4.3 PRINT SECTION ONE OF CREX MESSAGE.
-C               -----------------------------------
- 430  CONTINUE
-C
-      CALL CREXPRS1(KSEC1,KSEC3,KTDLEN,KTDLST,KTDEXL,
-     1              KTDEXP,KEL,CNAMES)
-C
-C
-C
-C*         4.6 PRINT SECTION 4 (DATA).
-C              -----------------------
- 460  CONTINUE
-C
-C          IN THE CASE OF MANY SUBSETS DEFINE RANGE OF SUBSETS
-C
-      IF(.NOT.OO) THEN
-      WRITE(*,'(a,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IST
-      WRITE(*,'(a,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IEND
-      OO=.false.
-      END IF
-C
-C              PRINT DATA
-C
-      ICODE=0
-      CALL CREXPRT(ICODE,IST,KSEC3(3),KEL,CNAMES,CUNITS,CVALS,
-     1           KVALS,VALUES,KSUP,KSEC1,IERR)
-C
-C
-C     -----------------------------------------------------------------
-C*          5. COLLECT DATA FOR REPACKING.
-C              ---------------------------
- 500  CONTINUE
-C      
-      IF(.NOT.OENC) GO TO 300
-C
-C               FIRST GET DATA DESCRIPTORS
-C
-      KK=0
-      IST=1
-      IEND=KSEC3(3)
-C
-      DO ISUBSET=IST, IEND
-
-
-      CALL CREXSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) THEN
-         print*,'CREXSEL: error ',kerr
-         CALL EXIT(2)
-      END IF
-C
-      JM1KELEM=(ISUBSET-1)*KEL
-C
-      DO 501 I=1,KTDEXL
-         INV=I+JM1KELEM
-         IN =I+JM1KELEM
-C
-         IF(CUNITS(I).EQ.'CHARACTER') THEN
-            IPOS =VALUES(INV)/1000.
-            ICH=NINT(VALUES(INV)-IPOS*1000)
-            KKK=KKK+1
-            VALUE(IN)=KKK*1000+ICH
-            IF(CVALS(IPOS)(1:1).EQ.'/') THEN
-               CV=' '
-               DO II=1,ICH
-               CV(II:II)=CHAR(255)
-               END DO
-               CVAL(KKK)=CV
-            ELSE
-              CVAL(KKK)=CVALS(IPOS)
-            END IF
-         ELSEIF(CUNITS(I)(1:2).EQ.'C '.AND.
-     1     KTDEXP(I)/1000.eq.12 ) THEN
-           VALUE(IN)=VALUES(INV)+273.15
-         ELSEIF(CUNITS(I)(1:2).EQ.'NB'.AND.
-     1     KTDEXP(I).EQ.015003) THEN
-           VALUE(IN)=VALUES(INV)*0.0001
-         ELSE
-            VALUE(IN)=VALUES(INV)
-         END IF
-C
-         IF(KTDEXP(I).EQ.31001.OR.KTDEXP(I).EQ.31002.OR.
-     1      KTDEXP(I).EQ.31000) THEN
-            KK=KK+1
-            KDATA(KK)=NINT(VALUES(INV))
-         END IF
- 501  CONTINUE
-C
-      END DO
-C
-      KDLEN=2
-      IF(KK.NE.0) KDLEN=KK
-
-C     -----------------------------------------------------------------
-C*          6. PACK BUFR MESSAGE.
-C              -----------------
- 600  CONTINUE
-C
-      KKK=0
-C
-      IF(KSEC0(3).LE.1) THEN
-         KSEC0(3)=3              ! Edition 3  of bufr message
-C
-         KSEC1(1)=18
-         KSEC1(2)=3              ! Bufr edition number
-         KSEC1(3)=KSEC1(3)
-         KSEC1(4)=1
-         KSEC1(5)=0            ! presence od section 2
-         KSEC1(7)=0
-         KSEC1(8)=0            ! Bufr local tables version number
-         KSEC1(9)=0
-         KSEC1(10)=0
-         KSEC1(11)=0
-         KSEC1(12)=0
-         KSEC1(13)=0
-         KSEC1(14)=0
-         KSEC1(15)=0           ! Bufr master table version number
-c
-         I_004001=0
-         I_004002=0
-         I_004003=0
-         I_004004=0
-         I_004005=0
-c
-         DO I=1,KTDEXL
-         IF(KTDEXP(I).EQ.004001) THEN
-            IF(I_004001.EQ.0) I_004001=I
-         ELSEIF(KTDEXP(I).EQ.004002) THEN
-            IF(I_004002.EQ.0) I_004002=I
-         ELSEIF(KTDEXP(I).EQ.004003) THEN
-            IF(I_004003.EQ.0) I_004003=I
-         ELSEIF(KTDEXP(I).EQ.004004) THEN
-            IF(I_004004.EQ.0) I_004004=I
-         ELSEIF(KTDEXP(I).EQ.004005) THEN
-            IF(I_004005.EQ.0) I_004005=I
-         END IF
-         END DO
-c
-         KSEC1(9)=NINT(VALUE(I_004001))-1900
-         IF(NINT(VALUE(I_004001)).GE.2000) THEN
-             KSEC1(9)=NINT(VALUE(I_004001))-2000
-         END IF
-         KSEC1(10)=NINT(VALUE(I_004002))
-         KSEC1(11)=NINT(VALUE(I_004003))
-         KSEC1(12)=NINT(VALUE(I_004004))
-         KSEC1(13)=NINT(VALUE(I_004005))
-c
-         KSEC1(14)=0
-         KSEC1(15)=13
-         KSEC1(16)=0
-      ELSEIF(KSEC0(3).EQ.2) THEN
-         KSEC0(3)=4              ! Edition 4  of bufr message
-c
-         KSEC1(1)=22             ! The size of section 1
-         KSEC1(2)=4
-         KSEC1(3)=KSEC1(3)
-         KSEC1(5)=0              ! presence od section 2
-         KSEC1(9)=0
-         KSEC1(10)=0
-         KSEC1(11)=0
-         KSEC1(12)=0
-         KSEC1(13)=0
-c
-         I_004001=0
-         I_004002=0
-         I_004003=0
-         I_004004=0
-         I_004005=0
-c
-         DO I=1,KTDEXL
-         IF(KTDEXP(I).EQ.004001) THEN
-            IF(I_004001.EQ.0) I_004001=I
-         ELSEIF(KTDEXP(I).EQ.004002) THEN
-            IF(I_004002.EQ.0) I_004002=I
-         ELSEIF(KTDEXP(I).EQ.004003) THEN
-            IF(I_004003.EQ.0) I_004003=I
-         ELSEIF(KTDEXP(I).EQ.004004) THEN
-            IF(I_004004.EQ.0) I_004004=I
-         ELSEIF(KTDEXP(I).EQ.004005) THEN
-            IF(I_004005.EQ.0) I_004005=I
-         END IF
-         END DO
-c
-         KSEC1( 9)=NINT(VALUE(I_004001))
-         KSEC1(10)=NINT(VALUE(I_004002))
-         KSEC1(11)=NINT(VALUE(I_004003))
-         KSEC1(12)=NINT(VALUE(I_004004))
-         KSEC1(13)=NINT(VALUE(I_004005))
-c
-         KSEC1(14)=0         ! Bufr master table
-         KSEC1(15)=KSEC1(17) ! Bufr master table version number
-         KSEC1(16)=KSEC1(16) ! Originating sub-centre
-         KSEC1(17)=KSEC1( 7) ! International sub-category
-         KSEC1( 7)=0
-         KSEC1(18)=0         ! Second
-c
-         
-      END IF
-c
-      KSEC3(4)=192                    ! No compression
-c
-      KBUFL=JBUFL
-C
-C
-C*          6.2 ENCODE DATA INTO BUFR MESSAGE.
-C               ------------------------------
- 620  CONTINUE
-C
-c              Modify descriptor list for delayed 
-c              replication factor
-c
-      J=0
-      DO I=1,KTDLEN
-      IIF=KTDLST(I)/100000
-      IF(IIF.EQ.1) THEN
-         II=KTDLST(I)/1000
-         IY=KTDLST(I)-II*1000
-         IF(IY.EQ.0) THEN
-           J=J+1
-           KTDLST1(J)=KTDLST(I)
-           J=J+1
-           KTDLST1(J)=031002
-         ELSE
-           j=j+1
-           KTDlst1(j)=KTDlst(i)
-         END IF
-      ELSE
-         J=J+1
-         KTDLST1(J)=KTDLST(I)
-      END IF
-      END DO
-c
-      KTDLEN=J
-c 
-      KERR=0
-c     
-      CALL BUFREN( KSEC0,KSEC1,KSEC2,KSEC3,KSEC4,
-     1             KTDLEN,KTDLST1,KDLEN,KDATA,KEL,   
-     2             KVALS,VALUE,CVAL,KBUFL,KBUFR,KERR)
-C
-      IF(KERR.gt.0) THEN
-         print*,'error is ',kerr
-         PRINT*,'ERROR DURING ENCODING.'
-         CALL EXIT(2)
-      END IF
-C
-C           6.3 WRITE PACKED BUFR MESSAGE INTO FILE.
-C               ------------------------------------
- 630  CONTINUE
-C
-      ILEN=KBUFL*NBYTPW
-C     
-      IERR=0
-      CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-      if(ierr.lt.0) then
-         print*,'Error writing into target file.'
-         CALL EXIT(2)
-      END IF
-C
-      GO TO 300
-C     -----------------------------------------------------------------
-C
-      END
diff --git a/tests/bufr/decode_bufr.F b/tests/bufr/decode_bufr.F
deleted file mode 100755
index d6fa27f..0000000
--- a/tests/bufr/decode_bufr.F
+++ /dev/null
@@ -1,623 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM BUFR
-C
-C**** *BUFR*
-C
-C
-C     PURPOSE.
-C     --------
-C         EXAMPLE OF USING BUFR UNPACKING/PACKING SOFTWARE.
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C         CALL BUSEL2
-C         CALL BUFREX
-C         CALL BUFREN
-C         CALL BUPRS0
-C         CALL BUPRS1
-C         CALL BUPRS2
-C         CALL BUPRS3
-C         CALL BUPRT
-C         CALL BUUKEY
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          M. DRAGOSAVAC    *ECMWF*       15/09/87.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =   9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=   4,
-     1          JSEC4=2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=512000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=3000,JCTST=9000,JCTEXT=9000,
-#else
-     2          JBPW =  32,JTAB =3000,JCTAB=3000,JCTST=9000,JCTEXT=9000,
-#endif
-     3          JWORK=4096000,JKEY=46, JTMAX=10,JTCLAS=64,JTEL=255)
-
-C
-      PARAMETER (KELEM=40000)
-      PARAMETER (KVALS=4096000)
-C 
-      DIMENSION KBUFF(JBUFL)
-      DIMENSION KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-      DIMENSION KEY  (JKEY),KREQ(2)
-      DIMENSION NREQUEST(2)
-C
-      REAL*8 VALUES(KVALS),VALUE(KVALS)
-      DIMENSION KTDLST(JELEM),KTDEXP(JELEM),KRQ(KELEM)
-      REAL*8 RQV(KELEM)
-      DIMENSION KDATA(200),KBOXR(JELEM*4)
-      REAL*8 VALS(KVALS)
-C
-      CHARACTER*256 CF,COUT,CARG(4)
-      CHARACTER*64 CNAMES(KELEM),CBOXN(JELEM*4)
-      CHARACTER*24 CUNITS(KELEM),CBOXU(JELEM*4)
-      CHARACTER*80 CVALS(kelem)
-      CHARACTER*80 CVAL(kelem)
-      CHARACTER*80 YENC
-      REAL*8 RVIND
-      REAL*8 EPS
-C
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C     MISSING VALUE INDICATOR
-C 
-      NBYTPW=JBPW/8
-      RVIND=1.7D38
-      NVIND=2147483647
-      IOBS=0
-      EPS=10.D-8
-      NPACK=0
-      IYEAR=NVIND
-      N=0
-      NCOM=0
-      OO=.FALSE.
-C
-C
-C
-C     GET INPUT AND OUTPUT FILE NAME.
-C
-      NARG=IARGC()
-C
-C
-      DO 104 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 104  CONTINUE
-
-      II=0
-      IO=0
-      DO 105 J=1,NARG
-      IF(CARG(J).EQ.'-i') THEN
-         IN=J
-      ELSEIF(CARG(J).EQ.'-o') THEN
-         IO=J
-      END IF
- 105  CONTINUE
-      IF(IN.EQ.0) THEN
-         PRINT*,'USAGE -- decode_bufr -i infile'
-         STOP
-      END IF
-      IF(IO.EQ.0.and.IN.EQ.0) THEN
-         PRINT*,'USAGE -- decode_bufr -i infile -o outfile'
-         STOP
-      END IF
-
-C
-      IF(IO.NE.0)  COUT=CARG(IO+1)
-C
-      IF(IO.LT.IN) THEN
-         IST=IN+1
-         IEND=NARG
-      ELSE
-         IST=IN+1
-         IEND=IO-1
-      END IF
-C
-C
-      IF(IO.NE.0) THEN
-         JJ=INDEX(COUT,' ')
-         JJ=JJ-1
-         CALL PBOPEN(IUNIT1,COUT(1:JJ),'W',IRET)
-         IF(IRET.EQ.-1) STOP 'OPEN FAILED ON BUFR.DAT'
-         IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-         IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-      END IF
-C
-      DO 101 II=IST,IEND
-
-      CF=CARG(II)
-      ILN=INDEX(CF,' ')
-      ILN=ILN-1
-
-      KRQL=0
-      NR=0
-      KREQ(1)=0
-      KREQ(2)=0
-      DO 103 I=1,KELEM
-      RQV(I)=RVIND
-      KRQ(I)=NVIND
- 103  CONTINUE
-C
-C*          1.2 OPEN FILE CONTAINING BUFR DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CF(1:ILN),'R',IRET)
-      IF(IRET.EQ.-1) STOP 'OPEN FAILED'
-      IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-      IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-C
-      IF(IO.NE.0) THEN
-         CALL PBOPEN(IUNIT1,COUT(1:JJ),'W',IRET)
-         IF(IRET.EQ.-1) STOP 'OPEN FAILED ON BUFR.DAT'
-         IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-         IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-      END IF
-C
-
-C
-C
-C     ----------------------------------------------------------------- 
-C*          2. SET REQUEST FOR EXPANSION.
-C              --------------------------
- 200  CONTINUE
-C
-      OPRT=.FALSE.
-      OENC=.FALSE.
-      WRITE(*,'(A,$)') ' DO YOU WANT TO PRINT( Y/N ) : '
-      READ (*,'(A)') YENC
-      IF(YENC(1:1).EQ.'Y'.OR.YENC(1:1).EQ.'y') THEN
-         OPRT=.TRUE.
-      END IF
-      ICODE=0
-      WRITE(*,'(A,$)') ' CODE TABLES TO BE PRINTED ( Y/N ) : '
-      READ (*,'(A)') YCODC
-      IF(YCODC(1:1).EQ.'Y'.OR.YCODC(1:1).EQ.'y') THEN
-         ICODE=1
-      END IF
-      WRITE(*,'(A,$)') ' DO YOU WANT ENCODING( Y/N ) : '
-      READ (*,'(A)') YENC
-      IF(YENC(1:1).EQ.'Y'.OR.YENC(1:1).EQ.'y') THEN
-          OENC=.TRUE.
-         WRITE(*,'(A,$)') ' NUMBER OF SUBSETS TO PACK : '
-         READ(*,'(BN,I4)')   NCOM
-         OCOMP=.FALSE.
-         WRITE(*,'(A,$)') ' DO YOU WANT COMPRESSION( Y/N ) : '
-         READ (*,'(A)') YCOMP
-         IF(YCOMP(1:1).EQ.'Y'.OR.YCOMP(1:1).EQ.'y') OCOMP=.TRUE.
-      END IF
-      WRITE(*,'(A,$)') ' RECORD NUMBER TO START FROM : '
-      READ(*,'(BN,I6)')   NR
-C
- 201  CONTINUE
-C
-      WRITE(*,'(A,$)') ' REQUESTED ELEMENT : ' 
-      READ(*,'(BN,I6)')   IEL 
-      WRITE(*,'(A,$)') ' REQUESTED VALUE   : '
-      READ(*,'(BN,F12.2)')   VAL
-      IF(IEL.EQ.0) THEN
-         KRQL=J
-      ELSE
-         J=J+1
-         KRQ(J)=IEL
-         RQV(J)=VAL
-         IF(VAL.EQ.0.) RQV(J)=RVIND
-         GO TO 201
-      END IF
-C
-      WRITE(*,'(A,$)') ' REQUESTED FLAG 1  : '
-      READ(*,'(BN,I6)')  KREQ(1)
-C
-      WRITE(*,'(A,$)') ' REQUESTED FLAG 2  : '
-      READ(*,'(BN,I6)')  KREQ(2)
-C
-      WRITE(*,'(A,$)') ' DO YOU WANT TO PRINT SECTION 0-3( Y/N ) : '
-      READ (*,'(A,$)') YENC
-      OSEC3=.FALSE.
-      IF(YENC(1:1).EQ.'Y'.OR.YENC(1:1).EQ.'y') OSEC3=.TRUE.
-C
-C*          2.1 SET REQUEST FOR PARTIAL EXPANSION.
-C               ----------------------------------
- 210  CONTINUE
-C
-      IERR=0
-      CALL BUSRQ(KREQ,KRQL,KRQ,RQV,IERR)
-C
-C     SET VARIABLE TO PACK BIG VALUES AS MISSING VALUE INDICATOR
-C
-      KPMISS=1
-      KPRUS=0
-      KOKEY=0
-      CALL BUPRQ(KPMISS,KPRUS,KOKEY)
-C
-C     -----------------------------------------------------------------
-      IF(NCOM.NE.0) THEN
-         KEL1=KVALS/NCOM
-         IF(KEL1.GT.KELEM) KEL1=KELEM
-      END IF
-C
-C*          3.  READ BUFR MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      KBUFL=0
-C
-      CALL PBBUFR(IUNIT,KBUFF,JBUFL,KBUFL,IERR) 
-      IF(IERR.EQ.-1) THEN
-         IF(NPACK.NE.0) GO TO 600
-         PRINT*,'NUMBER OF SUBSETS     ',IOBS
-         PRINT*,'NUMBER OF MESSAGES    ',N
-         STOP 'EOF'
-      END IF
-      IF(IERR.EQ.-2) STOP 'FILE HANDLING PROBLEM' 
-      IF(IERR.EQ.-3) STOP 'ARRAY TOO SMALL FOR PRODUCT'
-C
-      N=N+1
-c     PRINT*,'----------------------------------',N,' ',KBUFL
-      KBUFL=KBUFL/NBYTPW+1
-      IF(N.LT.NR) GO TO 300
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND BUFR MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-      CALL BUS0123( KBUFL,KBUFF,KSUP,KSEC0,KSEC1,KSEC2,KSEC3,IERR)
-      IF(IERR.NE.0) THEN
-         PRINT*,'ERROR IN BUS012: ',IERR
-         PRINT*,' BUFR MESSAGE NUMBER ',N,' CORRUPTED.'
-         IERR=0
-         GO TO 300
-      END IF
-C
-      KEL=KVALS/KSEC3(3)
-      IF(KEL.GT.KELEM) KEL=KELEM
-C
-      CALL BUFREX(KBUFL,KBUFF,KSUP,KSEC0 ,KSEC1,KSEC2 ,KSEC3 ,KSEC4,
-     1            KEL,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) THEN
-         CALL EXIT(2)
-      END IF
-C
-C
-      IOBS=IOBS+KSEC3(3)
-C
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-C     IF(IERR.NE.0) CALL EXIT(2)
-C
-C
-c      DO 401 IK=1,KSEC3(3)
-c
-c      CALL BUSEL2(IK,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-c    1             CUNITS,IERR)
-c      KSUP(5)=KTDEXL
-c      CALL BUBOX(IK,KSUP,KEL,KTDEXP,CNAMES,CUNITS,KVALS,VALUES,
-c    1            KBOX,KAPP,KLEN,KBOXR,VALS,CBOXN,CBOXU,IERR)
-C
-c 401  CONTINUE
-C
-C
-C*          4.1 PRINT CONTENT OF EXPANDED DATA.
-C               -------------------------------
- 410  CONTINUE
-C
-      IF(.NOT.OPRT) GO TO 500
-      IF(.NOT.OSEC3) GO TO 450
-C
-C*          4.2 PRINT SECTION ZERO OF BUFR MESSAGE.
-C               -----------------------------------
- 420  CONTINUE
-C
-
-      CALL BUPRS0(KSEC0)
-C
-C*          4.3 PRINT SECTION ONE OF BUFR MESSAGE.
-C               -----------------------------------
- 430  CONTINUE
-C
-      CALL BUPRS1(KSEC1)
-C
-C
-C*          4.4 PRINT SECTION TWO OF BUFR MESSAGE.
-C               -----------------------------------
- 440  CONTINUE
-C
-C              AT ECMWF SECTION 2 CONTAINS RDB KEY.
-C              SO UNPACK KEY
-C
-      CALL BUUKEY(KSEC1,KSEC2,KEY,KSUP,IERR)
-C
-C              PRINT KEY
-C
-      CALL BUPRS2(KSUP ,KEY)
-C
-C*          4.5 PRINT SECTION 3 OF BUFR MESSAGE.
-C               -----------------------------------
- 450  CONTINUE
-C
-C               FIRST GET DATA DESCRIPTORS
-C
-C     Multi subset uncompressed data descriptors for the 1st subset
-C     Each subset can contain completly different list of expanded
-C     discriptors
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(IERR.NE.0) CALL EXIT(2)
-C
-C               PRINT  CONTENT
-C
-      IF(OSEC3) THEN
-         CALL BUPRS3(KSEC3,KTDLEN,KTDLST,KTDEXL,KTDEXP,KEL,CNAMES)
-      END IF
-C
-C*         4.6 PRINT SECTION 4 (DATA).
-C              -----------------------
- 460  CONTINUE
-C
-C          IN THE CASE OF MANY SUBSETS DEFINE RANGE OF SUBSETS
-C
-      IF(.NOT.OO) THEN
-      WRITE(*,'(A,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I4)')   IST
-      WRITE(*,'(A,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I4)')   IEND
-      OO=.FALSE.
-      END IF
-C
-C              PRINT DATA
-C
-C     IF(KSEC1(6).EQ.11) THEN
-C
-C        IST=1
-C        IEND=KSEC3(3)
-C
-         CALL BUPRT(ICODE,IST,IEND,KEL,CNAMES,CUNITS,CVALS,
-     1              KVALS,VALUES,KSUP,KSEC1,IERR)
-C     ELSE
-C
-C              RESOLVE BIT MAPS FOR EACH SUBSET
-C
-C        ist=1
-C        iend=ksec3(3)
-C
-C        IF(IEND.GT.KSEC3(3)) IEND=KSEC3(3)
-C
-C        DO 461 IK=IST,IEND
-C 
-C        CALL BUSEL2(IK,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-C    1               CUNITS,IERR)
-C
-C        KSUP(5)=KTDEXL
-C        CALL BUBOX(IK,KSUP,KEL,KTDEXP,CNAMES,CUNITS,KVALS,VALUES,
-C    1              KBOX,KAPP,KLEN,KBOXR,VALS,CBOXN,CBOXU,IERR)
-C        IF(IERR.NE.0) CALL EXIT(2)
-C 
-C        CALL BUPRTBOX(KBOX,KAPP,KLEN,KBOXR,VALS,CBOXN,CBOXU)
-C
-C461     CONTINUE
-C     END IF
-C
-C     -----------------------------------------------------------------
-C*          5. COLLECT DATA FOR REPACKING.
-C              ---------------------------
- 500  CONTINUE
-C      
-C 
-      IF(.NOT.OENC) GO TO 300
-C
-      ISUBS=KSEC3(3)
-      DO J=1,ISUBS
-C
-      NPACK=NPACK+1
-C
-C            FIRST GET DATA DESCRIPTORS
-C
-      CALL BUSEL2(J,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(IERR.NE.0) CALL EXIT(2)
-C
-      DO I=1,KTDEXL
-      IO=I+(NPACK-1)*KEL1
-      IN=I+(J-1)*KEL
-C
-      IF(CUNITS(I).EQ.'CCITTIA5') THEN
-         IPOS =VALUES(IN)/1000.
-         ICH=NINT(VALUES(IN)-IPOS*1000)
-         KKK=KKK+1
-         VALUE(IO)=KKK*1000+ICH
-         CVAL(KKK)=CVALS(IPOS)
-      ELSE
-         VALUE(IO)=VALUES(IN)
-      END IF
-      IF(KTDEXP(I).EQ.31001.OR.KTDEXP(I).EQ.31002) THEN
-          KK=KK+1
-          KDATA(KK)=NINT(VALUE(IO))
-       END IF
-       IF(KTDEXP(I).EQ.004001) THEN
-          IYEAR=NINT(VALUE(IO))
-       END IF
-
-       END DO
-C
-       KDLEN=KK
-       IF(NPACK.EQ.NCOM) THEN
-         
-
-          KSEC3(3)=NPACK
-          KSEC1(5)=0
-          KSEC1(8)=1
-          KSEC1(15)=12
-          IF(KSEC0(3).LT.4) THEN
-             KSEC1(17)=255
-             KSEC1(18)=0
-          END IF
-          KSEC0(3)=3            ! EDITION 4 OF BUFR MESSAGE
-          IF(KSEC0(3).GE.4) KSEC1(1)=22
-          KSEC3(4)=0            ! NO COMPRESSION
-          IF(KSEC0(3).LE.3) THEN
-             IF(IYEAR.GT.2000) THEN
-                KSEC1(9)=IYEAR-2000
-             ELSE
-                KSEC1(9)=IYEAR-1900
-             END IF
-          ELSE
-             KSEC1(9)=IYEAR
-          END IF
-          IF(OCOMP) KSEC3(4)=64  ! COMPRESSION
-          KBUFL=JBUFL
-          CALL BUFREN( KSEC0,KSEC1,KSEC2,KSEC3,KSEC4,
-     1             KTDLEN,KTDLST,KDLEN,KDATA,KEL1,
-     2             KVALS,VALUE,CVAL,KBUFL,KBUFR,IERR)
-          IF(IERR.NE.0) THEN
-             PRINT*,'ERROR IS ',IERR
-             PRINT*,'ERROR DURING ENCODING.'
-             CALL EXIT(2)
-          END IF
-C
-          ILEN=KBUFL*NBYTPW
-C
-          IERR=0
-C
-          CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-          IF(IERR.LT.0) THEN
-             PRINT*,'ERROR WRITING INTO TARGET FILE.'
-             CALL EXIT(2)
-          END IF
-          PRINT*,'RECORD WRITTEN INTO FILE '
-C
-          NPACK=0
-          KKK=0
-          KK=0
-       END IF
-C
-       END DO
-C
-       GO TO 300
-C     -----------------------------------------------------------------
-C*          6. PACK BUFR MESSAGE BACK INTO BUFR.
-C              ---------------------------------
- 600  CONTINUE
-C
-     
-       KSEC3(3)=NPACK
-       KSEC1(8)=1
-       KSEC1(15)=12
-       KSEC0(3)=4            ! EDITION 4 OF BUFR MESSAGE
-       IF(KSEC0(3).GE.4) KSEC1(1)=22
-       IF(KSEC0(3).LT.4) THEN
-          KSEC1(17)=255
-          KSEC1(18)=0
-       END IF
-
-       KSEC3(4)=0            ! NO COMPRESSION
-       IF(KSEC1(9).LT.101) THEN
-          KSEC1(9)=IYEAR
-       END IF
-       
-C      
-       IF(OCOMP) KSEC3(4)=64  ! COMPRESSION  
-       KBUFL=JBUFL
-C
-C
-C*          6.2 ENCODE DATA INTO BUFR MESSAGE.
-C               ------------------------------
- 620   CONTINUE
-C
-       CALL BUFREN( KSEC0,KSEC1,KSEC2,KSEC3,KSEC4,
-     1             KTDLEN,KTDLST,KDLEN,KDATA,KEL1,
-     2             KVALS,VALUE,CVAL,KBUFL,KBUFR,IERR)
-       IF(IERR.NE.0) THEN
-          PRINT*,'ERROR IS ',IERR
-          PRINT*,'ERROR DURING ENCODING.'
-          CALL EXIT(2)
-       END IF
-C
-C           6.3 WRITE PACKED BUFR MESSAGE INTO FILE.
-C               ------------------------------------
- 630   CONTINUE
-C
-       ILEN=KBUFL*NBYTPW
-C    
-       CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-       IF(IERR.LT.0) THEN
-          PRINT*,'ERROR WRITING INTO TARGET FILE.'
-          CALL EXIT(2)
-       END IF
-       PRINT*,'RECORD WRITTEN INTO FILE ' 
-C
-       NPACK=0
-       KKK=0
-C
-       GO TO 300
-C     -----------------------------------------------------------------
-C
- 810  CONTINUE
-C
-      WRITE(*,'(1H ,A)') 'OPEN ERROR ON INPUT FILE'
-      GO TO 900
-C      
- 800  CONTINUE
-C
-      IF(IRET.EQ.-1) THEN
-         PRINT*,'NUMBER OF RECORDS PROCESSED ',N
-         PRINT*,'NUMBER OF OBSERVATIONS      ',IOBS
-      ELSE
-         PRINT*,' BUFR : ERROR= ',IERR
-      END IF
-C
- 900  CONTINUE
-C
-      CALL PBCLOSE(IUNIT,IRET)
- 101  CONTINUE
-      CALL PBCLOSE(IUNIT1,IRET)
-C
-      END
diff --git a/tests/bufr/decode_bufr_image.F b/tests/bufr/decode_bufr_image.F
deleted file mode 100644
index 2d37421..0000000
--- a/tests/bufr/decode_bufr_image.F
+++ /dev/null
@@ -1,262 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM DECODE_BUFR_IMAGE
-C
-C**** *DECODE_BUFR_IMAGE*
-C
-C
-C     PURPOSE.
-C     --------
-C         Expnds Opera run-length encoded composite images
-C         and creates image header and image file.
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          M. DRAGOSAVAC    *ECMWF*       15/07/2008.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =   9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=   4,
-     1          JSEC4=2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=512000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=3000,JCTST=9000,JCTEXT=9000,
-#else
-     2          JBPW =  32,JTAB =3000,JCTAB=3000,JCTST=9000,JCTEXT=9000,
-#endif
-     3          JWORK=4096000,JKEY=46, JTMAX=10,JTCLAS=64,JTEL=255)
-
-C
-      PARAMETER (JIMG=2500000)
-      PARAMETER (KELEM=320000)
-      PARAMETER (KVALS=4096000)
-   
-C 
-      DIMENSION KBUFF(JBUFL)
-      DIMENSION KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-C
-      REAL*8 VALUES(KVALS),VALUES_IMG(500)
-      INTEGER IMAGE(JIMG)
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM)
-      DIMENSION KTDEXP_IMG(KELEM)
-C
-      CHARACTER*256 CF,COUT,CARG(4),COUT1,COUT2,COUT3
-      CHARACTER*64 CNAMES(KELEM),CNAMES_IMG(KELEM)
-      CHARACTER*24 CUNITS(KELEM),CUNITS_IMG(KELEM)
-      CHARACTER*80 CVALS(KELEM),CVALS_IMG(KELEM)
-      REAL*8 RVIND
-C
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C     MISSING VALUE INDICATOR
-C 
-      NBYTPW=JBPW/8
-      RVIND=1.7D38
-      NVIND=2147483647
-      IOBS=0
-      N=0
-C
-C
-C
-C     GET INPUT AND OUTPUT FILE NAME.
-C
-      NARG=IARGC()
-C
-C
-      DO 104 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 104  CONTINUE
-
-      IF(NARG.EQ.0) THEN
-         PRINT*,'USAGE -- decode_bufr_image infile'
-         STOP
-      END IF
-C
-      DO 101 II=1,NARG
-
-      CF=CARG(II)
-      ILN=INDEX(CF,' ')-1
-C
-C*          1.2 OPEN FILE CONTAINING BUFR DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CF(1:ILN),'R',IRET)
-      IF(IRET.EQ.-1) STOP 'OPEN FAILED'
-      IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-      IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-C
-      COUT1=CF(1:ILN-5)//'.img'
-      ILN1=INDEX(COUT1,' ')-1
-      CALL PBOPEN(IUNIT1,COUT1(1:ILN1),'W',IRET)
-      IF(IRET.EQ.-1) STOP 'OPEN FAILED ON *.img file'
-      IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-      IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-C
-      COUT2=CF(1:ILN-5)//'.img_header'
-      ILN2=INDEX(COUT2,' ')-1
-      IUNIT2=40
-      OPEN(UNIT=IUNIT2,FILE=COUT2(1:ILN2),STATUS='UNKNOWN',IOSTAT=ios)
-      IF(IOS.NE.0) THEN
-        PRINT*,'Open error on ',COUT2(1:ILN2)
-        STOP 
-      END IF
-         
-C
-      COUT3=CF(1:ILN-5)//'.section_1'
-      ILN3=INDEX(COUT3,' ')-1
-      IUNIT3=41
-      OPEN(UNIT=IUNIT3,FILE=COUT3(1:ILN3),STATUS='UNKNOWN',IOSTAT=ios)
-      IF(IOS.NE.0) THEN
-        PRINT*,'Open error on ',COUT3(1:ILN3)
-        STOP 
-      END IF
-C
-C     ----------------------------------------------------------------- 
-C
-C*          3.  READ BUFR MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      KBUFL=0
-C
-      CALL PBBUFR(IUNIT,KBUFF,JBUFL,KBUFL,IERR) 
-      IF(IERR.EQ.-1) THEN
-         PRINT*,'NUMBER OF SUBSETS     ',IOBS
-         PRINT*,'NUMBER OF MESSAGES    ',N
-         STOP 'EOF'
-      END IF
-      IF(IERR.EQ.-2) STOP 'FILE HANDLING PROBLEM' 
-      IF(IERR.EQ.-3) STOP 'ARRAY TOO SMALL FOR PRODUCT'
-C
-      N=N+1
-      PRINT*,'----------------------------------',N,' ',KBUFL
-      KBUFL=KBUFL/NBYTPW+1
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND BUFR MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-      CALL BUS0123( KBUFL,KBUFF,KSUP,KSEC0,KSEC1,KSEC2,KSEC3,IERR)
-      IF(IERR.NE.0) THEN
-         PRINT*,'ERROR IN BUS012: ',IERR
-         PRINT*,' BUFR MESSAGE NUMBER ',N,' CORRUPTED.'
-         IERR=0
-         GO TO 300
-      END IF
-C
-      KEL=KVALS/KSEC3(3)
-      IF(KEL.GT.KELEM) KEL=KELEM
-C
-      CALL BUFREX(KBUFL,KBUFF,KSUP,KSEC0 ,KSEC1,KSEC2 ,KSEC3 ,KSEC4,
-     1            KEL,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) THEN
-         CALL EXIT(2)
-      END IF
-C
-      IOBS=IOBS+KSEC3(3)
-C
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-C     IF(IERR.NE.0) CALL EXIT(2)
-C
-C     Get full image as array of pixel values
-
-      CALL BUGET_OPERA_IMAGE(KSEC1,KTDEXL,KTDEXP,CNAMES,CUNITS,
-     1      KELEM,KVALS,VALUES,CVALS,KTDEXL_IMG,KTDEXP_IMG,
-     2      CNAMES_IMG,CUNITS_IMG,KVALS_IMG,VALUES_IMG,
-     3      CVALS_IMG,KSIZE_IMG_BYTES,IMAGE,KPIXEL_SIZE,KERR)
-
-c
-c
-C
-C     Write image meta data into file
-C     -------------------------------
-      DO I=1,KTDEXL_IMG
-      WRITE(IUNIT2,'(I6,1X,A64,1x,F20.8,1x,a24)') I,CNAMES_IMG(I),
-     c                                VALUES_IMG(I),CUNITS_IMG(I)
-      END DO
-
-C
-C     Write bufr section 1 into file
-C     ------------------------------
-      CALL BBUPRS1(IUNIT3,KSEC1)
-      IMX=KSIZE_IMG_BYTES
-C   
-C     Write image ( pixel values ) into file
-C     -----------------------------------------------------------------
-      CALL PBWRITE(IUNIT1,IMAGE,IMX,IERR)
-C
-C
-      GO TO 900 
-C     -----------------------------------------------------------------
-C
- 810  CONTINUE
-C
-      WRITE(*,'(1H ,A)') 'OPEN ERROR ON INPUT FILE'
-      GO TO 900
-C      
- 800  CONTINUE
-C
-      IF(IRET.EQ.-1) THEN
-         PRINT*,'NUMBER OF RECORDS PROCESSED ',N
-         PRINT*,'NUMBER OF OBSERVATIONS      ',IOBS
-      ELSE
-         PRINT*,' BUFR : ERROR= ',IERR
-      END IF
-C
- 900  CONTINUE
-C
-      CALL PBCLOSE(IUNIT,IRET)
-      CALL PBCLOSE(IUNIT1,IRET)
-      CLOSE(IUNIT2)
-      CLOSE(IUNIT3)
- 101  CONTINUE
-C
-      END
diff --git a/tests/bufr/tdexp.F b/tests/bufr/tdexp.F
deleted file mode 100755
index c8365a5..0000000
--- a/tests/bufr/tdexp.F
+++ /dev/null
@@ -1,187 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM TDEXP
-C
-C**** *TDEXP*
-C
-C
-C     PURPOSE.
-C     --------
-C         Expands list of Bufr data descriptors.
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C         CALL BUSEL
-C         CALL BUFREX
-C         CALL BUFREN
-C         CALL BUPRS0
-C         CALL BUPRS1
-C         CALL BUPRS2
-C         CALL BUPRS3
-C         CALL BUPRT
-C         CALL BUUKEY
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          M. DRAGOSAVAC    *ECMWF*       June 2005.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSEC1=40,JSEC3=4)
-      PARAMETER (KDLEN=200,KELEM=40000,KVALS=360000)
-C 
-      DIMENSION KSEC1(JSEC1)     ! ,KSEC3(JSEC3)
-C
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM)
-      DIMENSION KDATA(KDLEN)
-C
-      CHARACTER*64 CNAMES(KELEM)
-      CHARACTER*24 CUNITS(KELEM)
-C                                                                       
-C
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C
-      RVIND=1.7E38
-C
-C     INITIALIZE DELAYED REPLICATION FACTORS OR REFERENCE VALUES ETD.
-C
-C
-      KDATA(1)=127
-      KDATA(2)=5
-      KDATA(3)=5
-      KDATA(4)=5
-      KDATA(5)=5
-C
-C     SET DATA DECSRIPTORS
-C
-      KTDLST(  1)=301090
-      KTDLST(  2)=301091
-      KTDLST(  3)=302001
-      KTDLST(  4)=007004
-      KTDLST(  5)=010009
-      KTDLST(  6)=302072
-      KTDLST(  7)=101005
-      KTDLST(  8)=307063
-      KTDLST(  9)=302069
-      KTDLST( 10)=007032
-      KTDLST( 11)=007033
-      KTDLST( 12)=020031
-      KTDLST( 13)=020032
-      KTDLST( 14)=002038
-      KTDLST( 15)=022043
-      KTDLST( 16)=302021
-      KTDLST( 17)=302078
-      KTDLST( 18)=302073
-      KTDLST( 19)=302074
-      KTDLST( 20)=302075
-      KTDLST( 21)=004025
-      KTDLST( 22)=302076
-      KTDLST( 23)=302071
-      KTDLST( 24)=004025
-      KTDLST( 25)=013059
-      KTDLST( 26)=302083
-      KTDLST( 27)=033005
-      KTDLST( 28)=033006
-
-      KTDLST( 29)=223000
-      KTDLST( 30)=236000
-      KTDLST( 31)=101000
-      KTDLST( 32)=031001
-      KTDLST( 33)=031031
-      KTDLST( 34)=001031
-      KTDLST( 35)=001032
-      KTDLST( 36)=008083
-      KTDLST( 37)=101000
-      KTDLST( 38)=031001
-      KTDLST( 39)=223255
-
-      KTDLST( 40)=223000
-      KTDLST( 41)=237000
-      KTDLST( 42)=001031
-      KTDLST( 43)=001032
-      KTDLST( 44)=008083
-      KTDLST( 45)=101000
-      KTDLST( 46)=031001
-      KTDLST( 47)=223255
-
-      KTDLST( 48)=223000
-      KTDLST( 49)=237000
-      KTDLST( 50)=001031
-      KTDLST( 51)=001032
-      KTDLST( 52)=008083
-      KTDLST( 53)=101000
-      KTDLST( 54)=031001
-      KTDLST( 55)=223255
-
-      KTDLST( 56)=223000
-      KTDLST( 57)=237000
-      KTDLST( 58)=001031
-      KTDLST( 59)=001032
-      KTDLST( 60)=008083
-      KTDLST( 61)=101000
-      KTDLST( 62)=031001
-      KTDLST( 63)=223255
-
-
-
-      ktdlen=63
-
-C
-C     SET DATA DECSRIPTORS
-C
-C     SECTION 1 CONTENT
-C
-      KSEC1(2)=4     ! BUFR EDITION NUMBER
-      KSEC1(14)=0    ! BUFR MASTER TABLE USED
-      ksec1(16)=0    ! ORIGINATING SUB-CENTRE
-      KSEC1(3)=98    ! ORIGINATING CENTRE
-      KSEC1(8)=1     ! VERSION NUMBER OF LOCAL TABLE USED
-      KSEC1(15)=12    ! VERSION NUMBER OF MASTER TABLE USED
-C
-C     SECTION 3 CONTENT
-C
-C
-c
-      K=1
-      CALL BUXDES(K,KSEC1,KTDLEN,KTDLST,KDLEN,KDATA,KELEM,
-     1            KTDEXL,KTDEXP,CNAMES,CUNITS,KERR)
-C
-      END
diff --git a/tests/bufr/test.sh b/tests/bufr/test.sh
deleted file mode 100755
index 6a2cfb1..0000000
--- a/tests/bufr/test.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-cd ../
-path=`pwd`
-
-
-BUFR_TABLES=$path/bufrtables/
-export BUFR_TABLES
-
-cd examples
-
-./decode_bufr -i ../data/ISMD01_OKPR.bufr
diff --git a/tests/bufr_data_files.txt b/tests/bufr_data_files.txt
index 49e7c72..d6dfb8d 100644
--- a/tests/bufr_data_files.txt
+++ b/tests/bufr_data_files.txt
@@ -134,3 +134,4 @@ tros_31.bufr
 wavb_134.bufr
 207003.bufr
 new.bufr
+tropical_cyclone.bufr
diff --git a/tests/bufr_demo.f90 b/tests/bufr_demo.f90
deleted file mode 100644
index cbb5a9b..0000000
--- a/tests/bufr_demo.f90
+++ /dev/null
@@ -1,267 +0,0 @@
-      PROGRAM BFDEMO
-!
-!     BFDEMO - Program to demonstrate use of BUFREX routine.
-!
-!     Purpose.
-!     --------
-!
-!     Demonstrates use of BUFREX routine to unpack
-!     BUFR coded data.
-!
-!     Interface.
-!     ----------
-!
-!     File of BUFR coded data attached as 'input_datafile'
-!
-!     Method.
-!     -------
-!
-!     Read BUFR messages and print sections 0, 1, 2, 3 and 4.
-!
-!
-!     Externals.
-!     ----------
-!
-!     PBOPEN
-!     PBCLOSE
-!     PBBUFR
-!     BUS012
-!     BUFREX
-!     BUPRS0
-!     BUPRS1
-!     BUPRS2
-!     BUPRS3
-!     BUUKEY
-!     BUSEL
-!     BUPRT
-!
-!
-!     WMO Manual on Codes, Volume I, International Codes, PartB-Binary Codes
-!     WMO No. 306, FM 94-IX Ext BUFR.
-!
-!     Comments.
-!     ---------
-!
-!     BUFREX provides a number of packing/unpacking options.
-!     See documentation in routine BUFREX for details.
-!
-!     Author.
-!     -------
-!
-!     M. Dragosavac
-!
-!     Modifications.
-!     --------------
-!
-!     U. Modigliani     ECMWF   08.97
-!                       rewritten in Fortran 90
-!
-!-----------------------------------------------------------------
-!
-      IMPLICIT NONE
-!
-      EXTERNAL PBOPEN, PBCLOSE, PBBUFR, BUS012, BUFREX, BUPRS0, BUPRS1, &
-               BUPRS2, BUPRS3, BUUKEY, BUSEL, BUPRT
-!
-!     This parameter holds the 'number of bytes per integer'
-!
-      INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9)
-!
-!     These parameters hold the 'number of bytes per single/double precision real'
-!
-      INTEGER(KIND=I4B), PARAMETER :: NBYTES_SP = KIND(1.0)
-!
-      INTEGER(KIND=I4B), PARAMETER :: NBYTES_DP = KIND(1.0D0)
-!
-      INTEGER(KIND=I4B), PARAMETER :: JSUP = 9, JSEC0 = 3, JSEC1 = 40, &
-                         JSEC2 = 4096, JSEC3 = 4, JSEC4 = 2, JKEY = 46
-
-!     The default size of the Section 1 is 18 octets and 22 octets for
-!     Bufr Edition 4, if there are no local entries.
-!
-      INTEGER(KIND=I4B), PARAMETER :: & ! These paramters depend on the input data!
-        KELEM =  80000,  &              ! expected number of expanded elements
-        KVALS = 360000,  &              ! expected number of data values
-        JBUFL =  20000                  ! length of bufr message (words)
-!
-      INTEGER(KIND=I4B), DIMENSION(JBUFL) :: KBUFF
-!
-!      CHARACTER(LEN=*), PARAMETER :: INPUT_FILE='../data/synop_4.bufr'
-      CHARACTER(LEN=*), PARAMETER :: OPEN_MODE='r'
-!
-      CHARACTER(LEN=64), DIMENSION(KELEM)  :: CNAMES
-      CHARACTER(LEN=24), DIMENSION(KELEM)  :: CUNITS
-      CHARACTER(LEN=80), DIMENSION(KVALS)  :: CVALS
-!
-      INTEGER(KIND=I4B), DIMENSION(JSUP)  :: KSUP
-      INTEGER(KIND=I4B), DIMENSION(JSEC0) :: KSEC0
-      INTEGER(KIND=I4B), DIMENSION(JSEC1) :: KSEC1
-      INTEGER(KIND=I4B), DIMENSION(JSEC2) :: KSEC2
-      INTEGER(KIND=I4B), DIMENSION(JSEC3) :: KSEC3
-      INTEGER(KIND=I4B), DIMENSION(JSEC4) :: KSEC4
-
-      INTEGER(KIND=I4B), DIMENSION(JKEY) :: KEY
-!
-!     The array VALUES (and the missing value indicator RVIND) are
-!     declared as REAL*8 from emoslib version 370 onwards.
-!
-      REAL(KIND=NBYTES_DP), DIMENSION(KVALS)  :: VALUES
-!
-      INTEGER(KIND=I4B), DIMENSION(KELEM) :: KTDLST, KTDEXP
-!
-!     DATA CNAMES / KELEM * ' ' / , CUNITS / KELEM * ' ' /
-!
-!     Clear error counter.
-!
-      INTEGER(KIND=I4B) :: NUMERR = 0
-!
-!     Set message counter.
-!
-      INTEGER(KIND=I4B) :: NMESSAGE = 0
-      INTEGER(KIND=I4B) :: ISTATUS = 0
-      INTEGER(KIND=I4B) :: KUNIT, KBUFL, KEL, KTDLEN, KTDEXL
-      INTEGER(KIND=I4B) :: IONE = 1
-      INTEGER(KIND=I4B) :: ONE = 1
-!
-      INTEGER :: i
-      CHARACTER(len=255) :: arg
-      CALL getarg(1, arg)
-      CNAMES = ' '
-      CUNITS = ' '
-      CVALS = ' '
-!
-!     Open input file for reading.
-!
-      CALL PBOPEN (KUNIT, arg, OPEN_MODE, ISTATUS)
-!
-!     Check return code.
-!
-      WRITE ( * , * ) ' '
-      WRITE ( * , * ) 'BFDEMO: After PBOPEN, status code   = ', ISTATUS
-      WRITE ( * , * ) ' '
-      IF (ISTATUS .NE. 0) THEN
-          PRINT *, 'BFDEMO: PBOPEN failed.'
-          CALL EXIT (1)
-      END IF
-!
-!     This is the beginning of a loop through BUFR records
-!     reading one field at a time from the input datafile.
-!
-LOOP: DO WHILE (.TRUE.)
-!
-         WRITE ( * , * ) '****************************************************'
-         WRITE ( * , * ) ' '
-         CALL PBBUFR (KUNIT, KBUFF, JBUFL * NBYTES_SP, KBUFL, ISTATUS)
-         WRITE ( * , * ) 'BFDEMO: After PBBUFR, status code   = ', ISTATUS
-!
-         IF (ISTATUS .EQ. - 1) THEN
-!
-!        Exit the DO loop.
-!
-         EXIT LOOP
-         END IF
-!
-!        It can be more specific: see PBBUFR error codes.
-!
-         IF (ISTATUS .LT. - 1) THEN
-            PRINT *, 'BFDEMO: Error reading file.'
-            CALL EXIT (1)
-         END IF
-!
-         NMESSAGE = NMESSAGE + 1
-!
-         WRITE ( * , * ) 'BFDEMO: BUFR message number         = ', NMESSAGE
-         WRITE ( * , * ) 'BFDEMO: Length of message           = ', KBUFL
-         WRITE ( * , * ) ' '
-         WRITE ( * , * ) '****************************************************'
-         WRITE ( * , * ) ' '
-!
-         KBUFL = KBUFL / NBYTES_SP + 1
-!
-!        Expands only section 0, 1 and 2 of Bufr message.
-!
-         CALL BUS012 (KBUFL, KBUFF, KSUP, KSEC0, KSEC1, KSEC2, ISTATUS)
-!
-         IF(ISTATUS .NE. 0) THEN
-            WRITE ( * , * ) 'BFDEMO: Error in BUS012: ', ISTATUS
-            CYCLE LOOP
-         END IF
-!
-!        Decode Bufr message into fully expanded form; returning
-!        information relevant for all Bufr sections, expanded values,
-!        their names and units.
-!
-         KEL=KELEM
-         IF(KSUP(6).GT.1) THEN
-           KEL=KVALS/KSUP(6)
-           IF (KEL.GT.KELEM) KEL=KELEM
-         END IF
-!
-         CALL BUFREX (KBUFL, KBUFF, KSUP, KSEC0, KSEC1, KSEC2, KSEC3, KSEC4,   &
-                      KEL, CNAMES, CUNITS, KVALS, VALUES, CVALS, ISTATUS)
-!
-!        Check return code.
-!
-         IF (ISTATUS .GT. 0) THEN
-!
-!           Increase the number of errors' counter.
-!
-            NUMERR = NUMERR + 1
-            IF (ISTATUS .EQ. 61) THEN
-                WRITE ( * , * ) 'BFDEMO: BUFREX could not open table, error: ', ISTATUS
-                CALL EXIT (61)
-            END IF
-            CYCLE LOOP
-         END IF
-!
-!        Print section 0 of Bufr message.
-!
-         CALL BUPRS0 (KSEC0)
-!
-!        Print section 1 of Bufr message.
-!
-         CALL BUPRS1 (KSEC1)
-!
-!        Expands local ECMWF information from section 2.
-!
-         CALL BUUKEY (KSEC1, KSEC2, KEY, KSUP, ISTATUS)
-!
-!        Print section 2 of Bufr message (expanded RDB key).
-!
-         CALL BUPRS2 (KSUP, KEY)
-!
-!        Returns list of Data Descriptors as in Section 3  of Bufr
-!        message and total/requested list of elements.
-!
-         CALL BUSEL (KTDLEN, KTDLST, KTDEXL, KTDEXP, ISTATUS)
-!
-!        Print section 3 of Bufr message.
-!
-         CALL BUPRS3 (KSEC3, KTDLEN, KTDLST, KTDEXL, KTDEXP, KELEM, CNAMES)
-!
-!        Print expanded Bufr message.
-!
-         CALL BUPRT (IONE, ONE, KSUP(6), KEL, CNAMES, CUNITS, CVALS, KVALS, &
-                     VALUES, KSUP, KSEC1, ISTATUS)
-!
-!        Loop back for next BUFR record.
-!
-      END DO LOOP
-!
-!     End-of-file on input.
-!
-      WRITE ( * , * ) 'BFDEMO: End-of-file on input.'
-      WRITE ( * , * ) ' '
-      WRITE ( * , * ) '****************************************************'
-      WRITE ( * , * ) ' '
-      WRITE ( * , * ) 'BFDEMO: Number of records processed = ', NMESSAGE
-      WRITE ( * , * ) 'BFDEMO: Number of decoding errors   = ', NUMERR
-      WRITE ( * , * ) ' '
-      WRITE ( * , * ) '****************************************************'
-!
-      CALL PBCLOSE (KUNIT, ISTATUS)
-!
-      STOP 'BFDEMO: Terminated'
-!
-      END PROGRAM BFDEMO
-
diff --git a/tests/crex/Makefile b/tests/crex/Makefile
deleted file mode 100755
index 219da73..0000000
--- a/tests/crex/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-#                                 Makefile for example programs
-#
-#
-PLACE = ../../
-LIB = emos
-#
-
-include $(PLACE)config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include $(PLACE)options/options_$(ARCH)
-#
-#
-TARGETS  = all clean
-EXECS    = decode_crex create_crex crextdexp bufr2crex crex2bufr
-#
-#
-all :$(EXECS)
-
-decode_crex : decode_crex.o 
-	$(FC) $(FFLAGS) -o $@  decode_crex.o -L$(PLACE) -l$(LIB)$(R64)
-
-create_crex : create_crex.o
-	$(FC) $(FFLAGS) -o $@ create_crex.o -L$(PLACE) -l$(LIB)$(R64)
-
-crextdexp   : crextdexp.o
-	$(FC) $(FFLAGS) -o $@ crextdexp.o -L$(PLACE) -l$(LIB)$(R64)
-
-bufr2crex   : bufr2crex.o
-	$(FC) $(FFLAGS) -o $@ bufr2crex.o -L$(PLACE) -l$(LIB)$(R64)
-
-crex2bufr   : crex2bufr.o
-	$(FC) $(FFLAGS) -o $@ crex2bufr.o -L$(PLACE) -l$(LIB)$(R64)
-
-clean   :
-	@for name in $(EXECS); do\
-	(rm -f $$name *.o ); \
-	done 
-
-
diff --git a/tests/crex/Makefile.in b/tests/crex/Makefile.in
deleted file mode 100755
index 99ad4ac..0000000
--- a/tests/crex/Makefile.in
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-#                                 Makefile for example programs
-#
-A64 = plat
-R64 = reals
-ARCH = arch
-CNAME = comp
-#
-#
-PLACE = ../../
-#
-#
-include $(PLACE)config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include $(PLACE)options/options_$(ARCH)
-#
-TARGDIR  = ./
-#
-#
-TARGETS  = all clean
-EXECS    = decode_crex create_crex crextdexp bufr2crex crex2bufr
-#
-#
-all :$(EXECS)
-
-decode_crex : decode_crex.o 
-	$(FC) $(FFLAGS) -o $@  decode_crex.o -L$(PLACE) -lemos$(R64)
-
-create_crex : create_crex.o
-	$(FC) $(FFLAGS) -o $@ create_crex.o -L$(PLACE) -lemos$(R64)
-
-crextdexp   : crextdexp.o
-	$(FC) $(FFLAGS) -o $@ crextdexp.o -L$(PLACE) -lemos$(R64)
-
-bufr2crex   : bufr2crex.o
-	$(FC) $(FFLAGS) -o $@ bufr2crex.o -L$(PLACE) -lemos$(R64)
-
-crex2bufr   : crex2bufr.o
-	$(FC) $(FFLAGS) -o $@ crex2bufr.o -L$(PLACE) -lemos$(R64)
-
-clean   :
-	@for name in $(EXECS); do\
-	(rm -f $$name *.o ); \
-	done 
-
-
diff --git a/tests/crex/bufr2crex.F b/tests/crex/bufr2crex.F
deleted file mode 100755
index bf427b2..0000000
--- a/tests/crex/bufr2crex.F
+++ /dev/null
@@ -1,605 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      PROGRAM BUFR2CREX
-C
-C**** *BUFRCREX*
-C
-C
-C     PURPOSE.
-C     --------
-C         Bufr to CREX conversion.
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          MILAN DRAGOSAVAC    *ECMWF*       07/01/2004
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =   9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=    4,
-     1       JSEC4=   2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=512000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#else 
-     2          JBPW =  32,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#endif
-     3          JWORK=4096000,JKEY=46,JBYTE=80000)
-C
-      PARAMETER (KELEM=20000)
-      PARAMETER (KVALS=360000)
-C 
-      DIMENSION KBUFF(JBUFL)
-      DIMENSION KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-      DIMENSION KEY  (JKEY),KREQ(2)
-C
-      REAL*8 VALUES(KVALS)
-      REAL*8 RQV(KELEM)
-C
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM),KRQ(KELEM)
-      DIMENSION KDATA(2000)
-C
-      CHARACTER*256    COUT,CARG(4),CFIN
-      CHARACTER*64     CNAMES(KELEM)
-      CHARACTER*24     CUNITS(KELEM)
-      CHARACTER*80     CVALS(KVALS)
-      CHARACTER*80     YENC
-      CHARACTER*160000 YOUT
-      CHARACTER*3      CRCRLF
-C
-C     Common block containing bufr tables
-C
-      COMMON /BCOMTAB/ NTABBTR(JTAB),NTABBS (JTAB),NTABBRV(JTAB),
-     1                 NTABBDW(JTAB),NTABDTR(JTAB),NTABDST(JTAB),
-     2                 NTABDL (JTAB),NTABDSQ(JTAB*20),NTABP(64,255)
-C
-C             NTABBTR    - table B,  table reference              array
-C             NTABBS     - table B,  scale                        array
-C             NTABBRF    - table B,  reference value              array
-C             NTABBDW    - table B,  data width                   array
-C             NTABDTR    - table D,  table reference              array
-C             NTABDST    - table D,  starting pointers            array
-C             NTABDL     - table D,  lengths                      array
-C             NTABDSQ    - table D,  list of sequence descriptors array
-C
-      COMMON /BCOMWT/ NDWINC,NSCAM,NAFDW,NWT ,ODREPF,
-     1                N221,MREL,NFCM,NFUCM,MBMP,OMARKER,M0,
-     2                MBMPL,NSTACK(JELEM),NWTEN(JELEM),
-     3                NWTR (JELEM),NWTS (JELEM),NWTRV (JELEM),
-     4                NWTDW(JELEM)
-C
-C             NDWINC   -  data width increment
-C             NSCAM    -  scale multiplier
-C             NAFDW    -  augmented field data width
-C             NWT      -  pointer to working table
-C             NSTACK   -  list of data descriptors
-C             ODREPF   -  replication (logical)
-C             N221     -  data not present for n221 elements
-C             MREL     -  pointer to the last data element
-C             NFCM     -  first compressed message
-C             MBMP     -  pointer to the begining of bit map
-C             NWTR     -  working table reference
-C             NWTS     -  working scale
-C             NWTRV    -  working reference value
-C             NWTDW    -  working data width
-C
-      COMMON /BCOMWTC/ CWTEN(JELEM),CWTU (JELEM)
-C
-C             CWTEN    -  working table element naame
-C             CWTU     -  working table units
-C
-c
-      PARAMETER(JP=3000)
-C
-      CHARACTER*120 YENTRY
-      CHARACTER*15  YFNAME
-      CHARACTER*15  FMT
-      CHARACTER*6   CREXKTDLST(KELEM),CREXKTDLST0
-C
-      INTEGER IVALUE(KELEM)
-C
-C     Logical switch to use check digit indicator
-C
-      CHARACTER*4 YUSE_E
-C
-      INTEGER IVAL,IIVAL
-c
-      REAL*8 EPS
-      REAL*8 RVIND
-      REAL*8 VAL
-C
-      EQUIVALENCE (YOUT,KBUFR(1))
-C
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C 
-      NBYTPW=JBPW/8
-      RVIND=1.7E38
-      NVIND=2147483647
-      IOBS=0
-      EPS=1.0E-8
-      NPACK=0
-      N=0
-      OO=.FALSE.
-C
-      CRCRLF=CHAR(13)//CHAR(13)//CHAR(10)
-C
-C     Get input and output file name.
-C
-      NARG=IARGC()
-c
-      IF(NARG.LT.4) THEN
-         print*,'Usage -- bufr2crex -i infile -o outfile' 
-         STOP
-      END IF
-c
-      COUT=' '
-      CFIN=' '
-c
-      DO 101 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-c
-      DO 102 J=1,NARG,2
-        IF(CARG(J).EQ.'-i') THEN
-           CFIN=CARG(J+1)
-        ELSEIF(CARG(J).EQ.'-o') THEN
-           COUT=CARG(J+1)
-        ELSE
-            print*,'Usage -- bufr2crex -i infile -o outfile'
-            STOP
-        END IF
- 102  CONTINUE
-C
-      II=INDEX(CFIN,' ')
-      II=II-1
-      JJ=INDEX(COUT,' ')
-      JJ=JJ-1
-C
-      KRQL=0
-      NR=0
-      KREQ(1)=0
-      KREQ(2)=0
-C
-C
-C*          1.2 OPEN FILE CONTAINING BUFR DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CFIN(1:ii),'r',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-      CALL PBOPEN(IUNIT1,cout(1:jj),'w',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on bufr.dat'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-C     ----------------------------------------------------------------- 
-C*          2. SET REQUEST FOR EXPANSION.
-C              --------------------------
- 200  CONTINUE
-C
-      KREQ(1)=1
-      KREQ(2)=0
-C
-      OSEC3=.FALSE.
-      OPRT=.FALSE.
-      OENC=.TRUE.
-      ICODE=0
-      OCOMP=.FALSE.
-C
-C*          2.1 SET REQUEST FOR PARTIAL EXPANSION.
-C               ----------------------------------
- 210  CONTINUE
-C
-      KERR=0
-      CALL BUSRQ(KREQ,KRQL,KRQ,RQV,KERR)
-C
-C     -----------------------------------------------------------------
-C*          3.  READ BUFR MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      KBUFL=0
-C
-      IRET=0
-      CALL PBBUFR(IUNIT,KBUFF,JBYTE,KBUFL,IRET) 
-      IF(IRET.EQ.-1) THEN
-c         IF(N.NE.0) GO TO 600
-         print*,'Number of subsets     ',iobs
-         print*,'Number of messages    ',n
-         STOP 'EOF'
-      END IF
-      IF(IRET.EQ.-2) STOP 'File handling problem' 
-      IF(IRET.EQ.-3) STOP 'Array too small for product'
-C
-      N=N+1
-      KBUFL=KBUFL/nbytpw+1
-      IF(N.LT.NR) GO TO 300
-      print*,'----------------------',n
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND BUFR MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-      CALL BUS012(KBUFL,KBUFF,KSUP,KSEC0,KSEC1,KSEC2,KERR)
-      IF(KERR.NE.0) THEN
-         PRINT*,'Error in BUS012: ',KERR
-         PRINT*,' BUFR MESSAGE NUMBER ',N,' CORRUPTED.'
-         KERR=0
-         GO TO 300
-      END IF
-C
-      KEL=KELEM
-      IF(KSUP(6).GT.1) THEN
-         KEL=KVALS/KSUP(6)
-         IF(KEL.GT.KELEM) KEL=KELEM
-      END IF
-C
-      CALL BUFREX(KBUFL,KBUFF,KSUP,KSEC0 ,KSEC1,KSEC2 ,KSEC3 ,KSEC4,
-     1            KEL,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) THEN
-         IF(IERR.EQ.45) GO TO 300
-         IF(IERR.EQ.2) THEN
-            IERR=0
-            GO TO 300
-         END IF
-         CALL EXIT(2)
-      END IF
-c
-      IOBS=IOBS+KSEC3(3)
-c
-      NPACK=NPACK+1 
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-C*          4.1 PRINT CONTENT OF EXPANDED DATA.
-C               -------------------------------
- 410  CONTINUE
-C
-      IF(.NOT.OPRT) GO TO 500
-      IF(.NOT.OSEC3) GO TO 450
-C
-C*          4.2 PRINT SECTION ZERO OF BUFR MESSAGE.
-C               -----------------------------------
- 420  CONTINUE
-C
-
-      CALL BUPRS0(KSEC0)
-C
-C*          4.3 PRINT SECTION ONE OF BUFR MESSAGE.
-C               -----------------------------------
- 430  CONTINUE
-C
-      CALL BUPRS1(KSEC1)
-C
-C
-C*          4.4 PRINT SECTION TWO OF BUFR MESSAGE.
-C               -----------------------------------
- 440  CONTINUE
-c
-C              AT ECMWF SECTION 2 CONTAINS RDB KEY.
-C              SO UNPACK KEY
-C
-      CALL BUUKEY(KSEC1,KSEC2,KEY,KSUP,KERR)
-C
-C              PRINT KEY
-C
-      CALL BUPRS2(KSUP ,KEY)
-C
-C*          4.5 PRINT SECTION 3 OF BUFR MESSAGE.
-C               -----------------------------------
- 450  CONTINUE
-C
-C               FIRST GET DATA DESCRIPTORS
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-C               PRINT  CONTENT
-C
-      IF(OSEC3) THEN
-         CALL BUPRS3(KSEC3,KTDLEN,KTDLST,KTDEXL,KTDEXP,KEL,CNAMES)
-      END IF
-c
-C
-C*         4.6 PRINT SECTION 4 (DATA).
-C              -----------------------
- 460  CONTINUE
-C
-C          IN THE CASE OF MANY SUBSETS DEFINE RANGE OF SUBSETS
-C
-      IF(.NOT.OO) THEN
-      WRITE(*,'(a,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IST
-      WRITE(*,'(a,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IEND
-      OO=.FALSE.
-      END IF
-C
-C              PRINT DATA
-C
-      ICODE=0
-      CALL BUPRT(ICODE,IST,IEND,KEL,CNAMES,CUNITS,CVALS,
-     1           KVALS,VALUES,KSUP,KSEC1,IERR)
-C
-C
-C     -----------------------------------------------------------------
-C*          5. COLLECT DATA FOR REPACKING.
-C              ---------------------------
- 500  CONTINUE
-C      
-C               FIRST GET DATA DESCRIPTORS
-C
-      ISUBSET=1
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-C     -----------------------------------------------------------------
-C*          6. PACK CREX MESSAGE.
-C              ------------------
- 600  CONTINUE
-C
-C     Modify BUFR operators
-C
-      J=0
-      DO 602 I=1,KTDLEN
-      IF(KTDLST(I).EQ.222000) GO TO 603
-      IF(KTDLST(I).EQ.201000) GO TO 602 
-      IF(KTDLST(I).EQ.202000) GO TO 602
-      IF(KTDLST(I).EQ.204000) GO TO 602
-      IF(KTDLST(I).EQ.031000) GO TO 602
-      IF(KTDLST(I).EQ.031001) GO TO 602
-      IF(KTDLST(I).EQ.031002) GO TO 602
-C
-      CREXKTDLST0=' '
-      WRITE(CREXKTDLST0,'(I6.6)',IOSTAT=IOS) KTDLST(I)
-      IF(IOS.NE.0) THEN
-         print*,'Internal write error.'
-         CALL EXIT(2)
-      END IF
-      J=J+1
-      CREXKTDLST(J)(1:6)=CREXKTDLST0
-C
-      IF(CREXKTDLST(J)(1:1).EQ.'3') THEN
-         CREXKTDLST(J)(1:1)='D'
-      ELSEIF(CREXKTDLST(J)(1:1).EQ.'0') THEN
-         CREXKTDLST(J)(1:1)='B'
-      ELSEIF(CREXKTDLST(J)(1:1).EQ.'1') THEN
-         CREXKTDLST(J)(1:1)='R'
-c        scan for any 201000,202000 or 201y,202y followed by 206y
-         READ(CREXKTDLST(J)(2:3),'(I2.2)',IOSTAT=IOS) IELEMENTS
-         IF(IOS.NE.0) THEN
-            print*,'Internal read error.'
-            CALL EXIT(2)
-         END IF
-         IEL=IELEMENTS
-         DO IN=I,I+IELEMENTS-1
-         IF(KTDLST(IN).EQ.201000) IEL=IEL-1
-         IF(KTDLST(IN).EQ.202000) IEL=IEL-1
-         IF(KTDLST(IN).GE.201001.AND.KTDLST(IN).LE.201999.AND.
-     1      KTDLST(IN+1)/1000.EQ.206) IEL=IEL-1
-         IF(KTDLST(IN).GE.202001.AND.KTDLST(IN).LE.202999.AND.         
-     1      KTDLST(IN+1)/1000.EQ.206) IEL=IEL-1
-         END DO
-         WRITE(CREXKTDLST(J)(2:3),'(I2.2)',IOSTAT=IOS) IEl
-         IF(IOS.NE.0) THEN
-            print*,'Internal write error.'
-            CALL EXIT(2)
-         END IF
-      ELSEIF(CREXKTDLST(J)(1:3).EQ.'201') THEN
-         IF(KTDLST(I+1)/1000.EQ.206) THEN
-            J=J-1
-            GO TO 602
-         END IF
-         READ(CREXKTDLST(J)(4:6),'(I3.3)',IOSTAT=IOS) IY
-         IF(IOS.NE.0) THEN
-            print*,'Internal read error.'
-            CALL EXIT(2)
-         END IF
-         IBITS=IY-128
-         ICLASS=KTDLST(I+1)/1000
-         IYYY  =KTDLST(I+1)-ICLASS*1000+1
-         ICLASS=ICLASS+1
-         III=NTABP(ICLASS,IYYY)
-         IDW=NTABBDW(III)+IBITS
-         IRES=2.**IDW-1
-         JZ=0
-         DO WHILE(IRES.GT.0)
-         JZ=JZ+1
-         IRES=IRES/10
-         END DO
-         CREXKTDLST(J)(1:3)='C01'
-         WRITE(CREXKTDLST(J)(4:6),'(I3.3)',IOSTAT=IOS) JZ
-         IF(IOS.NE.0) THEN
-            print*,'Internal write error.'
-            CALL EXIT(2)
-         END IF
-      ELSEIF(CREXKTDLST(J)(1:3).EQ.'202') THEN
-         GO TO 602
-      ELSEIF(CREXKTDLST(J)(1:3).EQ.'205') THEN
-          CREXKTDLST(J)(1:3)='C05'
-      ELSE
-         print*,'Wrong data descriptor ',crexktdlst(j)
-         print*,'Data containing above descriptor can',
-     1          ' not be converted'
-         go to 300
-      END IF
- 602  CONTINUE
-c
- 603  CONTINUE
-C
-      ICREXLEN=J
-c
-C     Find delayed replications
-c
-      KDLEN=0
-C
-      IST=1
-      IEND=1
-      OMULTI=.FALSE.
-      IF(IAND(KSEC3(4),64).NE.0.AND.KSEC3(3).GT.1) THEN
-         IEND=KSEC3(3)
-         OMULTI=.TRUE.
-      END IF
-C
-      DO ISUBSET=IST, IEND
-
-      JJ=(ISUBSET-1)*KEL
-C
-      CALL BUSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-C
-      DO I=1,KTDEXL
-C
-        II=I+JJ
-C
-        IF(KTDEXP(I).EQ.031001.OR.
-     1     KTDEXP(I).EQ.031000.OR.
-     2     KTDEXP(I).EQ.031002) THEN
-           KDLEN=KDLEN+1
-           KDATA(KDLEN)=NINT(VALUES(II))
-        END IF
-      END DO
-C
-C*   Make unit conversion from K to Celsius
-C
-      DO I=1,KTDEXL
-        IF(CUNITS(I)(1:2).EQ.'K '.AND.
-     1     KTDEXP(I)/1000.EQ.12) THEN
-           IF(KTDEXP(I).NE.012064.AND.
-     1        KTDEXP(I).NE.012065.AND.
-     2        KTDEXP(I).NE.012070.AND.
-     2        KTDEXP(I).NE.012071.AND.
-     4        KTDEXP(I).NE.012164.AND.
-     5        KTDEXP(I).NE.012151.AND.
-     6        KTDEXP(I).NE.012051.AND.
-     7        KTDEXP(I).NE.022050.AND.
-     8        KTDEXP(I).NE.012171) THEN
-              IF(OMULTI) THEN
-              IJ=I+JJ
-              IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps) 
-     1           VALUES(IJ)=VALUES(IJ)-273.15 
-              ELSE
-              DO J=1,KSEC3(3)
-              IJ=I+(J-1)*KEL
-              IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps)
-     1           VALUES(IJ)=VALUES(IJ)-273.15
-              END DO
-              END IF
-           END IF
-        END IF
-        IF(CUNITS(I)(1:2).EQ.'PA'.AND.
-     1     KTDEXP(I).EQ.015003) THEN
-           IF(OMULTI) THEN
-           IJ=I+JJ
-           IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps)
-     1        VALUES(IJ)=VALUES(IJ)*10000.
-           ELSE
-           DO J=1,KSEC3(3)
-           IJ=I+(J-1)*KEL
-           IF(abs(VALUES(IJ)-rvind)/rvind.GT.eps) 
-     1        VALUES(IJ)=VALUES(IJ)*10000.
-           END DO
-           END IF
-        END IF
-      END DO
-C
-      END DO
-
-C
-C*          6.2 ENCODE DATA INTO CREX MESSAGE.
-C               ------------------------------
- 620  CONTINUE
-C
-      IF(KSEC1(2).EQ.4) THEN         ! Bufr edition number
-         KSEC1(2)=2                  ! Crex edition number
-         KSEC1(5)=KSEC3(3)           ! Number of subsets
-         KSEC1( 7)=KSEC1(17)         ! International sub category
-         KSEC1(17)=KSEC1(15)            ! Bufr master table version number
-         KSEC1(15)=3                    ! Crex version number used
-         KSEC1(18)=KSEC1(8)             ! Bufr version number of local tables
-      ELSE
-         KSEC1(17)=KSEC1(15)            ! Bufr master table version number
-         KSEC1(2)=1                  ! Crex edition number
-         KSEC1(15)=3                    ! Crex version number used
-         KSEC1(18)=KSEC1(8)             ! Bufr version number of local tables
-      END IF
-c
-      CALL CREXEN(KSEC0,KSEC1,KSEC3,
-     1            ICREXLEN,CREXKTDLST,KDLEN,KDATA,KEL,KVALS,
-     2            VALUES,CVALS,KBUFL,KBUFR,KERR)
-      IF(KERR.GT.0) THEN
-         print*,'CREXEN error:',KERR
-         go to 300
-      END IF
-C
-C           6.3 WRITE CREX MESSAGE INTO FILE.
-C               -----------------------------
- 630  CONTINUE
-C
-      ILEN=KBUFL
-C     
-      IERR=0
-      CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-      IF(IERR.LT.0) THEN
-         print*,'Error writing into target file.'
-         CALL EXIT(2)
-      END IF
-C
-      GO TO 300
-C
-      END
diff --git a/tests/crex/create_crex.F b/tests/crex/create_crex.F
deleted file mode 100755
index 58b807c..0000000
--- a/tests/crex/create_crex.F
+++ /dev/null
@@ -1,296 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM CREX
-C
-C**** *CREX*
-C
-C
-C     PURPOSE.
-C     --------
-C         Example of creating CREX message
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          MILAN DRAGOSAVAC    *ECMWF*       07/01/2004.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =   9,JSEC0=   3,JSEC1= 40,JSEC3=    4,
-     1          JBUFL= 8192)
-C
-      PARAMETER (KDLEN=200,KELEM=2000)
-      PARAMETER (KVALS=80000)
-C 
-      DIMENSION KBUFR(JBUFL)
-      DIMENSION KSEC0(JSEC0),KSEC1(JSEC1), KSEC3(JSEC3)
-C
-      REAL*8  VALUES(KVALS)
-      REAL*8 RVIND
-C
-      DIMENSION KDATA(KDLEN)
-C
-      CHARACTER*6  CREXKTDLST(KELEM),CREXKTDEXP(KELEM)
-      CHARACTER*64 CNAMES(kelem)
-      CHARACTER*24 CUNITS(kelem)
-      CHARACTER*80 CVALS(KVALS)
-      CHARACTER*80 YENC
-      CHARACTER*256 COUT, CARG(4)
-C      
-      CHARACTER*15000 YOUT
-      EQUIVALENCE(KBUFR(1),YOUT)
-C
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-      RVIND=1.7D38
-      NVIND=2147483647
-C
-C     GET INPUT AND OUTPUT FILE NAME.
-C
-      NARG=IARGC()
-C
-      IF(NARG.LT.2) THEN
-         print*,'Usage -- create_crex -o outfile'
-         STOP
-      END IF
-C
-      COUT=' '
-      CFIN=' '
-C
-      DO 101 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-C
-      DO 102 J=1,NARG,2
-        IF(CARG(J).EQ.'-o') THEN
-           COUT=CARG(J+1)
-        ELSE
-            print*,'Usage -- create_crex -o outfile'
-            STOP
-        END IF
- 102  CONTINUE
-C
-      JJ=INDEX(COUT,' ')
-      JJ=JJ-1
-C
-      CALL PBOPEN(IUNIT1,COUT(1:JJ),'w',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on bufr.dat'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-C     INITIALIZE DELAYED REPLICATION FACTORS OR REFERENCE VALUES ETD.
-C
-      KDATA( 1)=0
-      KDATA( 2)=0
-      KDATA( 3)=0
-      KDATA( 4)=0
-C
-      DO I=5,KDLEN
-       KDATA(I)=0
-      END DO
-C
-      KDLENG=200
-C
-C     SET DATA DECSRIPTORS
-C
-      CREXKTDLST(  1)= "D07005"
-c
-      KTDLEN=1
-
-      KSEC0(1)=0
-      KSEC0(2)=0
-      KSEC0(3)=2      ! Crex edition number
-C
-C     SECTION 1 CONTENT
-C
-      KSEC1(1)=0
-      KSEC1(2)=2     ! CREX Edition number (currently)
-      KSEC1(3)=98    ! Originating centre
-      KSEC1(4)=0     ! Update sequence number
-      KSEC1(5)=1     ! Number of subsets
-      KSEC1(6)=0     ! CREX data category
-      KSEC1(7)=2     ! International data sub-category
-      KSEC1(8)=0     ! version number of local table used
-      KSEC1(9)=2003  ! Year
-      KSEC1(10)=12   ! Month
-      KSEC1(11)=2   ! Day
-      KSEC1(12)=12   ! Hour
-      KSEC1(13)=0    ! Minute
-      KSEC1(14)=0    ! CREX Master table ( 0 for standard WMO crex tables)
-      KSEC1(15)=3    ! CREX table version number
-      KSEC1(16)=0    ! Originating sub-centre
-      KSEC1(17)=14   ! BUFR master table version number
-      KSEC1(18)=0    ! BUFR local table version number
-C
-
-      K=1
-      CALL CREXDES(K,KSEC1,KTDLEN,CREXKTDLST,KDLEN,KDATA,KELEM,
-     1            KTDEXL,CREXKTDEXP,CNAMES,CUNITS,KERR)
-      IF(KERR.NE.0) THEN
-         print*,'CREXDES: error'
-         STOP
-      END IF
-
-C
-C     SET VALUES TO BE PACKED
-C
-      K=1
-      KSUBSETS=1
-c
-      DO J=1,KSUBSETS
-
-      IK=(J-1)*KELEM
-      N=1
-      VALUES(N+IK)=13.         ! Block number
-      N=N+1                    !
-      VALUES(N+IK)=274.        ! station number
-      N=N+1                    !
-      VALUES(N+IK)=0.          ! type of station
-      N=N+1                    !
-      VALUES(N+IK)=2003.       ! year
-      N=N+1                    !
-      VALUES(N+IK)=12.         ! month
-      N=N+1                    !
-      VALUES(N+IK)=2.          ! day
-      N=N+1                    !
-      VALUES(N+IK)=12.         ! hour
-      N=N+1                    !
-      VALUES(N+IK)=0.          ! minute
-      N=N+1
-      VALUES(N+IK)=45.2        ! lat
-      N=N+1                    !
-      VALUES(N+IK)=20.5        ! lon
-      N=N+1                    !
-      VALUES(N+IK)=170.        ! station height
-      N=N+1                    !
-      VALUES(N+IK)=102000.     ! station level pressure
-      N=N+1
-      VALUES(N+IK)=102500.     ! msl pressure
-      N=N+1                    !
-      VALUES(N+IK)=100.        ! pressure change
-      N=N+1                    !
-      VALUES(N+IK)=rvind       ! characteristic of pressure change
-      N=N+1                    !
-      VALUES(N+IK)=300.        ! wind dir
-      N=N+1                    !
-      VALUES(N+IK)=8.5         ! wind speed
-      N=N+1                    !
-      VALUES(N+IK)=-5.0        ! T
-      N=N+1                    !
-      VALUES(N+IK)=-7.0        ! Td
-      N=N+1                    !
-      VALUES(N+IK)=70.         ! RH
-      N=N+1                    !
-      VALUES(N+IK)=1000.       ! visibility
-      N=N+1                    !
-      VALUES(N+IK)=rvind          
-      N=N+1                    !
-      VALUES(N+IK)=rvind
-      N=N+1                    !
-      VALUES(N+IK)=rvind         
-      N=N+1                    !
-      VALUES(N+IK)=rvind
-      N=N+1                    !
-      VALUES(N+IK)=rvind
-c
-      DO I=N,47
-      N=N+1                    !
-      VALUES(N+IK)=rvind        
-      END DO
-C                    !
-      END DO                    !
-C
-C     SET CCITTIA5 CALL SIGN 
-C
-      DO I=1,200
-      CVALS( I )=' '
-      END DO
-C
-C
-C     SECTION 3 CONTENT
-C
-      KSEC3(1)=0         ! TOTAL LENGTH OF SECTION 3
-      KSEC3(2)=0         ! RESERVED
-      KSEC3(3)= ksubsets ! NUMBER OF SUBSETS
-      KSEC3(4)=0
-C
-      IREP=0
-C
-C
-C*          6. PACK CREX MESSAGE
-C              -----------------
- 600  CONTINUE
-C
-C
-      KERR=0
-      CALL CREXEN( KSEC0,KSEC1,KSEC3,
-     1             KTDLEN,crexKTDLST,KDLENG,KDATA,KELEM,
-     2             KVALS,VALUES,CVALS,KBUFL,KBUFR,KERR)
-C
-
-      IF(KERR.GT.0) THEN
-         CALL EXIT(2)
-      ELSEIF(KERR.lt.0) then
-         print*,'Encoding return_code=',kerr
-      END IF 
-C
-C
-      ILEN=KBUFL
-C     ILEN=KSEC0(2)
-C
-      IERR=0
-      CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-      IF(IERR.LT.0) THEN
-         print*,'Error writing into target file.'
-         CALL EXIT(2)
-      END IF
-C
-C     Print CREX message on screen
-      print*,yout(1:ilen)
-C
-C     -----------------------------------------------------------------
-C
- 900  CONTINUE
-C
-      STOP
-      END
diff --git a/tests/crex/crex2bufr.F b/tests/crex/crex2bufr.F
deleted file mode 100755
index 15c0ad3..0000000
--- a/tests/crex/crex2bufr.F
+++ /dev/null
@@ -1,499 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM CREX2BUFR
-C
-C**** *CREX2BUFR*
-C
-C
-C     PURPOSE.
-C     --------
-C         Decode CREX coded data into BUFR format
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          MILAN DRAGOSAVAC    *ECMWF*       07/01/2004.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =  9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=    4,
-     1       JSEC4=   2,JELEM=320000,JSUBS=400,JCVAL=150 ,JBUFL=40000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#else
-     2          JBPW =  32,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#endif
-     3          JWORK=4096000,JKEY=46,JBYTE=80000)
-C
-      PARAMETER (KELEM=40000)
-      PARAMETER (KVALS=360000)
-C 
-      DIMENSION KBUFF(JBUFL),KBUFR(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC2(JSEC2),KSEC3(JSEC3),KSEC4(JSEC4)
-      DIMENSION KEY  (JKEY),KREQ(2)
-C
-      REAL*8 VALUES(KVALS), VALUE(KVALS)
-      REAL*8 RVIND
-      REAL*8 EPS
-C
-      DIMENSION KTDLST(KELEM),KTDEXP(KELEM),KTDLST1(KELEM)
-      DIMENSION KDATA(2000)
-C
-      CHARACTER*256 CF,COUT,CARG(4)
-      CHARACTER*64 CNAMES(KELEM)
-      CHARACTER*24 CUNITS(KELEM)
-      CHARACTER*80 CVALS(KVALS)
-      CHARACTER*80 CVAL(KVALS),CV
-      CHARACTER*80 YENC
-      CHARACTER*160000 YBUFF
-c
-      EQUIVALENCE(YBUFF,KBUFF(1))
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-      NBYTPW=JBPW/8
-      RVIND=1.7D38
-      NVIND=2147483647
-      IOBS=0
-      EPS=10.D-8
-      N=0
-      OCOMP=.FALSE.
-      OO=.FALSE.
-      CF=' '
-      COUT=' '
-      KKK=0
-C
-C     GET INPUT AND OUTPUT FILE NAME.
-C
-      NARG=IARGC()
-c
-      IF(NARG.NE.4) THEN
-         print*,'Usage -- crex2bufr -i infile -o outfile' 
-         STOP
-      END IF
-c
-      DO 101 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-c
-      IF(CARG(1).NE.'-i'.AND.CARG(1).NE.'-I'.OR.
-     1   CARG(2).EQ.' ') THEN
-         print*,'Usage -- crex2bufr -i inpfile -o outfile'
-         STOP
-      END IF
-      IF(CARG(3).NE.'-o'.AND.CARG(3).NE.'-O'.OR.
-     1   CARG(4).EQ.' ') THEN
-         print*,'Usage -- crex2bufr -i inpfile -o outfile'
-         STOP
-      END IF
-c
-      CF=CARG(2)
-      II=INDEX(CF,' ')
-      II=II-1
-      COUT=CARG(4)
-      I=INDEX(COUT,' ')
-      I=I-1
-C
-C*          1.2 OPEN FILE CONTAINING CREX DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CF(1:II),'r',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on input file'
-      IF(IRET.EQ.-2) STOP 'Invalid file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-c
-C
-C*          1.2.1 OPEN OUTPUT FILE.
-C               ------------------
- 121  CONTINUE
-C
-
-      CALL PBOPEN(IUNIT1,COUT(1:I),'w',IRET)
-      IF(IRET.EQ.-1) STOP 'open failed on output file'
-      IF(IRET.EQ.-2) STOP 'Invalid output file name'
-      IF(IRET.EQ.-3) STOP 'Invalid open mode specified'
-C
-C     ----------------------------------------------------------------- 
-C*          2. SET REQUEST FOR EXPANSION.
-C              --------------------------
- 200  CONTINUE
-C
-      NR=1
-      OPRT=.TRUE.
-      OENC=.FALSE.
-C
-      OENC=.TRUE.
-
- 210  CONTINUE
-C
-C
-C     -----------------------------------------------------------------
-C*          3.  READ CREX MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      IRET=0
-c
-      CALL PBCREX(IUNIT,KBUFF,JBUFL,KBUFL,IRET)
-      IF(IRET.LT.0) THEN
-         if(iret.eq.-1) stop 'End of file '
-         if(iret.eq.-2) stop 'Error in handling the file'
-         if(iret.eq.-3) stop 'Error during read CREX file.'
-      END IF
-c
-      N=N+1
-      print*,'----------------------------------',n
-      IF(N.LT.NR) GO TO 300
-      KEL=KELEM
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND CREX MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-      IERR=0
-      CALL CREXEX(KBUFL,YBUFF,KSUP,KSEC0 ,KSEC1,KSEC3 ,
-     1            KEL,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) then
-         print*,'CREX error ', ierr
-         IF(IERR.EQ.20.or.IERR.EQ.14) THEN
-            KEL=KVALS/KSUP(6)
-            GO TO 400
-         ELSE
-            CALL EXIT(2)
-         END IF
-      END IF
-C
-      
-      IOBS=IOBS+KSEC3(3)
-C
-      ISUBSET=1
-      CALL CREXSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,
-     1              CNAMES,CUNITS,KERR)
-      IF(KERR.NE.0) then
-         print*,'CREXSEL: error.'
-         CALL EXIT(2)
-      END IF
-C
-C*          4.1 PRINT CONTENT OF EXPANDED DATA.
-C               -------------------------------
- 410  CONTINUE
-C
-      IF(.NOT.OPRT) GO TO 500
-C
-C*          4.2 PRINT SECTION ZERO OF CREX MESSAGE.
-C               -----------------------------------
- 420  CONTINUE
-C
-
-      CALL CREXPRS0(KSEC0)
-C
-C*          4.3 PRINT SECTION ONE OF CREX MESSAGE.
-C               -----------------------------------
- 430  CONTINUE
-C
-      CALL CREXPRS1(KSEC1,KSEC3,KTDLEN,KTDLST,KTDEXL,
-     1              KTDEXP,KEL,CNAMES)
-C
-C
-C
-C*         4.6 PRINT SECTION 4 (DATA).
-C              -----------------------
- 460  CONTINUE
-C
-C          IN THE CASE OF MANY SUBSETS DEFINE RANGE OF SUBSETS
-C
-      IF(.NOT.OO) THEN
-      WRITE(*,'(a,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IST
-      WRITE(*,'(a,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I6)')   IEND
-      OO=.false.
-      END IF
-C
-C              PRINT DATA
-C
-      ICODE=0
-      CALL CREXPRT(ICODE,IST,KSEC3(3),KEL,CNAMES,CUNITS,CVALS,
-     1           KVALS,VALUES,KSUP,KSEC1,IERR)
-C
-C
-C     -----------------------------------------------------------------
-C*          5. COLLECT DATA FOR REPACKING.
-C              ---------------------------
- 500  CONTINUE
-C      
-      IF(.NOT.OENC) GO TO 300
-C
-C               FIRST GET DATA DESCRIPTORS
-C
-      KK=0
-      IST=1
-      IEND=KSEC3(3)
-C
-      DO ISUBSET=IST, IEND
-
-
-      CALL CREXSEL2(ISUBSET,KEL,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,
-     1            CUNITS,IERR)
-      IF(KERR.NE.0) THEN
-         print*,'CREXSEL: error ',kerr
-         CALL EXIT(2)
-      END IF
-C
-      JM1KELEM=(ISUBSET-1)*KEL
-C
-      DO 501 I=1,KTDEXL
-         INV=I+JM1KELEM
-         IN =I+JM1KELEM
-C
-         IF(CUNITS(I).EQ.'CHARACTER') THEN
-            IPOS =VALUES(INV)/1000.
-            ICH=NINT(VALUES(INV)-IPOS*1000)
-            KKK=KKK+1
-            VALUE(IN)=KKK*1000+ICH
-            IF(CVALS(IPOS)(1:1).EQ.'/') THEN
-               CV=' '
-               DO II=1,ICH
-               CV(II:II)=CHAR(255)
-               END DO
-               CVAL(KKK)=CV
-            ELSE
-              CVAL(KKK)=CVALS(IPOS)
-            END IF
-         ELSEIF(CUNITS(I)(1:2).EQ.'C '.AND.
-     1     KTDEXP(I)/1000.eq.12 ) THEN
-           VALUE(IN)=VALUES(INV)+273.15
-         ELSEIF(CUNITS(I)(1:2).EQ.'NB'.AND.
-     1     KTDEXP(I).EQ.015003) THEN
-           VALUE(IN)=VALUES(INV)*0.0001
-         ELSE
-            VALUE(IN)=VALUES(INV)
-         END IF
-C
-         IF(KTDEXP(I).EQ.31001.OR.KTDEXP(I).EQ.31002.OR.
-     1      KTDEXP(I).EQ.31000) THEN
-            KK=KK+1
-            KDATA(KK)=NINT(VALUES(INV))
-         END IF
- 501  CONTINUE
-C
-      END DO
-C
-      KDLEN=2
-      IF(KK.NE.0) KDLEN=KK
-
-C     -----------------------------------------------------------------
-C*          6. PACK BUFR MESSAGE.
-C              -----------------
- 600  CONTINUE
-C
-      KKK=0
-C
-      IF(KSEC0(3).LE.1) THEN
-         KSEC0(3)=3              ! Edition 3  of bufr message
-C
-         KSEC1(1)=18
-         KSEC1(2)=3              ! Bufr edition number
-         KSEC1(3)=KSEC1(3)
-         KSEC1(4)=1
-         KSEC1(5)=0            ! presence od section 2
-         KSEC1(7)=0
-         KSEC1(8)=0            ! Bufr local tables version number
-         KSEC1(9)=0
-         KSEC1(10)=0
-         KSEC1(11)=0
-         KSEC1(12)=0
-         KSEC1(13)=0
-         KSEC1(14)=0
-         KSEC1(15)=0           ! Bufr master table version number
-c
-         I_004001=0
-         I_004002=0
-         I_004003=0
-         I_004004=0
-         I_004005=0
-c
-         DO I=1,KTDEXL
-         IF(KTDEXP(I).EQ.004001) THEN
-            IF(I_004001.EQ.0) I_004001=I
-         ELSEIF(KTDEXP(I).EQ.004002) THEN
-            IF(I_004002.EQ.0) I_004002=I
-         ELSEIF(KTDEXP(I).EQ.004003) THEN
-            IF(I_004003.EQ.0) I_004003=I
-         ELSEIF(KTDEXP(I).EQ.004004) THEN
-            IF(I_004004.EQ.0) I_004004=I
-         ELSEIF(KTDEXP(I).EQ.004005) THEN
-            IF(I_004005.EQ.0) I_004005=I
-         END IF
-         END DO
-c
-         KSEC1(9)=NINT(VALUE(I_004001))-1900
-         IF(NINT(VALUE(I_004001)).GE.2000) THEN
-             KSEC1(9)=NINT(VALUE(I_004001))-2000
-         END IF
-         KSEC1(10)=NINT(VALUE(I_004002))
-         KSEC1(11)=NINT(VALUE(I_004003))
-         KSEC1(12)=NINT(VALUE(I_004004))
-         KSEC1(13)=NINT(VALUE(I_004005))
-c
-         KSEC1(14)=0
-         KSEC1(15)=13
-         KSEC1(16)=0
-      ELSEIF(KSEC0(3).EQ.2) THEN
-         KSEC0(3)=4              ! Edition 4  of bufr message
-c
-         KSEC1(1)=22             ! The size of section 1
-         KSEC1(2)=4
-         KSEC1(3)=KSEC1(3)
-         KSEC1(5)=0              ! presence od section 2
-         KSEC1(9)=0
-         KSEC1(10)=0
-         KSEC1(11)=0
-         KSEC1(12)=0
-         KSEC1(13)=0
-c
-         I_004001=0
-         I_004002=0
-         I_004003=0
-         I_004004=0
-         I_004005=0
-c
-         DO I=1,KTDEXL
-         IF(KTDEXP(I).EQ.004001) THEN
-            IF(I_004001.EQ.0) I_004001=I
-         ELSEIF(KTDEXP(I).EQ.004002) THEN
-            IF(I_004002.EQ.0) I_004002=I
-         ELSEIF(KTDEXP(I).EQ.004003) THEN
-            IF(I_004003.EQ.0) I_004003=I
-         ELSEIF(KTDEXP(I).EQ.004004) THEN
-            IF(I_004004.EQ.0) I_004004=I
-         ELSEIF(KTDEXP(I).EQ.004005) THEN
-            IF(I_004005.EQ.0) I_004005=I
-         END IF
-         END DO
-c
-         KSEC1( 9)=NINT(VALUE(I_004001))
-         KSEC1(10)=NINT(VALUE(I_004002))
-         KSEC1(11)=NINT(VALUE(I_004003))
-         KSEC1(12)=NINT(VALUE(I_004004))
-         KSEC1(13)=NINT(VALUE(I_004005))
-c
-         KSEC1(14)=0         ! Bufr master table
-         KSEC1(15)=KSEC1(17) ! Bufr master table version number
-         KSEC1(16)=KSEC1(16) ! Originating sub-centre
-         KSEC1(17)=KSEC1( 7) ! International sub-category
-         KSEC1( 7)=0
-         KSEC1(18)=0         ! Second
-c
-         
-      END IF
-c
-      KSEC3(4)=192                    ! No compression
-c
-      KBUFL=JBUFL
-C
-C
-C*          6.2 ENCODE DATA INTO BUFR MESSAGE.
-C               ------------------------------
- 620  CONTINUE
-C
-c              Modify descriptor list for delayed 
-c              replication factor
-c
-      J=0
-      DO I=1,KTDLEN
-      IIF=KTDLST(I)/100000
-      IF(IIF.EQ.1) THEN
-         II=KTDLST(I)/1000
-         IY=KTDLST(I)-II*1000
-         IF(IY.EQ.0) THEN
-           J=J+1
-           KTDLST1(J)=KTDLST(I)
-           J=J+1
-           KTDLST1(J)=031002
-         ELSE
-           j=j+1
-           KTDlst1(j)=KTDlst(i)
-         END IF
-      ELSE
-         J=J+1
-         KTDLST1(J)=KTDLST(I)
-      END IF
-      END DO
-c
-      KTDLEN=J
-c 
-      KERR=0
-c     
-      CALL BUFREN( KSEC0,KSEC1,KSEC2,KSEC3,KSEC4,
-     1             KTDLEN,KTDLST1,KDLEN,KDATA,KEL,   
-     2             KVALS,VALUE,CVAL,KBUFL,KBUFR,KERR)
-C
-      IF(KERR.gt.0) THEN
-         print*,'error is ',kerr
-         PRINT*,'ERROR DURING ENCODING.'
-         CALL EXIT(2)
-      END IF
-C
-C           6.3 WRITE PACKED BUFR MESSAGE INTO FILE.
-C               ------------------------------------
- 630  CONTINUE
-C
-      ILEN=KBUFL*NBYTPW
-C     
-      IERR=0
-      CALL PBWRITE(IUNIT1,KBUFR,ILEN,IERR)
-      if(ierr.lt.0) then
-         print*,'Error writing into target file.'
-         CALL EXIT(2)
-      END IF
-C
-      GO TO 300
-C     -----------------------------------------------------------------
-C
-      END
diff --git a/tests/crex/crextdexp.F b/tests/crex/crextdexp.F
deleted file mode 100755
index 917f340..0000000
--- a/tests/crex/crextdexp.F
+++ /dev/null
@@ -1,167 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM CREXEXP
-C
-C**** *CREXEXP*
-C
-C
-C     PURPOSE.
-C     --------
-C         Expands list of CREX data descriptors.
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          M. DRAGOSAVAC    *ECMWF*       07/01/2004.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSEC1=40,JSEC3=4)
-      PARAMETER (KDLEN=200,KELEM=4000)
-C 
-      DIMENSION KSEC1(JSEC1) 
-C
-      DIMENSION KDATA(KDLEN)
-C
-      CHARACTER*64 CNAMES(KELEM)
-      CHARACTER*24 CUNITS(KELEM)
-      CHARACTER*6  CREXKTDLST(KELEM)
-      CHARACTER*6  CREXKTDEXP(KELEM)
-C
-      REAL*8 RVIND
-C                                                                       
-C
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-C
-      RVIND=1.7E38
-C
-C     INITIALIZE DELAYED REPLICATION FACTORS 
-C
-      DO I=1,KDLEN
-      KDATA(I)=1
-      END DO
-C
-C     SET DATA DECSRIPTORS
-C
-      N=1
-      CREXKTDLST( N)="D01090"
-      N=N+1
-      CREXKTDLST( N)="D02031"
-      N=N+1
-      CREXKTDLST( N)="D02032"
-      N=N+1
-      CREXKTDLST( N)="D02033"
-      N=N+1
-      CREXKTDLST( N)="D02004"
-      N=N+1
-      CREXKTDLST( N)="R01000"
-      N=N+1
-      CREXKTDLST( N)="D02005"
-      N=N+1
-      CREXKTDLST( N)="D02038"
-      N=N+1
-      CREXKTDLST( N)="D02044"
-      N=N+1
-      CREXKTDLST( N)="R01002"
-      N=N+1
-      CREXKTDLST( N)="D02039"
-      N=N+1
-      CREXKTDLST( N)="R02002"
-      N=N+1
-      CREXKTDLST( N)="B04024"
-      N=N+1
-      CREXKTDLST( N)="B13011"
-      N=N+1
-      CREXKTDLST( N)="B07032"
-      N=N+1
-      CREXKTDLST( N)="B04024"
-      N=N+1
-      CREXKTDLST( N)="B12111"
-      N=N+1
-      CREXKTDLST( N)="B04024"
-      N=N+1
-      CREXKTDLST( N)="B12112"
-      N=N+1
-      CREXKTDLST( N)="B07032"
-      N=N+1
-      CREXKTDLST( N)="B02002"
-      N=N+1
-      CREXKTDLST( N)="B08021"
-      N=N+1
-      CREXKTDLST( N)="B04025"
-      N=N+1
-      CREXKTDLST( N)="B11001"
-      N=N+1
-      CREXKTDLST( N)="B11002"
-      N=N+1
-      CREXKTDLST( N)="B08021"
-
-      KTDLEN=N
-C
-C     SECTION 1 CONTENT
-C
-      KSEC1(2)=2     ! CREX EDITION NUMBER
-      KSEC1(3)=98    ! Originating Centre ( oooo)
-      KSEC1(4)=0     ! Update sequence number (uu)
-      KSEC1(5)=1     ! Number of subsets ( sss)
-      KSEC1(6)=0     ! CREX data category (nnn)
-      KSEC1(7)=1     ! International data sub-category (mmm)
-      KSEC1(8)=1     ! Version number of local table used
-      KSEC1(9)=2004  ! Year
-      KSEC1(10)=11   ! Month
-      KSEC1(11)=29   ! Daay
-      KSEC1(12)=12   ! Hour
-      KSEC1(13)=00   ! Minute
-      KSEC1(14)=0    ! CREX Master table (tt)
-      KSEC1(15)=3    ! Version number of Master table used (vv)
-      KSEC1(16)=0    ! Originating sub-centre (ppp)
-      KSEC1(17)=12   ! Bufr master table version number
-      KSEC1(18)=0    ! Bufr version number of local table used
-C
-C     SECTION 3 CONTENT
-C
-      K=1
-      CALL CREXDES(K,KSEC1,KTDLEN,CREXKTDLST,KDLEN,KDATA,KELEM,
-     1            KTDEXL,CREXKTDEXP,CNAMES,CUNITS,KERR)
-C
-      END
diff --git a/tests/crex/decode_crex.F b/tests/crex/decode_crex.F
deleted file mode 100755
index 3462a90..0000000
--- a/tests/crex/decode_crex.F
+++ /dev/null
@@ -1,280 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM DECODE_CREX
-C
-C**** *DECODE_CREX*
-C
-C
-C     PURPOSE.
-C     --------
-C         DECODE CREX CODED DATA
-C
-C
-C**   INTERFACE.
-C     ----------
-C
-C          NONE.
-C
-C     METHOD.
-C     -------
-C
-C          NONE.
-C
-C
-C     EXTERNALS.
-C     ----------
-C
-C          CREXEX    
-C          CREXSEL 
-C          CREXPRS0 
-C          CREXPRT
-C          PBOPEN
-C          PBCLOSE 
-C          PBCREX
-C          GETARG    
-C         
-C         
-C         
-C
-C     REFERENCE.
-C     ----------
-C
-C          NONE.
-C
-C     AUTHOR.
-C     -------
-C
-C          M. DRAGOSAVAC    *ECMWF*       15/09/2003.
-C
-C
-C     MODIFICATIONS.
-C     --------------
-C
-C          NONE.
-C
-C
-      IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
-C
-      PARAMETER(JSUP =   9,JSEC0=   3,JSEC1= 40,JSEC2=4096,JSEC3=    4,
-     1          JSEC4=   2,JELEM=40000,JSUBS=400,JCVAL=150 ,JBUFL=80000,
-#ifdef JBPW_64
-     2          JBPW =  64,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#else
-     2          JBPW =  32,JTAB =3000,JCTAB=120,JCTST=1800,JCTEXT=1200,
-#endif
-     3          JWORK=360000,JKEY=46,JBYTE=80000)
-C
-      PARAMETER (KELEM=8000)
-      PARAMETER (KVALS=360000)
-C 
-      DIMENSION KBUFF(JBUFL)
-      DIMENSION KSUP(JSUP)  ,KSEC0(JSEC0),KSEC1(JSEC1)
-      DIMENSION KSEC3(JSEC3)
-C
-      REAL*8 VALUES(KVALS)
-      REAL*8 RVIND
-      REAL*8 EPS
-C
-      DIMENSION KTDLST(JELEM),KTDEXP(JELEM)
-      DIMENSION KDATA(200)
-C
-      CHARACTER*256 CF,CARG(4)
-      CHARACTER*64 CNAMES(KELEM)
-      CHARACTER*24 CUNITS(KELEM)
-      CHARACTER*80 CVALS(KVALS)
-      CHARACTER*80 YENC
-      CHARACTER*320000 YBUFF
-C
-      EQUIVALENCE(YBUFF,KBUFF(1))
-C                                                                       
-C     ------------------------------------------------------------------
-C*          1. INITIALIZE CONSTANTS AND VARIABLES.
-C              -----------------------------------
- 100  CONTINUE
-C
-      NBYTPW=JBPW/8
-      RVIND=1.7D38
-      NVIND=2147483647
-      IOBS=0
-      EPS=1.D-8
-      N=0
-      OO=.FALSE.
-      CF=' '
-C
-C     INPUT FILE NAME
-C
-C     GET INPUT AND OUTPUT FILE NAME.
-C
-      NARG=IARGC()
-C
-      IF(NARG.NE.2) THEN
-         PRINT*,'USAGE -- decode_crex -i infile ' 
-         STOP
-      END IF
-C
-      DO 101 J=1,NARG
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-C
-      IF(CARG(1).NE.'-I'.AND.CARG(1).NE.'-i'.OR.
-     1   CARG(2).EQ.' ') THEN
-         PRINT*,'USAGE -- decode_crex -i inpfile '
-         STOP
-      END IF
-
-C
-      CF=CARG(2)
-      II=INDEX(CF,' ')
-      II=II-1
-C
-C*          1.2 OPEN FILE CONTAINING CREX DATA.
-C               -------------------------------
- 120  CONTINUE
-C
-      IRET=0 
-      CALL PBOPEN(IUNIT,CF(1:II),'R',IRET)
-      IF(IRET.EQ.-1) STOP 'OPEN FAILED ON INPUT FILE'
-      IF(IRET.EQ.-2) STOP 'INVALID FILE NAME'
-      IF(IRET.EQ.-3) STOP 'INVALID OPEN MODE SPECIFIED'
-C
-C     ----------------------------------------------------------------- 
-C*          2. SET REQUEST FOR EXPANSION.
-C              --------------------------
- 200  CONTINUE
-C
-      OPRT=.FALSE.
-      OENC=.FALSE.
-      WRITE(*,'(A,$)') ' DO YOU WANT TO PRINT( Y/N ) : '
-      READ (*,'(A)') YENC
-      IF(YENC(1:1).EQ.'Y'.OR.YENC(1:1).EQ.'y') THEN
-         OPRT=.TRUE.
-      END IF
-C
- 201  CONTINUE
-C
-      WRITE(*,'(A,$)') ' DO YOU WANT TO PRINT SECTION 0-3( Y/N ) : '
-      READ (*,'(A,$)') YENC
-      OSEC3=.FALSE.
-      IF(YENC(1:1).EQ.'Y'.OR.YENC(1:1).EQ.'y') OSEC3=.TRUE.
-C
- 210  CONTINUE
-C
-C
-C     -----------------------------------------------------------------
-C*          3.  READ CREX MESSAGE.
-C               ------------------
- 300  CONTINUE
-C
-      IERR=0
-      IRET=0
-C
-      YBUFF(1:15000)=' '
-      CALL PBCREX(IUNIT,KBUFF,JBUFL,KBUFL,IRET)
-      IF(IRET.LT.0) THEN
-         IF(IRET.EQ.-1) THEN
-            PRINT*,'NUMBER OF CREX MESSAGES PROCESSED ',N
-            PRINT*,'NUMBER OF CREX OBSERVATIONS       ',IOBS
-            STOP 'END OF FILE '
-         END IF
-         IF(IRET.EQ.-2) STOP 'ERROR IN HANDLING THE FILE'
-         IF(IRET.EQ.-3) STOP 'ERROR DURING READ CREX FILE.'
-      END IF
-C
-      N=N+1
-      PRINT*,'----------------------------------',N
-      print*,YBUFF(1:KBUFL)
-C
-C     -----------------------------------------------------------------
-C*          4. EXPAND CREX MESSAGE.
-C              --------------------
- 400  CONTINUE
-C
-     
-      IERR=0
-      CALL CREXEX(KBUFL,YBUFF,KSUP,KSEC0 ,KSEC1,KSEC3 ,
-     1            KELEM,CNAMES,CUNITS,KVALS,VALUES,CVALS,IERR)
-C
-      IF(IERR.NE.0) THEN
-         PRINT*,'CREX ERROR ', IERR
-         GO TO 300
-      END IF
-C
-C
-      IOBS=IOBS+KSEC3(3)
-C
-      ISUBSET=1
-      CALL CREXSEL2(ISUBSET,KELEM,KTDLEN,KTDLST,KTDEXL,KTDEXP,
-     1              CNAMES,CUNITS,KERR)
-      IF(KERR.NE.0) THEN
-         PRINT*,'CREXSEL: ERROR.'
-         CALL EXIT(2)
-      END IF
-C
-C*          4.1 PRINT CONTENT OF EXPANDED DATA.
-C               -------------------------------
- 410  CONTINUE
-C
-      IF(.NOT.OPRT) GO TO 300
-      IF(.NOT.OSEC3) GO TO 450
-C
-C*          4.2 PRINT SECTION ZERO OF CREX MESSAGE.
-C               -----------------------------------
- 420  CONTINUE
-C
-      CALL CREXPRS0(KSEC0)
-C
-C*          4.3 PRINT SECTION ONE OF CREX MESSAGE.
-C               -----------------------------------
- 430  CONTINUE
-C
-      ISUBSET=1
-      CALL CREXSEL2(ISUBSET,KELEM,KTDLEN,KTDLST,KTDEXL,KTDEXP,
-     1              CNAMES,CUNITS,KERR)
-      IF(KERR.NE.0) CALL EXIT(2)
-C
-      CALL CREXPRS1(KSEC1,KSEC3,KTDLEN,KTDLST,KTDEXL,
-     1              KTDEXP,KELEM,CNAMES)
-C
-C
-C
-C*          4.5 PRINT SECTION 2 OF CREX MESSAGE.
-C               -----------------------------------
- 450  CONTINUE
-C
-C
-C*         4.6 PRINT SECTION 2 (DATA).
-C              -----------------------
- 460  CONTINUE
-C
-C          IN THE CASE OF MANY SUBSETS DEFINE RANGE OF SUBSETS
-C
-      IF(.NOT.OO) THEN
-      WRITE(*,'(A,$)') ' STARTING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I4)')   IST
-      WRITE(*,'(A,$)') ' ENDING SUBSET TO BE PRINTED : '
-      READ(*,'(BN,I4)')   IEND
-      OO=.FALSE.
-      END IF
-C
-C              PRINT DATA
-C
-      ICODE=0
-      CALL CREXPRT(ICODE,IST,IEND,KELEM,CNAMES,CUNITS,CVALS,
-     1             KVALS,VALUES,KSUP,KSEC1,IERR)
-C
-C
-      GO TO 300
-C
-    
-C     -----------------------------------------------------------------
- 900  CONTINUE
-C
-      END
diff --git a/tests/crex/test.sh b/tests/crex/test.sh
deleted file mode 100755
index a13d93d..0000000
--- a/tests/crex/test.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-cd ../
-path=`pwd`
-
-
-CREX_TABLES=$path/crextables/
-export CREX_TABLES
-
-cd examples
-
-./decode_crex -i ../data/temp.crex
diff --git a/tests/data_in/spectral.grib b/tests/data_in/spectral.grib
deleted file mode 100644
index 9b42219..0000000
Binary files a/tests/data_in/spectral.grib and /dev/null differ
diff --git a/tests/data_ref/spectral-ll.grib b/tests/data_ref/spectral-ll.grib
deleted file mode 100644
index 8b7f89a..0000000
Binary files a/tests/data_ref/spectral-ll.grib and /dev/null differ
diff --git a/tests/data_ref/spectral-rg.grib b/tests/data_ref/spectral-rg.grib
deleted file mode 100644
index 7c4c594..0000000
Binary files a/tests/data_ref/spectral-rg.grib and /dev/null differ
diff --git a/tests/fft.F b/tests/fft.F
deleted file mode 100644
index 3c88de4..0000000
--- a/tests/fft.F
+++ /dev/null
@@ -1,31 +0,0 @@
-      program fft
-c Copyright 1981-2012 ECMWF.
-c
-c This software is licensed under the terms of the Apache Licence
-c Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-c
-c In applying this licence, ECMWF does not waive the privileges and immunities
-c granted to it by virtue of its status as an intergovernmental organisation
-c nor does it submit to any jurisdiction.
-c
-      parameter (n=2*2*3*5,m=20)
-      dimension a((n+2)*m),trigs(n),work(m*(n+1))
-      integer ifax(10)
-      call set99(trigs,ifax,n)
-      do 11 i=1,(n+2)*m
-      a(i)=0
-11    continue
-      do 1 j=1,m
-      do 1 i=1,n
-      a((j-1)*(n+2)+i)=j
-1     continue
-c     write (2,*)(a(i),i=1,n)
-c      t1=secnds(real(0.))
-c     write(*,*)t1
-      call fft99(a,work,trigs,ifax,1,n+2,n,m,-1)
-c      t2=secnds(real(t1))
-c      write(*,*)t2
-      write (*,2)(a(i),i=1,n)
- 2     format(4(f20.12,2x))
-      end
-
diff --git a/tests/fft99.F b/tests/fft99.F
new file mode 100644
index 0000000..849e601
--- /dev/null
+++ b/tests/fft99.F
@@ -0,0 +1,31 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+      program fft
+      parameter (n=2*2*3*5,m=20)
+      dimension a((n+2)*m),trigs(n),work(m*(n+1))
+      integer ifax(10)
+      call set99(trigs,ifax,n)
+      do 11 i=1,(n+2)*m
+      a(i)=0
+11    continue
+      do 1 j=1,m
+      do 1 i=1,n
+      a((j-1)*(n+2)+i)=j
+1     continue
+c     write (2,*)(a(i),i=1,n)
+c      t1=secnds(real(0.))
+c     write(*,*)t1
+      call fft99(a,work,trigs,ifax,1,n+2,n,m,-1)
+c      t2=secnds(real(t1))
+c      write(*,*)t2
+      write (*,2)(a(i),i=1,n)
+ 2     format(4(f20.12,2x))
+      end
+
diff --git a/tests/fftw.F b/tests/fftw.F
new file mode 100644
index 0000000..d09670c
--- /dev/null
+++ b/tests/fftw.F
@@ -0,0 +1,77 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+      program fftw
+      implicit none
+      
+      integer n
+      integer m
+      integer i
+      integer j
+      parameter (n=2*2*3*5)
+      parameter (m=20)
+
+      real    a     ((n+2)*m)
+      real    trigs (n)
+      real    work  (m*(n+1))
+      integer ifax  (10)
+
+#include "fftw3.f"
+      integer*8 plan
+
+
+      integer KLONO
+      integer JPLONO
+      real del
+      real angle
+      real PZFA((n+2)*m)
+      real FFTWOUT(n)
+      REAL PPI
+      PARAMETER ( PPI = 3.14159265358979 )
+
+
+C     Generate sines and cosines for angles 0 to pi in N steps
+C     (possibly the only surviving part of set99)
+      del = (2.0*ppi) / float(n)
+      do i = 0, (n/2)-1
+        angle        = float(i)*del
+        trigs(2*i+1) = cos(angle)
+        trigs(2*i+2) = sin(angle)
+      enddo
+
+
+      call set99(trigs,ifax,n)
+
+      a = 0
+      do j = 1, m
+        do i = 1, n
+          a((j-1)*(n+2)+i) = j
+        enddo
+      enddo
+
+      call fft99(a,work,trigs,ifax,1,n+2,n,m,-1)
+
+      KLONO  = n
+      JPLONO = n
+      PZFA   = a
+
+      FFTWOUT(1:KLONO) = 0.
+      CALL DFFTW_PLAN_DFT_C2R_1D( PLAN, KLONO, PZFA, FFTWOUT,
+     .  FFTW_ESTIMATE
+     .+ FFTW_UNALIGNED
+     .+ FFTW_NO_SIMD )
+      CALL DFFTW_EXECUTE( PLAN )
+      PZFA( 1:KLONO              ) = FFTWOUT(1:KLONO) 
+      PZFA( KLONO+1:(JPLONO+2)*m ) = 0.
+      a = PZFA
+      CALL DFFTW_DESTROY_PLAN( PLAN )
+
+      write (*,'(4(f20.12,2x))') (a(i),i=1,n)
+      end
+
diff --git a/tests/gribex/Makefile b/tests/gribex/Makefile
deleted file mode 100644
index 8a576fd..0000000
--- a/tests/gribex/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-#                                 Makefile for example programs
-#
-LIBPATH = ../../
-#
-include ../../config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include ../../options/options_$(ARCH)
-#
-TARGETS = all clean
-EXECS   = agrdemo find_t 
-#
-#
-all: $(EXECS)
-
-agrdemo: agrdemo.o
-	$(FC) $(FFLAGS) -o $@ agrdemo.o -L$(LIBPATH) -lemos$(R64)
-
-find_t: find_t.o
-	$(FC) $(FFLAGS) -o $@ find_t.o -L$(LIBPATH) -lemos$(R64)
-
-
-clean:
-	@for name in $(EXECS) ; do\
-	(rm -f $$name $$name.o $$name.f); \
-	done
diff --git a/tests/gribex/Makefile.in b/tests/gribex/Makefile.in
deleted file mode 100644
index 68e51db..0000000
--- a/tests/gribex/Makefile.in
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-#                                 Makefile for example programs
-A64 = plat
-R64 = reals
-ARCH = arch
-CNAME = comp
-#
-LIBPATH = ../../
-#
-include ../../config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include ../../options/options_$(ARCH)
-#
-TARGETS = all clean
-EXECS   = agrdemo find_t 
-#
-#
-all: $(EXECS)
-
-agrdemo: agrdemo.o
-	$(FC) $(FFLAGS) -o $@ agrdemo.o -L$(LIBPATH) -lemos$(R64)
-
-find_t: find_t.o
-	$(FC) $(FFLAGS) -o $@ find_t.o -L$(LIBPATH) -lemos$(R64)
-
-
-clean:
-	@for name in $(EXECS) ; do\
-	(rm -f $$name $$name.o $$name.f); \
-	done
diff --git a/tests/gribex/README b/tests/gribex/README
deleted file mode 100644
index 3238363..0000000
--- a/tests/gribex/README
+++ /dev/null
@@ -1,36 +0,0 @@
-
-   This directory contains example for the GRIB decoding and how to handle
-a Unix file containing GRIB edition 1 products in an indexed fashion.
-
-   GRIB data are in ../data directory.
-
-   make
-
-   will compile both examples
-
-   Before you run you have to set two environment variables:
-   ECMWF_LOCAL_TABLE_PATH and LOCAL_DEFINITION_TEMPLATES
-
-   or just run:
-
-   ./test.sh
-
-agrdemo.F :
-
-Executable version of agrdemo.F can be run:
- 
-./agrdemo -i ../data/latlon.grib
-
-   It will print a listing of the Grib header records together
-with a few of the data values.
-   Also, you can run ./agrdemo for different sort of grib data:
-gaussian.grib , spectral.grib , latlon.grib
-
-find_t.F :
-
- This program uses PBGPARM to locate temperature fields in a file of GRIB
-products and writes them to a target file.
-
-./find_t -i ../data/850ght.grib -o outputfile
-
-Program can be easy modified to select the geopotencial field instead
diff --git a/tests/gribex/agrdemo.F b/tests/gribex/agrdemo.F
deleted file mode 100644
index e47f33b..0000000
--- a/tests/gribex/agrdemo.F
+++ /dev/null
@@ -1,265 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM GRDEMO
-C
-      IMPLICIT NONE
-C
-C**** GRDEMO - Program to demonstrate use of GRIBEX routine.
-C
-C     Purpose.
-C     --------
-C
-C     Demonstrates use of GRIBEX routine to unpack
-C     GRIB coded data.
-C
-C**   Interface.
-C     ----------
-C
-C     Method.
-C     -------
-C
-C     Prints sections 0, 1, 2, 3 and 4 of GRIB message.
-C
-C     Externals.
-C     ----------
-C
-C     GRIBEX
-C     GRPRS0
-C     GRPRS1
-C     GRPRS2
-C     GRPRS3
-C     GRPRS4
-C     PBOPEN
-C     PBGRIB
-C     PBCLOSE
-C
-C     Reference.
-C     ----------
-C
-C     WMO Manual on Codes for GRIB definition.
-C     WMO Publication No. 9, Volume B, for grid catalogue numbers.
-C
-C     Modifications
-C     -------------
-C
-C     K. Fielding     ECMWF     Dec 2000
-C     Set missing value for bit controlled fields.
-C
-C     Comments.
-C     ---------
-C
-C     GRIBEX provides a number of packing/unpacking options.
-C     See documentation for details.
-C
-C
-C     -----------------------------------------------------------------
-C
-C     Arrays are dimensioned to accommodate T213/N160 data volumes.
-C     JPBYTE is number of bytes per REAL
-C
-      INTEGER JPACK, JPBYTE
-C
-      PARAMETER (JPACK = 280000)
-      PARAMETER (JPBYTE = 4)
-C
-C     Array for integer parameters from section 0 of GRIB message.
-C
-      INTEGER ISEC0 (2)
-C
-C     Array for integer parameters from section 1 of GRIB message.
-C
-      INTEGER ISEC1 (1024)
-C
-C     Array for integer parameters from section 2 of GRIB message.
-C
-      INTEGER ISEC2 (1024)
-C
-C     Array for integer parameters from section 3 of GRIB message.
-C
-      INTEGER ISEC3 (2)
-C
-C     Array for integer parameters from section 4 of GRIB message.
-C
-      INTEGER ISEC4 (512)
-C
-C     Array for real parameters from section 2 of GRIB message.
-C
-      REAL ZSEC2 (512)
-C
-C     Array for real parameters from section 3 of GRIB message.
-C
-      REAL ZSEC3 (2)
-C
-C     Array for real parameters from section 4 of GRIB message.
-C     This is the binary data section and the array to hold
-C     the unpacked data may need to be 4 times as long as that
-C     for the packed data.
-C
-      REAL ZSEC4 (JPACK * 4)
-C
-C     Array to read in packed data.
-C
-      INTEGER INBUFF (JPACK)
-C
-C     GRIBEX routine has a number of encoding/decoding options.
-C
-      CHARACTER*256 YDATAFILE
-      CHARACTER*2 INPUT
-      CHARACTER*1 YOPER
-      INTEGER IFILE, NUMERR, IPBLEN, IWORD, IFILEN, IRET, IARGC, NARGS
-      INTEGER JCOUNT, LENOUT
-      INTEGER JLAT, JLONG, JSTART, JEND
-      REAL ZFIRST, ZLAST, ZSTEP, ZLAT
-      REAL ZMAX
-C
-C     Pick up file names from command line.
-C
-      NARGS = IARGC()
-      IF( NARGS.LT.2 ) THEN
-         print*,'Usage: agrdemo -i inputfile'
-         STOP
-      END IF
-
-      CALL GETARG(1,INPUT)
-
-      IF(INPUT.EQ.'-i') THEN
-         CALL GETARG(2,YDATAFILE)
-      ELSE
-         print*,'Usage: agrdemo -i inputfile' 
-         STOP
-      END IF
-
-C     Clear error counter.
-C
-      NUMERR = 0
-C
-C     Lengths of INBUFF and PSEC4
-C
-      IPBLEN = JPACK * JPBYTE
-C
-      IFILEN = INDEX(YDATAFILE,' ') - 1
-C
-      CALL PBOPEN (IFILE, YDATAFILE (1: IFILEN), 'R', IRET)
-C
-      IF ( IRET .NE. 0 ) THEN
-        WRITE (*, *) ' Return code from PBOPEN = ', IRET
-        CALL PBCLOSE(IFILE, IRET)
-        STOP 'Fault in PBOPEN'
-      ENDIF
-C
-C     Loop through GRIB products in file.
-      JCOUNT = 0
-C
-   50 CONTINUE
-      JCOUNT = JCOUNT + 1
-C
-C     Read packed field into INBUFF.
-      CALL PBGRIB (IFILE, INBUFF, IPBLEN, LENOUT, IRET )
-C
-      IF ( IRET .LT. 0 ) THEN
-        WRITE (*, *) ' Return code from pbgrib = ', IRET
-        IF ( IRET .EQ. -1) THEN
-          WRITE  (*, *) ' End of file. Number of products =', (JCOUNT-1)
-          CALL PBCLOSE (IFILE, IRET)
-          WRITE (*,*) ' GRDEMO : Number of decoding errors = ', NUMERR
-          STOP 'EOF'
-        ELSE
-          WRITE (*, *) ' kret = ',IRET,' after ', JCOUNT,' products.'
-          CALL PBCLOSE (IFILE, IRET)
-          STOP 'Fault in PBGRIB'
-        ENDIF
-      ENDIF
-C
-C     'D' function to unpack entire GRIB message.
-C
-      YOPER = 'D'
-      WRITE (*,*) ' GRDEMO : Function code = ', YOPER
-C
-      IRET = 1
-      LENOUT = LENOUT / JPBYTE
-C
-C     Set missing data values
-C
-      ISEC3 (2) = -99999
-      ZSEC3 (2) = -99999.0
-C
-      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
-     X             ZSEC4, IPBLEN, INBUFF, LENOUT, IWORD, YOPER, IRET)
-C
-C     Check return code.
-C
-      WRITE (*,*) ' GRDEMO : GRIBEX return code = ', IRET
-      IF (IRET .EQ. - 6) WRITE (*,*) ' GRDEMO : Pseudo-grib data found.'
-      IF (IRET .GT. 0) THEN
-        NUMERR = NUMERR + 1
-        GO TO 50
-      ENDIF
-C
-C     Print section 0 , 1 , 2 and 3 (if present) and 4.
-C     Section 1 is the product definition section.
-C     Section 2 is the grid definition section.
-C     Section 3 is the bit-map section.
-C     Section 4 is the data section.
-C
-      CALL GRPRS0 (ISEC0)
-      CALL GRPRS1 (ISEC0, ISEC1)
-C
-      IF (ISEC1 (5) .EQ. 0 .OR. ISEC1 (5) .EQ. 64) THEN
-        WRITE (*,*) ' GRDEMO : No section 2 in GRIB message.'
-      ELSE
-        CALL GRPRS2 (ISEC0, ISEC2, ZSEC2)
-      ENDIF
-C
-      IF (ISEC1 (5) .EQ. 0 .OR. ISEC1 (5) .EQ. 128) THEN
-        WRITE (*,*) ' GRDEMO : No section 3 in GRIB message.'
-      ELSE
-        CALL GRPRS3 (ISEC0, ISEC3, ZSEC3)
-      ENDIF
-C
-      CALL GRPRS4 (ISEC0, ISEC4, ZSEC4)
-C
-C     Sample code to print maximum and minimum value in data.
-C
-C     ZMAX = ZSEC4 (1)
-C     ZMIN = ZSEC4 (1)
-C
-C     DO JLAT = 2, ISEC4 (1)
-C       ZMAX = MAX (ZMAX, ZSEC4 (JLAT) )
-C       ZMIN = MIN (ZMIN, ZSEC4 (JLAT) )
-C     ENDDO
-C     WRITE (*, *)
-C     WRITE (*, *) 'Maximum value in field is ', ZMAX
-C     WRITE (*, *) 'Minimum value in field is ', ZMIN
-C     WRITE (*, *)
-C
-C     Sample code to print all values along lines of
-C     latitude for a lat/long grid only.
-C
-C     ZFIRST = REAL (ISEC2 (5) ) / 1000.0
-C     ZLAST = REAL (ISEC2 (8) ) / 1000.0
-C     ZSTEP = REAL (ISEC2 (9) ) / 1000.0
-C     WRITE (*, *) 'Longitudes from ', ZFIRST, ' to ', ZLAST,
-C    1  ' with stride ', ZSTEP
-C
-C     DO JLAT = 1, ISEC2 (3)
-C       ZLAT = REAL (ISEC2 (4) - (JLAT - 1) * ISEC2 (10) ) / 1000.0
-C       JSTART = (JLAT - 1) * ISEC2 (2) + 1
-C       JEND = JLAT * ISEC2 (2)
-C       WRITE (*, *)
-C       WRITE (*, *) 'Values at latitude ', ZLAT
-C       WRITE (*, *)
-C       WRITE(*, '(1H , 5E16.5)' )
-C    1    (ZSEC4 (JLONG), JLONG = JSTART, JEND)
-C     ENDDO
-C
-      GO TO 50
-C
-      END
diff --git a/tests/gribex/find_t.F b/tests/gribex/find_t.F
deleted file mode 100644
index ad9c722..0000000
--- a/tests/gribex/find_t.F
+++ /dev/null
@@ -1,101 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM FIND_T
-      IMPLICIT NONE
-C
-      INTEGER JPACK, JPBYTES
-      PARAMETER (JPACK = 300000)
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER INBUFF
-      DIMENSION INBUFF(JPACK)
-      INTEGER IRET, NARGS, N, J, ILENB, LENOUT, NTEMPS
-      INTEGER IVALUE, NUMBER, ISIZE, IPARAM, ITEMP, IARGC
-C
-      INTEGER  PBGTOTL, PBGPUT, PBGGET, PBGLENG, PBGPARM
-      EXTERNAL PBGTOTL, PBGPUT, PBGGET, PBGLENG, PBGPARM
-      EXTERNAL GETENV
-C
-      CHARACTER*128 INFILE, OUTFILE, CARG(4)
-C
-C **********************************************************************
-C
-C     Pick up file names from command line.
-C
-      NARGS = IARGC()
-	  IF( NARGS.LT.4 ) THEN
-         print*,'Usage: find_t -i inputfile -o outputfile'
-         STOP
-      END IF
-
-      DO 101 J=1,NARGS
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-
-      DO 102 J=1,NARGS,2
-        IF(CARG(J).EQ.'-i') THEN
-           INFILE=CARG(J+1)
-        ELSEIF(CARG(J).EQ.'-o') THEN
-           OUTFILE=CARG(J+1)
-        ELSE
-            print*,'Usage: find_t -i inputfile -o outputfile'
-            STOP
-        END IF
- 102  CONTINUE
-C
-C     Count number of GRIBs in the file
-C
-      NUMBER = PBGTOTL(INFILE)
-      WRITE(*,*) 'Number of GRIBs in the file = ', NUMBER
-      IF( NUMBER.EQ.0 ) STOP 'No Gribs found'
-C
-C     Search for temperature fields.
-C     (Temperature is code 130 in table 128.)
-C
-      NTEMPS = 0
-      ITEMP = (128*1000) + 130
-      ILENB = JPACK * JPBYTES
-C
-      DO N = 1, NUMBER
-C
-        IPARAM = PBGPARM(INFILE,N)
-C
-C       Handle the GRIB product if it is a temperature field
-C
-        IF( IPARAM.EQ.ITEMP ) THEN
-C
-C         Check buffer is big enough for GRIB field.
-C
-          ISIZE = PBGLENG(INFILE,N)
-          IF( ISIZE.GT.ILENB ) THEN
-            WRITE(*,*) 'Field size (bytes)  = ', ISIZE
-            WRITE(*,*) 'Buffer size (bytes) = ', ILENB
-            STOP 'Buffer too small for field'
-          ENDIF
-C
-C         Read temperature field and write it to the output file.
-C
-          NTEMPS = NTEMPS + 1
-          LENOUT = PBGGET(INFILE, INBUFF, ILENB, N)
-          IF( LENOUT.LT.0 ) STOP 'Problem reading temperature field'
-C
-          IRET = PBGPUT(OUTFILE, INBUFF, LENOUT)
-          IF( IRET.LT.LENOUT ) STOP 'Problem writing temperature field'
-C
-        ENDIF
-C
-      ENDDO
-C
-      WRITE(*,*) 'Number of temperature fields copied = ', NTEMPS
-      IF( NTEMPS.EQ.0 ) WRITE(*,*) 'No output file created'
-C
-      STOP
-      END
diff --git a/tests/gribex/test.sh b/tests/gribex/test.sh
deleted file mode 100755
index 6f4bb40..0000000
--- a/tests/gribex/test.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-cd ../
-path=`pwd`
-
-ECMWF_LOCAL_TABLE_PATH=$path/gribtables
-export ECMWF_LOCAL_TABLE_PATH
-
-LOCAL_DEFINITION_TEMPLATES=$path/gribtemplates
-export LOCAL_DEFINITION_TEMPLATES
-
-cd examples
-
-./agrdemo -i ../data/latlon.grib
diff --git a/tests/gribex_demo.F b/tests/gribex_demo.F
new file mode 100644
index 0000000..d643f03
--- /dev/null
+++ b/tests/gribex_demo.F
@@ -0,0 +1,268 @@
+C Copyright 1981-2012 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+       PROGRAM GRDEMO
+C
+      IMPLICIT NONE
+C
+C**** GRDEMO - Program to demonstrate use of GRIBEX routine.
+C
+C     Purpose.
+C     --------
+C
+C     Demonstrates use of GRIBEX routine to unpack
+C     GRIB coded data.
+C
+C**   Interface.
+C     ----------
+C
+C     Method.
+C     -------
+C
+C     Prints sections 0, 1, 2, 3 and 4 of GRIB message.
+C
+C     Externals.
+C     ----------
+C
+C     GRIBEX
+C     GRPRS0
+C     GRPRS1
+C     GRPRS2
+C     GRPRS3
+C     GRPRS4
+C     PBOPEN
+C     PBGRIB
+C     PBCLOSE
+C
+C     Reference.
+C     ----------
+C
+C     WMO Manual on Codes for GRIB definition.
+C     WMO Publication No. 9, Volume B, for grid catalogue numbers.
+C
+C     Modifications
+C     -------------
+C
+C     K. Fielding     ECMWF     Dec 2000
+C     Set missing value for bit controlled fields.
+C
+C     Comments.
+C     ---------
+C
+C     GRIBEX provides a number of packing/unpacking options.
+C     See documentation for details.
+C
+C
+C     -----------------------------------------------------------------
+C
+C     Arrays are dimensioned to accommodate T213/N160 data volumes.
+C     JPBYTE is number of bytes per REAL
+C
+      INTEGER JPACK, JPBYTE
+C
+      PARAMETER (JPACK = 280000)
+      PARAMETER (JPBYTE = 4)
+C
+C     Array for integer parameters from section 0 of GRIB message.
+C
+      INTEGER ISEC0 (2)
+C
+C     Array for integer parameters from section 1 of GRIB message.
+C
+      INTEGER ISEC1 (1024)
+C
+C     Array for integer parameters from section 2 of GRIB message.
+C
+      INTEGER ISEC2 (1024)
+C
+C     Array for integer parameters from section 3 of GRIB message.
+C
+      INTEGER ISEC3 (2)
+C
+C     Array for integer parameters from section 4 of GRIB message.
+C
+      INTEGER ISEC4 (512)
+C
+C     Array for real parameters from section 2 of GRIB message.
+C
+      REAL ZSEC2 (512)
+C
+C     Array for real parameters from section 3 of GRIB message.
+C
+      REAL ZSEC3 (2)
+C
+C     Array for real parameters from section 4 of GRIB message.
+C     This is the binary data section and the array to hold
+C     the unpacked data may need to be 4 times as long as that
+C     for the packed data.
+C
+      REAL ZSEC4 (JPACK * 4)
+C
+C     Array to read in packed data.
+C
+      INTEGER INBUFF (JPACK)
+C
+C     GRIBEX routine has a number of encoding/decoding options.
+C
+      CHARACTER*256 YDATAFILE
+      CHARACTER*2 INPUT
+      CHARACTER*1 YOPER
+      INTEGER IFILE, NUMERR, IPBLEN, IWORD, IFILEN, IRET, IARGC, NARGS
+      INTEGER JCOUNT, LENOUT
+      INTEGER JLAT, JLONG, JSTART, JEND
+      REAL ZFIRST, ZLAST, ZSTEP, ZLAT
+      REAL ZMAX
+C
+C     Pick up file names from command line.
+C
+      NARGS = IARGC()
+      IF( NARGS.LT.2 ) THEN
+         print*,'Usage: agrdemo -i inputfile'
+         CALL EXIT(2)
+      END IF
+
+      CALL GETARG(1,INPUT)
+
+      IF(INPUT.EQ.'-i') THEN
+         CALL GETARG(2,YDATAFILE)
+      ELSE
+         print*,'Usage: agrdemo -i inputfile'
+         CALL EXIT(2)
+      END IF
+
+C     Clear error counter.
+C
+      NUMERR = 0
+C
+C     Lengths of INBUFF and PSEC4
+C
+      IPBLEN = JPACK * JPBYTE
+C
+      IFILEN = INDEX(YDATAFILE,' ') - 1
+C
+      CALL PBOPEN (IFILE, YDATAFILE (1: IFILEN), 'R', IRET)
+C
+      IF ( IRET .NE. 0 ) THEN
+        WRITE (*, *) ' Return code from PBOPEN = ', IRET
+C       CALL PBCLOSE(IFILE, IRET)  ! (problem if PBOPEN failed)
+        WRITE (*, *) 'Fault in PBOPEN'
+        CALL EXIT(2)
+      ENDIF
+C
+C     Loop through GRIB products in file.
+      JCOUNT = 0
+C
+   50 CONTINUE
+      JCOUNT = JCOUNT + 1
+C
+C     Read packed field into INBUFF.
+      CALL PBGRIB (IFILE, INBUFF, IPBLEN, LENOUT, IRET )
+C
+      IF ( IRET .LT. 0 ) THEN
+        WRITE (*, *) ' Return code from pbgrib = ', IRET
+        IF ( IRET .EQ. -1) THEN
+          WRITE  (*, *) ' End of file. Number of products =', (JCOUNT-1)
+          CALL PBCLOSE (IFILE, IRET)
+          WRITE (*,*) ' GRDEMO : Number of decoding errors = ', NUMERR
+          STOP 'EOF'
+        ELSE
+          WRITE (*, *) ' kret = ',IRET,' after ', JCOUNT,' products.'
+          CALL PBCLOSE (IFILE, IRET)
+          WRITE (*, *) 'Fault in PBGRIB'
+          CALL EXIT(2)
+        ENDIF
+      ENDIF
+C
+C     'D' function to unpack entire GRIB message.
+C
+      YOPER = 'D'
+      WRITE (*,*) ' GRDEMO : Function code = ', YOPER
+C
+      IRET = 1
+      LENOUT = LENOUT / JPBYTE
+C
+C     Set missing data values
+C
+      ISEC3 (2) = -99999
+      ZSEC3 (2) = -99999.0
+C
+      CALL GRIBEX (ISEC0, ISEC1, ISEC2, ZSEC2, ISEC3, ZSEC3, ISEC4,
+     X             ZSEC4, IPBLEN, INBUFF, LENOUT, IWORD, YOPER, IRET)
+C
+C     Check return code.
+C
+      WRITE (*,*) ' GRDEMO : GRIBEX return code = ', IRET
+      IF (IRET .EQ. - 6) WRITE (*,*) ' GRDEMO : Pseudo-grib data found.'
+      IF (IRET .GT. 0) THEN
+        NUMERR = NUMERR + 1
+        GO TO 50
+      ENDIF
+C
+C     Print section 0 , 1 , 2 and 3 (if present) and 4.
+C     Section 1 is the product definition section.
+C     Section 2 is the grid definition section.
+C     Section 3 is the bit-map section.
+C     Section 4 is the data section.
+C
+      CALL GRPRS0 (ISEC0)
+      CALL GRPRS1 (ISEC0, ISEC1)
+C
+      IF (ISEC1 (5) .EQ. 0 .OR. ISEC1 (5) .EQ. 64) THEN
+        WRITE (*,*) ' GRDEMO : No section 2 in GRIB message.'
+      ELSE
+        CALL GRPRS2 (ISEC0, ISEC2, ZSEC2)
+      ENDIF
+C
+      IF (ISEC1 (5) .EQ. 0 .OR. ISEC1 (5) .EQ. 128) THEN
+        WRITE (*,*) ' GRDEMO : No section 3 in GRIB message.'
+      ELSE
+        CALL GRPRS3 (ISEC0, ISEC3, ZSEC3)
+      ENDIF
+C
+      CALL GRPRS4 (ISEC0, ISEC4, ZSEC4)
+C
+C     Sample code to print maximum and minimum value in data.
+C
+C     ZMAX = ZSEC4 (1)
+C     ZMIN = ZSEC4 (1)
+C
+C     DO JLAT = 2, ISEC4 (1)
+C       ZMAX = MAX (ZMAX, ZSEC4 (JLAT) )
+C       ZMIN = MIN (ZMIN, ZSEC4 (JLAT) )
+C     ENDDO
+C     WRITE (*, *)
+C     WRITE (*, *) 'Maximum value in field is ', ZMAX
+C     WRITE (*, *) 'Minimum value in field is ', ZMIN
+C     WRITE (*, *)
+C
+C     Sample code to print all values along lines of
+C     latitude for a lat/long grid only.
+C
+C     ZFIRST = REAL (ISEC2 (5) ) / 1000.0
+C     ZLAST = REAL (ISEC2 (8) ) / 1000.0
+C     ZSTEP = REAL (ISEC2 (9) ) / 1000.0
+C     WRITE (*, *) 'Longitudes from ', ZFIRST, ' to ', ZLAST,
+C    1  ' with stride ', ZSTEP
+C
+C     DO JLAT = 1, ISEC2 (3)
+C       ZLAT = REAL (ISEC2 (4) - (JLAT - 1) * ISEC2 (10) ) / 1000.0
+C       JSTART = (JLAT - 1) * ISEC2 (2) + 1
+C       JEND = JLAT * ISEC2 (2)
+C       WRITE (*, *)
+C       WRITE (*, *) 'Values at latitude ', ZLAT
+C       WRITE (*, *)
+C       WRITE(*, '(1H , 5E16.5)' )
+C    1    (ZSEC4 (JLONG), JLONG = JSTART, JEND)
+C     ENDDO
+C
+      GO TO 50
+C
+      END
+
diff --git a/tests/include.sh.in b/tests/include.sh.in
deleted file mode 100644
index 298eacc..0000000
--- a/tests/include.sh.in
+++ /dev/null
@@ -1,10 +0,0 @@
-set -ea
-# For CMake
-
-export src_dir=@PROJECT_SOURCE_DIR@
-export data_dir=@PROJECT_SOURCE_DIR@/data
-export tools_dir=@CMAKE_BINARY_DIR@/bin
-export tests_dir=@CMAKE_SOURCE_DIR@/tests
-export tests_bin_dir=@CMAKE_BINARY_DIR@/tests
-
-export grib_compare=@GRIB_COMPARE@
diff --git a/tests/interpolation.F b/tests/interpolation.F
deleted file mode 100644
index 0f2e982..0000000
--- a/tests/interpolation.F
+++ /dev/null
@@ -1,144 +0,0 @@
-      PROGRAM INTERPOLATION
-C
-      IMPLICIT NONE
-      INTEGER IPROD
-      INTEGER INTV
-      REAL REALV
-      CHARACTER*20 CHARV
-      DIMENSION INTV(4), REALV(4), CHARV(4)
-C
-      INTEGER JPGRIB, JPEXPAND, JPLONG, JPLAT, JPBYTES
-C
-C     This should allow an 0.5 degree global grid as input(if required)
-C
-      PARAMETER(JPGRIB = 2000000)
-C
-      PARAMETER(JPBYTES = 4)
-      PARAMETER(JPLONG = 361)
-      PARAMETER(JPLAT  = 720)
-      PARAMETER(JPEXPAND = JPLONG * JPLAT)
-C
-      INTEGER IOGRIB(JPGRIB), INGRIB(JPGRIB)
-C
-      REAL ZNFELDI(JPEXPAND), ZNFELDO(JPEXPAND)
-C
-      INTEGER IUNIT1, IUNIT2, IREC, INLENG, IERR, IRET
-C
-C     Externals
-C
-      INTEGER INTOUT, INTF2, IARGC
-C
-      CHARACTER*2 OPTION
-      CHARACTER*256 INFILE, OUTFILE
-      INTEGER IJDC
-      EXTERNAL GETENV
-C
-      IJDC = IARGC()
-      IF( IJDC.LT.3 ) THEN
-       print*,'Usage: ./interpolation option inputfile outputfile'
-       print*,'Possible options:'
-       print*,'ll-spectral to lat-long or any grid to lat long'
-       print*,'gg-spectral to regular gaussian or any grid to gaussian'
-       print*,'qr-spectral to red gaussian or red gaussian red gaussian'
-       STOP
-      ENDIF
-
-      CALL GETARG(1,OPTION)
-      CALL GETARG(2,INFILE)
-      CALL GETARG(3,OUTFILE)
-C
-      IRET = 0
-C
-C     Turn on autoresol
-C
-      INTV(1) = 1
-      IRET = INTOUT('autoresol', INTV, REALV, CHARV)
-      IF( IRET.NE.0 ) STOP 'autoresol INTOUT failed.'
-C
-C     Define area to be used for interpolating the new field(s).
-C
-      REALV(1) = 0.0
-      REALV(2) = 0.0
-      REALV(3) = 0.0
-      REALV(4) = 0.0
-
-      IRET = INTOUT('area', INTV, REALV, CHARV)
-      IF( IRET.NE.0 ) STOP 'area INTOUT failed.'
-C
-C     Define grid to be used for interpolating the new field(s).
-C
-      IF( OPTION.EQ.'ll' ) THEN
-        REALV(1) = 0.5
-        REALV(2) = 0.5
-        IRET = INTOUT('grid', INTV, REALV, CHARV)
-        IF( IRET.NE.0 ) STOP 'grid INTOUT failed.'
-      ENDIF
-C
-      IF( OPTION.EQ.'gg' ) THEN
-        INTV(1) = 80
-        IRET = INTOUT('regular', INTV, REALV, CHARV)
-        IF( IRET.NE.0 ) STOP 'regular INTOUT failed.'
-      ENDIF
-C
-C
-      IF( OPTION.EQ.'qr' ) THEN
-        INTV(1) = 80
-        IRET = INTOUT('reduced', INTV, REALV, CHARV)
-        IF( IRET.NE.0 ) STOP 'reduced INTOUT failed.'
-      ENDIF
-C
-C     Open input and output files.
-C
-      CALL PBOPEN(IUNIT1, infile, 'r', IERR)
-      IF( IERR.NE.0 ) STOP 'PBOPEN failed'
-      CALL PBOPEN(IUNIT2, outfile, 'w', IERR)
-      IF( IERR.NE.0 ) STOP 'PBOPEN failed'
-      IPROD = 0
-C
-C     Start of loop through input GRIB-coded fields
-C
- 200  CONTINUE
-C
-        IPROD = IPROD + 1
-C
-C       READ next product
-C
-        CALL PBGRIB(IUNIT1, IOGRIB, JPGRIB * JPBYTES, IREC, IERR)
-        IF( IERR .EQ. -1 ) GOTO 900
-        IF( IERR .NE. 0 ) STOP 'PBGRIB failed'
-C
-C       Interpolate
-C
-        WRITE(*,*) ' Interpolate product number ', IPROD
-        INLENG = JPGRIB
-        IRET = INTF2(IOGRIB,IREC,INGRIB,INLENG)
-        IF( IRET.NE.0 ) STOP 'INTF failed.'
-C
-C       Write the new product to file
-C
-        IF( INLENG.GT.0 ) THEN
-          CALL PBWRITE( IUNIT2, INGRIB, INLENG*JPBYTES, IERR)
-        ELSE
-          WRITE(*,*) 'Output same as input'
-          CALL PBWRITE( IUNIT2, IOGRIB, IREC, IERR)
-        ENDIF
-        IF( IERR.LT.0 ) STOP 'PBWRITE failed'
-C
-C       Loop back for next product
-C
-      GOTO 200
-C
-C     Closedown
-C
- 900  CONTINUE
-C
-      IPROD = IPROD - 1
-      WRITE(*,*) ' All done after ', IPROD, ' products.'
-C
-C     Close input and output files.
-C
-      CALL PBCLOSE(IUNIT1, IERR)
-      CALL PBCLOSE(IUNIT2, IERR)
-C
-      STOP
-      END
diff --git a/tests/interpolation.sh b/tests/interpolation.sh
deleted file mode 100755
index fe27d82..0000000
--- a/tests/interpolation.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-. ./include.sh
-
-#export JDCNDBG=1
-#export INTF2_DEBUG=1
-
-EMOSLIB_FILES=${src_dir}/tables/interpol
-export EMOSLIB_FILES
-
-compare="$grib_compare -P -T 2 -f"
-
-tool=./interpolation
-data=${src_dir}/tests/data_in
-out=./data_out
-ref=${src_dir}/tests/data_ref
-
-mkdir -p $out
-
-option=ll
-x=spectral-ll.grib
-file=spectral.grib
-
-echo "******************************"
-echo "     SH to LL             ****"
-echo "******************************"
-$tool $option $data/$file $out/$x
-$compare ${ref}/$x $out/$x
-
-option=qr
-x=spectral-rg.grib
-
-echo "******************************"
-echo "     SH to RG             ****"
-echo "******************************"
-$tool $option $data/$file $out/$x
-$compare ${ref}/$x $out/$x
-
diff --git a/tests/interpolation_example_grib_api.F b/tests/interpolation_example_grib_api.F
deleted file mode 100644
index ed0843d..0000000
--- a/tests/interpolation_example_grib_api.F
+++ /dev/null
@@ -1,163 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM SAMPLE1
-C
-      IMPLICIT NONE
-      INTEGER IPROD
-      INTEGER INTV
-      REAL REALV
-      CHARACTER*20 CHARV
-      DIMENSION INTV(4), REALV(4), CHARV(4)
-C
-      INTEGER JPGRIB, JPBYTES
-C
-      PARAMETER (JPGRIB = 2000000)
-C
-C     JPBYTES is the size in bytes on an 'INTEGER'
-C     Set JPBYTES = 8 on a 64-bit machine.
-C
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER INGRIB, NEWFLD
-      DIMENSION INGRIB(JPGRIB), NEWFLD(JPGRIB)
-C
-      REAL ZNFELDI, ZNFELDO
-      DIMENSION ZNFELDI(1), ZNFELDO(1)
-C
-      INTEGER IUNIT1, IUNIT2, IREC, INLEN, NEWLEN, IRET, NARGS
-      INTEGER*4 J
-C
-C     Externals
-      INTEGER INTOUT, INTF2, IARGC
-
-      CHARACTER*128 INFILE, OUTFILE, CARG(4)
-C
-C **********************************************************************
-C
-C     Pick up file names from command line.
-C
-      NARGS = IARGC()
-      IF( NARGS.LT.4 ) THEN
-        print*,'Usage: interpolation_example -i inputfile -o outputfile'
-        CALL EXIT(2)
-      END IF
-
-      DO 101 J=1,NARGS
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-
-      DO 102 J=1,NARGS,2
-        IF(CARG(J).EQ.'-i') THEN
-           INFILE=CARG(J+1)
-        ELSEIF(CARG(J).EQ.'-o') THEN
-           OUTFILE=CARG(J+1)
-        ELSE
-        print*,'Usage: interpolation_example -i inputfile -o outputfile'
-        CALL EXIT(2)
-        END IF
- 102  CONTINUE
-
-C     Define the packing accuracy for the new field(s).
-C
-      INTV(1) = 24
-      IRET = INTOUT('accuracy', INTV, REALV, CHARV)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' First INTOUT failed.'
-        CALL EXIT(2)
-      ENDIF
-C
-C     Define the geographical area for the new field(s).
-C
-      REALV(1) =  60.0
-      REALV(2) = -10.0
-      REALV(3) =  40.0
-      REALV(4) =  15.0
-      IRET = INTOUT('area', INTV, REALV, CHARV)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' Second INTOUT failed.'
-        CALL EXIT(2)
-      ENDIF
-C
-C     Define the grid interval for the new field(s).
-C
-      REALV(1) = 1.5
-      REALV(2) = 1.5
-      IRET = INTOUT('grid', INTV, REALV, CHARV)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' Third INTOUT failed.'
-        CALL EXIT(2)
-      ENDIF
-C
-C     Open input and output files.
-C
-      CALL PBOPEN(IUNIT1, INFILE, 'r', IRET)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' PBOPEN failed'
-        CALL EXIT(2)
-      END IF
-      CALL PBOPEN(IUNIT2, OUTFILE, 'w', IRET)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' PBOPEN failed'
-        CALL EXIT(2)
-      END IF
-      IPROD = 0
-C
-C     Start of loop through input GRIB-coded fields
-C
- 200  CONTINUE
-        IPROD = IPROD + 1
-C
-C       Read next product.
-C
-        CALL PBGRIB(IUNIT1, INGRIB, JPGRIB*JPBYTES, IREC, IRET)
-        IF ( IRET.EQ.-1 ) GOTO 900
-        IF ( IRET.NE.0 ) THEN
-            WRITE(*,*) ' PBGRIB failed'
-            CALL EXIT(2)
-         END IF
-C
-C       Interpolate.
-C
-        WRITE(*,*) ' Interpolate product number ', IPROD
-        NEWLEN = JPGRIB
-        INLEN  = IREC
-        IRET = INTF2(INGRIB,INLEN,NEWFLD,NEWLEN)
-        IF ( IRET.NE.0 ) THEN
-          WRITE(*,*) ' INTF2 failed.'
-          CALL EXIT(2)
-        ENDIF
-C
-C       Write the new product to file.
-C
-       CALL PBWRITE( IUNIT2, NEWFLD, NEWLEN*JPBYTES, IRET)
-        IF ( IRET.LT.(NEWLEN*JPBYTES) ) THEN
-            WRITE(*,*) ' PBWRITE failed'
-            CALL EXIT(2)
-        END IF
-C
-C       Loop back for next product.
-C
-      GOTO 200
-C
-C     Closedown.
-C
- 900  CONTINUE
-C
-      IPROD = IPROD - 1
-      WRITE(*,*) ' All done after ', IPROD, ' products.'
-C
-C     Close input and output files.
-C 
-      CALL PBCLOSE(IUNIT1, IRET)
-      CALL PBCLOSE(IUNIT2, IRET)
-C
-      STOP
-      END
diff --git a/tests/interpolation_example_gribex.F b/tests/interpolation_example_gribex.F
deleted file mode 100644
index 28319d7..0000000
--- a/tests/interpolation_example_gribex.F
+++ /dev/null
@@ -1,152 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-       PROGRAM SAMPLE1
-C
-      IMPLICIT NONE
-      INTEGER IPROD
-      INTEGER INTV
-      REAL REALV
-      CHARACTER*20 CHARV
-      DIMENSION INTV(4), REALV(4), CHARV(4)
-C
-      INTEGER JPGRIB, JPBYTES
-C
-      PARAMETER (JPGRIB = 2000000)
-C
-C     JPBYTES is the size in bytes on an 'INTEGER'
-C     Set JPBYTES = 8 on a 64-bit machine.
-C
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER INGRIB, NEWFLD
-      DIMENSION INGRIB(JPGRIB), NEWFLD(JPGRIB)
-C
-      REAL ZNFELDI, ZNFELDO
-      DIMENSION ZNFELDI(1), ZNFELDO(1)
-C
-      INTEGER IUNIT1, IUNIT2, IREC, INLEN, NEWLEN, IRET, NARGS
-      INTEGER*4 J
-C
-C     Externals
-      INTEGER INTOUT, INTF, IARGC
-
-      CHARACTER*128 INFILE, OUTFILE, CARG(4)
-C
-C **********************************************************************
-C
-C     Pick up file names from command line.
-C
-      NARGS = IARGC()
-      IF( NARGS.LT.4 ) THEN
-        print*,'Usage: interpolation_example -i inputfile -o outputfile'
-        CALL EXIT(1)
-      END IF
-
-      DO 101 J=1,NARGS
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
-
-      DO 102 J=1,NARGS,2
-        IF(CARG(J).EQ.'-i') THEN
-           INFILE=CARG(J+1)
-        ELSEIF(CARG(J).EQ.'-o') THEN
-           OUTFILE=CARG(J+1)
-        ELSE
-        print*,'Usage: interpolation_example -i inputfile -o outputfile'
-        CALL EXIT(1)
-        END IF
- 102  CONTINUE
-
-C     Define the packing accuracy for the new field(s).
-C
-      INTV(1) = 24
-      IRET = INTOUT('accuracy', INTV, REALV, CHARV)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' First INTOUT failed.'
-        CALL EXIT(1)
-      ENDIF
-C
-C     Define the grid interval for the new field(s).
-C
-      REALV(1) = 1.5
-      REALV(2) = 1.5
-      IRET = INTOUT('grid', INTV, REALV, CHARV)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' Third INTOUT failed.'
-        CALL EXIT(1)
-      ENDIF
-
-C
-C     Open input and output files.
-C
-      CALL PBOPEN(IUNIT1, INFILE, 'r', IRET)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' PBOPEN failed'
-        CALL EXIT(1)
-      END IF
-      CALL PBOPEN(IUNIT2, OUTFILE, 'w', IRET)
-      IF ( IRET.NE.0 ) THEN
-        WRITE(*,*) ' PBOPEN failed'
-        CALL EXIT(1)
-      END IF
-      IPROD = 0
-C
-C     Start of loop through input GRIB-coded fields
-C
- 200  CONTINUE
-        IPROD = IPROD + 1
-C
-C       Read next product.
-C
-        CALL PBGRIB(IUNIT1, INGRIB, JPGRIB*JPBYTES, IREC, IRET)
-        IF ( IRET.EQ.-1 ) GOTO 900
-        IF ( IRET.NE.0 ) THEN
-            WRITE(*,*) ' PBGRIB failed'
-            CALL EXIT(1)
-        END IF
-C
-C       Interpolate.
-C
-        WRITE(*,*) ' Interpolate product number ', IPROD
-        NEWLEN = JPGRIB
-        INLEN  = IREC/JPBYTES
-        IRET = INTF(INGRIB,INLEN,ZNFELDI,NEWFLD,NEWLEN,ZNFELDO)
-        IF ( IRET.NE.0 ) THEN
-          WRITE(*,*) ' INTF failed.'
-          CALL EXIT(1)
-        ENDIF
-C
-C       Write the new product to file.
-C
-       CALL PBWRITE( IUNIT2, NEWFLD, NEWLEN*JPBYTES, IRET)
-        IF ( IRET.LT.(NEWLEN*JPBYTES) ) THEN
-            WRITE(*,*) ' PBWRITE failed'
-            CALL EXIT(1)
-        END IF
-C
-C       Loop back for next product.
-C
-      GOTO 200
-C
-C     Closedown.
-C
- 900  CONTINUE
-C
-      IPROD = IPROD - 1
-      WRITE(*,*) ' All done after ', IPROD, ' products.'
-C
-C     Close input and output files.
-C 
-      CALL PBCLOSE(IUNIT1, IRET)
-      CALL PBCLOSE(IUNIT2, IRET)
-C
-      STOP
-      END
diff --git a/tests/interpolation_example_wind.F b/tests/interpolation_example_wind.F
deleted file mode 100644
index ec371bf..0000000
--- a/tests/interpolation_example_wind.F
+++ /dev/null
@@ -1,104 +0,0 @@
-      PROGRAM SAMPLE4
-C
-      IMPLICIT NONE
-      INTEGER INTV
-      REAL REALV
-      CHARACTER*20 CHARV
-      DIMENSION INTV(4), REALV(4), CHARV(4)
-C
-      INTEGER JPGRIB, JPBYTES
-C
-      PARAMETER (JPGRIB = 7000000)
-C
-C     Set JPBYTES = 8 on a 64-bit machine.
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER IVOGRIB (JPGRIB), IDVGRIB (JPGRIB)
-      INTEGER IUGRIB (JPGRIB), IVGRIB (JPGRIB)
-C
-      INTEGER IUNIT1, IUNIT2, IREC, INLENG, IERR, IRET,J,NARGS
-C
-C     Externals
-      INTEGER INTOUT, INTUVP2, IARGC
-      LOGICAL ISSAME
-C
-      CHARACTER*128 INFILE, OUTFILE, CARG(4)
- 
-C **********************************************************************
-C
-C     Pick up file names from command line.
-C
-      NARGS = IARGC()
-      IF( NARGS.LT.4 ) THEN
-        print*,'Usage: interpolation_example2 -i infile -o outfile'
-        STOP
-      END IF
- 
-      DO 101 J=1,NARGS
-      CALL GETARG(J,CARG(J))
- 101  CONTINUE
- 
-      DO 102 J=1,NARGS,2
-        IF(CARG(J).EQ.'-i') THEN
-           INFILE=CARG(J+1)
-        ELSEIF(CARG(J).EQ.'-o') THEN
-           OUTFILE=CARG(J+1)
-        ELSE
-        print*,'Usage: interpolation_example2 -i infile -o outfile'
-        STOP
-        END IF
- 102  CONTINUE
- 
-C **********************************************************************
- 
-C     Set output grid interval
-      REALV(1) = 3.0
-      REALV(2) = 3.0
-      IRET = INTOUT('grid',INTV,REALV,CHARV)
-      IF ( IRET .NE. 0 ) THEN
-        STOP 'grid setting INTOUT failed.'
-      ENDIF
-C
-C     Open input and output files.
-      CALL PBOPEN(IUNIT1, INFILE, 'r', IERR)
-      IF ( IERR .NE. 0 ) STOP ' PBOPEN failed'
-      CALL PBOPEN(IUNIT2, OUTFILE, 'w', IERR)
-      IF ( IERR .NE. 0 ) STOP ' PBOPEN failed'
-C
-C     Read vorticity.
-      CALL PBGRIB(IUNIT1, IVOGRIB, JPGRIB * JPBYTES, IREC, IERR)
-      IF ( IERR .EQ. -1 ) GOTO 900
-      IF ( IERR .NE. 0 ) STOP ' PBGRIB failed for vorticity'
-C
-C     Read divergence.
-      CALL PBGRIB(IUNIT1, IDVGRIB, JPGRIB * JPBYTES, IREC, IERR)
-      IF ( IERR .EQ. -1 ) GOTO 900
-      IF ( IERR .NE. 0 ) STOP ' PBGRIB failed for divergence'
-C
-C     Create U and V
-      WRITE(*,*) ' Create U and V.'
-      INLENG = JPGRIB
-      IRET = INTUVP2(IVOGRIB, IDVGRIB, JPGRIB, IUGRIB, IVGRIB, INLENG)
-      IF ( IRET .NE. 0 ) THEN
-        WRITE(*,*) ' INTUVP failed.'
-        STOP
-      ENDIF
-C
-C     Write the new U and V products to file
-      IF ( INLENG .GT. 0 ) THEN
-        CALL PBWRITE(IUNIT2, IUGRIB, INLENG*JPBYTES, IERR)
-        IF ( IERR .LT. (INLENG*JPBYTES) ) STOP ' PBWRITE failed'
-        CALL PBWRITE(IUNIT2, IVGRIB, INLENG*JPBYTES, IERR)
-        IF ( IERR .LT. (INLENG*JPBYTES) ) STOP ' PBWRITE failed'
-      ENDIF
-C
-C     Closedown
- 900  CONTINUE
-C
-C     Close input and output files.
-      CALL PBCLOSE(IUNIT1, IERR)
-      CALL PBCLOSE(IUNIT2, IERR)
-C
-      STOP
-      END
-      
\ No newline at end of file
diff --git a/tests/link_mars.F b/tests/link_mars.F
new file mode 100644
index 0000000..2092fb7
--- /dev/null
+++ b/tests/link_mars.F
@@ -0,0 +1,42 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+      PROGRAM LINK_MARS
+      IMPLICIT NONE
+C
+C     Checks symbols when linking.
+C
+      INTEGER I
+      REAL R
+      CHARACTER C
+      INTEGER IARGC
+C
+      INTEGER AREACHK
+      INTEGER IBASINI
+      INTEGER INTF
+      INTEGER INTIN
+      INTEGER INTOUT
+      INTEGER intf2
+      INTEGER intuvp2
+      INTEGER intuvs2
+      INTEGER intvect2
+      IF (IARGC().LT.0) THEN
+          CALL INTLOG (I,C,I)
+          I = AREACHK  (R,R,R,R,R,R)
+          I = IBASINI  (I)
+          I = INTF     (I,I,R,I,I,R)
+          I = INTIN    (C,I,R,C)
+          I = INTOUT   (C,I,R,C)
+          I = intf2    (C,I,C,I)
+          I = intuvp2  (C,C,I,C,C,I)
+          I = intuvs2  (C,C,I,C,C,I)
+          I = intvect2 (C,C,I,C,C,I)
+      END IF
+      END
+
diff --git a/tests/link_prodgen.F b/tests/link_prodgen.F
new file mode 100644
index 0000000..4be457d
--- /dev/null
+++ b/tests/link_prodgen.F
@@ -0,0 +1,48 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+      PROGRAM LINK_PRODGEN
+      IMPLICIT NONE
+C
+C     Checks symbols when linking.
+C
+      INTEGER I
+      REAL R
+      CHARACTER C
+      LOGICAL L
+      COMPLEX J
+      INTEGER IARGC
+C
+      INTEGER HIRLAM
+      INTEGER HIRLAMW
+      INTEGER HIRLSM
+      INTEGER INTF
+      INTEGER INTIN
+      INTEGER INTOUT
+      INTEGER JGETGG
+      INTEGER JGGLAT
+      INTEGER WV2DINT
+      INTEGER WVQLINT
+      IF (IARGC().LT.0) THEN
+          CALL FREECF  (I)
+          CALL JNUMGG  (I,C,I,I)
+          CALL JVOD2UV (J,J,I,J,J,I)
+          I = HIRLAM  (L,R,I,I,R,R,R,R,I,I,I)
+          I = HIRLAMW (L,R,R,I,I,R,R,R,R,R,I,I,I)
+          I = HIRLSM  (L,R,I,I,R,R,R,R,I,I,I)
+          I = INTF    (I,I,R,I,I,R)
+          I = INTIN   (C,I,R,C)
+          I = INTOUT  (C,I,R,C)
+          I = JGETGG  (I,C,R,I,I)
+          I = JGGLAT  (I,R)
+          I = WV2DINT (I,I,I,I,R,R,R,R,R,I,R,R)
+          I = WVQLINT (I,I,I,I,R,R,R,R,R,I,R,R)
+      END IF
+      END
+
diff --git a/tests/tc_tracks.sh b/tests/tc_tracks.sh
deleted file mode 100755
index 1045d16..0000000
--- a/tests/tc_tracks.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-set -e
-
-. ./include.sh
-
-#rm -f tracks_05W_PEIPAH_2014041000.eps.bufr4 tracks_05W_PEIPAH_2014041000.eps.bufr
-
-echo "${tools_dir}/tc_tracks_eps -i ${tests_dir}/tc_tracks/tracks_05W_PEIPAH_2014041000.fm -o ${tests_bin_dir}/tracks_05W_PEIPAH_2014041000.eps.bufr"
-
-${tools_dir}/tc_tracks_eps -i ${tests_dir}/tc_tracks/tracks_05W_PEIPAH_2014041000.fm -o ${tests_bin_dir}/tracks_05W_PEIPAH_2014041000.eps.bufr
-${tools_dir}/tc_tracks_eps -4 -i ${tests_dir}/tc_tracks/tracks_05W_PEIPAH_2014041000.fm -o ${tests_bin_dir}/tracks_05W_PEIPAH_2014041000.eps.bufr4
-cmp ${tests_bin_dir}/tracks_05W_PEIPAH_2014041000.eps.bufr4 ${tests_dir}/tc_tracks/tracks_05W_PEIPAH_2014041000.eps.bufr4
-cmp ${tests_bin_dir}/tracks_05W_PEIPAH_2014041000.eps.bufr ${tests_dir}/tc_tracks/tracks_05W_PEIPAH_2014041000.eps.bufr
-
-
-${tools_dir}/tc_tracks_det -i ${tests_dir}/tc_tracks/tracks_15U_ITA_2014041012.fm -o ${tests_bin_dir}/tracks_15U_ITA_2014041012.det.bufr
-${tools_dir}/tc_tracks_det -4 -i ${tests_dir}/tc_tracks/tracks_15U_ITA_2014041012.fm -o ${tests_bin_dir}/tracks_15U_ITA_2014041012.det.bufr4
-
-cmp ${tests_bin_dir}/tracks_15U_ITA_2014041012.det.bufr ${tests_dir}/tc_tracks/tracks_15U_ITA_2014041012.det.bufr
-cmp ${tests_bin_dir}/tracks_15U_ITA_2014041012.det.bufr4 ${tests_dir}/tc_tracks/tracks_15U_ITA_2014041012.det.bufr4
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 3cd1518..adad6ac 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,3 +1,48 @@
-add_subdirectory( bufrtools_wmo )
+# configure Fortran-based targets for double precision (compilation & linking)
+ecbuild_add_fortran_flags(${emos_double_precision_flags})
 
-add_subdirectory( singlePointInterpolation )
+if( HAVE_LIBEMOS_BUFRDC )
+  add_subdirectory( bufrtools_wmo )
+endif()
+
+if( HAVE_LIBEMOS_INTERPOLATION )
+
+  add_subdirectory( lsmReducedGaussian )
+
+  if( NOT HAVE_GRIBEX_ABORT )
+    add_subdirectory( singlePointInterpolation )
+  endif()
+
+  ecbuild_add_executable(
+    TARGET      gg_latitudes NOINSTALL
+    SOURCES     gg_latitudes.F
+    DEFINITIONS ${LIBEMOS_DEFINITIONS}
+    LIBS        emos )
+
+  if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" )
+    set_source_files_properties( gg_gridname.c PROPERTIES COMPILE_DEFINITIONS "FORTRAN_LINKER_PGI" )
+    ecbuild_add_executable(
+      TARGET      gg_gridname NOINSTALL
+      SOURCES     gg_gridname.c
+      DEFINITIONS ${LIBEMOS_DEFINITIONS}
+      INCLUDES    ${GRIB_API_INCLUDE_DIRS}
+      LIBS        emos
+      LINKER_LANGUAGE Fortran )
+
+  else()
+    ecbuild_add_executable(
+      TARGET      gg_gridname NOINSTALL
+      SOURCES     gg_gridname.c
+      DEFINITIONS ${LIBEMOS_DEFINITIONS}
+      INCLUDES    ${GRIB_API_INCLUDE_DIRS}
+      LIBS        emos )
+  endif()
+
+  ecbuild_add_executable(
+    TARGET      int NOINSTALL
+    SOURCES     int.F except.c
+    DEFINITIONS ${LIBEMOS_DEFINITIONS}
+    INCLUDES    ${GRIB_API_INCLUDE_DIRS}
+    LIBS        emos )
+
+endif()
diff --git a/tools/Dchange_grib/Dchange_grib.f b/tools/Dchange_grib/Dchange_grib.f
deleted file mode 100755
index b004199..0000000
--- a/tools/Dchange_grib/Dchange_grib.f
+++ /dev/null
@@ -1,212 +0,0 @@
-      PROGRAM DCHANGE
-      IMPLICIT NONE
-C
-      INTEGER JPACK, JPBYTES
-      PARAMETER (JPACK = 280000)
-      PARAMETER (JPBYTES = 4)
-      REAL MAXFLT
-      PARAMETER (MAXFLT = 2147483647.0)
-C
-      INTEGER ISEC0(2),ISEC1(1024),ISEC2(1024),ISEC3(2),ISEC4(512)
-      INTEGER IUSEC0(2),IUSEC1(1024),IUSEC2(1024),IUSEC3(2), IUSEC4(512)
-C
-      REAL ZSEC2(512),ZSEC3(2),ZSEC4(JPACK*4),USEC4(JPACK*4)
-      INTEGER INBUFF(JPACK)
-      INTEGER IRET, FILE1, FILE2, JCOUNT
-      INTEGER ILENB, LENOUT, IPUNP, IWORD, LOOP
-C
-      CHARACTER*4 CNMEXP
-      CHARACTER*128 INFILE, OUTFILE, NAMFILE
-      INTEGER IJDC, IARGC
-cs      EXTERNAL IARGC, GETENV
-C
-      NAMELIST /USHEAD/IUSEC0,IUSEC1,IUSEC2,IUSEC3,IUSEC4,CNMEXP
-C
-C     -----------------------------------------------------------------|
-C
-      IJDC = IARGC()
-      IF( IJDC.LT.3 ) THEN
-        WRITE(*,*) 'Usage: Dchange_grib namelist input output'
-        STOP 'Faulty program options'
-      ENDIF
-C
-      CALL GETARG(1,NAMFILE)
-      CALL GETARG(2,INFILE)
-      CALL GETARG(3,OUTFILE)
-C
-C     Open the input file
-C
-      CALL PBOPEN(FILE1, INFILE, "R", IRET)
-      IF( IRET.NE.0 ) THEN
-        WRITE(*, *) 'Return code from PBOPEN = ',IRET
-        CALL PBCLOSE(FILE1, IRET)
-        STOP 'Fault in PBOPEN opening input file'
-      ENDIF
-C
-C     Open the output file
-C
-      CALL PBOPEN(FILE2, OUTFILE, "w", IRET)
-      IF( IRET.NE.0 ) THEN
-        WRITE (*, *) 'Return code from PBOPEN = ',IRET
-        STOP 'Fault in PBOPEN opening output file'
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C
-C     Initialize namelist, read input
-C
-      DO LOOP =1,2
-        IUSEC3(LOOP)=-999
-      ENDDO
-C
-      DO LOOP=1,1024
-        IUSEC1(LOOP)=-999
-      ENDDO
-C
-      DO LOOP=1,1024
-        IUSEC2(LOOP)=-999
-      ENDDO
-C
-      DO LOOP=1,512
-        IUSEC4(LOOP)=-999
-      ENDDO
-C
-      CNMEXP='9999'
-C
-      OPEN(12,FILE=NAMFILE,FORM='FORMATTED',STATUS='OLD',ERR=900)
-C
-      READ(12,USHEAD)
-C      
-      DO LOOP=1,1024
-        IF(IUSEC1(LOOP).NE.-999) THEN
-          WRITE(*,*)
-     X      "Element ",LOOP," of header 1 changed to ",IUSEC1(LOOP)
-        ENDIF
-      ENDDO   
-C
-      IF (CNMEXP(1:4).NE.'9999') WRITE(*,*)
-     1   "EXPVER (element 41 of header 1) changed to ",CNMEXP(1:4)
-
-
-      DO LOOP=1,1024
-        IF(IUSEC2(LOOP).NE.-999) THEN
-          WRITE(*,*)
-     X      "Element ",LOOP," of header 2 changed to ",IUSEC2(LOOP)
-        ENDIF
-      ENDDO
-C
-      DO LOOP=1,2
-        IF(IUSEC3(LOOP).NE.-999) THEN
-          WRITE(*,*)
-     X      "Element ",LOOP," of header 3 changed to ",IUSEC3(LOOP)
-        ENDIF
-      ENDDO
-C   
-      DO LOOP=1,512
-        IF(IUSEC4(LOOP).NE.-999) THEN
-          WRITE(*,*)
-     X      "Element ",LOOP," of header 4 changed to ",IUSEC4(LOOP)
-        ENDIF
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C
-      JCOUNT = 0
-C
-   50 CONTINUE
-C
-C     Read packed field into INBUFF.
-C
-      ILENB = JPACK*JPBYTES
-      CALL PBGRIB(FILE1, INBUFF, ILENB, LENOUT, IRET )
-      IF( IRET.LT.0 ) THEN
-        IF( IRET.EQ.-1 ) THEN
-C
-          CALL PBCLOSE(FILE2, IRET)
-          IF( IRET.LT.0 ) THEN
-            WRITE(*, *) 'Return code from PBCLOSE = ',IRET
-            STOP 'Fault in PBCLOSE closing output file'
-          ENDIF
-C
-          CALL PBCLOSE(FILE1, IRET)
-          WRITE(*, *) 'Number of GRIB products changed = ',JCOUNT
-          STOP 'End-of-file for input'
-        ELSE
-          WRITE (*, *) 'Return code from PBGRIB = ',IRET
-          CALL PBCLOSE(FILE1, IRET)
-          WRITE(*,*) 'Fault in PBGRIB reading product number ', JCOUNT
-          STOP 'Fault in PBGRIB reading product'
-        ENDIF
-      ENDIF
-C
-      JCOUNT = JCOUNT + 1
-C
-C     Unpack GRIB message.
-C
-      ZSEC3(2) = -MAXFLT
-      ISEC3(2) = INT(ZSEC3(2))
-      IRET = 1
-      IPUNP = JPACK * JPBYTES
-      ILENB = (LENOUT + (JPBYTES-1))/JPBYTES
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,INBUFF,ILENB,IWORD,'D',IRET)
-      IF( IRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX problem decoding product ',JCOUNT
-        WRITE(*,*) 'GRIBEX return code = ',IRET
-        STOP 'GRIBEX error'
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C
-C     Repack the field and write to results file
-C
-C
-C     Changes the header, according to user requests
-C
-      DO LOOP=1,1024
-        IF(IUSEC1(LOOP).NE.-999) ISEC1(LOOP)=IUSEC1(LOOP)
-      ENDDO
-C
-      IF (CNMEXP(1:4).NE.'9999')  READ(CNMEXP,'(A4)') ISEC1(41)
-C
-      DO LOOP=1,1024
-        IF(IUSEC2(LOOP).NE.-999) ISEC2(LOOP)=IUSEC2(LOOP)
-      ENDDO
-C
-      DO LOOP=1,2
-        IF(IUSEC3(LOOP).NE.-999) ISEC3(LOOP)=IUSEC3(LOOP)
-      ENDDO
-C
-      DO LOOP=1,512
-        IF(IUSEC4(LOOP).NE.-999) ISEC4(LOOP)=IUSEC4(LOOP)
-      ENDDO
-C
-      IRET = 1
-      IPUNP = ISEC4(1)
-      ILENB = JPACK
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,INBUFF,ILENB,IWORD,'C',IRET)
-      IF( IRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX problem encoding product ',JCOUNT
-        WRITE(*,*) 'GRIBEX return code = ',IRET
-        STOP 'GRIBEX error'
-      ENDIF
-C
-      LENOUT = IWORD * JPBYTES
-      CALL PBWRITE(FILE2, INBUFF, LENOUT, IRET)
-      IF( IRET.LT.LENOUT ) THEN
-        WRITE(*,*) 'Problem writing product ',JCOUNT
-        WRITE(*,*) 'Return code from PBWRITE = ',IRET
-        STOP 'Fault in PBWRITE'
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C
-      GOTO 50
-C
-  900 CONTINUE
-C
-      WRITE(*, *) 'Namelist OPEN failed'
-C
-      STOP
-      END
diff --git a/tools/Dchange_grib/Makefile.cluster b/tools/Dchange_grib/Makefile.cluster
deleted file mode 100755
index 3dcc25e..0000000
--- a/tools/Dchange_grib/Makefile.cluster
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-#
-VERSION=000281
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-#
-#EMOSLIB= /home/ma/emos/lib/linux/$(VERSION)/libemos.R64.D64.I32.a
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = -g -DREAL_8=1
-#
-FC      = pgf90
-FFLAGS =  -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.clusterA64 b/tools/Dchange_grib/Makefile.clusterA64
deleted file mode 100755
index 240ec77..0000000
--- a/tools/Dchange_grib/Makefile.clusterA64
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-#
-VERSION=000281
-EMOSLIB= /usr/local/lib64/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-#
-#EMOSLIB= /home/ma/emos/lib/linux/$(VERSION)/libemos.R64.D64.I32.a
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = -g -DREAL_8=1 -m64
-#
-FC      = pgf90
-FFLAGS =  -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER -tp k8-64
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.hpia64 b/tools/Dchange_grib/Makefile.hpia64
deleted file mode 100755
index ca3d6bc..0000000
--- a/tools/Dchange_grib/Makefile.hpia64
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-VERSION=000281
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I64.a
-#EMOSLIB= /home/ma/emos/lib/hpia64/$(VERSION)/libemos.R64.D64.I64.a
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC     = cc
-CFLAGS = +DD64 -Ae -D_XPG2 -Dhp -DhpiaR64 -DREAL_8 -DINTEGER_8 -DPOINTER_64 +Z -O
-#
-FC     = /opt/fortran90/bin/f90
-FFLAGS = +DD64 -g +autodbl +O0 +pic=long +real_constant=double
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.ibm_power4 b/tools/Dchange_grib/Makefile.ibm_power4
deleted file mode 100755
index bc674a0..0000000
--- a/tools/Dchange_grib/Makefile.ibm_power4
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-VERSION=000281
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-#
-#EMOSLIB= /home/ma/emos/lib/$(VERSION)/libemos.R64.D64.I32.a
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = xlc_r
-#
-CFLAGS  = -g -O3 -qstrict -q64 -qwarn64 -qarch=pwr3 -qtune=pwr3 -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DIBM -DIBM_POWER4 -Drs6000 -DPOINTER_64 -DINTEGER_IS_INT -DSHAREDMEMORY -DFOPEN64
-#
-FC      = xlf90_r
-CPPFLAGS=-DREAL_BIGGER_THAN_INTEGER,-DREAL_8,-DIBM,-Drs6000,-DPOINTER_64,-DINTEGER_IS_INT,-DIBM_POWER4,-DSHAREDMEMORY,-DFOPEN64
-
-FFLAGS  = -g -qsigtrap -O3 -qstrict -q64 -qextname -qarch=pwr4 -qtune=pwr4 -qwarn64 -qrealsize=8 -qintsize=4 -qalign=4k -qsource -qflttrap=overflow:zerodivide:invalid:enable:imprecise -qfixed=72 -qintlog
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-.F.o:
-	$(FC) -WF,$(CPPFLAGS) $(FFLAGS) -c $*.F
-#
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.linux b/tools/Dchange_grib/Makefile.linux
deleted file mode 100755
index f11cb07..0000000
--- a/tools/Dchange_grib/Makefile.linux
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-#
-VERSION=000281
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-#
-#EMOSLIB= /home/ma/emos/lib/linux/$(VERSION)/libemos.R64.D64.I32.a
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = -g -DREAL_8=1 -m32
-#
-FC      = pgf90
-FFLAGS =  -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER -tp px
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.linuxA64 b/tools/Dchange_grib/Makefile.linuxA64
deleted file mode 100755
index e8684a1..0000000
--- a/tools/Dchange_grib/Makefile.linuxA64
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-#
-VERSION=000281
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-#
-#EMOSLIB= /home/ma/emos/lib/linux/$(VERSION)/libemos.R64.D64.I32.a
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = -g -DREAL_8=1 -m64
-#
-FC      = pgf90
-FFLAGS =  -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER -tp k8-64
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.rs6000 b/tools/Dchange_grib/Makefile.rs6000
deleted file mode 100755
index d20ae3d..0000000
--- a/tools/Dchange_grib/Makefile.rs6000
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-VERSION=000281
-
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = cc
-CFLAGS  = -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DFORTRAN_NO_UNDERSCORE -DIBM -Drs6000 -g
-#
-FC      = xlf
-FFLAGS  = -qrealsize=8 -qintsize=4 -qalign=4k -qnosource -g
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/Makefile.sgimips b/tools/Dchange_grib/Makefile.sgimips
deleted file mode 100755
index 240736b..0000000
--- a/tools/Dchange_grib/Makefile.sgimips
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-EMOSLIB= /home/ma/emos/lib/sgimips_n32/000200/libemos.R64.D64.I32.a
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = 
-OBJS.c = $(SRCS.c:.c=.o)
-#
-SRCS   = $(SRCS.F) $(SRCS.c)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-FC     = f90
-FFLAGS = -g -r8 -align64
-#
-CC     = cc
-CFLAGS = -g
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-Dchange_grib: Dchange_grib.f $(SRCS) $(OBJS)
-	$(FC) $(FFLAGS) -o Dchange_grib Dchange_grib.f $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf Dchange_grib Dchange_grib.o $(OBJS) core
diff --git a/tools/Dchange_grib/changeList b/tools/Dchange_grib/changeList
deleted file mode 100755
index 2ac45fc..0000000
--- a/tools/Dchange_grib/changeList
+++ /dev/null
@@ -1,13 +0,0 @@
-  &USHEAD
-    IUSEC1(1)=190,
-    IUSEC1(22)=232,
-    IUSEC1(24)=1,
-    IUSEC1(37)=1,
-    IUSEC1(38)=6,
-    IUSEC1(39)=9,
-    IUSEC1(40)=1090,
-    IUSEC1(42)=0,
-    IUSEC1(43)=0,
-    IUSEC3(2)=-55555,
-    CNMEXP='smpi',
- /
diff --git a/tools/bufr_exports/synop2bufr/Makefile b/tools/bufr_exports/synop2bufr/Makefile
deleted file mode 100755
index 750172a..0000000
--- a/tools/bufr_exports/synop2bufr/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-#                                 Makefile for example programs
-A64 = 
-R64 = 
-ARCH = linux
-CNAME = 
-#
-PLACE = ../
-LIB = bufr
-#
-include $(PLACE)config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include $(PLACE)options/options_$(ARCH)
-#
-#
-TARGDIR  = ./
-#
-#
-TARGETS  = all clean
-EXECS    =  synop2bufr create_gts_header
-#
-#
-all :$(EXECS)
-
-synop2bufr: synop2bufr.o
-	$(FC) $(FFLAGS) -o $@ synop2bufr.o -L$(PLACE) -l$(LIB)$(R64)
-create_gts_header: create_gts_header.o
-	$(FC) $(FFLAGS) -o $@ create_gts_header.o -L$(PLACE) -l$(LIB)$(R64)
-clean   :
-	@for name in $(EXECS); do\
-	(rm -f $$name *.o ); \
-	done 
diff --git a/tools/bufr_exports/synop2bufr/Makefile.in b/tools/bufr_exports/synop2bufr/Makefile.in
deleted file mode 100755
index c66492f..0000000
--- a/tools/bufr_exports/synop2bufr/Makefile.in
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-#                                 Makefile for example programs
-A64 = plat
-R64 = reals
-ARCH = arch
-CNAME = comp
-#
-PLACE = ../
-LIB = bufr
-#
-include $(PLACE)config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include $(PLACE)options/options_$(ARCH)
-#
-#
-TARGDIR  = ./
-#
-#
-TARGETS  = all clean
-EXECS    = synop2bufr
-#
-#
-all :$(EXECS)
-
-synop2bufr: synop2bufr.o
-	$(FC) $(FFLAGS) -o $@ synop2bufr.o -L$(PLACE) -l$(LIB)$(R64)
-create_gts_header: create_gts_header.o
-	$(FC) $(FFLAGS) -o $@ create_gts_header.o -L$(PLACE) -l$(LIB)$(R64)
-clean   :
-	@for name in $(EXECS); do\
-	(rm -f $$name *.o ); \
-	done 
diff --git a/tools/bufr_exports/synop2bufr/README b/tools/bufr_exports/synop2bufr/README
old mode 100755
new mode 100644
diff --git a/tools/bufr_exports/synop2bufr/create_gts_header.f b/tools/bufr_exports/synop2bufr/create_gts_header.f
old mode 100755
new mode 100644
diff --git a/tools/bufr_exports/synop2bufr/station_list/Makefile b/tools/bufr_exports/synop2bufr/station_list/Makefile
deleted file mode 100755
index 2502a8b..0000000
--- a/tools/bufr_exports/synop2bufr/station_list/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-#                                 Makefile for example programs
-A64 = 
-R64 = 
-ARCH = linux
-CNAME = 
-#
-PLACE = ../../
-LIB = bufr
-#
-include $(PLACE)config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include $(PLACE)options/options_$(ARCH)
-#
-#
-TARGDIR  = ./
-#
-#
-TARGETS  = all clean
-EXECS    =  wmo_make_station make_synop2bufr_station
-#
-#
-all :$(EXECS)
-
-wmo_make_station: wmo_make_station.o
-	$(FC) $(FFLAGS) -o $@ wmo_make_station.o -L$(PLACE) -l$(LIB)$(R64)
-make_synop2bufr_station: make_synop2bufr_station.o
-	$(FC) $(FFLAGS) -o $@ make_synop2bufr_station.o -L$(PLACE) -l$(LIB)$(R64)
-clean   :
-	@for name in $(EXECS); do\
-	(rm -f $$name *.o ); \
-	done 
diff --git a/tools/bufr_exports/synop2bufr/station_list/Makefile.in b/tools/bufr_exports/synop2bufr/station_list/Makefile.in
deleted file mode 100755
index 34c8544..0000000
--- a/tools/bufr_exports/synop2bufr/station_list/Makefile.in
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-#                                 Makefile for example programs
-A64 = plat
-R64 = reals
-ARCH = arch
-CNAME = comp
-#
-PLACE = ../../
-LIB = bufr
-#
-include $(PLACE)config/config.$(ARCH)$(CNAME)$(R64)$(A64)
-#
-include $(PLACE)options/options_$(ARCH)
-#
-#
-TARGDIR  = ./
-#
-#
-TARGETS  = all clean
-EXECS    = wmo_make_station
-#
-#
-all :$(EXECS)
-
-wmo_make_station: wmo_make_station.o
-	$(FC) $(FFLAGS) -o $@ wmo_make_station.o -L$(PLACE) -l$(LIB)$(R64)
-clean   :
-	@for name in $(EXECS); do\
-	(rm -f $$name *.o ); \
-	done 
diff --git a/tools/bufr_exports/synop2bufr/station_list/important_stations.dat b/tools/bufr_exports/synop2bufr/station_list/important_stations.dat
old mode 100755
new mode 100644
diff --git a/tools/bufr_exports/synop2bufr/station_list/make_synop2bufr_station.f b/tools/bufr_exports/synop2bufr/station_list/make_synop2bufr_station.f
old mode 100755
new mode 100644
diff --git a/tools/bufr_exports/synop2bufr/station_list/read_station.f b/tools/bufr_exports/synop2bufr/station_list/read_station.f
old mode 100755
new mode 100644
diff --git a/tools/bufr_exports/synop2bufr/station_list/wmo_make_station.f b/tools/bufr_exports/synop2bufr/station_list/wmo_make_station.f
old mode 100755
new mode 100644
diff --git a/tools/bufr_exports/synop2bufr/synop2bufr.f b/tools/bufr_exports/synop2bufr/synop2bufr.f
old mode 100755
new mode 100644
diff --git a/tools/bufrtools_wmo/CMakeLists.txt b/tools/bufrtools_wmo/CMakeLists.txt
index 7af654a..09f55eb 100644
--- a/tools/bufrtools_wmo/CMakeLists.txt
+++ b/tools/bufrtools_wmo/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 # configure Fortran-based targets for double precision (compilation & linking)
-set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${emos_double_precision_flags}")
+ecbuild_add_fortran_flags(${emos_double_precision_flags})
 
 
 # if( CMAKE_Fortran_COMPILER_ID MATCHES "GNU" )
@@ -51,8 +51,7 @@ list( APPEND bufrtools_bins_F90
   bufr_add_bias
   bufr_merg
   bufr_merge_tovs
-  bufr_simulate
-  grib2bufr )
+  bufr_simulate )
 
 list( APPEND bufrtools_bins_tracks
   tc_tracks
@@ -100,9 +99,17 @@ if( ENABLE_FORTRAN90 )
     ecbuild_add_executable(
       TARGET      ${tool}
       SOURCES     ${tool}.F90
+      CONDITION   HAVE_LIBEMOS_GRIBEX
       DEFINITIONS ${LIBEMOS_DEFINITIONS}
       LIBS        bufr_module my_exit emos )
   endforeach()
 
+  ecbuild_add_executable(
+      TARGET      grib2bufr
+      SOURCES     grib2bufr.F90
+      CONDITION   HAVE_LIBEMOS_GRIBEX
+      DEFINITIONS ${LIBEMOS_DEFINITIONS}
+      LIBS        my_exit emos )
+
 endif( ENABLE_FORTRAN90 )
 
diff --git a/tools/bufrtools_wmo/bufr_add_bias.F90 b/tools/bufrtools_wmo/bufr_add_bias.F90
index 06c27c6..080c4a4 100644
--- a/tools/bufrtools_wmo/bufr_add_bias.F90
+++ b/tools/bufrtools_wmo/bufr_add_bias.F90
@@ -274,6 +274,7 @@
          if(ksec1(7).eq.172) OSURF=.true.
          if(ksec1(7).eq.176) OSURF=.true.
          if(ksec1(7).eq.180) OSURF=.true.
+         if(ksec1(7).eq.181) OSURF=.true.
          if(ksec1(7).eq.182) OSURF=.true.
       end if
 !
diff --git a/tools/changeExpver/Makefile.hpca b/tools/changeExpver/Makefile.hpca
deleted file mode 100644
index 9bf0e7b..0000000
--- a/tools/changeExpver/Makefile.hpca
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-EMOSLIB = /home/ma/emos/lib/000200/libemos.R64.D64.I32.a
-CLIBS   = -lc
-#
-CC      = xlc_r
-CFLAGS  = -g -O3 -qstrict -q64 -qwarn64 -qarch=pwr3 -qtune=pwr3 -DINTEGER_IS_INT
-#
-changeExpver: changeExpver.c
-	$(CC) $(CFLAGS) -o changeExpver changeExpver.c $(EMOSLIB) $(CLIBS)
-
-chgrib: chgrib.c
-	$(CC) $(CFLAGS) -o chgrib chgrib.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm changeExpver chgrib *.o core
diff --git a/tools/changeExpver/Makefile.vpp b/tools/changeExpver/Makefile.vpp
deleted file mode 100644
index d5b2579..0000000
--- a/tools/changeExpver/Makefile.vpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-EMOSLIB = /home/ma/emos/lib/000220/libemos.R32.D64.I32.a
-#
-CC      = vcc
-CFLAGS  = -O -K3 -Keopt -Kpopt -Wv,-Ps -Wv,-m3
-#
-changeExpver: changeExpver.c
-	$(CC) $(CFLAGS) -o changeExpver changeExpver.c $(EMOSLIB)
-
-clean:
-	\rm changeExpver *.o core
diff --git a/tools/changeExpver/changeExpver.c b/tools/changeExpver/changeExpver.c
deleted file mode 100644
index d5a7a9d..0000000
--- a/tools/changeExpver/changeExpver.c
+++ /dev/null
@@ -1,105 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "fortint.h"
-
-#define BUFFLEN 1000000
-#define PADBUFFLEN 1000000
-#define OK 0
-#define ENDOFFILE -1
-#define BUFFERTOOSMALL -3
-
-#define ONEBYTEINT(a)   (fortint) ( *(a) )
-#define TWOBYTEINT(a)   (fortint) ( (*(a))<<8 | (*((a)+1))<<0 )
-#define THREEBYTEINT(a) (fortint) (TWOBYTEINT((a))<<8 | (*((a)+2))<<0 )
-#define FOURBYTEINT(a)  (fortint) (THREEBYTEINT((a))<<8 | (*((a)+3))<<0 )
-
-fortint readgrib( FILE * , char * ,fortint * );
-
-int main(int argc, char ** argv ) {
-FILE * inFile, * outFile;
-unsigned char * buffer;
-fortint bufsize = BUFFLEN;
-fortint loop, size, newlen, buflen, status, productNumber = 0;
-fortint lastGribEnd = 0, currentGribStart = 0;
-fortint paddingLength, currentGribLength;
-unsigned char paddingBuffer[PADBUFFLEN];
-
-  if( argc < 3) {
-    printf("Usage: changeExpver expver sourceFile targetFile\n");
-    exit(1);
-  }
-
-  if( (inFile = fopen(argv[2],"r")) == NULL ) {
-    printf("Problem opening file %s for reading\n",argv[2]);
-    exit(1);
-  }
-
-  if( (outFile = fopen(argv[3],"w")) == NULL ) {
-    printf("Problem opening file %s for reading\n",argv[3]);
-    exit(1);
-  }
-
-   buffer = (unsigned char *) malloc(bufsize);
-   if( buffer == NULL ) {
-    printf("Problem with malloc for GRIB buffer\n");
-    exit(1);
-  }
-
-  for( loop = 0; loop < PADBUFFLEN; loop++ ) paddingBuffer[loop] = '\0';
-
-  do {
-    lastGribEnd = ftell(inFile);
-    buflen = bufsize;
-    status = (fortint) readgrib(inFile,(char *)buffer,(fortint *)&buflen);
-
-    switch( status ) {
-
-      case OK:
-        productNumber++;
-        currentGribLength = THREEBYTEINT(&buffer[4]);
-        currentGribStart = ftell(inFile) - currentGribLength;
-        paddingLength = currentGribStart - lastGribEnd;
-        if( paddingLength ) {
-          size = fwrite(paddingBuffer,(size_t)1,(size_t)paddingLength,outFile);
-          if( size != paddingLength ) {
-            printf("Problem writing padding bytes to file %s\n", outFile);
-            exit(1);
-          }
-        }
-        memcpy(&buffer[53],argv[1],4);
-        size = fwrite(buffer, (size_t) 1, (size_t) buflen, outFile);
-        if( size != buflen ) {
-          printf("Problem writing to file %s\n", outFile);
-          exit(1);
-        }
-        break;
-
-      case ENDOFFILE:
-        currentGribStart = ftell(inFile);
-        paddingLength = currentGribStart - lastGribEnd;
-        if( paddingLength ) {
-          size = fwrite(paddingBuffer,(size_t)1,(size_t)paddingLength,outFile);
-          if( size != paddingLength ) {
-            printf("Problem writing padding bytes to file %s\n", outFile);
-            exit(1);
-          }
-        }
-        break;
-
-      case BUFFERTOOSMALL:
-        printf("Buffer too small\n");
-        exit(1);
-
-      default:
-        printf("Problem reading GRIB product; status = %d\n", status);
-        exit(1);
-
-    }
-
-  } while( status == 0 );
-
-  exit(0);
-
-}
diff --git a/tools/changeExpver/fortint.h b/tools/changeExpver/fortint.h
deleted file mode 100644
index a8752d0..0000000
--- a/tools/changeExpver/fortint.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef FORTINT_H
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#ifdef hpR64
-#define fortint long long
-#else
-#define fortint long
-#endif
-#endif
-
-#endif /* end of  FORTINT_H */
diff --git a/tools/changeExpver/makefile b/tools/changeExpver/makefile
deleted file mode 100644
index 4d6b27c..0000000
--- a/tools/changeExpver/makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-EMOSLIB = -lemos
-#
-CC      = cc
-CFLAGS  = -O2
-#
-changeExpver: changeExpver.c
-	$(CC) $(CFLAGS) -o changeExpver changeExpver.c $(EMOSLIB)
-
-chgrib: chgrib.c
-	$(CC) $(CFLAGS) -o chgrib chgrib.c $(EMOSLIB)
-
-clean:
-	\rm changeExpver chgrib *.o core
diff --git a/tools/changeGrib/Makefile b/tools/changeGrib/Makefile
deleted file mode 100644
index 366cf70..0000000
--- a/tools/changeGrib/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-EMOSLIB = -lemos
-#
-CC      = cc
-CFLAGS  = -O2
-#
-changeGrib: changeGrib.c
-	$(CC) $(CFLAGS) -o changeGrib changeGrib.c $(EMOSLIB)
-
-clean:
-	\rm changeGrib *.o core
diff --git a/tools/changeGrib/Makefile.vpp b/tools/changeGrib/Makefile.vpp
deleted file mode 100644
index dd69fce..0000000
--- a/tools/changeGrib/Makefile.vpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-EMOSLIB = -L/home/ma/emos/lib/000090 -lemos.R32.D64.I32
-#
-CC      = vcc
-CFLAGS  = -O -K3 -Keopt -Kpopt -Wv,-Ps -Wv,-m3
-#
-changeGrib: changeGrib.c
-	$(CC) $(CFLAGS) -o changeGrib changeGrib.c $(EMOSLIB)
-
-clean:
-	\rm changeGrib *.o core
diff --git a/tools/changeGrib/changeGrib.c b/tools/changeGrib/changeGrib.c
deleted file mode 100644
index 56574f6..0000000
--- a/tools/changeGrib/changeGrib.c
+++ /dev/null
@@ -1,395 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define SECTION0 8
-
-#define TABLE2 1
-#define TABLE2OCTET SECTION0+3
-#define CENTRE 2
-#define CENTREOCTET SECTION0+4
-#define GENPID 3
-#define GENPIDOCTET SECTION0+5
-#define GRID 4
-#define GRIDOCTET SECTION0+6
-#define PARAM 6
-#define PARAMOCTET SECTION0+8
-#define LEVELIND 7
-#define LEVELINDOCTET SECTION0+9
-#define LEVEL1 8
-#define LEVEL1OCTET SECTION0+10
-#define LEVEL2 9
-#define LEVEL2OCTET SECTION0+11
-#define YEAR 10
-#define YEAROCTET SECTION0+12
-#define MONTH 11
-#define MONTHOCTET SECTION0+13
-#define DAY 12
-#define DAYOCTET SECTION0+14
-#define HOUR 13
-#define HOUROCTET SECTION0+15
-#define MINUTE 14
-#define MINUTEOCTET SECTION0+16
-#define TIMEUNIT 15
-#define TIMEUNITOCTET SECTION0+17
-#define TIME1 16
-#define TIME1OCTET SECTION0+18
-#define TIME2 17
-#define TIME2OCTET SECTION0+19
-#define TIMERANGE 18
-#define TIMERANGEOCTET SECTION0+20
-#define NUMINAV 19
-#define NUMINAVOCTET SECTION0+21
-#define NUMMISSING 20
-#define NUMMISSINGOCTET SECTION0+23
-#define CENTURY 21
-#define CENTURYOCTET SECTION0+24
-#define SUBCENTRE 22
-#define SUBCENTREOCTET SECTION0+25
-#define DECSCALE 23
-#define DECSCALEOCTET SECTION0+26
-#define LOCALUSE 37
-#define LOCALUSEOCTET SECTION0+40
-#define CLASS 38
-#define CLASSOCTET SECTION0+41
-#define TYPE 39
-#define TYPEOCTET SECTION0+42
-#define STREAM 40
-#define STREAMOCTET SECTION0+43
-#define EXPVER 41
-#define EXPVEROCTET SECTION0+45
-
-#define BUFFLEN 1000000
-#define OK 0
-#define ENDOFFILE -1
-#define BUFFERTOOSMALL -3
-
-typedef struct Changes {
-  int * types;
-  int * values;
-  int numberOfValues;
-} Changes;
-
-
-void patchHeader(unsigned char *, Changes *);
-int readChanges(FILE * , Changes ** );
-long readgrib( FILE * , unsigned char * ,long * );
-
-
-int main( int argc, char ** argv ) {
-FILE * changeList, * sourceFile, * targetFile;
-int status;
-Changes * changes = NULL;
-unsigned char * buffer;
-long size, position, buflen, bufsize = BUFFLEN;
-
-  if(argc < 4 ) {
-    printf("\nUsage: changeGrib changeList sourceFile targetFile\n");
-    printf("changeList is formattted as a Fortran-style NAMELIST\n\n");
-    printf("  &USHEAD\n");
-    printf("    IUSEC1(10)=99,\n");
-    printf("    IUSEC1(11)=12,\n");
-    printf("    IUSEC1(12)=25,\n");
-    printf("    IUSEC1(13)=23,\n");
-    printf("    IUSEC1(41)=jdc1,\n");
-    printf(" /\n");
-
-    exit(1);
-  }
-
-  if( (changeList = fopen(argv[1],"r")) == NULL ) {
-    printf("Problem opening file %s for reading\n",argv[1]);
-    exit(1);
-  }
-/*
-// Read required changes
-*/
-  status = readChanges(changeList, &changes);
-  if( status != 0 ) {
-    printf("Problem reading required changes from file %s\n",argv[1]);
-    exit(1);
-  }
-
-  if( ( sourceFile = fopen(argv[2],"r")) == NULL ) {
-    printf("Problem opening file %s for reading\n",argv[2]);
-    exit(1);
-  }
-
-  if( (targetFile = fopen(argv[3],"w")) == NULL ) {
-    printf("Problem opening file %s for writing\n",argv[3]);
-    exit(1);
-  }
-/*
-// Allocate buffer for reading GRIB products
-*/
-   buffer = (unsigned char *) malloc(bufsize);
-   if( buffer == NULL ) {
-    printf("Problem with malloc for GRIB buffer\n");
-    exit(1);
-  }
-
-/*
-// Loop through GRIB products:
-//  - read GRIB from sourceFile
-//  - patch section 1
-//  - write GRIB to targetFile
-*/
-
-  do {
-    buflen = bufsize;
-    position = ftell(sourceFile);
-    status = (int) readgrib(sourceFile,buffer,&buflen);
-
-    switch( status ) {
-
-      case OK:
-
-        {unsigned char * p = buffer+SECTION0;
-         int length = ((*p)<<16) + (*(p+1)<<8) + (*(p+2));
-
-         if( length < 29 ) {
-           printf("GRIB is not using an ECMWF local definition\n");
-           exit(1);
-         }
-        }
-
-        patchHeader(buffer,changes);
-        size = fwrite(buffer, (size_t) 1, (size_t) buflen, targetFile);
-        if( size != buflen ) {
-          printf("Problem writing to file %s\n", argv[3]);
-          exit(1);
-        }
-        break;
-
-      case ENDOFFILE:
-        break;
-
-      case BUFFERTOOSMALL:
-        bufsize *= 10;
-        buffer = (unsigned char *) realloc(buffer,(size_t) bufsize);
-        buflen = bufsize;
-        status = fseek(sourceFile,position,0);
-        if( status < 0 ) {
-          perror("Error repositioning file");
-          exit(1);
-        }
-        status = (int) readgrib(sourceFile,buffer,&buflen);
-        if( status == BUFFERTOOSMALL ) {
-          printf("Buffer size still too small at %d bytes\n",bufsize);
-          exit(1);
-        }
-
-        {unsigned char * p = buffer+SECTION0;
-         int length = ((*p)<<16) + (*(p+1)<<8) + (*(p+2));
-
-         if( length < 29 ) {
-           printf("GRIB is not using an ECMWF local definition\n");
-           exit(1);
-         }
-        }
-
-        patchHeader(buffer,changes);
-        size = fwrite(buffer, (size_t) 1, (size_t) buflen, targetFile);
-        if( size != buflen ) {
-          patchHeader(buffer,changes);
-          size = fwrite(buffer, (size_t) 1, (size_t) buflen, targetFile);
-          if( size != buflen ) {
-            printf("Problem writing to file %s\n", argv[3]);
-            exit(1);
-          }
-        }
-        break;
-
-      default:
-        printf("Problem reading GRIB product; status = %d\n", status);
-        exit(1);
-
-    }
-
-  } while( status == 0 );
-
-/*
-// That's all
-*/
-/*
-??free(&(changes->types));
-??free(&(changes->values));
-*/
-  free(changes);
-  fclose(sourceFile);
-  fclose(targetFile);
-
-}
-
-int readChanges(FILE * changeList, Changes ** realChanges) {
-char line[80], expver[5];
-int type, value;
-Changes * changes;
-
-  fscanf(changeList,"%s",line);
-  if( strcmp(line,"&USHEAD") != 0 ) {
-    printf("changeList does not start with &USHEAD\n");
-    return 1;
-  }
-
-  changes = (Changes *) malloc(sizeof(Changes));
-  changes->numberOfValues = 0;
-  changes->types = NULL;
-  changes->values  = NULL;
-
-  do {
-    fscanf(changeList,"%s",line);
-    if( strcmp(line,"/") != 0 ) {
-      sscanf(line,"IUSEC1(%d)=%d,",&type,&value);
-
-      changes->numberOfValues++;
-      changes->types =
-        (int *) realloc(changes->types,changes->numberOfValues*sizeof(int));
-      changes->types[changes->numberOfValues-1] = type;
-
-      changes->values =
-        (int *) realloc(changes->values,changes->numberOfValues*sizeof(int));
-
-      if( type == EXPVER ) {
-        sscanf(line,"IUSEC1(%d)=%s,",&type,expver);
-        memcpy(&(changes->values[changes->numberOfValues-1]),expver,4);
-      }
-      else
-        changes->values[changes->numberOfValues-1]  = value;
-
-    }
-  } while( !feof(changeList) );
-
-  fclose(changeList);
-  *realChanges = changes;
-  return 0;
-}
-
-void patchHeader(unsigned char * buffer, Changes * changes) {
-int next, value;
-
-  for( next = 0; next < (changes->numberOfValues); next++ ) {
-    switch( changes->types[next] ) {
-
-      case YEAR:
-        buffer[YEAROCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case MONTH:
-        buffer[MONTHOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case DAY:
-        buffer[DAYOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case HOUR:
-        buffer[HOUROCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case MINUTE:
-        buffer[MINUTEOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case CENTURY:
-        buffer[CENTURYOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TABLE2:
-        buffer[TABLE2OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case CENTRE:
-        buffer[CENTREOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case GENPID:
-        buffer[GENPIDOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case GRID:
-        buffer[GRIDOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case PARAM:
-        buffer[PARAMOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case LEVELIND:
-        buffer[LEVELINDOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case LEVEL1:
-        buffer[LEVEL1OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case LEVEL2:
-        buffer[LEVEL2OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIMEUNIT:
-        buffer[TIMEUNITOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIME1:
-        buffer[TIME1OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIME2:
-        buffer[TIME2OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIMERANGE:
-        buffer[TIMERANGEOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case NUMINAV:
-        value = changes->values[next];
-        buffer[NUMINAVOCTET] = (unsigned char) ( (value >> 8 ) & 0xff);
-        buffer[NUMINAVOCTET+1] = (unsigned char) ( value & 0xff);
-        break;
-
-      case NUMMISSING:
-        buffer[NUMMISSINGOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case SUBCENTRE:
-        buffer[SUBCENTREOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case DECSCALE:
-        value = changes->values[next];
-        buffer[DECSCALEOCTET] = (unsigned char) ( (value >> 8 ) & 0xff);
-        buffer[DECSCALEOCTET+1] = (unsigned char) ( value & 0xff);
-        break;
-
-      case LOCALUSE:
-/*
-//      buffer[LOCALUSEOCTET] = (unsigned char) changes->values[next];
-*/
-        printf("Not allowed to change ECMWF local usage definition number\n");
-        break;
-
-      case CLASS:
-        buffer[CLASSOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TYPE:
-        buffer[TYPEOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case STREAM:
-        value = changes->values[next];
-        buffer[STREAMOCTET] = (unsigned char) ( (value >> 8 ) & 0xff);
-        buffer[STREAMOCTET+1] = (unsigned char) ( value & 0xff);
-        break;
-
-      case EXPVER:
-        memcpy(&buffer[EXPVEROCTET],&(changes->values[next]),4);
-        break;
-
-    }
-
-  }
-  return;
-}
diff --git a/tools/changeStream/Makefile.hpca b/tools/changeStream/Makefile.hpca
deleted file mode 100644
index 0f3a2f4..0000000
--- a/tools/changeStream/Makefile.hpca
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-EMOSLIB = /home/ma/emos/lib/000200/libemos.R64.D64.I32.a
-CLIBS   = -lc
-#
-CC      = xlc_r
-CFLAGS  = -g -O3 -qstrict -q64 -qwarn64 -qarch=pwr3 -qtune=pwr3 -DINTEGER_IS_INT
-#
-changeStream: changeStream.c
-	$(CC) $(CFLAGS) -o changeStream changeStream.c $(EMOSLIB) $(CLIBS)
-
-changeExpver: changeExpver.c
-	$(CC) $(CFLAGS) -o changeExpver changeExpver.c $(EMOSLIB) $(CLIBS)
-
-chgrib: chgrib.c
-	$(CC) $(CFLAGS) -o chgrib chgrib.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm  changeStream changeExpver chgrib *.o core
diff --git a/tools/changeStream/changeStream.c b/tools/changeStream/changeStream.c
deleted file mode 100644
index 387522f..0000000
--- a/tools/changeStream/changeStream.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "fortint.h"
-#include "movebytes.h"
-
-#define BUFFLEN 1000000
-#define PADBUFFLEN 1000000
-#define OK 0
-#define ENDOFFILE -1
-#define BUFFERTOOSMALL -3
-
-#define ONEBYTEINT(a)   (fortint) ( *(a) )
-#define TWOBYTEINT(a)   (fortint) ( (*(a))<<8 | (*((a)+1))<<0 )
-#define THREEBYTEINT(a) (fortint) (TWOBYTEINT((a))<<8 | (*((a)+2))<<0 )
-#define FOURBYTEINT(a)  (fortint) (THREEBYTEINT((a))<<8 | (*((a)+3))<<0 )
-
-fortint readgrib( FILE * , char * ,fortint * );
-
-int main(int argc, char ** argv ) {
-FILE * inFile, * outFile;
-unsigned char * buffer;
-fortint bufsize = BUFFLEN;
-fortint loop, size, newlen, buflen, status, productNumber = 0, stream;
-fortint lastGribEnd = 0, currentGribStart = 0;
-fortint paddingLength, currentGribLength;
-unsigned char paddingBuffer[PADBUFFLEN];
-
-  if( argc < 3) {
-    printf("Usage: changeStream stream sourceFile targetFile\n");
-    exit(1);
-  }
-
-  if( (inFile = fopen(argv[2],"r")) == NULL ) {
-    printf("Problem opening file %s for reading\n",argv[2]);
-    exit(1);
-  }
-
-  if( (outFile = fopen(argv[3],"w")) == NULL ) {
-    printf("Problem opening file %s for reading\n",argv[3]);
-    exit(1);
-  }
-
-   buffer = (unsigned char *) malloc(bufsize);
-   if( buffer == NULL ) {
-    printf("Problem with malloc for GRIB buffer\n");
-    exit(1);
-  }
-
-  for( loop = 0; loop < PADBUFFLEN; loop++ ) paddingBuffer[loop] = '\0';
-
-  stream = atol(argv[1]);
-
-  do {
-    lastGribEnd = ftell(inFile);
-    buflen = bufsize;
-    status = (fortint) readgrib(inFile,(char *)buffer,(fortint *)&buflen);
-
-    switch( status ) {
-
-      case OK:
-        productNumber++;
-        currentGribLength = THREEBYTEINT(&buffer[4]);
-        currentGribStart = ftell(inFile) - currentGribLength;
-        paddingLength = currentGribStart - lastGribEnd;
-        if( paddingLength ) {
-          size = fwrite(paddingBuffer,(size_t)1,(size_t)paddingLength,outFile);
-          if( size != paddingLength ) {
-            printf("Problem writing padding bytes to file %s\n", outFile);
-            exit(1);
-          }
-        }
-        MOVE2BYTES(&buffer[51],&stream);
-        size = fwrite(buffer, (size_t) 1, (size_t) buflen, outFile);
-        if( size != buflen ) {
-          printf("Problem writing to file %s\n", outFile);
-          exit(1);
-        }
-        break;
-
-      case ENDOFFILE:
-        currentGribStart = ftell(inFile);
-        paddingLength = currentGribStart - lastGribEnd;
-        if( paddingLength ) {
-          size = fwrite(paddingBuffer,(size_t)1,(size_t)paddingLength,outFile);
-          if( size != paddingLength ) {
-            printf("Problem writing padding bytes to file %s\n", outFile);
-            exit(1);
-          }
-        }
-        break;
-
-      case BUFFERTOOSMALL:
-        printf("Buffer too small\n");
-        exit(1);
-
-      default:
-        printf("Problem reading GRIB product; status = %d\n", status);
-        exit(1);
-
-    }
-
-  } while( status == 0 );
-
-  exit(0);
-
-}
diff --git a/tools/changeStream/fortint.h b/tools/changeStream/fortint.h
deleted file mode 100644
index a8752d0..0000000
--- a/tools/changeStream/fortint.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef FORTINT_H
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#ifdef hpR64
-#define fortint long long
-#else
-#define fortint long
-#endif
-#endif
-
-#endif /* end of  FORTINT_H */
diff --git a/tools/changeStream/movebytes.h b/tools/changeStream/movebytes.h
deleted file mode 100644
index 37e7478..0000000
--- a/tools/changeStream/movebytes.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef MOVEBYTES_H
-#define MOVEBYTES_H
-
-#define MOVE2BYTES(p,n) ( *(p)     = ((*(n)>> 8) & 0xFF) ) , \
-                        ( *((p)+1) = ((*(n)>> 0) & 0xFF) )
-
-#endif /* MOVEBYTES_H */
diff --git a/tools/compareGribFiles/Makefile.FUJITSU b/tools/compareGribFiles/Makefile.FUJITSU
deleted file mode 100755
index 6d52af4..0000000
--- a/tools/compareGribFiles/Makefile.FUJITSU
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-EMOSLIB= -L/home/ma/emos/lib/$(EMOS_CYCLE) -lemos.R64.D64.I32
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-CLIBS   = -lm -lc /usr/lang/lib/libcvp.a
-#
-.SUFFIXES: .o .c .F
-#
-PLATFORM_DEFINES_FORTRAN = -Wp,"-DFUJITSU" -Wp,"-D__uxp__"
-PLATFORM_DEFINES_C = -DFUJITSU -D__uxp__
-#
-FC      = frt
-FFLAGS = -X9 -Aabd -Oe,-E,-P,-U -Sw -Wp,"-DREAL_8" -Wp,"-DREAL_BIGGER_THAN_INTEGER" $(PLATFORM_DEFINES_FORTRAN)
-#
-CC      = vcc
-CFLAGS = -K 3 -Wv,-Ps -c -Wv,-m3 -DREAL_8=1 -DPOINTER_64 -DINTEGER_IS_INT $(PLATFORM_DEFINES_C)
-#
-.F.o:
-	rm -f $@
-	$(FC) $(FFLAGS) -c $<
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.VPP5000 b/tools/compareGribFiles/Makefile.VPP5000
deleted file mode 100755
index b403e41..0000000
--- a/tools/compareGribFiles/Makefile.VPP5000
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-EMOSLIB= -L/home/ma/emos/lib/$(EMOS_CYCLE) -lemos.R64.D64.I32
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-CLIBS   = -lm -lc
-#
-.SUFFIXES: .o .c .F
-#
-PLATFORM_DEFINES_FORTRAN = -Wp,"-DFUJITSU" -Wp,"-D__uxp__"
-PLATFORM_DEFINES_C = -DFUJITSU -D__uxp__
-#
-FC      = frt
-FFLAGS = -X9 -Aabd -Oe,-E,-P,-U -Sw -Wp,"-DPOINTER_64" -Wp,"-DREAL_8=1" -Wp,"-DINTEGER_IS_INT" -Wp,"-DREAL_BIGGER_THAN_INTEGER" $(PLATFORM_DEFINES_FORTRAN)
-#
-CC      = cc
-CFLAGS  = -K 3 -Wv,-Ps -c -Wv,-m3 -DREAL_8=1 -DPOINTER_64 -DINTEGER_IS_INT $(PLATFORM_DEFINES_C)
-#
-.F.o:
-	rm -f $@
-	$(FC) $(FFLAGS) -c $<
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.cluster b/tools/compareGribFiles/Makefile.cluster
deleted file mode 100755
index 815afc5..0000000
--- a/tools/compareGribFiles/Makefile.cluster
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# This is old path for libemos
-#EMOSLIB= -L/home/ma/emos/lib/linux/$(EMOS_CYCLE) -lemos.R64.D64.I32
-
-EMOSLIB= -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = $(DEBUG) -m32 -DREAL_8 -Dlinux -DFOPEN64
-#CFLAGS  = $(DEBUG) -DREAL_8
-FASTCFLAGS = $(CFLAGS)
-#
-FC      = pgf90
-FFLAGS =  $(DEBUG) -tp px -i4 -r8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER $(USE_NO_POINTERS)
-#
-.F.o:
-	rm -f $@
-	$(FC) $(FFLAGS) -c $<
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.clusterA64 b/tools/compareGribFiles/Makefile.clusterA64
deleted file mode 100755
index 70512f2..0000000
--- a/tools/compareGribFiles/Makefile.clusterA64
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# This is old path for libemos
-#EMOSLIB= -L/home/ma/emos/lib/linux/$(EMOS_CYCLE) -lemos.R64.D64.I32
-
-EMOSLIB= -L/usr/local/lib64/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = $(DEBUG) -m64 -DREAL_8 -Dlinux -DFOPEN64
-#CFLAGS  = $(DEBUG) -DREAL_8
-FASTCFLAGS = $(CFLAGS)
-#
-FC      = pgf90
-FFLAGS =  $(DEBUG) -tp k8-64 -i4 -r8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER $(USE_NO_POINTERS)
-#
-.F.o:
-	rm -f $@
-	$(FC) $(FFLAGS) -c $<
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.hpia64 b/tools/compareGribFiles/Makefile.hpia64
deleted file mode 100755
index 49e3614..0000000
--- a/tools/compareGribFiles/Makefile.hpia64
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-#EMOSLIB= /home/ma/emos/lib/hpia64/$(EMOS_CYCLE)/libemos.R32.D64.I32.a
-
-EMOSLIB= /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I64.a
-
-LIBS= +U77
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CPPFLAGS = -Dhp
-#
-CC      = cc
-CFLAGS  =  +DD64 -Ae -D_XPG2 -Dhp -DhpiaR64 -DREAL_8 -DINTEGER_8 -DPOINTER_64 +Z -O
-
-FASTCFLAGS = $(CFLAGS)
-#
-FC      = /opt/fortran90/bin/f90
-FFLAGS  = +DD64  +autodbl $(DEBUG) +pic=long +real_constant=double
-#
-LDFLAGS = -Wl,-B,immediate,-B,nonfatal,+s +s -L . -l emos
-#
-.F.o:
-	/usr/ccs/lbin/cpp -P $(CPPFLAGS) $< > $*.f
-	$(FC) $(FFLAGS) -c $*.f
-	\rm -f $*.f
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB) $(LIBS)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.hppa b/tools/compareGribFiles/Makefile.hppa
deleted file mode 100755
index c42bad0..0000000
--- a/tools/compareGribFiles/Makefile.hppa
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-EMOSLIB= /home/ma/emos/lib/hppa/$(EMOS_CYCLE)/libemos.R32.D64.I32.a
-#LIBS= /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/libg2c.a
-LIBS= +U77
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CPPFLAGS = -Dhp
-#
-CC      = cc
-CFLAGS  = -Aa -D_INCLUDE_HPUX_SOURCE -D_INCLUDE_XOPEN_SOURCE \
--D_INCLUDE_AES_SOURCE -D_INCLUDE_POSIX_SOURCE -D_XPG2 \
--DFORTRAN_NO_UNDERSCORE -Dhp +z -O +DAportable
-FASTCFLAGS = -Aa -D_INCLUDE_HPUX_SOURCE -D_INCLUDE_XOPEN_SOURCE \
--D_INCLUDE_AES_SOURCE -D_INCLUDE_POSIX_SOURCE -D_XPG2 \
--DFORTRAN_NO_UNDERSCORE -Dhp +z -O +DAportable
-#
-#FC      = fort77
-#FFLAGS  = +z +U77 +O2 +R -V +T -w66 -Dhp
-#FC      = f77
-FC      = /opt/fortran/bin/f77
-FFLAGS  = +z +U77 +O2 +T -w66 -Dhp +FPD +DAportable
-#
-LDFLAGS = -Wl,-B,immediate,-B,nonfatal,+s +s -L . -l emos
-#
-.F.o:
-	/usr/ccs/lbin/cpp -P $(CPPFLAGS) $< > $*.f
-	$(FC) $(FFLAGS) -c $*.f
-	\rm -f $*.f
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB) $(LIBS)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.ibm_power4 b/tools/compareGribFiles/Makefile.ibm_power4
deleted file mode 100755
index 45d0028..0000000
--- a/tools/compareGribFiles/Makefile.ibm_power4
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-#EMOSLIB= -L/home/ma/emos/lib/$(EMOS_CYCLE) -lemos.R64.D64.I32
-
-EMOSLIB= -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-FC      = xlf90_r
-CPPFLAGS=-DREAL_BIGGER_THAN_INTEGER,-DREAL_8,-DIBM,-Drs6000,-DPOINTER_64,-DINTEGER_IS_INT,-DIBM_POWER4,-DSHAREDMEMORY,-DFOPEN64
-
-FFLAGS  = -g -qsigtrap -O3 -qstrict -q64 -qextname -qarch=pwr4 -qtune=pwr4 -qwarn64 -qrealsize=8 -qintsize=4 -qalign=4k -qsource -qflttrap=overflow:zerodivide:invalid:enable:imprecise -qfixed=72 -qintlog
-#
-CC      = xlc_r
-CFLAGS  = -g -O3 -qstrict -q64 -qwarn64 -qarch=pwr3 -qtune=pwr3 -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DIBM -DIBM_POWER4 -Drs6000 -DPOINTER_64 -DINTEGER_IS_INT -DSHAREDMEMORY -DFOPEN64
-#
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-.F.o:
-	$(FC) -WF,$(CPPFLAGS) $(FFLAGS) -c $*.F
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-#	$(FC) -WF,$(CPPFLAGS) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-
-try: try.F $(OBJS)
-	$(FC) -WF,$(CPPFLAGS) $(FFLAGS) -o try try.F $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf try compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.linux b/tools/compareGribFiles/Makefile.linux
deleted file mode 100755
index 28340ec..0000000
--- a/tools/compareGribFiles/Makefile.linux
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# This is old path for libemos
-#EMOSLIB= -L/home/ma/emos/lib/linux/$(EMOS_CYCLE) -lemos.R64.D64.I32
-
-EMOSLIB= -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-CC      = gcc
-CFLAGS  = $(DEBUG) -DREAL_8 -Dlinux -DFOPEN64
-#CFLAGS  = $(DEBUG) -DREAL_8
-FASTCFLAGS = $(CFLAGS)
-#
-FC      = pgf90
-FFLAGS =  $(DEBUG) -i4 -r8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER $(USE_NO_POINTERS)
-#
-.F.o:
-	rm -f $@
-	$(FC) $(FFLAGS) -c $<
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.rs6000 b/tools/compareGribFiles/Makefile.rs6000
deleted file mode 100755
index c4b78d2..0000000
--- a/tools/compareGribFiles/Makefile.rs6000
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-#EMOSLIB= -L/home/ma/emos/lib/rs6000/$(EMOS_CYCLE) -lemos.R64.D64.I32
-
-EMOSLIB = /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I32.a
-
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-FC     = xlf
-FFLAGS = -qrealsize=8 -qintsize=4 -qalign=4k -qnosource
-#
-CC     = cc
-CFLAGS = -DFORTRAN_NO_UNDERSCORE -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DIBM -Drs6000 -DFOPEN64
-#
-.F.o:
-	- cc $(CFLAGS) -P -C -c $<
-	mv $*.i $*.f 
-	$(FC) $(FFLAGS) -qintlog -c $*.f
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/Makefile.sgimips b/tools/compareGribFiles/Makefile.sgimips
deleted file mode 100755
index 10ca8ff..0000000
--- a/tools/compareGribFiles/Makefile.sgimips
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-EMOSLIB= -L/home/ma/emos/lib/sgimips_n32/$(EMOS_CYCLE) -lemosDebug.R64.D64.I32
-SRCS.F = 
-OBJS.F = $(SRCS.F:.F=.o)
-SRCS.c = jdcexit.c PBXroutines.c jmemcmp.c
-OBJS.c = $(SRCS.c:.c=.o)
-OBJS   = $(OBJS.F) $(OBJS.c)
-#
-.SUFFIXES: .o .c .F
-#
-FC     = f77
-FFLAGS = -g -r8 -align64
-#
-CC     = cc
-CFLAGS = -g -DREAL_8
-#
-.F.o:
-	rm -f $@
-	$(FC) $(FFLAGS) -c $<
-.c.o:
-	rm -f $@
-	$(CC) $(CFLAGS) -c $<
-
-compareGribFiles: compareGribFiles.F $(OBJS)
-	$(FC) $(FFLAGS) -o compareGribFiles compareGribFiles.F $(OBJS) $(EMOSLIB)
-
-clean:
-	\rm -rf compareGribFiles.o compareGribFiles $(OBJS) core
diff --git a/tools/compareGribFiles/PBGroutines.c b/tools/compareGribFiles/PBGroutines.c
deleted file mode 100755
index f0464af..0000000
--- a/tools/compareGribFiles/PBGroutines.c
+++ /dev/null
@@ -1,2545 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "PBGroutines.h"
-
-#ifdef gribAPI
-long date_to_Julian(long ddate);
-long Julian_to_date(long jdate);
-#else
-long date_to_julian(long ddate);
-long julian_to_date(long jdate);
-#endif
-
-integer pbginitInput(_fcd filename, fortint filename_len);
-integer pbginitOutput(_fcd filename, fortint filename_len);
-void copyName(_fcd * , _fcd , fortint );
-
-fortint readgrib(FILE * file, unsigned char * buffer, fortint * prod_len);
-
-void pbgindx(fortint);
-
-void gribdata( unsigned char * header,
-               integer number_of_fields,
-               integer * parameter,
-               integer * level,
-               integer * date,
-               integer * time,
-               integer * timestep,
-               integer * localDefinitionNumber,
-               integer * type,
-               integer * stream,
-               integer * repres,
-               integer * levtype,
-               integer * number,
-               integer * vdate,
-               integer * vtime,
-               integer * tcNumber,
-               integer * tcTotal,
-               integer * clusterMethod,
-               integer * tcStep,
-               integer * clusterStepEnd,
-               integer * tcNorth,
-               integer * tcWest,
-               integer * tcSouth,
-               integer * tcEast,
-               integer * clusterOpFcNumber,
-               integer * clusterControlFcNumber,
-               integer * tcNumOfFcs,
-               integer * probScale,
-               integer * probIndicator,
-               integer * probLower,
-               integer * probUpper,
-               integer * ni,
-               integer * nj,
-               integer * nlat,
-               integer * nlon,
-               integer * slat,
-               integer * slon,
-               integer * di,
-               integer * dj,
-               integer * splat,
-               integer * splon,
-               integer * quasi,
-               integer * directionNumber,
-               integer * frequencyNumber,
-               integer * optimisationTime,
-               integer * leadTime,
-               integer * sensitiveAreaDomain,
-               integer * sensitiveAreaMethod,
-               integer * verifyingMonth,
-               integer * averagingPeriod,
-               integer * forecastMonth,
-               integer * referenceDate,
-               integer * climateDateFrom,
-               integer * climateDateTo,
-               integer * thresholdUnitsScale,
-               integer * thresholdIndicator,
-               integer * lowerThreshold,
-               integer * upperThreshold
-             );
-
-static gribfile * latestFile(collection);
-static gribfile * currentFile(collection, integer);
-
-/*
-// 
-*/
-#define DEBUGOFF 1
-#define DEBUG1 (debugSet > DEBUGOFF )
-#define DEBUG2 (debugSet > (DEBUGOFF + 1) )
-static char * debugLevel;
-static int debugSet = 0;
-
-#define ONEBYTELONG(a)   (long) ( *(a) )
-#define TWOBYTELONG(a)   (long) ( (*(a))<<8 | (*((a)+1))<<0 )
-#define THREEBYTELONG(a) (long) (TWOBYTELONG((a))<<8 | (*((a)+2))<<0 )
-#define FOURBYTELONG(a)  (long) (THREEBYTELONG((a))<<8 | (*((a)+3))<<0 )
-
-#define MISSING -1
-#define NOTGIVEN(x) ((x) == MISSING )
-#define MATCH(a,b)  (NOTGIVEN((a)) || ((a) == (b)))
-
-#define HEADLEN 10000
-
-integer exists(_fcd , fortint );
-integer addRead(_fcd , fortint );
-integer addWrite(_fcd , fortint );
-void removeFile(_fcd , fortint );
-
-collection openFiles = {exists,addRead,addWrite,removeFile,-1,-1,NULL};
-
-void pbgindx(fortint thisFile) {
-/*
-// Fills in details of current file
-*/
-unsigned char header[HEADLEN];
-fortint status;
-fortint headerlen;
-OFF_T space;
-integer number_of_fields = 0;
-gribfile * file = currentFile(openFiles,thisFile);
-
-/*
-// Loop through products in the file
-*/
-  file->offset[0] = 0;
-  do {
-    headerlen = HEADLEN;
-    status = readgrib( file->fp, header, &headerlen);
-
-/*
-// Accept product if OK or if only problem is 'buffer too small' or
-// on EOF
-*/
-    if( (status!=0) && (status!=-3) && (status!=-1) ) exit(1);
-    if( status == -1 ) break;
-
-/*
-// Note the product byte offset in the file
-*/
-    file->length[number_of_fields] = (integer) headerlen;
-#ifdef FOPEN64
-    file->offset[number_of_fields] =
-      (OFF_T) ftello64(file->fp) - (OFF_T) file->length[number_of_fields];
-#else
-    file->offset[number_of_fields] =
-      (OFF_T) ftell(file->fp) - file->length[number_of_fields];
-#endif
-
-/*
-// If it's a GRIB edition 1 product, pick up more information
-// (parameter,level,..)
-*/
-    if( strncmp((char *)header,"GRIB", 4)==0 ) {
-/*
-//    Eliminate GRIB editions 0 and -1
-*/
-      if( (header[ 7] != '\1') ) break;
-      if( (header[19] == '\0') && (header[20] == '\0') &&
-          (header[21] == '\0') && (header[22] == '\0') &&
-          (header[23] == '\0') ) break;
-
-      gribdata( header,
-                number_of_fields,
-                file->parameter,
-                file->level,
-                file->date,
-                file->time,
-                file->timestep,
-                file->localDefinitionNumber,
-                file->type,
-                file->stream,
-                file->repres,
-                file->levtype,
-                file->number,
-                file->vdate,
-                file->vtime,
-                file->tcNumber,
-                file->tcTotal,
-                file->clusterMethod,
-                file->tcStep,
-                file->clusterStepEnd,
-                file->tcNorth,
-                file->tcWest,
-                file->tcSouth,
-                file->tcEast,
-                file->clusterOpFcNumber,
-                file->clusterControlFcNumber,
-                file->tcNumOfFcs,
-                file->probScale,
-                file->probIndicator,
-                file->probLower,
-                file->probUpper,
-                file->ni,
-                file->nj,
-                file->nlat,
-                file->nlon,
-                file->slat,
-                file->slon,
-                file->di,
-                file->dj,
-                file->splat,
-                file->splon,
-                file->quasi,
-                file->directionNumber,
-                file->frequencyNumber,
-                file->optimisationTime,
-                file->leadTime,
-                file->sensitiveAreaDomain,
-                file->sensitiveAreaMethod,
-                file->verifyingMonth,
-                file->averagingPeriod,
-                file->forecastMonth,
-                file->referenceDate,
-                file->climateDateFrom,
-                file->climateDateTo,
-                file->thresholdUnitsScale,
-                file->thresholdIndicator,
-                file->lowerThreshold,
-                file->upperThreshold
-              );
-
-#define REALLOC(a) (a)  =  realloc((a) , (size_t) space)
-
-      number_of_fields++;
-      if( number_of_fields == file->max ) {
-        integer newSize = (file->max)*2;
-        file->max = newSize;
-
-        space = (OFF_T) (sizeof(OFF_T)*newSize);
-        REALLOC(file->offset);
-
-        space = (OFF_T) (sizeof(integer)*newSize);
-        REALLOC(file->length);
-        REALLOC(file->parameter);
-        REALLOC(file->level);
-        REALLOC(file->date);
-        REALLOC(file->time);
-        REALLOC(file->timestep);
-        REALLOC(file->localDefinitionNumber);
-        REALLOC(file->type);
-        REALLOC(file->stream);
-        REALLOC(file->repres);
-        REALLOC(file->levtype);
-        REALLOC(file->number);
-        REALLOC(file->vdate);
-        REALLOC(file->vtime);
-        REALLOC(file->tcNumber);
-        REALLOC(file->tcTotal);
-        REALLOC(file->clusterMethod);
-        REALLOC(file->tcStep);
-        REALLOC(file->clusterStepEnd);
-        REALLOC(file->tcNorth);
-        REALLOC(file->tcWest);
-        REALLOC(file->tcSouth);
-        REALLOC(file->tcEast);
-        REALLOC(file->clusterOpFcNumber);
-        REALLOC(file->clusterControlFcNumber);
-        REALLOC(file->tcNumOfFcs);
-        REALLOC(file->probScale);
-        REALLOC(file->probIndicator);
-        REALLOC(file->probLower);
-        REALLOC(file->probUpper);
-        REALLOC(file->ni);
-        REALLOC(file->nj);
-        REALLOC(file->nlat);
-        REALLOC(file->nlon);
-        REALLOC(file->slat);
-        REALLOC(file->slon);
-        REALLOC(file->di);
-        REALLOC(file->dj);
-        REALLOC(file->splat);
-        REALLOC(file->splon);
-        REALLOC(file->quasi);
-        REALLOC(file->directionNumber);
-        REALLOC(file->frequencyNumber);
-        REALLOC(file->optimisationTime);
-        REALLOC(file->leadTime);
-        REALLOC(file->sensitiveAreaDomain);
-        REALLOC(file->sensitiveAreaMethod);
-        REALLOC(file->verifyingMonth);
-        REALLOC(file->averagingPeriod);
-        REALLOC(file->forecastMonth);
-        REALLOC(file->referenceDate);
-        REALLOC(file->climateDateFrom);
-        REALLOC(file->climateDateTo);
-        REALLOC(file->thresholdUnitsScale);
-        REALLOC(file->thresholdIndicator);
-        REALLOC(file->lowerThreshold);
-        REALLOC(file->upperThreshold);
-      }
-    }
-        
-  } while( (!feof(file->fp)) &&
-           (number_of_fields < file->max)
-         );
-
-  file->count = number_of_fields;
-
-  return;
-}
-
-void gribdata( unsigned char * header,
-               integer index,
-               integer * parameter,
-               integer * level,
-               integer * date,
-               integer * time,
-               integer * timestep,
-               integer * localDefinitionNumber,
-               integer * type,
-               integer * stream,
-               integer * repres,
-               integer * levtype,
-               integer * number,
-               integer * vdate,
-               integer * vtime,
-               integer * tcNumber,
-               integer * tcTotal,
-               integer * clusterMethod,
-               integer * tcStep,
-               integer * clusterStepEnd,
-               integer * tcNorth,
-               integer * tcWest,
-               integer * tcSouth,
-               integer * tcEast,
-               integer * clusterOpFcNumber,
-               integer * clusterControlFcNumber,
-               integer * tcNumOfFcs,
-               integer * probScale,
-               integer * probIndicator,
-               integer * probLower,
-               integer * probUpper,
-               integer * ni,
-               integer * nj,
-               integer * nlat,
-               integer * nlon,
-               integer * slat,
-               integer * slon,
-               integer * di,
-               integer * dj,
-               integer * splat,
-               integer * splon,
-               integer * quasi,
-               integer * directionNumber,
-               integer * frequencyNumber,
-               integer * optimisationTime,
-               integer * leadTime,
-               integer * sensitiveAreaDomain,
-               integer * sensitiveAreaMethod,
-               integer * verifyingMonth,
-               integer * averagingPeriod,
-               integer * forecastMonth,
-               integer * referenceDate,
-               integer * climateDateFrom,
-               integer * climateDateTo,
-               integer * thresholdUnitsScale,
-               integer * thresholdIndicator,
-               integer * lowerThreshold,
-               integer * upperThreshold
-             )
-/*
-// Returns parameter, level, date, time , etc information 
-// for a GRIB product.
-*/
-{
-
-/*
-// Decode the GRIB product
-*/
-
-#define POLAR_STEREO 5
-
-#define SEC1 7
-#define LEN1 8
-#define TABLE 4
-#define PARAM 9
-#define LEVELTYPE 10
-#define LEVEL1 11
-#define LEVEL2 12
-#define YY 13
-#define MM 14
-#define DD 15
-#define HOUR 16
-#define MIN 17
-#define TIMEUNIT 18
-#define STEP1 19
-#define STEP2 20
-#define TIMERANGE 21
-#define CENTURY 25
-#define LOCALDEF 41
-#define CLASS 42
-#define TYPE 43
-#define STREAM 44
-#define NUMBER 50
-#define REPRES 6
-#define NI 7
-#define NJ 9
-#define NLAT 11
-#define NLON 14
-#define SLAT 18
-#define SLON 21
-#define DI 24
-#define DJ 26
-#define DI_PS 21
-#define DJ_PS 24
-#define SPLAT 33
-#define SPLON 36
-
-#define ISOTHERMAL_LEVEL   20
-#define ISOBARIC_LEVEL     100
-#define ALTITUDE           103
-#define HEIGHT             105
-#define SIGMA_LEVEL        107
-#define HYBRID_LEVEL       109
-#define DEPTH_BELOW_LAND   111
-#define ISENTROPIC_LEVEL   113
-#define PRESSURE_DIFF      115
-#define VORTICITY_SURF     117
-#define HEIGHT_HIGH_PREC   125
-#define SATELLITE_BAND     127
-#define DEPTH_BELOW_SEA    160
-#define ENTIRE_ATMOSPHERE  200
-#define ENTIRE_OCEAN       201
-#define ISOBARIC_HIGH_PREC 210
-
-#define PROBABILITY 16
-#define PROBSCALE   52
-#define PROBINDIC   53
-#define PROBLOWER   54
-#define PROBUPPER   56
-
-#define CLUSTERMEAN         14
-#define CLUSTERSD           15
-#define CLUSTERNUMBER       50
-#define CLUSTERTOTAL        51
-#define CLUSTERMETHOD       53
-#define CLUSTERSTEP         54
-#define CLUSTERSTEPEND      56
-#define CLUSTERNORTH        58
-#define CLUSTERWEST         61
-#define CLUSTERSOUTH        64
-#define CLUSTEREAST         67
-#define CLUSTEROPFCNUM      70
-#define CLUSTERCONTROLFCNUM 71
-#define CLUSTERFORECASTS    72
-
-#define TUBETYPE      24
-#define TUBENUMBER    50
-#define TUBETOTAL     51
-#define TUBESTEP      71
-#define TUBENORTH     55
-#define TUBEWEST      58
-#define TUBESOUTH     61
-#define TUBEEAST      64
-#define TUBEFORECASTS 79
-
-#define CLUSTERMEAN         14
-#define CLUSTERSD           15
-#define CLUSTERNUMBER       50
-#define CLUSTERTOTAL        51
-#define CLUSTERMETHOD       53
-#define CLUSTERSTEP         54
-#define CLUSTERSTEPEND      56
-#define CLUSTERNORTH        58
-#define CLUSTERWEST         61
-#define CLUSTERSOUTH        64
-#define CLUSTEREAST         67
-#define CLUSTEROPFCNUM      70
-#define CLUSTERCONTROLFCNUM 71
-#define CLUSTERFORECASTS    72
-
-#define DIRECTIONNUMBER 52
-#define FREQUENCYNUMBER 53
-
-#define OPTIMISATIONTIME    92
-#define LEADTIME            93
-#define SENSITIVEAREADOMAIN 94
-#define SENSITIVEAREAMETHOD 95
-
-#define VERIFYINGMONTH      56
-#define AVERAGINGPERIOD     60
-#define FORECASTMONTH       61
-#define REFERENCEDATE       63
-#define CLIMATEDATEFROM     67
-#define CLIMATEDATETO       71
-#define THRESHOLDUNITSSCALE 75
-#define THRESHOLDINDICATOR  76
-#define LOWERTHRESHOLD      77
-#define UPPERTHRESHOLD      79
-
-integer table, leveltype, timeunit, timerange, multiplier, century, year;
-integer twoByteNumber, ECclass, ensembleNumber;
-integer section2Offset;
-integer status, eight = 8, sixteen = 16, twentyFour = 24;
-
-  table = header[SEC1+TABLE];
-  parameter[index] = table*1000 + header[SEC1+PARAM];
-
-  leveltype = header[SEC1+LEVELTYPE];
-  levtype[index] = leveltype;
-
-  switch( leveltype ) {
-
-    case ISOTHERMAL_LEVEL  :
-    case ISOBARIC_LEVEL    :
-    case ALTITUDE          :
-    case HEIGHT            :
-    case SIGMA_LEVEL       :
-    case HYBRID_LEVEL      :
-    case DEPTH_BELOW_LAND  :
-    case ISENTROPIC_LEVEL  :
-    case PRESSURE_DIFF     :
-    case VORTICITY_SURF    :
-    case HEIGHT_HIGH_PREC  :
-    case SATELLITE_BAND    :
-    case DEPTH_BELOW_SEA   :
-    case ENTIRE_ATMOSPHERE :
-    case ENTIRE_OCEAN      :
-    case ISOBARIC_HIGH_PREC:
-/*            level[index] = header[SEC1+LEVEL1]*256 + header[SEC1+LEVEL2]; */
-              level[index] = TWOBYTELONG(&header[SEC1+LEVEL1]);
-              break;
-
-    default: level[index] = header[SEC1+LEVEL1];
-  }
-
-  century = header[SEC1+CENTURY];
-  year = (century-1)*100 + header[SEC1+YY];
-  date[index] = year*10000 + header[SEC1+MM]*100 + header[SEC1+DD];
-
-  time[index] = header[SEC1+HOUR]*100 + header[SEC1+MIN];
-
-  timeunit = header[SEC1+TIMEUNIT];
-
-#define DAY          2
-#define MONTH        3
-#define THREE_HOURS  10
-#define SIX_HOURS    11
-#define TWELVE_HOURS 12
-
-  switch( timeunit ) {
-
-    case DAY :
-             multiplier = 24;
-             break;
-
-    case MONTH :
-             multiplier = 30*24;
-             break;
-
-    case THREE_HOURS :
-             multiplier = 3;
-             break;
-
-    case SIX_HOURS :
-             multiplier = 6;
-             break;
-
-    case TWELVE_HOURS :
-             multiplier = 12;
-             break;
-
-    default: multiplier = 1;
-  }
-
-#define RANGE_P1_TO_P2 2
-#define ACCUMULATION 4
-#define DIFFERENCE   5
-#define TWOBYTE      10
-
-  timerange = header[SEC1+TIMERANGE];
-
-  switch( timerange ) {
-
-    case TWOBYTE :
-             timestep[index] = TWOBYTELONG(&header[SEC1+STEP1])*multiplier;
-             break;
-
-    default: timestep[index] = header[SEC1+STEP2]*multiplier*10000 +
-                               header[SEC1+STEP1]*multiplier;
-  }
-
-  type[index] = header[SEC1+TYPE];
-
-#define ANALYSIS    2
-
-  if( type[index] == ANALYSIS ) {
-    vdate[index] = date[index];
-    vtime[index] = time[index];
-  }
-  else {
-    long iverd  = (time[index] + timestep[index]*100) / 2400;
-#ifdef gribAPI
-    long ijvday = date_to_Julian(date[index]) + iverd;
-    vdate[index] = Julian_to_date(ijvday);
-#else
-    long ijvday = date_to_julian(date[index]) + iverd;
-    vdate[index] = julian_to_date(ijvday);
-#endif
-    vtime[index] = (time[index] + timestep[index]*100) - (iverd*2400);
-  }
-
-  localDefinitionNumber[index] = header[SEC1+LOCALDEF];
-  ECclass = header[SEC1+CLASS];
-  stream[index] = TWOBYTELONG(&header[SEC1+STREAM]);
-
-  twoByteNumber = ( (localDefinitionNumber[index] == 4) && (stream[index] == 1090) ) ||
-                  (localDefinitionNumber[index] == 9) ||
-                  (localDefinitionNumber[index] == 15) ||
-                  (localDefinitionNumber[index] == 16) ||
-                  (localDefinitionNumber[index] == 21) ||
-                  (localDefinitionNumber[index] == 23);
-
-  if( twoByteNumber )
-    ensembleNumber = TWOBYTELONG(&header[SEC1+NUMBER]);
-  else
-    ensembleNumber = header[SEC1+NUMBER];
-  number[index] = ensembleNumber;
-
-/*
-// Extra information for tubes
-*/
-  if( type[index] == TUBETYPE ) {
-    tcNumber[index]    = header[SEC1+TUBENUMBER];
-    tcTotal[index]     = header[SEC1+TUBETOTAL];
-    tcStep[index]      = TWOBYTELONG(&header[SEC1+TUBESTEP]);
-    tcNorth[index]     = THREEBYTELONG(&header[SEC1+TUBENORTH]);
-    dsgnbt_(&tcNorth[index],&tcNorth[index],&twentyFour,&status);
-    tcWest[index]      = THREEBYTELONG(&header[SEC1+TUBEWEST]);
-    dsgnbt_(&tcWest[index],&tcWest[index],&twentyFour,&status);
-    tcSouth[index]     = THREEBYTELONG(&header[SEC1+TUBESOUTH]);
-    dsgnbt_(&tcSouth[index],&tcSouth[index],&twentyFour,&status);
-    tcEast[index]      = THREEBYTELONG(&header[SEC1+TUBEEAST]);
-    dsgnbt_(&tcEast[index],&tcEast[index],&twentyFour,&status);
-    tcNumOfFcs[index] = header[SEC1+TUBEFORECASTS];
-  }
-
-/*
-// Extra information for clusters
-*/
-  if( (type[index] == CLUSTERMEAN) || (type[index] == CLUSTERSD) ) {
-    tcNumber[index]    = header[SEC1+CLUSTERNUMBER];
-    tcTotal[index]     = header[SEC1+CLUSTERTOTAL];
-    clusterMethod[index]     = header[SEC1+CLUSTERMETHOD];
-    tcStep[index]      = TWOBYTELONG(&header[SEC1+CLUSTERSTEP]);
-    clusterStepEnd[index]      = TWOBYTELONG(&header[SEC1+CLUSTERSTEPEND]);
-    tcNorth[index]     = THREEBYTELONG(&header[SEC1+CLUSTERNORTH]);
-    dsgnbt_(&tcNorth[index],&tcNorth[index],&twentyFour,&status);
-    tcWest[index]      = THREEBYTELONG(&header[SEC1+CLUSTERWEST]);
-    dsgnbt_(&tcWest[index],&tcWest[index],&twentyFour,&status);
-    tcSouth[index]     = THREEBYTELONG(&header[SEC1+CLUSTERSOUTH]);
-    dsgnbt_(&tcSouth[index],&tcSouth[index],&twentyFour,&status);
-    tcEast[index]      = THREEBYTELONG(&header[SEC1+CLUSTEREAST]);
-    dsgnbt_(&tcEast[index],&tcEast[index],&twentyFour,&status);
-    clusterOpFcNumber[index] = header[SEC1+CLUSTEROPFCNUM];
-    clusterControlFcNumber[index] = header[SEC1+CLUSTERCONTROLFCNUM];
-    tcNumOfFcs[index] = header[SEC1+CLUSTERFORECASTS];
-  }
-/*
-// Extra information for probabilities
-*/
-  if( type[index] == PROBABILITY ) {
-    probScale[index] = header[SEC1+PROBSCALE];
-    dsgnbt_(&probScale[index],&probScale[index],&eight,&status);
-    probIndicator[index] = header[SEC1+PROBINDIC];
-    probLower[index] = 65535;
-    if( probIndicator[index] != 2 ) {
-      probLower[index] = TWOBYTELONG(&header[SEC1+PROBLOWER]);
-      dsgnbt_(&probLower[index],&probLower[index],&sixteen,&status);
-    }
-    probUpper[index] = 65535;
-    if( probIndicator[index] != 1 ) {
-      probUpper[index] = TWOBYTELONG(&header[SEC1+PROBUPPER]);
-      dsgnbt_(&probUpper[index],&probUpper[index],&sixteen,&status);
-    }
-  }
-/*
-// Extra information for wave 2D spectra
-*/
-  if( localDefinitionNumber[index] == 13 ) {
-    directionNumber[index] = header[SEC1+DIRECTIONNUMBER];
-    frequencyNumber[index] = header[SEC1+FREQUENCYNUMBER];
-  }
-/*
-// Extra information for sensitive area forecasts
-*/
-  if( localDefinitionNumber[index] == 21 ) {
-    optimisationTime[index]    = header[SEC1+OPTIMISATIONTIME];
-    leadTime[index]            = header[SEC1+LEADTIME];
-    sensitiveAreaDomain[index] = header[SEC1+SENSITIVEAREADOMAIN];
-    sensitiveAreaMethod[index] =
-      TWOBYTELONG(&header[SEC1+SENSITIVEAREAMETHOD]);
-  }
-/*
-// Extra information for coupled atmospheric, wave and ocean models
-*/
-  if( localDefinitionNumber[index] == 23 ) {
-    unsigned char scale;
-
-    verifyingMonth[index]     = FOURBYTELONG(&header[SEC1+VERIFYINGMONTH]);
-    averagingPeriod[index]    = ONEBYTELONG(&header[SEC1+AVERAGINGPERIOD]);
-    forecastMonth[index]      = TWOBYTELONG(&header[SEC1+FORECASTMONTH]);
-    referenceDate[index]      = FOURBYTELONG(&header[SEC1+REFERENCEDATE]);
-    climateDateFrom[index]    = FOURBYTELONG(&header[SEC1+CLIMATEDATEFROM]);
-    climateDateTo[index]      = FOURBYTELONG(&header[SEC1+CLIMATEDATETO]);
-    scale = header[SEC1+THRESHOLDUNITSSCALE];
-    if( scale & 0x80 ) {
-      scale &= 0x7f;
-      thresholdUnitsScale[index] = - ONEBYTELONG(&scale);
-    }
-    else
-      thresholdUnitsScale[index] = ONEBYTELONG(&scale);
-    thresholdIndicator[index] = ONEBYTELONG(&header[SEC1+THRESHOLDINDICATOR]);
-    lowerThreshold[index]     = TWOBYTELONG(&header[SEC1+LOWERTHRESHOLD]);
-    upperThreshold[index]     = TWOBYTELONG(&header[SEC1+UPPERTHRESHOLD]);
-  }
-
-/*
-// Section 2
-*/
-  section2Offset = THREEBYTELONG(&header[LEN1]);
-  repres[index] = header[LEN1+section2Offset-1+REPRES];
-
-  ni[index] = TWOBYTELONG(&header[LEN1+section2Offset-1+NI]);
-  nj[index] = TWOBYTELONG(&header[LEN1+section2Offset-1+NJ]);
-
-  nlat[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+NLAT]);
-  dsgnbt_(&nlat[index],&nlat[index],&twentyFour,&status);
-
-  nlon[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+NLON]);
-  dsgnbt_(&nlon[index],&nlon[index],&twentyFour,&status);
-
-  slat[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+SLAT]);
-  dsgnbt_(&slat[index],&slat[index],&twentyFour,&status);
-
-/*
-// Section 2 is different for polar stereographic
-*/
-  if( repres[index] == POLAR_STEREO ) {
-    di[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+DI_PS]);
-    dj[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+DJ_PS]);
-  }
-  else {
-    slon[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+SLON]);
-    dsgnbt_(&slon[index],&slon[index],&twentyFour,&status);
-
-    di[index] = TWOBYTELONG(&header[LEN1+section2Offset-1+DI]);
-    dj[index] = TWOBYTELONG(&header[LEN1+section2Offset-1+DJ]);
-
-    splat[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+SPLAT]);
-    dsgnbt_(&splat[index],&splat[index],&twentyFour,&status);
-
-    splon[index] = THREEBYTELONG(&header[LEN1+section2Offset-1+SPLON]);
-    dsgnbt_(&splon[index],&splon[index],&twentyFour,&status);
-  }
-
-  quasi[index] = ( (ni[index] == 0xFFFF) || (nj[index] == 0xFFFF) );
-
-  return;
-
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgtotl_(_fcd filename, fortint filename_len) {
-/*
-// Returns number of GRIB products in the file.
-*/
-integer thisFile;
-gribfile * file;
-
-  thisFile = pbginitInput(filename,filename_len);
-  file = currentFile(openFiles, thisFile);
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBGTOTL: Number of GRIBs in file %s = %d\n", pfile, file->count);
-    free(pfile);
-  }
-  return ( file->count );
-}
-
-fortint pbgtotl(_fcd filename, fortint filename_len) {
-  return pbgtotl_(filename,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgleng_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns length (in bytes) of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGLENG: length of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->length[index]);
-        free(pfile);
-      }
-      return ( file->length[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgleng(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgleng_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgoffs_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns offset (in bytes) of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGOFFS: offset of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->offset[index]);
-        free(pfile);
-      }
-      return ( file->offset[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgoffs(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgoffs_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgparm_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns parameter number of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGPARM: parameter number of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->parameter[index]);
-        free(pfile);
-      }
-      return ( file->parameter[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgparm(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgparm_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbglevl_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns level of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGLEVL: level of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->level[index]);
-        free(pfile);
-      }
-      return ( file->level[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbglevl(_fcd filename, fortint * n, fortint filename_len) {
-  return pbglevl_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgdate_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns date (as YYMMDD) of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGDATE: date of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->date[index]);
-        free(pfile);
-      }
-      return ( file->date[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgdate(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgdate_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgtime_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns time (as HHMM) of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGTIME: time of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->time[index]);
-        free(pfile);
-      }
-      return ( file->time[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgtime(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgtime_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgstep_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns timestep of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGSTEP: timestep of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->timestep[index]);
-        free(pfile);
-      }
-      return ( file->timestep[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgstep(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgstep_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgtype_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns field type of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGTYPE: type of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->type[index]);
-        free(pfile);
-      }
-      return ( file->type[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgtype(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgtype_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgstrm_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns stream of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGSTRM: stream of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->stream[index]);
-        free(pfile);
-      }
-      return ( file->stream[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgstrm(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgstrm_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgrepr_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns repres of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGREPR: repres of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->repres[index]);
-        free(pfile);
-      }
-      return ( file->repres[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgrepr(_fcd filename, fortint * n, fortint filename_len) {
-  return pbgrepr_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbglevt_(_fcd filename, fortint * n, fortint filename_len) {
-/*
-// Returns levtype of GRIB product n or -1 if n is greater
-// than the number of products in the file, or less than 1.
-*/
-integer index = (*n)-1;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-      if( DEBUG1 ) {
-        _fcd pfile;
-        copyName(&pfile, filename, filename_len);
-        printf("PBGLEVT: levtype of GRIB %d in file %s = %d\n",
-               (index+1), pfile, file->levtype[index]);
-        free(pfile);
-      }
-      return ( file->levtype[index] );
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbglevt(_fcd filename, fortint * n, fortint filename_len) {
-  return pbglevt_(filename,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgfind_(
-  _fcd filename,
-  fortint * param,
-  fortint * level,
-  fortint * date,
-  fortint * time,
-  fortint * step, 
-  fortint * n,
-  fortint filename_len) {
-/*
-// Returns the index of the GRIB product with the specified param, level, ..
-// Searching starts after GRIB product n.
-*/
-integer index = (*n);
-integer p = *param, l = *level, d = *date, t = *time, s = *step;
-integer loop;
-integer thisFile;
-gribfile * file;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-
-    for( loop = index; loop < file->count; loop++ ) {
-      if( p == file->parameter[loop] )
-        if( l == file->level[loop] )
-          if( d == file->date[loop] )
-            if( t == file->time[loop] )
-              if( s == file->timestep[loop] )
-                return (loop+1);
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgfind(
-  _fcd filename,
-  fortint * param,
-  fortint * level,
-  fortint * date,
-  fortint * time,
-  fortint * step, 
-  fortint * n,
-  fortint filename_len) {
-  return pbgfind_(filename,param,level,date,time,step,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgvfind_(
-  _fcd filename,
-  fortint * param,
-  fortint * level,
-  fortint * vdate,
-  fortint * vtime,
-  fortint * status,
-  fortint * n,
-  fortint filename_len) {
-/*
-// Returns the index of the GRIB product with the specified param, level,
-// verifying data and time (vdate & vtime).
-// Searching starts after GRIB product n.
-//
-// Returns the index of the first match found, or -1 if no match is found.
-// If more than one match is found (eg analysis and forecast fields),
-// status returns the index of the second match; otherwise status = 0.
-*/
-integer index = (*n);
-integer p = *param, l = *level, d = *vdate, t = *vtime;
-integer loop;
-integer thisFile;
-gribfile * file;
-
-  *status = 0;
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-
-    for( loop = index; loop < file->count; loop++ ) {
-      if( p == file->parameter[loop] )
-        if( l == file->level[loop] )
-          if( d == file->vdate[loop] )
-            if( t == file->vtime[loop] ) {
-              long innerloop;
-              for( innerloop = loop+1; innerloop < file->count; innerloop++ ) {
-                if( p == file->parameter[innerloop] )
-                  if( l == file->level[innerloop] )
-                    if( d == file->vdate[innerloop] )
-                      if( t == file->vtime[innerloop] )
-                        *status = innerloop+1 ;
-              }
-              return (loop+1);
-            }
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgvfind(
-  _fcd filename,
-  fortint * param,
-  fortint * level,
-  fortint * vdate,
-  fortint * vtime,
-  fortint * status,
-  fortint * n,
-  fortint filename_len) {
-  return pbgvfind_(filename,param,level,vdate,vtime,status,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-#define L_PARAM    0
-#define L_LEVEL    1
-#define L_DATE     2
-#define L_TIME     3
-#define L_STEP     4
-#define L_ENSEMBLE 5
-#define L_TYPE     6
-#define L_STREAM   7
-#define L_REPRES   8
-#define L_LEVTYPE  9
-#define L_VDATE    10
-#define L_VTIME    11
-#define L_NI       12
-#define L_NJ       13
-#define L_NLAT     14
-#define L_NLON     15
-#define L_SLAT     16
-#define L_SLON     17
-#define L_DI       18
-#define L_DJ       19
-#define L_SPLAT    20
-#define L_SPLON    21
-#define L_QUASI    22
-
-#define L_PROBSCALE 23
-#define L_PROBINDIC 24
-#define L_PROBLOWER 25
-#define L_PROBUPPER 26
-
-#define L_TUBENUM  23
-#define L_TUBETOT  24
-#define L_TUBEN    25
-#define L_TUBEW    26
-#define L_TUBES    27
-#define L_TUBEE    28
-#define L_TUBESTP  29
-#define L_TUBEFC   30
-
-#define L_CLUSNUM  23
-#define L_CLUSTOT  24
-#define L_CLUSMETH 25
-#define L_CLUSSTP  26
-#define L_CLUSSTPE 27
-#define L_CLUSN    28
-#define L_CLUSW    29
-#define L_CLUSS    30
-#define L_CLUSE    31
-#define L_CLUSOPFC 32
-#define L_CLUSCFFC 33
-#define L_CLUSFC   34
-
-#define L_DIRECTIONNUMBER 23
-#define L_FREQUENCYNUMBER 24
-
-#define L_OPTIMISATIONTIME    23
-#define L_LEADTIME            24
-#define L_SENSITIVEAREADOMAIN 25
-#define L_SENSITIVEAREAMETHOD 26
-
-#define L_VERIFYINGMONTH      23
-#define L_AVERAGINGPERIOD     24
-#define L_FORECASTMONTH       25
-#define L_REFERENCEDATE       26
-#define L_CLIMATEDATEFROM     27
-#define L_CLIMATEDATETO       28
-#define L_THRESHOLDUNITSSCALE 29
-#define L_THRESHOLDINDICATOR  30
-#define L_LOWERTHRESHOLD      31
-#define L_UPPERTHRESHOLD      32
-
-#define L_LOCALDEF 35
-
-#define L_ALIST_LENGTH 12
-#define L_BLIST_LENGTH 36
-
-fortint pbgafind_(
-  _fcd filename,
-  fortint * list,
-  fortint * n,
-  fortint filename_len) {
-/*
-// Returns the index of the GRIB product with the specified param, level, ..
-// Searching starts after GRIB product n.
-*/
-integer index = (*n);
-integer param    = list[L_PARAM],
-        level    = list[L_LEVEL],
-        date     = list[L_DATE],
-        time     = list[L_TIME],
-        step     = list[L_STEP],
-        ensemble = list[L_ENSEMBLE],
-        type     = list[L_TYPE],
-        stream   = list[L_STREAM],
-        repres   = list[L_REPRES],
-        levtype  = list[L_LEVTYPE],
-        vdate    = list[L_VDATE],
-        vtime    = list[L_VTIME];
-integer loop;
-integer thisFile;
-gribfile * file;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    integer loop;
-
-    copyName(&pfile, filename, filename_len);
-    printf("PBGAFIND: searching file %s\n", pfile);
-    free(pfile);
-
-    for( loop = 0; loop < L_ALIST_LENGTH ; loop++ ) {
-      if( list[loop] != MISSING )
-        printf("PBGAFIND: ilist[%d] = %d\n", (loop+1), list[loop] );
-    }
-  }
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-
-    for( loop = index; loop < file->count; loop++ ) {
-      if( MATCH(param,file->parameter[loop]) )
-      if( MATCH(level,file->level[loop]) )
-      if( MATCH(date,file->date[loop]) )
-      if( MATCH(time,file->time[loop]) )
-      if( MATCH(step,file->timestep[loop]) )
-      if( MATCH(ensemble,file->number[loop]) )
-      if( MATCH(type,file->type[loop]) )
-      if( MATCH(stream,file->stream[loop]) )
-      if( MATCH(repres,file->repres[loop]) )
-      if( MATCH(levtype,file->levtype[loop]) )
-      if( MATCH(vdate,file->vdate[loop]) )
-      if( MATCH(vtime,file->vtime[loop]) ) {
-        if( DEBUG1 ) {
-          _fcd pfile;
-          copyName(&pfile, filename, filename_len);
-          printf("PBGAFIND: matching GRIB found at position %d in file %s\n",
-                 (loop+1), pfile);
-          free(pfile);
-        }
-        return (loop+1);
-      }
-    }
-  }
-
-  return (-1);
-}
-
-fortint pbgafind(_fcd filename,fortint* list,fortint* n,fortint filename_len) {
-  return pbgafind_(filename,list,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbgbfind_(
-  _fcd filename,
-  fortint * list,
-  fortint * n,
-  fortint filename_len) {
-/*
-// Returns the index of the GRIB product with the specified param, level, ..
-// Searching starts after GRIB product n.
-*/
-integer index = (*n);
-integer param         =  list[L_PARAM],
-        level         =  list[L_LEVEL],
-        date          =  list[L_DATE],
-        time          =  list[L_TIME],
-        step          =  list[L_STEP],
-        localDef      =  list[L_LOCALDEF],
-        ensemble      =  list[L_ENSEMBLE],
-        type          =  list[L_TYPE],
-        stream        =  list[L_STREAM],
-        repres        =  list[L_REPRES],
-        levtype       =  list[L_LEVTYPE],
-        vdate         =  list[L_VDATE],
-        vtime         =  list[L_VTIME],
-        ni            =  list[L_NI],
-        nj            =  list[L_NJ],
-        nlat          =  list[L_NLAT],
-        nlon          =  list[L_NLON],
-        slat          =  list[L_SLAT],
-        slon          =  list[L_SLON],
-        di            =  list[L_DI],
-        dj            =  list[L_DJ],
-        splat         =  list[L_SPLAT],
-        splon         =  list[L_SPLON],
-        quasi         =  list[L_QUASI];
-integer tcNumber               = MISSING,
-        tcTotal                = MISSING,
-        clusterMethod          = MISSING,
-        tcStep                 = MISSING,
-        clusterStepEnd         = MISSING,
-        tcNorth                = MISSING,
-        tcWest                 = MISSING,
-        tcSouth                = MISSING,
-        tcEast                 = MISSING,
-        clusterOpFcNumber      = MISSING,
-        clusterControlFcNumber = MISSING,
-        tcNumOfFcs             = MISSING,
-        probScale              = MISSING,
-        probIndicator          = MISSING,
-        probLower              = MISSING,
-        probUpper              = MISSING,
-        directionNumber        = MISSING,
-        frequencyNumber        = MISSING,
-        optimisationTime       = MISSING,
-        leadTime               = MISSING,
-        sensitiveAreaDomain    = MISSING,
-        sensitiveAreaMethod    = MISSING,
-        verifyingMonth         = MISSING,
-        averagingPeriod        = MISSING,
-        forecastMonth          = MISSING,
-        referenceDate          = MISSING,
-        climateDateFrom        = MISSING,
-        climateDateTo          = MISSING,
-        thresholdUnitsScale    = MISSING,
-        thresholdIndicator     = MISSING,
-        lowerThreshold         = MISSING,
-        upperThreshold         = MISSING;
-integer loop;
-integer thisFile;
-gribfile * file;
-
- if( DEBUG1 ) {
-   _fcd pfile;
-   integer loop;
-
-   copyName(&pfile, filename, filename_len);
-   printf("PBGBFIND: searching file %s\n", pfile);
-   free(pfile);
-
-   for( loop = 0; loop < L_BLIST_LENGTH ; loop++ ) {
-     if( list[loop] != MISSING )
-       printf("PBGBFIND: ilist[%d] = %d\n", (loop+1), list[loop] );
-   }
- }
-
- if( (type == CLUSTERMEAN) || (type == CLUSTERSD) ) {
-   tcNumber               =  list[L_CLUSNUM];
-   tcTotal                =  list[L_CLUSTOT];
-   clusterMethod          =  list[L_CLUSMETH];
-   tcStep                 =  list[L_CLUSSTP];
-   clusterStepEnd         =  list[L_CLUSSTPE];
-   tcNorth                =  list[L_CLUSN];
-   tcWest                 =  list[L_CLUSW];
-   tcSouth                =  list[L_CLUSS];
-   tcEast                 =  list[L_CLUSE];
-   clusterOpFcNumber      =  list[L_CLUSOPFC];
-   clusterControlFcNumber =  list[L_CLUSCFFC];
-   tcNumOfFcs             =  list[L_CLUSFC];
- }
-
- if( type == TUBETYPE) {
-   tcNumber    =  list[L_TUBENUM];
-   tcTotal     =  list[L_TUBETOT];
-   tcStep      =  list[L_TUBESTP];
-   tcNorth     =  list[L_TUBEN];
-   tcWest      =  list[L_TUBEW];
-   tcSouth     =  list[L_TUBES];
-   tcEast      =  list[L_TUBEE];
-   tcNumOfFcs  =  list[L_TUBEFC];
- }
-
- if( type == PROBABILITY) {
-   probScale     = list[L_PROBSCALE];
-   probIndicator = list[L_PROBINDIC];
-   probLower     = list[L_PROBLOWER];
-   probUpper     = list[L_PROBUPPER];
- }
-
- if( localDef == 13 ) {
-   directionNumber = list[L_DIRECTIONNUMBER];
-   frequencyNumber = list[L_FREQUENCYNUMBER];
- }
-
- if( localDef == 21 ) {
-   optimisationTime    = list[L_OPTIMISATIONTIME];
-   leadTime            = list[L_LEADTIME];
-   sensitiveAreaDomain = list[L_SENSITIVEAREADOMAIN];
-   sensitiveAreaMethod = list[L_SENSITIVEAREAMETHOD];
- }
-
- if( localDef == 23 ) {
-   verifyingMonth      = list[L_VERIFYINGMONTH];
-   averagingPeriod     = list[L_AVERAGINGPERIOD];
-   forecastMonth       = list[L_FORECASTMONTH];
-   referenceDate       = list[L_REFERENCEDATE];
-   climateDateFrom     = list[L_CLIMATEDATEFROM];
-   climateDateTo       = list[L_CLIMATEDATETO];
-   thresholdUnitsScale = list[L_THRESHOLDUNITSSCALE];
-   thresholdIndicator  = list[L_THRESHOLDINDICATOR];
-   lowerThreshold      = list[L_LOWERTHRESHOLD];
-   upperThreshold      = list[L_UPPERTHRESHOLD];
- }
-
- if( index >= 0 ) {
-  thisFile = pbginitInput(filename,filename_len);
-  file = currentFile(openFiles, thisFile);
-
-  for( loop = index; loop < file->count; loop++ ) {
-   if( MATCH(param,file->parameter[loop]) )
-   if( MATCH(level,file->level[loop]) )
-   if( MATCH(step,file->timestep[loop]) )
-   if( MATCH(time,file->time[loop]) )
-   if( MATCH(date,file->date[loop]) )
-   if( MATCH(ensemble,file->number[loop]) )
-   if( MATCH(type,file->type[loop]) )
-   if( MATCH(stream,file->stream[loop]) )
-   if( MATCH(repres,file->repres[loop]) )
-   if( MATCH(levtype,file->levtype[loop]) )
-   if( MATCH(vdate,file->vdate[loop]) )
-   if( MATCH(vtime,file->vtime[loop]) )
-   if( MATCH(ni,file->ni[loop]) )
-   if( MATCH(nj,file->nj[loop]) )
-   if( MATCH(nlat,file->nlat[loop]) )
-   if( MATCH(nlon,file->nlon[loop]) )
-   if( MATCH(slat,file->slat[loop]) )
-   if( MATCH(slon,file->slon[loop]) )
-   if( MATCH(di,file->di[loop]) )
-   if( MATCH(dj,file->dj[loop]) )
-   if( MATCH(splat,file->splat[loop]) )
-   if( MATCH(splon,file->splon[loop]) )
-   if( MATCH(quasi,file->quasi[loop]) )
-   if( MATCH(tcNumber,file->tcNumber[loop]) )
-   if( MATCH(tcTotal,file->tcTotal[loop]) )
-   if( MATCH(clusterMethod,file->clusterMethod[loop]) )
-   if( MATCH(tcStep,file->tcStep[loop]) )
-   if( MATCH(clusterStepEnd,file->clusterStepEnd[loop]) )
-   if( MATCH(tcNorth,file->tcNorth[loop]) )
-   if( MATCH(tcWest,file->tcWest[loop]) )
-   if( MATCH(tcSouth,file->tcSouth[loop]) )
-   if( MATCH(tcEast,file->tcEast[loop]) )
-   if( MATCH(clusterOpFcNumber,file->clusterOpFcNumber[loop]) )
-   if( MATCH(clusterControlFcNumber,file->clusterControlFcNumber[loop]) )
-   if( MATCH(tcNumOfFcs,file->tcNumOfFcs[loop]) )
-   if( MATCH(probScale,file->probScale[loop]) )
-   if( MATCH(probIndicator,file->probIndicator[loop]) )
-   if( MATCH(probLower,file->probLower[loop]) )
-   if( MATCH(probUpper,file->probUpper[loop]) )
-   if( MATCH(directionNumber,file->directionNumber[loop]) )
-   if( MATCH(frequencyNumber,file->frequencyNumber[loop]) )
-   if( MATCH(optimisationTime,file->optimisationTime[loop]) )
-   if( MATCH(leadTime,file->leadTime[loop]) )
-   if( MATCH(sensitiveAreaDomain,file->sensitiveAreaDomain[loop]) )
-   if( MATCH(sensitiveAreaMethod,file->sensitiveAreaMethod[loop]) )
-   if( MATCH(verifyingMonth,file->verifyingMonth[loop]) )
-   if( MATCH(averagingPeriod,file->averagingPeriod[loop]) )
-   if( MATCH(forecastMonth,file->forecastMonth[loop]) )
-   if( MATCH(referenceDate,file->referenceDate[loop]) )
-   if( MATCH(climateDateFrom,file->climateDateFrom[loop]) )
-   if( MATCH(climateDateTo,file->climateDateTo[loop]) )
-   if( MATCH(thresholdUnitsScale,file->thresholdUnitsScale[loop]) )
-   if( MATCH(thresholdIndicator,file->thresholdIndicator[loop]) )
-   if( MATCH(lowerThreshold,file->lowerThreshold[loop]) )
-   if( MATCH(upperThreshold,file->upperThreshold[loop]) ) {
-     if( DEBUG1 ) {
-       _fcd pfile;
-       copyName(&pfile, filename, filename_len);
-       printf("PBGBFIND: matching GRIB found at position %d in file %s\n",
-       (loop+1), pfile);
-       free(pfile);
-     }
-     return (loop+1);
-   }
-  }
- }
-
- return (-1);
-}
-
-fortint pbgbfind(_fcd filename,fortint* list,fortint* n,fortint filename_len) {
-  return pbgbfind_(filename,list,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-
-#define INDEX_TOO_BIG  -1
-#define FSEEK_ERROR    -2
-#define FREAD_ERROR    -2
-#define BUFF_TOO_SMALL -3
-
-fortint pbgget_(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint * n, fortint filename_len) {
-/*
-// Gets the nth GRIB product.
-*/
-integer index = (*n)-1;
-integer length, status;
-size_t offset;
-integer thisFile;
-FILE * fp;
-gribfile * file;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBGGET: getting GRIB number %d in file %s\n",
-    (index+1), pfile);
-    free(pfile);
-  }
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-
-      length = file->length[index];
-
-      if( DEBUG1 ) printf("PBGGET: length of GRIB number %d = %d\n",
-                          (index+1), length);
-
-      if( *bufflen < length ) {
-        fprintf(stderr,
-          "PBGGET: user buffer too small, %d bytes required\n", length);
-        return BUFF_TOO_SMALL;
-      }
-
-      offset = file->offset[index];
-
-      if( DEBUG1 ) printf("PBGGET: offset of GRIB number %d = %d\n",
-                          (index+1), offset);
-
-      fp = file->fp;
-#ifdef FOPEN64
-      if( fseeko64( fp, offset, 0) ) {
-#else
-      if( fseek( fp, offset, 0) ) {
-#endif
-        perror("PBGGET: error in fseek");
-        return FSEEK_ERROR;
-      }
-
-      status = fread(buffer, 1, length, fp);
-      if( status != length ) {
-        fprintf(stderr,"PBGGET: error in fread\n");
-        return FREAD_ERROR;
-      }
-      
-      return length;
-    }
-  }
-
-  return INDEX_TOO_BIG;
-
-}
-
-fortint pbgget(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint * n, fortint filename_len) {
-  return pbgget_(filename,buffer,bufflen,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-
-#define FWRITE_ERROR -1
-
-fortint pbgput_(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint filename_len) {
-/*
-// Write an array to a file.
-*/
-integer length;
-integer thisFile;
-FILE * fp;
-gribfile * file;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBGPUT: putting %d bytes to file %s\n", *bufflen, pfile);
-    free(pfile);
-  }
-
-  thisFile = pbginitOutput(filename,filename_len);
-  file = currentFile(openFiles, thisFile);
-
-  fp = file->fp;
-  length = fwrite(buffer, 1, *bufflen, fp);
-
-  if( DEBUG1 ) printf("PBGPUT: number of bytes written = %d\n", length);
-
-  if( length!=(*bufflen) )
-    return FWRITE_ERROR;
-  else
-    return (*bufflen);
-}
-
-fortint pbgput(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint filename_len) {
-  return pbgput_(filename,buffer,bufflen,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-void pbgclos_(_fcd filename, fortint filename_len) {
-
-  openFiles.removeFile(filename, filename_len);
-  return;
-
-}
-
-void pbgclos(_fcd filename, fortint filename_len) {
-  pbgclos_(filename,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-integer pbginitInput(_fcd filename, fortint filename_len) {
-/*
-// Initialise indices for current file if necessary.
-*/
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBG_pbginitInput: checking if file %s already open\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = openFiles.exists(filename,filename_len);
-
-  if( thisFile == -1 ) {
-    if( DEBUG2 ) printf("PBG_pbginitInput: file not yet open\n");
-    return ( openFiles.addRead(filename, filename_len) );
-  }
-
-  if( DEBUG2 ) printf("PBG_pbginitInput: file has open slot %d\n", thisFile);
-  return thisFile;
-
-}
-
-integer pbginitOutput(_fcd filename, fortint filename_len) {
-/*
-// Initialise output file if necessary.
-*/
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBG_pbginitOutput: checking if file %s already open\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = openFiles.exists(filename,filename_len);
-
-  if( thisFile == -1 ) {
-    if( DEBUG2 ) printf("PBG_pbginitOutput: file not yet open\n");
-    return ( openFiles.addWrite(filename, filename_len) );
-  }
-
-  if( DEBUG2 ) printf("PBG_pbginitOutput: file has open slot %d\n", thisFile);
-  return thisFile;
-
-}
-
-integer exists(_fcd filename , fortint filename_len) {
-integer n;
-_fcd pfile;
-gribfile * file;
-
-
-/*
-// See if DEBUG switched on.
-*/
-    if( ! debugSet ) {
-      debugLevel = getenv("PBG_DEBUG");
-      if( debugLevel == NULL )
-        debugSet = DEBUGOFF;              /* off */
-      else {
-        int loop;
-        for( loop = 0; loop < strlen(debugLevel) ; loop++ ) {
-          if( ! isdigit(debugLevel[loop]) ) {
-            printf("Invalid number string in PBG_DEBUG: %s\n", debugLevel);
-            printf("PBG_DEBUG must comprise only digits [0-9].\n");
-            debugSet = DEBUGOFF;
-          }
-        }
-        debugSet = DEBUGOFF + atol( debugLevel );
-      }
-      if( DEBUG2 ) printf("PBG_exists: PBG_DEBUG switched on\n");
-    }
-
-  if( openFiles.count > -1 ) {
-
-    copyName(&pfile, filename, filename_len);
-
-    if( DEBUG2 ) printf("PBG_exists: looking for filename = %s\n", pfile);
-
-    for( n = 0; n <= openFiles.count; n++ ) {
-      file = currentFile(openFiles, n);
-      if( file != 0 ) {
-        if( strcmp( file->fname, pfile ) == 0 ) {
-          free(pfile);
-          if( DEBUG2 ) printf("PBG_exists: file found in slot= %d\n", n);
-          return n;
-        }
-      }
-    }
-
-    free(pfile);
-  }
-  return -1;
-}
-
-integer addFile(_fcd filename , fortint filename_len, char readwriteflag) {
-_fcd pfile;
-char mode[2] = " ";
-FILE * in;
-gribfile * previousLatest, * latest;
-
-  openFiles.count++;
-
-  copyName(&pfile, filename, filename_len);
-
-  if( DEBUG2 ) printf("PBG_addFile: adding filename = %s\n", pfile);
-
-  mode[0] = readwriteflag;
-#ifdef FOPEN64
-  in = fopen64(pfile,mode);
-#else
-  in = fopen(pfile,mode);
-#endif
-  if( in == NULL ) {
-    perror("Error opening file");
-    exit(1);
-  }
-
-  if( openFiles.count == 0 ) {
-    openFiles.files = (gribfile *)malloc(sizeof(gribfile));
-    latest = openFiles.files;
-  }
-  else {
-    previousLatest = latestFile(openFiles);
-    previousLatest->next = (gribfile *)malloc(sizeof(gribfile));
-    latest = previousLatest->next;
-  }
-
-  latest->fp = in;
-  copyName(&(latest->fname),filename,filename_len);
-  latest->readwriteflag = readwriteflag;
-  latest->max = MAX_NUMBER_OF_GRIBS;
-  latest->count = 0;
-
-#define MALLOC(a) (a) = (void *) malloc(space)
-
-  if( readwriteflag == 'r' ) {
-    integer space;
-
-    space = sizeof(OFF_T)*MAX_NUMBER_OF_GRIBS;
-    MALLOC(latest->offset);
-
-    space = sizeof(integer)*MAX_NUMBER_OF_GRIBS;
-    MALLOC(latest->length);
-    MALLOC(latest->parameter);
-    MALLOC(latest->level);
-    MALLOC(latest->date);
-    MALLOC(latest->time);
-    MALLOC(latest->timestep);
-    MALLOC(latest->localDefinitionNumber);
-    MALLOC(latest->type);
-    MALLOC(latest->stream);
-    MALLOC(latest->repres);
-    MALLOC(latest->levtype);
-    MALLOC(latest->number);
-    MALLOC(latest->vdate);
-    MALLOC(latest->vtime);
-    MALLOC(latest->tcNumber);
-    MALLOC(latest->tcTotal);
-    MALLOC(latest->clusterMethod);
-    MALLOC(latest->tcStep);
-    MALLOC(latest->clusterStepEnd);
-    MALLOC(latest->tcNorth);
-    MALLOC(latest->tcWest);
-    MALLOC(latest->tcSouth);
-    MALLOC(latest->tcEast);
-    MALLOC(latest->clusterOpFcNumber);
-    MALLOC(latest->clusterControlFcNumber);
-    MALLOC(latest->tcNumOfFcs);
-    MALLOC(latest->probScale);
-    MALLOC(latest->probIndicator);
-    MALLOC(latest->probLower);
-    MALLOC(latest->probUpper);
-    MALLOC(latest->ni);
-    MALLOC(latest->nj);
-    MALLOC(latest->nlat);
-    MALLOC(latest->nlon);
-    MALLOC(latest->slat);
-    MALLOC(latest->slon);
-    MALLOC(latest->di);
-    MALLOC(latest->dj);
-    MALLOC(latest->splat);
-    MALLOC(latest->splon);
-    MALLOC(latest->quasi);
-    MALLOC(latest->directionNumber);
-    MALLOC(latest->frequencyNumber);
-    MALLOC(latest->optimisationTime);
-    MALLOC(latest->leadTime);
-    MALLOC(latest->sensitiveAreaDomain);
-    MALLOC(latest->sensitiveAreaMethod);
-    MALLOC(latest->verifyingMonth);
-    MALLOC(latest->averagingPeriod);
-    MALLOC(latest->forecastMonth);
-    MALLOC(latest->referenceDate);
-    MALLOC(latest->climateDateFrom);
-    MALLOC(latest->climateDateTo);
-    MALLOC(latest->thresholdUnitsScale);
-    MALLOC(latest->thresholdIndicator);
-    MALLOC(latest->lowerThreshold);
-    MALLOC(latest->upperThreshold);
-  }
-
-  latest->next = 0;
-
-  if( DEBUG2 ) printf("PBG_addFile: adding file %s in slot = %d\n",
-                       pfile, openFiles.count);
-
-  free(pfile);
-  return openFiles.count;
-
-}
-
-void removeFile(_fcd filename , fortint filename_len) {
-integer thisFile;
-int status;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBG_removeFile: trying to remove filename = %s\n", pfile);
-    free(pfile);
-  }
- 
-  thisFile = openFiles.exists(filename,filename_len);
-
-  if( thisFile != -1 ) {
-    integer index;
-    gribfile * previous = openFiles.files;
-    gribfile * current;
-
-    current = previous;
-
-    for( index = 0; index < thisFile; index++ ) {
-      previous = current;
-      current = current->next;
-    }
-
-    status = fclose(current->fp);
-    if( status != 0 ) {
-      perror("Error closing file");
-      exit(1);
-    }
-    if( DEBUG2 ) printf("PBG_removeFile: removing file %s from slot %d\n",
-                         current->fname, thisFile);
-    free(current->fname);
-
-/*
-//  Input files have arrays of values
-*/
-    if( current->readwriteflag == 'r' ) {
-      free(current->offset);
-      free(current->length);
-      free(current->parameter);
-      free(current->level);
-      free(current->date);
-      free(current->time);
-      free(current->timestep);
-      free(current->localDefinitionNumber);
-      free(current->type);
-      free(current->stream);
-      free(current->repres);
-      free(current->levtype);
-      free(current->number);
-      free(current->vdate);
-      free(current->vtime);
-      free(current->tcNumber);
-      free(current->tcTotal);
-      free(current->clusterMethod);
-      free(current->tcStep);
-      free(current->clusterStepEnd);
-      free(current->tcNorth);
-      free(current->tcWest);
-      free(current->tcSouth);
-      free(current->tcEast);
-      free(current->clusterOpFcNumber);
-      free(current->clusterControlFcNumber);
-      free(current->tcNumOfFcs);
-      free(current->probScale);
-      free(current->probIndicator);
-      free(current->probLower);
-      free(current->probUpper);
-      free(current->ni);
-      free(current->nj);
-      free(current->nlat);
-      free(current->nlon);
-      free(current->slat);
-      free(current->slon);
-      free(current->di);
-      free(current->dj);
-      free(current->splat);
-      free(current->splon);
-      free(current->quasi);
-      free(current->directionNumber);
-      free(current->frequencyNumber);
-      free(current->optimisationTime);
-      free(current->leadTime);
-      free(current->sensitiveAreaDomain);
-      free(current->sensitiveAreaMethod);
-      free(current->verifyingMonth);
-      free(current->averagingPeriod);
-      free(current->forecastMonth);
-      free(current->referenceDate);
-      free(current->climateDateFrom);
-      free(current->climateDateTo);
-      free(current->thresholdUnitsScale);
-      free(current->thresholdIndicator);
-      free(current->lowerThreshold);
-      free(current->upperThreshold);
-    }
-
-    if( thisFile == 0 ) 
-      openFiles.files = (current->next);
-    else
-       previous->next = (current->next);
-    free(current);
-    
-    openFiles.count--;
-  }
-}
-
-integer addRead(_fcd filename , fortint filename_len) {
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBG_addRead: add for reading filename = %s\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = addFile(filename,filename_len,'r');
-
-  pbgindx( thisFile);
-
-  return thisFile;
-}
-
-integer addWrite(_fcd filename , fortint filename_len) {
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBG_addWrite: add for writing filename = %s\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = addFile(filename,filename_len,'w');
-
-  return thisFile;
-}
-
-void copyName(_fcd * pfile, _fcd filename, fortint filename_len) {
-/*
-// Copies FORTRAN filename to C string.
-*/
-char * blankCharacterPointer;
-integer space;
-
-  *pfile = (char *) malloc((size_t) (filename_len+1) );
-  memcpy(*pfile, filename, (size_t) filename_len);
-  space = (integer) filename_len;
-  (*pfile)[space] = '\0';
-
-  blankCharacterPointer = strchr(filename, ' ');
-  if( blankCharacterPointer != NULL ) {
-    space = (integer) (blankCharacterPointer - filename);
-    (*pfile)[space] = '\0';
-  }
-
-  return;
-}
-
-gribfile * latestFile(collection openFiles) {
-integer index;
-gribfile * last = openFiles.files;
-
-  for( index = 1; index < openFiles.count; index++ )
-    last =  last->next;
-
-  return last;
-
-}
-
-gribfile * currentFile(collection openFiles, integer thisFile) {
-integer index;
-gribfile * current = openFiles.files;
-
-  for( index = 0; index < thisFile; index++ )
-    current = current->next;
-
-  return current;
-}
-
-#ifdef gribAPI
-long Julian_to_date(long jdate) {
-#else
-long julian_to_date(long jdate) {
-#endif
-long x,y,d,m,e;
-long day,month,year;
-
-    x = 4 * jdate - 6884477;
-    y = (x / 146097) * 100;
-    e = x % 146097;
-    d = e / 4;
-
-    x = 4 * d + 3;
-    y = (x / 1461) + y;
-    e = x % 1461;
-    d = e / 4 + 1;
-
-    x = 5 * d - 3;
-    m = x / 153 + 1;
-    e = x % 153;
-    d = e / 5 + 1;
-
-    if( m < 11 )
-    	month = m + 2;
-    else
-    	month = m - 10;
-
-    day = d;
-    year = y + m / 11;
-
-    return year * 10000 + month * 100 + day;
-}
-
-#ifdef gribAPI
-long date_to_Julian(long ddate) {
-#else
-long date_to_julian(long ddate) {
-#endif
-long  m1,y1,a,b,c,d,j1;
-long month,day,year;
-
-    year = ddate / 10000;
-    ddate %= 10000;
-    month  = ddate / 100;
-    ddate %= 100;
-    day = ddate;
-
-
-    if (year < 100) year = year + 1900;
-
-    if (month > 2)
-    {
-    	m1 = month - 3;
-    	y1 = year;
-    }
-    else
-    {
-    	m1 = month + 9;
-    	y1 = year - 1;
-    }
-
-    a = 146097*(y1/100)/4;
-    d = y1 % 100;
-    b = 1461*d/4;
-    c = (153*m1+2)/5+day+1721119;
-    j1 = a+b+c;
-
-    return(j1);
-}
-
-fortint pbggeth012_(_fcd,fortint*,fortint,fortint,fortint);
-fortint soffset012_(unsigned char*,fortint*,fortint*,fortint*);
-
-#define XFIND_ERROR -1
-
-fortint pbgxfind_(fortint * grib1, _fcd filename, fortint filename_len)
-{
-unsigned char* buffer1 = (unsigned char*) grib1;
-static fortint* ibuffer2 = NULL;
-static buffer2Length = 0;
-fortint status, totalLength, headerLength, numberOfGribs, loop;
-fortint is0, is1, is2;
-fortint js0, js1, js2;
-
-  numberOfGribs = pbgtotl_(filename,filename_len);
-  if( numberOfGribs < 1 ) {
-    if( DEBUG1 ) {
-      _fcd pfile;
-      copyName(&pfile, filename, filename_len);
-      printf("PBXFIND: No GRIBs in file %s\n", pfile);
-      free(pfile);
-    }
-    return XFIND_ERROR;
-  }
-
-  status = soffset012_(buffer1, &is0, &is1, &is2);
-  if( status ) return XFIND_ERROR;
-
-  totalLength = THREEBYTELONG(buffer1+is0+4);
-  headerLength = (is1 - is0);
-  headerLength += THREEBYTELONG(buffer1+is1);
-  if( is2 != 0 ) headerLength += THREEBYTELONG(buffer1+is2);
-
-  for( loop = 0; loop < numberOfGribs; loop++) {
-    fortint next, totalLength2, headerLength2;
-    unsigned char * buffer2;
-
-    next = loop + 1;
-
-    if( ibuffer2 != NULL ) {
-      if( buffer2Length < headerLength ) {
-        ibuffer2 = (fortint*) realloc(ibuffer2,headerLength);
-        if( ibuffer2 == NULL ) {
-          printf("pbgxfind_: realloc failed\n");
-          return XFIND_ERROR;
-        }
-        buffer2Length = headerLength;
-      }
-    }
-    else {
-      ibuffer2 = (fortint*) malloc(headerLength);
-      if( ibuffer2 == NULL ) {
-        printf("pbgxfind_: malloc failed\n");
-        return XFIND_ERROR;
-      }
-      buffer2Length = headerLength;
-    }
-
-    totalLength2 =
-      pbggeth012_(filename,ibuffer2,buffer2Length,next,filename_len);
-
-    if( totalLength2 > 1 ) {
-
-      buffer2 = (unsigned char*) ibuffer2;
-      status = soffset012_(buffer2, &js0, &js1, &js2);
-      if( status ) return XFIND_ERROR;
-
-      if( totalLength == totalLength2 ) {
-        headerLength2 = (js1 - js0);
-        headerLength2 += THREEBYTELONG(buffer2+js1);
-        if( js2 != 0 ) headerLength2 += THREEBYTELONG(buffer2+js2);
-
-        if( headerLength == headerLength2 ) {
-          if( (memcmp((buffer1+is0),(buffer2+js0),(size_t)headerLength) == 0) )
-            return next;
-        }
-      }
-    }
-
-  }
-
-  return XFIND_ERROR;
-}
-
-fortint pbgxfind(fortint * grib1, _fcd filename, fortint filename_len) {
-  return pbgxfind_(grib1,filename,filename_len);
-}
-
-#define GRIB_TOO_SMALL -4
-
-fortint pbggeth012_(_fcd filename, fortint* buffer, fortint bufflen,
-                    fortint n, fortint filename_len) {
-/*
-// Gets section 0,1 and 2 for the nth GRIB product.
-*/
-integer index = n - 1;
-integer length, status;
-size_t offset;
-integer thisFile;
-FILE * fp;
-gribfile * file;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("pbggeth012: getting GRIB number %d in file %s\n",
-    (index+1), pfile);
-    free(pfile);
-  }
-
-  if( index >= 0 ) {
-    thisFile = pbginitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-
-      length = file->length[index];
-
-      if( DEBUG1 ) printf("pbggeth012: length of GRIB number %d = %d\n",
-                          (index+1), length);
-
-      if( length < bufflen ) return GRIB_TOO_SMALL;
-
-      offset = file->offset[index];
-
-      if( DEBUG1 ) printf("pbggeth012: offset of GRIB number %d = %d\n",
-                          (index+1), offset);
-
-      fp = file->fp;
-#ifdef FOPEN64
-      if( fseeko64( fp, offset, 0) ) {
-#else
-      if( fseek( fp, offset, 0) ) {
-#endif
-        perror("pbggeth012: error in fseek");
-        return FSEEK_ERROR;
-      }
-
-      status = fread(buffer, 1, bufflen, fp);
-      if( status != bufflen ) {
-        fprintf(stderr,"pbggeth012: error in fread\n");
-        return FREAD_ERROR;
-      }
-      
-      return length;
-    }
-  }
-
-  return INDEX_TOO_BIG;
-
-}
-
-#define ERROR(a,b) {perror(a);return b;}
-#define GRIB 0x47524942
-#define len3oct(p) ((((long)*(p))<<16) + (((long)*(p+1))<<8) + (long)*(p+2))
-#define BIT1 0x80
-#define BIT2 0x40
-#define BIT3 0x20
-#define BIT4 0x10
-#define BIT5 0x08
-#define BIT6 0x04
-#define BIT7 0x02
-#define BIT8 0x01
-
-static int grab(unsigned char * , unsigned char * , long ,long ,long * );
-
-fortint soffset012_(
-  unsigned char * buffer,
-  fortint* is0,
-  fortint* is1,
-  fortint* is2 ) {
-long s0, s1, s2, edition;
-int large = 0;
-int found = 0;
-int code = 0;
-long bytes_read = 0, advance;
-unsigned char p, edit_num, flag23;
-unsigned char size[3];
-int section0 = 8, section1, section2;
-long total;
-
-/*
-// Read bytes until "GRIB" found
-*/
-    do {
-      if( grab(buffer, &p, 1, 1, &bytes_read) != 0) return 1;
-      code = ( (code << 8) + p ) & 0xFFFFFFFF;
-      if (code == GRIB ) found = 1;
-    } while ( ! found );
-    s0 = bytes_read - 4;
-    bytes_read = 4;
-/*
-// Now find out which edition of GRIB is present (default is 1)
-*/
-    edition = 1;
-    s1 = s0 + 8;
-    if( (*(buffer+21-s0) == '\0') && (*(buffer+22-s0) == '\0') ) {
-      edition = -1;                            /* GRIB edition -1 */
-      s1 = s0;
-      section1 = 20;
-      section0 = 4;
-    }
-    else {
-      if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-      total = len3oct(size);
-      if( total == 24 ) {
-/*
-// Move past the edition number
-*/
-        if( grab(buffer, &edit_num, 1, 1, &bytes_read) != 0) return 1;
-        edition = 0;                         /* GRIB edition 0 */
-        section1 = 24;
-        s1 = s0 + 4;
-        section0 = 4;
-      }
-    }
-
-    if( edition == 1 ) {
-/*
-// See if it is an extra large (wave) product
-*/
-      if( total > 0x800000 ) {
-        total = (total&0x7fffff) * 120;
-        large = 1;
-      }
-/*
-// Move past the edition number
-*/
-      if( grab(buffer, &edit_num, 1, 1, &bytes_read) != 0) return 1;
-/*
-// Read length of section 1
-*/
-      if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-      section1 = len3oct(size);
-    }
-/*
-// Now figure out if section 2 is present
-*/
-    advance = 4;
-    bytes_read += advance;
-    if( grab(buffer, &flag23, 1, 1, &bytes_read) != 0) return 1;
-    section2 = flag23 & BIT1;
-
-/*
-// Advance to end of section 1
-*/
-    advance = section1 - (bytes_read - section0);
-    bytes_read += advance;
-/*
-// Read section 2 length if it is given
-*/
-    if( section2 ) {
-      s2 = s0 + bytes_read;
-      if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-      section2 = len3oct(size);
-      advance = section2 - (bytes_read - section0 - section1);
-      bytes_read += advance;
-    }
-    else {
-      section2 = 0;
-      s2 = 0;
-    }
-/*
-// Success!
-*/
-    *is0 = (fortint) s0;
-    *is1 = (fortint) s1;
-    *is2 = (fortint) s2;
-    return 0;
-}
-
-static int grab(unsigned char * buffer, unsigned char * where, long size,long cnt,long * num_bytes_read)
-{
-long number = size*cnt;
-
-    memcpy(where, (buffer+(*num_bytes_read)), number);
-    *num_bytes_read += number;
-
-    return 0;
-}
diff --git a/tools/compareGribFiles/PBGroutines.h b/tools/compareGribFiles/PBGroutines.h
deleted file mode 100755
index 5058d3d..0000000
--- a/tools/compareGribFiles/PBGroutines.h
+++ /dev/null
@@ -1,180 +0,0 @@
-#ifndef PBG_ROUTINES_H
-#define PBG_ROUTINES_H
-
-#include <stdio.h>
-#include <sys/types.h>
-
-#ifdef FOPEN64
-#define OFF_T off64_t
-#else
-#define OFF_T off_t
-#endif
-
-#define _fcd char *
-#define fortint int
-#define integer int
-#define bool int
-
-#define MAX_NUMBER_OF_GRIBS 100
-
-typedef struct gribfile {
-
-  FILE *  fp;
-  _fcd    fname;
-  char readwriteflag;
-  integer max;
-  integer count;
-  OFF_T * offset;
-  integer * length;
-  integer * parameter;
-  integer * level;
-  integer * date;
-  integer * time;
-  integer * timestep;
-  integer * localDefinitionNumber;
-  integer * type;
-  integer * stream;
-  integer * repres;
-  integer * levtype;
-  integer * number;
-  integer * vdate;
-  integer * vtime;
-  integer * tcNumber;
-  integer * tcTotal;
-  integer * clusterMethod;
-  integer * tcStep;
-  integer * clusterStepEnd;
-  integer * tcNorth;
-  integer * tcWest;
-  integer * tcSouth;
-  integer * tcEast;
-  integer * clusterOpFcNumber;
-  integer * clusterControlFcNumber;
-  integer * tcNumOfFcs;
-  integer * probScale;
-  integer * probIndicator;
-  integer * probLower;
-  integer * probUpper;
-  integer * ni;
-  integer * nj;
-  integer * nlat;
-  integer * nlon;
-  integer * slat;
-  integer * slon;
-  integer * di;
-  integer * dj;
-  integer * splat;
-  integer * splon;
-  integer * quasi;
-  integer * directionNumber;
-  integer * frequencyNumber;
-  integer * optimisationTime;
-  integer * leadTime;
-  integer * sensitiveAreaDomain;
-  integer * sensitiveAreaMethod;
-  integer * verifyingMonth;
-  integer * averagingPeriod;
-  integer * forecastMonth;
-  integer * referenceDate;
-  integer * climateDateFrom;
-  integer * climateDateTo;
-  integer * thresholdUnitsScale;
-  integer * thresholdIndicator;
-  integer * lowerThreshold;
-  integer * upperThreshold;
-
-  struct gribfile *next;
-
-}gribfile;
-
-typedef struct collection {
-
-  integer (* exists)(_fcd , fortint);
-  integer (* addRead)(_fcd , fortint);
-  integer (* addWrite)(_fcd , fortint);
-  void (* removeFile)(_fcd , fortint);
-
-  integer count;
-  integer max;
-  struct gribfile * files;
-
-}collection;
-
-
-/*
-// Prototypes
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-fortint pbgtotl(_fcd filename, fortint filename_len);
-fortint pbgtotl_(_fcd filename, fortint filename_len);
-fortint pbgleng(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgleng_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgoffs(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgoffs_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgparm(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgparm_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbglevl(_fcd filename, fortint * n, fortint filename_len);
-fortint pbglevl_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgdate(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgdate_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgtime(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgtime_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgstep(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgstep_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgtype(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgtype_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgstrm(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgstrm_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgrepr(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgrepr_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbglevt(_fcd filename, fortint * n, fortint filename_len);
-fortint pbglevt_(_fcd filename, fortint * n, fortint filename_len);
-fortint pbgfind(_fcd filename,
-                fortint * param, fortint * level, fortint * date,
-                fortint * time,  fortint * step,  fortint * n,
-                fortint filename_len);
-fortint pbgfind_(_fcd filename,
-                fortint * param, fortint * level, fortint * date,
-                fortint * time,  fortint * step,  fortint * n,
-                fortint filename_len);
-fortint pbgafind(_fcd filename, fortint * list, fortint * n,
-                fortint filename_len);
-fortint pbgafind_(_fcd filename, fortint * list, fortint * n,
-                fortint filename_len);
-fortint pbgbfind(_fcd filename, fortint * list, fortint * n,
-                fortint filename_len);
-fortint pbgbfind_(_fcd filename, fortint * list, fortint * n,
-                fortint filename_len);
-fortint pbgvfind(_fcd filename,
-                fortint * param, fortint * level, fortint * vdate,
-                fortint * vtime, fortint * status, fortint * n,
-                fortint filename_len);
-fortint pbgvfind_(_fcd filename,
-                fortint * param, fortint * level, fortint * vdate,
-                fortint * vtime, fortint * status, fortint * n,
-                fortint filename_len);
-fortint pbgxfind_(fortint * grib1, _fcd filename, fortint filename_len);
-fortint pbgxfind(fortint * grib1, _fcd filename, fortint filename_len);
-
-fortint pbgget(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint * n, fortint filename_len);
-fortint pbgget_(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint * n, fortint filename_len);
-
-fortint pbgput(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint filename_len);
-fortint pbgput_(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint filename_len);
-
-void pbgclos(_fcd filename, fortint filename_len);
-void pbgclos_(_fcd filename, fortint filename_len);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of  PBG_ROUTINES_H */
diff --git a/tools/compareGribFiles/PBXroutines.c b/tools/compareGribFiles/PBXroutines.c
deleted file mode 100755
index 24adf9b..0000000
--- a/tools/compareGribFiles/PBXroutines.c
+++ /dev/null
@@ -1,1210 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "PBXroutines.h"
-#include "hash.h"
-
-#define hashsize(n) ((ub4)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-
-#define XFIND_ERROR -1
-#define FSEEK_ERROR -2
-#define FREAD_ERROR -2
-#define INDEX_TOO_BIG -1
-#define BUFF_TOO_SMALL -3
-
-/*
---------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-For every delta with one or two bits set, and the deltas of all three
-  high bits or all three low bits, whether the original value of a,b,c
-  is almost all zero or is uniformly distributed,
-* If mix() is run forward or backward, at least 32 bits in a,b,c
-  have at least 1/4 probability of changing.
-* If mix() is run forward, every bit of c will change between 1/3 and
-  2/3 of the time.  (Well, 22/100 and 78/100 for some 2-bit deltas.)
-mix() was built out of 36 single-cycle latency instructions in a 
-  structure that could supported 2x parallelism, like so:
-      a -= b; 
-      a -= c; x = (c>>13);
-      b -= c; a ^= x;
-      b -= a; x = (a<<8);
-      c -= a; b ^= x;
-      c -= b; x = (b>>13);
-      ...
-  Unfortunately, superscalar Pentiums and Sparcs can't take advantage 
-  of that parallelism.  They've also turned some of those single-cycle
-  latency instructions into multi-cycle latency instructions.  Still,
-  this is the fastest good hash I could find.  There were about 2^^68
-  to choose from.  I only looked at a billion or so.
---------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
-  a -= b; a -= c; a ^= (c>>13); \
-  b -= c; b -= a; b ^= (a<<8); \
-  c -= a; c -= b; c ^= (b>>13); \
-  a -= b; a -= c; a ^= (c>>12);  \
-  b -= c; b -= a; b ^= (a<<16); \
-  c -= a; c -= b; c ^= (b>>5); \
-  a -= b; a -= c; a ^= (c>>3);  \
-  b -= c; b -= a; b ^= (a<<10); \
-  c -= a; c -= b; c ^= (b>>15); \
-}
-
-/*
---------------------------------------------------------------------
-hash() -- hash a variable-length key into a 32-bit value
-  k       : the key (the unaligned variable-length array of bytes)
-  len     : the length of the key, counting by bytes
-  initval : can be any 4-byte value
-Returns a 32-bit value.  Every bit of the key affects every bit of
-the return value.  Every 1-bit and 2-bit delta achieves avalanche.
-About 6*len+35 instructions.
-
-The best hash table sizes are powers of 2.  There is no need to do
-mod a prime (mod is sooo slow!).  If you need less than 32 bits,
-use a bitmask.  For example, if you need only 10 bits, do
-  h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (ub1 **)k, do it like this:
-  for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
-
-By Bob Jenkins, 1996.  bob_jenkins at burtleburtle.net.  You may use this
-code any way you wish, private, educational, or commercial.  It's free.
-
-See http://burtleburtle.net/bob/hash/evahash.html
-Use for hash table lookup, or anything where one collision in 2^^32 is
-acceptable.  Do NOT use for cryptographic purposes.
---------------------------------------------------------------------
-*/
-
-ub4 hash( k, length, initval)
-register ub1* k;        /* the key */
-register ub4  length;   /* the length of the key */
-register ub4  initval;  /* the previous hash, or an arbitrary value */
-{
-   register ub4 a,b,c,len;
-
-   /* Set up the internal state */
-   len = length;
-   a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
-   c = initval;         /* the previous hash value */
-
-   /*---------------------------------------- handle most of the key */
-   while (len >= 12)
-   {
-      a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
-      b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
-      c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
-      mix(a,b,c);
-      k += 12; len -= 12;
-   }
-
-   /*------------------------------------- handle the last 11 bytes */
-   c += length;
-   switch(len)              /* all the case statements fall through */
-   {
-   case 11: c+=((ub4)k[10]<<24);
-   case 10: c+=((ub4)k[9]<<16);
-   case 9 : c+=((ub4)k[8]<<8);
-      /* the first byte of c is reserved for the length */
-   case 8 : b+=((ub4)k[7]<<24);
-   case 7 : b+=((ub4)k[6]<<16);
-   case 6 : b+=((ub4)k[5]<<8);
-   case 5 : b+=k[4];
-   case 4 : a+=((ub4)k[3]<<24);
-   case 3 : a+=((ub4)k[2]<<16);
-   case 2 : a+=((ub4)k[1]<<8);
-   case 1 : a+=k[0];
-     /* case 0: nothing left to add */
-   }
-   mix(a,b,c);
-   /*-------------------------------------------- report the result */
-   return c;
-}
-
-long date_to_julian(long ddate);
-long julian_to_date(long jdate);
-
-integer pbxinitInput(_fcd filename, fortint filename_len);
-integer pbxinitOutput(_fcd filename, fortint filename_len);
-void copyName(_fcd* , _fcd , fortint );
-
-fortint readgrib(FILE* file, unsigned char* buffer, fortint* prod_len);
-
-void pbxindx(fortint);
-
-integer gribHashNumber(unsigned char*,integer*);
-void addHashNumberToFile(gribfile*,unsigned char*,integer,integer,integer);
-
-static gribfile* latestFile(collection);
-static gribfile* currentFile(collection, integer);
-
-/*
-// 
-*/
-#define DEBUGOFF 1
-#define DEBUG1 (debugSet > DEBUGOFF )
-#define DEBUG2 (debugSet > (DEBUGOFF + 1) )
-static char* debugLevel;
-static int debugSet = 0;
-
-#define ONEBYTELONG(a)   (long) ( *(a) )
-#define TWOBYTELONG(a)   (long) ( (*(a))<<8 | (*((a)+1))<<0 )
-#define THREEBYTELONG(a) (long) (TWOBYTELONG((a))<<8 | (*((a)+2))<<0 )
-#define FOURBYTELONG(a)  (long) (THREEBYTELONG((a))<<8 | (*((a)+3))<<0 )
-
-#define MISSING -1
-#define NOTGIVEN(x) ((x) == MISSING )
-#define MATCH(a,b)  (NOTGIVEN((a)) || ((a) == (b)))
-
-#define HEADLEN 10000
-
-integer exists(_fcd , fortint );
-integer addRead(_fcd , fortint );
-integer addWrite(_fcd , fortint );
-void removeFile(_fcd , fortint );
-
-collection openFiles = {exists,addRead,addWrite,removeFile,-1,-1,NULL};
-
-void pbxindx(fortint thisFile) {
-/*
-// Fills in details of current file
-*/
-unsigned char header[HEADLEN];
-fortint status;
-fortint headerlen;
-OFF_T space;
-integer number, headerLength, number_of_fields = 0;
-gribfile* file = currentFile(openFiles,thisFile);
-
-/*
-// Loop through products in the file
-// Accept product if OK or if only problem is 'buffer too small' or on EOF
-*/
-  file->offset[0] = 0;
-  do {
-    headerlen = HEADLEN;
-    status = readgrib(file->fp,header,&headerlen);
-    if( (status!=0) && (status!=-3) && (status!=-1) ) exit(1);
-    if( status == -1 ) break;
-/*
-// Note the product byte offset in the file
-*/
-    file->length[number_of_fields] = (OFF_T) headerlen;
-#ifdef FOPEN64
-    file->offset[number_of_fields] =
-      ftello64(file->fp) - file->length[number_of_fields];
-#else
-    file->offset[number_of_fields] =
-      (OFF_T) ftell(file->fp) - file->length[number_of_fields];
-#endif
-
-/*
-// If it's a GRIB edition 1 product, pick up more information
-// (parameter,level,..)
-*/
-    if( strncmp((char*)header,"GRIB", 4)==0 ) {
-/*
-//    Eliminate GRIB editions 0 and -1
-*/
-      if( (header[ 7] != '\1') ) break;
-      if( (header[19] == '\0') && (header[20] == '\0') &&
-          (header[21] == '\0') && (header[22] == '\0') &&
-          (header[23] == '\0') ) break;
-
-      number = gribHashNumber(header,&headerLength);
-      addHashNumberToFile(file,header,headerLength,number,number_of_fields);
-
-#define REALLOC(a) (a)  =  realloc((a) , (size_t) space)
-
-      number_of_fields++;
-      if( number_of_fields == file->max ) {
-        integer newSize = (file->max)*2;
-        file->max = newSize;
-
-        space = (OFF_T) (sizeof(OFF_T)*newSize);
-        REALLOC(file->offset);
-
-        space = (OFF_T) (sizeof(integer)*newSize);
-        REALLOC(file->length);
-/*
-JDC      REALLOC(file->hashNumber);
-*/
-      }
-    }
-        
-  } while( (!feof(file->fp)) &&
-           (number_of_fields < file->max)
-         );
-
-  file->count = number_of_fields;
-
-  return;
-}
-
-fortint soffset012_(unsigned char*,fortint*,fortint*,fortint*);
-
-integer gribHashNumber( unsigned char* header, integer* headerLength)
-/*
-// Returns hashNumber for a GRIB product.
-*/
-{
-fortint status, is0, is1, is2;
-
-  status = soffset012_(header, &is0, &is1, &is2);
-
-  *headerLength = (is1 - is0);
-  *headerLength += THREEBYTELONG(header+is1);
-  if( is2 != 0 ) *headerLength += THREEBYTELONG(header+is2);
-
-  return hash((header+is0),*headerLength,0);
-}
-
-/*
-// ****************************************************************
-*/
-fortint pbxtotl_(_fcd filename, fortint filename_len) {
-/*
-// Returns number of GRIB products in the file.
-*/
-integer thisFile;
-gribfile* file;
-
-  thisFile = pbxinitInput(filename,filename_len);
-  file = currentFile(openFiles, thisFile);
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBXTOTL: Number of GRIBs in file %s = %d\n", pfile, file->count);
-    free(pfile);
-  }
-  return ( file->count );
-}
-
-fortint pbxtotl(_fcd filename, fortint filename_len) {
-  return pbxtotl_(filename,filename_len);
-}
-
-fortint pbxget_(_fcd filename, fortint* buffer, fortint* bufflen,
-               fortint* n, fortint filename_len) {
-/*
-// Gets the nth GRIB product.
-*/
-integer index = (*n)-1;
-integer length, status;
-OFF_T offset;
-integer thisFile;
-FILE* fp;
-gribfile* file;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBXGET: getting GRIB number %d in file %s\n",
-    (index+1), pfile);
-    free(pfile);
-  }
-
-  if( index >= 0 ) {
-    thisFile = pbxinitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-
-      length = file->length[index];
-
-      if( DEBUG1 ) printf("PBXGET: length of GRIB number %d = %d\n",
-                          (index+1), length);
-
-      if( *bufflen < length ) {
-        fprintf(stderr,
-          "PBXGET: user buffer too small, %d bytes required\n", length);
-        return BUFF_TOO_SMALL;
-      }
-
-      offset = file->offset[index];
-
-      if( DEBUG1 ) printf("PBXGET: offset of GRIB number %d = %d\n",
-                          (index+1), offset);
-
-      fp = file->fp;
-#ifdef FOPEN64
-      if( fseeko64( fp, offset, 0) ) {
-#else
-      if( fseek( fp, offset, 0) ) {
-#endif
-        perror("PBXGET: error in fseek");
-        return FSEEK_ERROR;
-      }
-
-      status = fread(buffer, 1, length, fp);
-      if( status != length ) {
-        fprintf(stderr,"PBXGET: error in fread\n");
-        return FREAD_ERROR;
-      }
-      
-      return length;
-    }
-  }
-
-  return INDEX_TOO_BIG;
-
-}
-
-fortint pbxget(_fcd filename, fortint* buffer, fortint* bufflen,
-               fortint* n, fortint filename_len) {
-  return pbxget_(filename,buffer,bufflen,n,filename_len);
-}
-
-/*
-// ****************************************************************
-*/
-integer pbxinitInput(_fcd filename, fortint filename_len) {
-/*
-// Initialise indices for current file if necessary.
-*/
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBX_pbxinitInput: checking if file %s already open\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = openFiles.exists(filename,filename_len);
-
-  if( thisFile == -1 ) {
-    if( DEBUG2 ) printf("PBX_pbxinitInput: file not yet open\n");
-    return ( openFiles.addRead(filename, filename_len) );
-  }
-
-  if( DEBUG2 ) printf("PBX_pbxinitInput: file has open slot %d\n", thisFile);
-  return thisFile;
-
-}
-
-integer pbxinitOutput(_fcd filename, fortint filename_len) {
-/*
-// Initialise output file if necessary.
-*/
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBX_pbxinitOutput: checking if file %s already open\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = openFiles.exists(filename,filename_len);
-
-  if( thisFile == -1 ) {
-    if( DEBUG2 ) printf("PBX_pbxinitOutput: file not yet open\n");
-    return ( openFiles.addWrite(filename, filename_len) );
-  }
-
-  if( DEBUG2 ) printf("PBX_pbxinitOutput: file has open slot %d\n", thisFile);
-  return thisFile;
-
-}
-
-integer exists(_fcd filename , fortint filename_len) {
-integer n;
-_fcd pfile;
-gribfile* file;
-
-
-/*
-// See if DEBUG switched on.
-*/
-    if( ! debugSet ) {
-      debugLevel = getenv("PBX_DEBUG");
-      if( debugLevel == NULL )
-        debugSet = DEBUGOFF;              /* off */
-      else {
-        int loop;
-        for( loop = 0; loop < strlen(debugLevel) ; loop++ ) {
-          if( ! isdigit(debugLevel[loop]) ) {
-            printf("Invalid number string in PBX_DEBUG: %s\n", debugLevel);
-            printf("PBX_DEBUG must comprise only digits [0-9].\n");
-            debugSet = DEBUGOFF;
-          }
-        }
-        debugSet = DEBUGOFF + atol( debugLevel );
-      }
-      if( DEBUG2 ) printf("PBX_exists: PBX_DEBUG switched on\n");
-    }
-
-  if( openFiles.count > -1 ) {
-
-    copyName(&pfile, filename, filename_len);
-
-    if( DEBUG2 ) printf("PBX_exists: looking for filename = %s\n", pfile);
-
-    for( n = 0; n <= openFiles.count; n++ ) {
-      file = currentFile(openFiles, n);
-      if( file != 0 ) {
-        if( strcmp( file->fname, pfile ) == 0 ) {
-          free(pfile);
-          if( DEBUG2 ) printf("PBX_exists: file found in slot= %d\n", n);
-          return n;
-        }
-      }
-    }
-
-    free(pfile);
-  }
-  return -1;
-}
-
-integer addFile(_fcd filename , fortint filename_len, char readwriteflag) {
-_fcd pfile;
-char mode[2] = " ";
-FILE* in;
-gribfile* previousLatest, * latest;
-
-  openFiles.count++;
-
-  copyName(&pfile, filename, filename_len);
-
-  if( DEBUG2 ) printf("PBX_addFile: adding filename = %s\n", pfile);
-
-  mode[0] = readwriteflag;
-#ifdef FOPEN64
-  in = fopen64(pfile,mode);
-#else
-  in = fopen(pfile,mode);
-#endif
-  if( in == NULL ) {
-    perror("Error opening file");
-    exit(1);
-  }
-
-  if( openFiles.count == 0 ) {
-    openFiles.files = (gribfile*)malloc(sizeof(gribfile));
-    latest = openFiles.files;
-  }
-  else {
-    previousLatest = latestFile(openFiles);
-    previousLatest->next = (gribfile*)malloc(sizeof(gribfile));
-    latest = previousLatest->next;
-  }
-
-  latest->fp = in;
-  copyName(&(latest->fname),filename,filename_len);
-  latest->readwriteflag = readwriteflag;
-  latest->max = MAX_NUMBER_OF_GRIBS;
-  latest->count = 0;
-
-#define MALLOC(a) (a) = (void*) malloc(space)
-
-  if( readwriteflag == 'r' ) {
-    integer space;
-
-    space = sizeof(OFF_T)*MAX_NUMBER_OF_GRIBS;
-    MALLOC(latest->offset);
-
-    space = sizeof(integer)*MAX_NUMBER_OF_GRIBS;
-    MALLOC(latest->length);
-/*
-JDC  MALLOC(latest->hashTable);
-*/
-     latest->fileHashTable = NULL;
-  }
-
-  latest->next = 0;
-
-  if( DEBUG2 ) printf("PBX_addFile: adding file %s in slot = %d\n",
-                       pfile, openFiles.count);
-
-  free(pfile);
-  return openFiles.count;
-
-}
-
-void removeFile(_fcd filename , fortint filename_len) {
-integer thisFile;
-int status;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBX_removeFile: trying to remove filename = %s\n", pfile);
-    free(pfile);
-  }
- 
-  thisFile = openFiles.exists(filename,filename_len);
-
-  if( thisFile != -1 ) {
-    integer index;
-    gribfile* previous = openFiles.files;
-    gribfile* current;
-
-    current = previous;
-
-    for( index = 0; index < thisFile; index++ ) {
-      previous = current;
-      current = current->next;
-    }
-
-    status = fclose(current->fp);
-    if( status != 0 ) {
-      perror("Error closing file");
-      exit(1);
-    }
-    if( DEBUG2 ) printf("PBX_removeFile: removing file %s from slot %d\n",
-                         current->fname, thisFile);
-    free(current->fname);
-
-/*
-//  Input files have arrays of values
-*/
-    if( current->readwriteflag == 'r' ) {
-      free(current->offset);
-      free(current->length);
-/*
-JDC    free(current->hashNumber);
-*/
-    }
-
-    if( thisFile == 0 ) 
-      openFiles.files = (current->next);
-    else
-       previous->next = (current->next);
-    free(current);
-    
-    openFiles.count--;
-  }
-}
-
-integer addRead(_fcd filename , fortint filename_len) {
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBX_addRead: add for reading filename = %s\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = addFile(filename,filename_len,'r');
-
-  pbxindx( thisFile);
-
-  return thisFile;
-}
-
-integer addWrite(_fcd filename , fortint filename_len) {
-integer thisFile;
-
-  if( DEBUG2 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("PBX_addWrite: add for writing filename = %s\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = addFile(filename,filename_len,'w');
-
-  return thisFile;
-}
-
-void copyName(_fcd* pfile, _fcd filename, fortint filename_len) {
-/*
-// Copies FORTRAN filename to C string.
-*/
-char* blankCharacterPointer;
-integer space;
-
-  *pfile = (char*) malloc((size_t) (filename_len+1) );
-  memcpy(*pfile, filename, (size_t) filename_len);
-  space = (integer) filename_len;
-  (*pfile)[space] = '\0';
-
-  blankCharacterPointer = strchr(filename, ' ');
-  if( blankCharacterPointer != NULL ) {
-    space = (integer) (blankCharacterPointer - filename);
-    (*pfile)[space] = '\0';
-  }
-
-  return;
-}
-
-gribfile* latestFile(collection openFiles) {
-integer index;
-gribfile* last = openFiles.files;
-
-  for( index = 1; index < openFiles.count; index++ )
-    last =  last->next;
-
-  return last;
-
-}
-
-gribfile* currentFile(collection openFiles, integer thisFile) {
-integer index;
-gribfile* current = openFiles.files;
-
-  for( index = 0; index < thisFile; index++ )
-    current = current->next;
-
-  return current;
-}
-
-long julian_to_date(long jdate) {
-long x,y,d,m,e;
-long day,month,year;
-
-    x = 4 * jdate - 6884477;
-    y = (x / 146097) * 100;
-    e = x % 146097;
-    d = e / 4;
-
-    x = 4 * d + 3;
-    y = (x / 1461) + y;
-    e = x % 1461;
-    d = e / 4 + 1;
-
-    x = 5 * d - 3;
-    m = x / 153 + 1;
-    e = x % 153;
-    d = e / 5 + 1;
-
-    if( m < 11 )
-    	month = m + 2;
-    else
-    	month = m - 10;
-
-    day = d;
-    year = y + m / 11;
-
-    return year * 10000 + month * 100 + day;
-}
-
-long date_to_julian(long ddate) {
-long  m1,y1,a,b,c,d,j1;
-long month,day,year;
-
-    year = ddate / 10000;
-    ddate %= 10000;
-    month  = ddate / 100;
-    ddate %= 100;
-    day = ddate;
-
-
-    if (year < 100) year = year + 1900;
-
-    if (month > 2)
-    {
-    	m1 = month - 3;
-    	y1 = year;
-    }
-    else
-    {
-    	m1 = month + 9;
-    	y1 = year - 1;
-    }
-
-    a = 146097*(y1/100)/4;
-    d = y1 % 100;
-    b = 1461*d/4;
-    c = (153*m1+2)/5+day+1721119;
-    j1 = a+b+c;
-
-    return(j1);
-}
-
-fortint soffset012_(unsigned char*,fortint*,fortint*,fortint*);
-
-integer findHashEntry(gribfile*,integer,unsigned char*,integer);
-
-fortint pbxxfind_(fortint* grib1, _fcd filename, fortint filename_len)
-{
-unsigned char* buffer1 = (unsigned char*) grib1;
-static fortint* ibuffer2 = NULL;
-static buffer2Length = 0;
-fortint status, totalLength, headerLength, numberOfGribs, loop;
-fortint is0, is1, is2;
-fortint js0, js1, js2;
-ub4 hash1, hash2;
-integer thisFile;
-gribfile* file;
-fortint next;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    integer loop;
-
-    copyName(&pfile, filename, filename_len);
-    printf("PBXXFIND: searching file %s\n", pfile);
-    free(pfile);
-  }
-
-  thisFile = pbxinitInput(filename,filename_len);
-  file = currentFile(openFiles, thisFile);
-
-  numberOfGribs = pbxtotl_(filename,filename_len);
-  if( numberOfGribs < 1 ) {
-    if( DEBUG1 ) {
-      _fcd pfile;
-      copyName(&pfile, filename, filename_len);
-      printf("PBXFIND: No GRIBs in file %s\n", pfile);
-      free(pfile);
-    }
-    return XFIND_ERROR;
-  }
-
-  status = soffset012_(buffer1, &is0, &is1, &is2);
-  if( status ) return XFIND_ERROR;
-
-  totalLength = THREEBYTELONG(buffer1+is0+4);
-  headerLength = (is1 - is0);
-  headerLength += THREEBYTELONG(buffer1+is1);
-  if( is2 != 0 ) headerLength += THREEBYTELONG(buffer1+is2);
-  hash1 = hash((buffer1+is0),headerLength,0);
-
-  if( (next = findHashEntry(file,hash1,(buffer1+is0),headerLength) ) >= 0 )
-    return (next+1);
-  else 
-    return XFIND_ERROR;
-}
-
-fortint pbxxfind(fortint* grib1, _fcd filename, fortint filename_len) {
-  return pbxxfind_(grib1,filename,filename_len);
-}
-
-#define GRIB_TOO_SMALL -4
-
-fortint pbxgeth012_(_fcd filename, fortint* buffer, fortint bufflen,
-                    fortint n, fortint filename_len) {
-/*
-// Gets section 0,1 and 2 for the nth GRIB product.
-*/
-integer index = n - 1;
-integer length, status;
-OFF_T offset;
-integer thisFile;
-FILE* fp;
-gribfile* file;
-
-  if( DEBUG1 ) {
-    _fcd pfile;
-    copyName(&pfile, filename, filename_len);
-    printf("pbxgeth012: getting GRIB number %d in file %s\n",
-    (index+1), pfile);
-    free(pfile);
-  }
-
-  if( index >= 0 ) {
-    thisFile = pbxinitInput(filename,filename_len);
-    file = currentFile(openFiles, thisFile);
-    if( index < file->count ) {
-
-      length = file->length[index];
-
-      if( DEBUG1 ) printf("pbxgeth012: length of GRIB number %d = %d\n",
-                          (index+1), length);
-
-      if( length < bufflen ) return GRIB_TOO_SMALL;
-
-      offset = file->offset[index];
-
-      if( DEBUG1 ) printf("pbxgeth012: offset of GRIB number %d = %d\n",
-                          (index+1), offset);
-
-      fp = file->fp;
-#ifdef FOPEN64
-      if( fseeko64( fp, offset, 0) ) {
-#else
-      if( fseek( fp, offset, 0) ) {
-#endif
-        perror("pbxgeth012: error in fseek");
-        return FSEEK_ERROR;
-      }
-
-      status = fread(buffer, 1, bufflen, fp);
-      if( status != bufflen ) {
-        fprintf(stderr,"pbxgeth012: error in fread\n");
-        return FREAD_ERROR;
-      }
-      
-      return length;
-    }
-  }
-
-  return INDEX_TOO_BIG;
-
-}
-
-#define ERROR(a,b) {perror(a);return b;}
-#define GRIB 0x47524942
-#define len3oct(p) ((((long)*(p))<<16) + (((long)*(p+1))<<8) + (long)*(p+2))
-#define BIT1 0x80
-#define BIT2 0x40
-#define BIT3 0x20
-#define BIT4 0x10
-#define BIT5 0x08
-#define BIT6 0x04
-#define BIT7 0x02
-#define BIT8 0x01
-
-static int grab(unsigned char* , unsigned char* , long ,long ,long* );
-
-fortint soffset012_(
-  unsigned char* buffer,
-  fortint* is0,
-  fortint* is1,
-  fortint* is2 ) {
-long s0, s1, s2, edition;
-int large = 0;
-int found = 0;
-int code = 0;
-long bytes_read = 0, advance;
-unsigned char p, edit_num, flag23;
-unsigned char size[3];
-int section0 = 8, section1, section2;
-long total;
-
-/*
-// Read bytes until "GRIB" found
-*/
-    do {
-      if( grab(buffer, &p, 1, 1, &bytes_read) != 0) return 1;
-      code = ( (code << 8) + p ) & 0xFFFFFFFF;
-      if (code == GRIB ) found = 1;
-    } while ( ! found );
-    s0 = bytes_read - 4;
-    bytes_read = 4;
-/*
-// Now find out which edition of GRIB is present (default is 1)
-*/
-    edition = 1;
-    s1 = s0 + 8;
-    if( (*(buffer+21-s0) == '\0') && (*(buffer+22-s0) == '\0') ) {
-      edition = -1;                            /* GRIB edition -1 */
-      s1 = s0;
-      section1 = 20;
-      section0 = 4;
-    }
-    else {
-      if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-      total = len3oct(size);
-      if( total == 24 ) {
-/*
-// Move past the edition number
-*/
-        if( grab(buffer, &edit_num, 1, 1, &bytes_read) != 0) return 1;
-        edition = 0;                         /* GRIB edition 0 */
-        section1 = 24;
-        s1 = s0 + 4;
-        section0 = 4;
-      }
-    }
-
-    if( edition == 1 ) {
-/*
-// See if it is an extra large (wave) product
-*/
-      if( total > 0x800000 ) {
-        total = (total&0x7fffff) * 120;
-        large = 1;
-      }
-/*
-// Move past the edition number
-*/
-      if( grab(buffer, &edit_num, 1, 1, &bytes_read) != 0) return 1;
-/*
-// Read length of section 1
-*/
-      if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-      section1 = len3oct(size);
-    }
-/*
-// Now figure out if section 2 is present
-*/
-    advance = 4;
-    bytes_read += advance;
-    if( grab(buffer, &flag23, 1, 1, &bytes_read) != 0) return 1;
-    section2 = flag23 & BIT1;
-
-/*
-// Advance to end of section 1
-*/
-    advance = section1 - (bytes_read - section0);
-    bytes_read += advance;
-/*
-// Read section 2 length if it is given
-*/
-    if( section2 ) {
-      s2 = s0 + bytes_read;
-      if( grab(buffer, size, 3, 1, &bytes_read) != 0) return 1;
-      section2 = len3oct(size);
-      advance = section2 - (bytes_read - section0 - section1);
-      bytes_read += advance;
-    }
-    else {
-      section2 = 0;
-      s2 = 0;
-    }
-/*
-// Success!
-*/
-    *is0 = (fortint) s0;
-    *is1 = (fortint) s1;
-    *is2 = (fortint) s2;
-    return 0;
-}
-
-static int grab(unsigned char* buffer, unsigned char* where, long size,long cnt,long* num_bytes_read)
-{
-long number = size*cnt;
-
-    memcpy(where, (buffer+(*num_bytes_read)), number);
-    *num_bytes_read += number;
-
-    return 0;
-}
-
-#define BASIC_HASH_TABLE_SIZE 1000
-#define BASIC_HIT_LIST_SIZE 2
-
-#define FILETABLE(a) ((a)->fileHashTable)
-#define FILEENTRIES(a) (*(*FILETABLE(a)).entries)
-#define ENTRY(a,b) ((a)->fileHashTable)->entries[(b)]
-#define HIT(a,b,c) (ENTRY((a),(b)))->hitList[(c)]
-
-void addHashEntry(
-  gribfile* file,
-  unsigned char* header,
-  integer headerLength,
-  integer number,
-  integer index)
-{
-integer nextEntry = (*FILETABLE(file)).numberOfEntries;
-integer maximum = (*FILETABLE(file)).maximumNumberOfEntries;
-integer loop;
-
-  if( DEBUG1 ) printf("addHashEntry: file = %0x\n",file);
-/*
-// See if hash number already in the hit list
-*/
-  for( loop = 0; loop < nextEntry; loop++ ) {
-
-    if( ENTRY(file,loop)->value == number ) {
-      integer nextHitEntry = ENTRY(file,loop)->numberOfHits;
-      integer maximumHits  = ENTRY(file,loop)->maximumNumberOfHits;
-
-      if( DEBUG1 ) {
-        printf("addHashEntry: %0x already in hash table in position %d\n",
-               number,loop);
-        printf("addHashEntry: numberOfHits = %d\n",
-               ENTRY(file,loop)->numberOfHits);
-      }
-      if( nextHitEntry < maximumHits ) {
-        HIT(file,loop,nextHitEntry)->index = index;
-        HIT(file,loop,nextHitEntry)->length = headerLength;
-        HIT(file,loop,nextHitEntry)->bytes =
-          (unsigned char*) malloc(headerLength);
-        memcpy(HIT(file,loop,nextHitEntry)->bytes,header,headerLength);
-        ENTRY(file,loop)->numberOfHits++;
-        if( DEBUG1) printf("addHashEntry: numberOfHits -> %d\n",
-                           ENTRY(file,loop)->numberOfHits);
-      }
-      else {
-        integer hitLoop, newMaximum = maximumHits * 2;
-        hit** newList = (hit**) malloc(sizeof(hit*)*newMaximum);
-
-        if( DEBUG1 ) {
-          printf("addHashEntry: nextHitEntry = %d\n",nextHitEntry);
-          printf("addHashEntry: old hit limit = %d\n",maximumHits);
-          printf("addHashEntry: expand to %d\n",newMaximum);
-        }
-        
-        for( hitLoop = 0; hitLoop < maximumHits; hitLoop++ )
-          newList[hitLoop] = HIT(file,loop,hitLoop);
-
-        for( hitLoop = maximumHits; hitLoop < newMaximum; hitLoop++ ) {
-          newList[hitLoop] = (hit*) malloc(sizeof(hit));
-          newList[hitLoop]->index = -1; 
-          newList[hitLoop]->length = 0; 
-          newList[hitLoop]->bytes = NULL; 
-        }
-
-        free(ENTRY(file,loop)->hitList);
-        ENTRY(file,loop)->hitList = newList;
-        ENTRY(file,loop)->maximumNumberOfHits = newMaximum;
-
-        HIT(file,loop,nextHitEntry)->index = index;
-        HIT(file,loop,nextHitEntry)->length = headerLength;
-        HIT(file,loop,nextHitEntry)->bytes =
-          (unsigned char*) malloc(headerLength);
-        memcpy(HIT(file,loop,nextHitEntry)->bytes,header,headerLength);
-        ENTRY(file,loop)->numberOfHits++;
-      }
-
-      return;
-    }
-  }
-
-  if( nextEntry < maximum ) {
-    ENTRY(file,nextEntry)->value = number;
-    if( DEBUG1 )
-      printf("addHashEntry: ENTRY(file,%d) = %0x\n",
-             nextEntry,ENTRY(file,nextEntry)->value);
-    HIT(file,nextEntry,0)->index = index;
-    HIT(file,nextEntry,0)->length = headerLength;
-    HIT(file,nextEntry,0)->bytes = (unsigned char*) malloc(headerLength);
-    memcpy(HIT(file,nextEntry,0)->bytes,header,headerLength);
-    ENTRY(file,nextEntry)->numberOfHits = 1;
-
-    (*FILETABLE(file)).numberOfEntries++;
-  }
-  else {
-    integer loop, newSize= maximum * 2;
-    integer entryLoop, hitLoop;
-    hashValue** newEntries = (hashValue**) malloc(sizeof(hashValue*)*newSize);
-
-    if( DEBUG1 ) {
-      printf("addHashEntry: Hash table full\n");
-      printf("addHashEntry: nextEntry = %d\n",nextEntry);
-      printf("addHashEntry: current maximum = %d\n",maximum);
-      printf("addHashEntry: increase maximum to %d\n",newSize);
-    }
-
-    for( entryLoop = 0; entryLoop < maximum; entryLoop++ )
-      newEntries[entryLoop] = (file->fileHashTable)->entries[entryLoop];
-
-    for( entryLoop = maximum; entryLoop < newSize; entryLoop++ ) {
-      newEntries[entryLoop] = (hashValue*) malloc(sizeof(hashValue));
-      newEntries[entryLoop]->hitList =
-        (hit**) malloc(sizeof(hit)*BASIC_HIT_LIST_SIZE);
-      newEntries[entryLoop]->maximumNumberOfHits = BASIC_HIT_LIST_SIZE;
-      newEntries[entryLoop]->value = -1;
-
-      for( hitLoop = 0; hitLoop < BASIC_HIT_LIST_SIZE; hitLoop++ ) {
-        newEntries[entryLoop]->hitList[hitLoop] = (hit*) malloc(sizeof(hit));
-        newEntries[entryLoop]->hitList[hitLoop]->index = 0;
-        newEntries[entryLoop]->hitList[hitLoop]->length = 0;
-        newEntries[entryLoop]->hitList[hitLoop]->bytes = NULL;
-      }
-    }
-
-    free((file->fileHashTable)->entries);
-    (file->fileHashTable)->entries = newEntries;
-    (*FILETABLE(file)).maximumNumberOfEntries = newSize;
-
-    ENTRY(file,nextEntry)->value = number;
-    if( DEBUG1 )
-      printf("addHashEntry: ENTRY(file,%d) = %0x\n",
-             nextEntry,ENTRY(file,nextEntry)->value);
-    HIT(file,nextEntry,0)->index = index;
-    HIT(file,nextEntry,0)->length = headerLength;
-    HIT(file,nextEntry,0)->bytes = (unsigned char*) malloc(headerLength);
-    memcpy(HIT(file,nextEntry,0)->bytes,header,headerLength);
-    ENTRY(file,nextEntry)->numberOfHits = 1;
-
-    (*FILETABLE(file)).numberOfEntries++;
-  }
-
-  return;
-}
-
-void addHashNumberToFile(
-  gribfile* file,
-  unsigned char* header,
-  integer headerLength,
-  integer number,
-  integer index)
-{
-integer entryLoop, hitLoop;
-
-  if( FILETABLE(file) == NULL ) {
-
-    FILETABLE(file) = (hashTable*) malloc(sizeof(hashTable));
-
-    (*FILETABLE(file)).entries =
-      (hashValue**) malloc(sizeof(hashValue*)*BASIC_HASH_TABLE_SIZE);
-    (*FILETABLE(file)).maximumNumberOfEntries = BASIC_HASH_TABLE_SIZE;
-    (*FILETABLE(file)).numberOfEntries = 0;
-
-    for( entryLoop = 0; entryLoop < BASIC_HASH_TABLE_SIZE; entryLoop++ ) {
-
-      (*FILETABLE(file)).entries[entryLoop] =
-        (hashValue*) malloc(sizeof(hashValue));
-
-      ENTRY(file,entryLoop)->hitList =
-        (hit**) malloc(sizeof(hit)*BASIC_HIT_LIST_SIZE);
-      ENTRY(file,entryLoop)->maximumNumberOfHits = BASIC_HIT_LIST_SIZE;
-      ENTRY(file,entryLoop)->value = -1;
-
-      for( hitLoop = 0; hitLoop < BASIC_HIT_LIST_SIZE; hitLoop++ ) {
-        ENTRY(file,entryLoop)->hitList[hitLoop] = (hit*) malloc(sizeof(hit));
-        HIT(file,entryLoop,hitLoop)->index = 0;
-        HIT(file,entryLoop,hitLoop)->length = 0;
-        HIT(file,entryLoop,hitLoop)->bytes = NULL;
-      }
-    }
-  }
-
-  addHashEntry(file,header,headerLength,number,index);
-
-  return;
-}
-
-#define HASH_NOT_FOUND -1
-
-integer correctMatchingHit(hashValue*,unsigned char*,integer);
-
-integer findHashEntry(
-  gribfile* file,
-  integer number,
-  unsigned char* header,
-  integer headerLength)
-{
-/*
-// See if hash number in the hit list
-*/
-integer numberInList = (*FILETABLE(file)).numberOfEntries;
-integer loop;
-
-  if( DEBUG1 )
-    printf("findHashEntry: file = %0x, number = %0x\n",file, number);
-  for( loop = 0; loop < numberInList; loop++ ) {
-    if( ENTRY(file,loop)->value == number ) {
-      if( DEBUG2 ) {
-        printf("findHashEntry: %0x in hash table in position %d\n",
-               number,loop);
-        printf("findHashEntry: numberOfHits = %d\n",
-               ENTRY(file,loop)->numberOfHits);
-      }
-      return correctMatchingHit(ENTRY(file,loop), header, headerLength);
-    }
-  }
-  return HASH_NOT_FOUND;
-}
-
-integer correctMatchingHit(
-  hashValue* entry,
-  unsigned char* header,
-  integer headerLength)
-{
-/*
-// See if key details have a match in the hit list
-*/
-integer loop;
-hit* nextHit;
-
-  for( loop = 0; loop < entry->numberOfHits; loop++ ) {
-    nextHit = entry->hitList[loop];
-    if( nextHit->length == headerLength )
-      if( memcmp(nextHit->bytes,header,headerLength) == 0 )
-        return nextHit->index;
-  }
-
-  return HASH_NOT_FOUND;
-}
diff --git a/tools/compareGribFiles/PBXroutines.h b/tools/compareGribFiles/PBXroutines.h
deleted file mode 100755
index fecc316..0000000
--- a/tools/compareGribFiles/PBXroutines.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef PBX_ROUTINES_H
-#define PBX_ROUTINES_H
-
-
-#ifdef linux
-# if !defined __off64_t_defined
-typedef __off64_t off64_t;
-#define __off64_t_defined
-#endif
-#define __USE_LARGEFILE64
-#define _LARGEFILE64_SOURCE
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "hash.h"
-
-#ifdef FOPEN64
-#define OFF_T off64_t
-extern OFF_T ftello64(FILE *);
-#else
-#define OFF_T off_t
-#endif
-
-#define _fcd char *
-#define fortint int
-/*#define integer int*/
-#define integer OFF_T
-#define bool int
-
-#define MAX_NUMBER_OF_GRIBS 100
-
-typedef struct hit {
-  integer index;
-  integer length;
-  unsigned char* bytes;
-} hit;
-
-typedef struct hashValue {
-  integer value;
-  integer numberOfHits;
-  integer maximumNumberOfHits;
-  hit** hitList;
-} hashValue;
-
-typedef struct hashTable {
-  integer numberOfEntries;
-  integer maximumNumberOfEntries;
-  hashValue** entries;
-} hashTable;
-
-typedef struct gribfile {
-  FILE *  fp;
-  _fcd    fname;
-  char readwriteflag;
-  integer max;
-  integer count;
-  OFF_T * offset;
-  OFF_T * length;
-  hashTable* fileHashTable;
-  struct gribfile *next;
-}gribfile;
-
-typedef struct collection {
-  integer (* exists)(_fcd , fortint);
-  integer (* addRead)(_fcd , fortint);
-  integer (* addWrite)(_fcd , fortint);
-  void (* removeFile)(_fcd , fortint);
-  integer count;
-  integer max;
-  struct gribfile * files;
-}collection;
-
-
-/*
-// Prototypes
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-fortint pbxtotl(_fcd filename, fortint filename_len);
-fortint pbxtotl_(_fcd filename, fortint filename_len);
-fortint pbxxfind_(fortint * grib1, _fcd filename, fortint filename_len);
-fortint pbxxfind(fortint * grib1, _fcd filename, fortint filename_len);
-
-fortint pbxget(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint * n, fortint filename_len);
-fortint pbxget_(_fcd filename, fortint * buffer, fortint * bufflen,
-               fortint * n, fortint filename_len);
-void pbxclos(_fcd filename, fortint filename_len);
-void pbxclos_(_fcd filename, fortint filename_len);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of  PBX_ROUTINES_H */
diff --git a/tools/compareGribFiles/compareGribFiles.F b/tools/compareGribFiles/compareGribFiles.F
deleted file mode 100755
index 1c3490a..0000000
--- a/tools/compareGribFiles/compareGribFiles.F
+++ /dev/null
@@ -1,637 +0,0 @@
-#define MISSING -55555.0
-
-      PROGRAM CMPGFS
-      IMPLICIT NONE
-C
-      INTEGER JPACK, JPMXOPT
-      PARAMETER (JPACK=1080000)
-      PARAMETER (JPMXOPT=10)
-C
-      INTEGER IS0,IS1,IS2,IS3,IS4,IEDITN,LENGTH
-      INTEGER JS0,JS1,JS2,JS3,JS4,JEDITN,IZERO
-      INTEGER KRET, LENOUT1, LENOUT2, IWORD, LOOP, N, ICOUNT, ILEVEL
-      INTEGER NVALS1, NVALS2, ISTATUS, ITOTAL1, ITOTAL2
-      INTEGER NFAILS, NFAIL1
-      INTEGER NEXT1, NEXT2, ILIST(36)
-      INTEGER ISEC0(2), ISEC1(1024), ISEC2(1024), ISEC3(2), ISEC4(1024)
-      INTEGER JSEC0(2), JSEC1(1024), JSEC2(1024), JSEC3(2), JSEC4(1024)
-      INTEGER INBUFF1(JPACK), INBUFF2(JPACK)
-      REAL ZSEC2(1024), ZSEC3(2), ARRAY1(1500000), ARRAY2(1500000)
-      REAL WSEC2(1024)
-      REAL V1, V2, DIFF
-      LOGICAL LLEVEL, LFAIL, LFAIL1, LRANDOM, LPRINT, LDIFF
-      LOGICAL LBIT2BT, LBIT4BT
-C
-      CHARACTER*128 COMPFILE1, COMPFILE2, OPTIONS(JPMXOPT)
-      INTEGER IARGC
-      EXTERNAL IARGC, GETENV
-      INTEGER FILE1, FILE2, JCOUNT, ILENB, IPUNP
-      REAL MAXVAL1,MAXVAL2, MAXDIFF, MAXPERC, MEAN, TOLERNC, MARGIN
-      REAL MAXDV1, MAXDV2
-      REAL MINVAL1,MINVAL2, AVERAGE1, AVERAGE2
-C
-C     Externals
-C
-      INTEGER PBXTOTL, PBXGET, PBXXFIND, JMEMCMP, SOFFSET
-C
-C     Statement function
-C
-      REAL A, B
-      LOGICAL NOTEQ
-      NOTEQ(A,B) = (ABS((A)-(B)).GT.1E-3)
-C
-C     -----------------------------------------------------------------|
-C     Handle command line
-C     -----------------------------------------------------------------|
-C
-      JCOUNT = IARGC()
-C
-C     Help output (and exit)
-C
-      IF( JCOUNT.EQ.0 ) THEN
-        WRITE(*,*) 'Usage: compareGribFiles [options] file1 file2'
-        WRITE(*,*) '       where options are:'
-        WRITE(*,*) '     -pN      for printout level N,'
-        WRITE(*,*) '              N = 0 for no printout'
-        WRITE(*,*) '              N = 1, 2, .. for increasing detail'
-        WRITE(*,*) '              Default N = 1'
-        WRITE(*,*) '     -tX      to specify a tolerance percentage'
-        WRITE(*,*) '              for comparing field values. X must'
-        WRITE(*,*) '              be a real number, eg 5.0'
-        WRITE(*,*) '              Default X = 0.0'
-        WRITE(*,*) '     -fail    if compare to stop after a failing'
-        WRITE(*,*) '              comparison.'
-        WRITE(*,*) '              Default is to continue.'
-        WRITE(*,*) '     -bit2bit for a bit to bit comparison between'
-        WRITE(*,*) '              GRIBS headers in the two files'
-        WRITE(*,*) '     -bit4bit for a bit for bit comparison between'
-        WRITE(*,*) '              GRIBS in the two files'
-        WRITE(*,*) '     -random  if the GRIB products are in a'
-        WRITE(*,*) '              different order on the two files.'
-        WRITE(*,*) '              Default is to assume the same order.'
-        WRITE(*,*) ' '
-        WRITE(*,*) 'The return status is 0 if the values in the GRIBs'
-        WRITE(*,*) 'in are within the given tolerance.'
-        WRITE(*,*) 'Otherwise, the return status is 1.'
-        WRITE(*,*) ' '
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-C     Check usage (and exit)
-C
-      IF( JCOUNT.LT.2 ) THEN
-        WRITE(*,*) 'Usage: compare [options] file1 file2'
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-      IF( JCOUNT.GT.2 ) THEN
-        IF( JCOUNT.GT.(JPMXOPT+2) ) THEN
-          WRITE(*,*) 'Too many options on command line, max = ', JPMXOPT
-          ISTATUS = 1
-          GOTO 990
-        ENDIF
-        DO LOOP = 1, (JCOUNT-2)
-          CALL GETARG(LOOP,OPTIONS(LOOP))
-        ENDDO
-      ENDIF
-C
-      CALL GETARG((JCOUNT-1),COMPFILE1)
-      CALL GETARG(JCOUNT,COMPFILE2)
-C
-C     Default tolerance and print output level
-C
-      TOLERNC = 0.0
-      MARGIN = 0.0
-      ILEVEL = 1
-      LLEVEL = .FALSE.
-      LFAIL1 = .FALSE.
-      LRANDOM = .FALSE.
-      LBIT2BT = .FALSE.
-      LBIT4BT = .FALSE.
-      NFAILS = 0
-      NFAIL1 = 0
-C
-C     Check options to see if defaults to be overridden
-C
-      DO LOOP = 1, (JCOUNT-2)
-C
-C       Print level option
-C
-        IF( OPTIONS(LOOP)(1:2).EQ.'-p' ) THEN
-          ILEVEL = ICHAR(OPTIONS(LOOP)(3:3)) - ICHAR('0')
-          IF( (ILEVEL.LT.0).OR.(ILEVEL.GT.9) ) THEN
-             WRITE(*,*) 'Invalid -p option: ' // OPTIONS(LOOP)
-            ISTATUS = 1
-            GOTO 990
-          ENDIF
-C
-C         Set flag if print level set
-C
-          LLEVEL = .TRUE.
-        ENDIF
-C
-C       Tolerance option
-C
-        IF( OPTIONS(LOOP)(1:2).EQ.'-t' ) THEN
-          READ(OPTIONS(LOOP)(3:23),'(F20.10)') TOLERNC
-          IF( TOLERNC.LT.0.0 ) TOLERNC = 0.0
-          IF( TOLERNC.GT.100.0 ) TOLERNC = 100.0
-        ENDIF
-C
-C       Bit to bit option
-C
-        IF( OPTIONS(LOOP)(1:8).EQ.'-bit2bit' ) LBIT2BT = .TRUE.
-C
-C       Bit for bit option
-C
-        IF( OPTIONS(LOOP)(1:8).EQ.'-bit4bit' ) LBIT4BT = .TRUE.
-C
-C       Fail option
-C
-        IF( OPTIONS(LOOP)(1:5).EQ.'-fail' ) LFAIL1 = .TRUE.
-C
-C       Random option
-C
-        IF( OPTIONS(LOOP)(1:7).EQ.'-random' ) LRANDOM = .TRUE.
-C
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Open the data files
-C     -----------------------------------------------------------------|
-C
-      ITOTAL1 = PBXTOTL(COMPFILE1)
-      IF( ITOTAL1.LT.1 ) THEN
-        WRITE(*, *) 'No GRIBS found in file: ', COMPFILE1
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-      ITOTAL2 = PBXTOTL(COMPFILE2)
-      IF( ITOTAL2.LT.1 ) THEN
-        WRITE(*, *) 'No GRIBS found in file: ', COMPFILE2
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-      IF( ITOTAL1.NE.ITOTAL2 ) THEN
-        WRITE(*, *) 'The files have different number of GRIBs'
-        WRITE(*, *) ITOTAL1, ' GRIB(s) in '
-        WRITE(*, *) COMPFILE1
-        WRITE(*, *) ITOTAL2, ' GRIB(s) in '
-        WRITE(*, *) COMPFILE2
-        IF( LFAIL1 ) THEN
-          ISTATUS = 1
-          GOTO 990
-        ENDIF
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Read GRIB products one at a time
-C     -----------------------------------------------------------------|
-C
-      LFAIL = .FALSE.
-      ICOUNT = 0
-      NEXT1 = 0
-C
-   50 CONTINUE
-C
-      NEXT1 = NEXT1 + 1
-C
-C     Clear arrays to allow clean comparisons
-C
-      DO LOOP = 1, 1024
-        ISEC1(LOOP) = 0
-        JSEC1(LOOP) = 0
-        ISEC2(LOOP) = 0
-        JSEC2(LOOP) = 0
-        ISEC4(LOOP) = 0
-        JSEC4(LOOP) = 0
-        ZSEC2(LOOP) = 0.0
-        WSEC2(LOOP) = 0.0
-      ENDDO
-      DO LOOP = 1, 2
-        ISEC0(LOOP) = 0
-        JSEC0(LOOP) = 0
-        ISEC3(LOOP) = 0
-        JSEC3(LOOP) = 0
-        ZSEC3(LOOP) = 0.0
-      ENDDO
-C
-C     Read packed field from first file into INBUFF1.
-C
-      LENOUT1 = PBXGET(COMPFILE1,INBUFF1, JPACK*4, NEXT1)
-      IF( LENOUT1.LT.0 ) THEN
-        WRITE(*, *) COMPFILE1 // ' read error for GRIB ', NEXT1
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-C     Unpack GRIB message headers.
-C
-      KRET = 1
-      IPUNP = 1500000
-      ILENB = (LENOUT1+3)/4
-      ISEC3(2) = NINT(MISSING)
-      ZSEC3(2) = MISSING
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ARRAY1,IPUNP,INBUFF1,ILENB,IWORD,'I',KRET)
-C
-      IF( KRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX return code = ',KRET
-        WRITE(*,*) 'GRIBEX error in product from file: ' // COMPFILE1
-        WRITE(*,*) 'Product number = ', NEXT1
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-C     Read packed field from second file into INBUFF2.
-C
-C     Are the fields in a different sequence on the two file?
-C
-      IF( LRANDOM ) THEN
-C
-        NEXT2 = PBXXFIND(INBUFF1,COMPFILE2)
-        IF( NEXT2.LT.0 ) THEN
-          WRITE(*, *) COMPFILE2 // ' error finding matching GRIB'
-          WRITE(*,*) 'Product number = ', NEXT1
-          ISTATUS = 1
-          GOTO 990
-        ENDIF
-C
-C     ... the fields are in the same sequence on the two files
-C
-      ELSE
-        NEXT2 = NEXT1
-      ENDIF
-C
-      LENOUT2 = PBXGET(COMPFILE2,INBUFF2, JPACK*4, NEXT2)
-      IF( LENOUT2.LT.0 ) THEN
-        WRITE(*, *) COMPFILE2 // ' read error for GRIB ', NEXT2
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-      ICOUNT = ICOUNT + 1
-C
-C     -----------------------------------------------------------------|
-C     If requested, compare the GRIBs bit for bit
-C     -----------------------------------------------------------------|
-C
-      IF( LBIT4BT ) THEN
-        IF( LENOUT1.NE.LENOUT2) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' and ', NEXT2,' are NOT bit for bit the same'
-          LFAIL = .FALSE.
-          GOTO 800
-        ENDIF
-C
-        IZERO = 0
-        KRET = JMEMCMP(INBUFF1,IZERO,INBUFF2,IZERO,LENOUT1)
-        IF( KRET.NE.0 ) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' and ', NEXT2,' are NOT bit for bit the same'
-          LFAIL = .FALSE.
-        ELSE
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' and ', NEXT2,' are  bit for bit the same'
-        ENDIF
-        GOTO 800
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     If requested, compare the GRIBs bit to bit
-C     -----------------------------------------------------------------|
-C
-      IF( LBIT2BT ) THEN
-        IF( LENOUT1.NE.LENOUT2) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' - ', NEXT2,' are different lengths'
-          LFAIL = .FALSE.
-Cjdc      GOTO 800
-        ENDIF
-C
-        KRET = SOFFSET(INBUFF1,IS0,IS1,IS2,IS3,IS4,IEDITN)
-        KRET = SOFFSET(INBUFF2,JS0,JS1,JS2,JS3,JS4,JEDITN)
-C
-        LENGTH = IS1 - IS0
-        KRET = JMEMCMP(INBUFF1,IS0,INBUFF2,JS0,LENGTH)
-        IF( KRET.NE.0 ) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' - ', NEXT2,' sections 0 differ'
-          LFAIL = .FALSE.
-        ENDIF
-C
-        LENGTH = IS2 - IS1
-        KRET = JMEMCMP(INBUFF1,IS1,INBUFF2,JS1,LENGTH)
-        IF( KRET.NE.0 ) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' - ', NEXT2,' sections 1 differ'
-          LFAIL = .FALSE.
-        ENDIF
-C
-        IF( IS3.NE.0 ) THEN
-          LENGTH = IS3 - IS2
-        ELSE
-          LENGTH = IS4 - IS2
-        ENDIF
-        KRET = JMEMCMP(INBUFF1,IS2,INBUFF2,JS2,LENGTH)
-        IF( KRET.NE.0 ) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' - ', NEXT2,' sections 2 differ'
-          LFAIL = .FALSE.
-        ENDIF
-C
-        IF( IS3.NE.0 ) THEN
-          LENGTH = IS4 - IS3
-          KRET = JMEMCMP(INBUFF1,IS3,INBUFF2,JS3,LENGTH)
-          IF( KRET.NE.0 ) THEN
-            WRITE(*,*)
-     X      'GRIBs', NEXT1,' - ', NEXT2,' sections 3 differ'
-            LFAIL = .FALSE.
-          ENDIF
-        ENDIF
-C
-Cjdc    LENGTH = LENOUT1 - IS4
-        LENGTH = 11
-        KRET = JMEMCMP(INBUFF1,IS4,INBUFF2,JS4,LENGTH)
-        IF( KRET.NE.0 ) THEN
-          WRITE(*,*)
-     X    'GRIBs', NEXT1,' - ', NEXT2,' sections 4 leading bytes differ'
-          LFAIL = .FALSE.
-        ENDIF
-C
-        GOTO 800
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Otherwise, compare the GRIB values
-C     -----------------------------------------------------------------|
-C
-C     Unpack GRIB messages.
-C
-      KRET = 1
-      IPUNP = 1500000
-      ILENB = (LENOUT1+3)/4
-      ISEC3(2) = NINT(MISSING)
-      ZSEC3(2) = MISSING
-      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ARRAY1,IPUNP,INBUFF1,ILENB,IWORD,'D',KRET)
-C
-      IF( KRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX return code = ',KRET
-        WRITE(*,*) 'GRIBEX error in product from file: ' // COMPFILE1
-        WRITE(*,*) 'Product number = ', NEXT1
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-      NVALS1 = ISEC4(1)
-C
-      KRET = 1
-      IPUNP = 1500000
-      ILENB = (LENOUT2+3)/4
-      CALL GRIBEX (JSEC0,JSEC1,JSEC2,WSEC2,JSEC3,ZSEC3,JSEC4,
-     X             ARRAY2,IPUNP,INBUFF2,ILENB,IWORD,'D',KRET)
-C
-      IF( KRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX return code = ',KRET
-        WRITE(*,*) 'GRIBEX error in product from file: ' // COMPFILE2
-        WRITE(*,*) 'Product number = ', NEXT2
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-      NVALS2 = JSEC4(1)
-C
-      IF( NVALS1.NE.NVALS2 ) THEN
-        WRITE(*,*) 'Comparing GRIB ',NEXT1,' from '  // COMPFILE1
-        WRITE(*,*) 'with      GRIB ',NEXT2,' from '  // COMPFILE2
-        WRITE(*,*) 'The two GRIBs have different number of values'
-        WRITE(*,*) NVALS1,' values in the grib from ' // COMPFILE1
-        WRITE(*,*) NVALS2,' values in the grib from ' // COMPFILE2
-        IF( LFAIL1 ) THEN
-          ISTATUS = 1
-          GOTO 990
-        ENDIF
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Compare the GRIB headers
-C     -----------------------------------------------------------------|
-C
-      LDIFF = .TRUE.
-      DO LOOP = 1, 1024
-        IF( ISEC1(LOOP).NE.JSEC1(LOOP) ) THEN
-          IF( LDIFF ) THEN
-            WRITE(*,*) 'GRIBs', NEXT1,' and ', NEXT2,': headers differ'
-            LDIFF = .FALSE.
-          ENDIF
-          WRITE(*,*) 'ISEC1(',LOOP,') : ', ISEC1(LOOP), JSEC1(LOOP)
-        ENDIF
-      ENDDO
-C
-      DO LOOP = 1, 1024
-        IF( ISEC2(LOOP).NE.JSEC2(LOOP) ) THEN
-          IF( LDIFF ) THEN
-            WRITE(*,*) 'GRIB headers differ:'
-            LDIFF = .FALSE.
-          ENDIF
-          WRITE(*,*) 'ISEC2(',LOOP,') : ', ISEC2(LOOP), JSEC2(LOOP)
-        ENDIF
-      ENDDO
-C
-      DO LOOP = 1, 1024
-        IF( ISEC4(LOOP).NE.JSEC4(LOOP) ) THEN
-          IF( LDIFF ) THEN
-            WRITE(*,*) 'GRIB headers differ:'
-            LDIFF = .FALSE.
-          ENDIF
-          WRITE(*,*) 'ISEC4(',LOOP,') : ', ISEC4(LOOP), JSEC4(LOOP)
-        ENDIF
-      ENDDO
-C
-      DO LOOP = 1, 1024
-        IF( ZSEC2(LOOP).NE.WSEC2(LOOP) ) THEN
-          IF( LDIFF ) THEN
-            WRITE(*,*) 'GRIB headers differ:'
-            LDIFF = .FALSE.
-          ENDIF
-          WRITE(*,*) 'ZSEC2(',LOOP,') : ', ZSEC2(LOOP), WSEC2(LOOP)
-        ENDIF
-      ENDDO
-C
-C     -----------------------------------------------------------------|
-C     Compare the arrays
-C     -----------------------------------------------------------------|
-C
-C     Initialize the max/min values for the field
-C
-      DO LOOP = 1, NVALS1
-        V1 = ARRAY1(LOOP)
-        IF( NOTEQ(V1,MISSING) ) THEN
-          MAXVAL1 = V1
-          MINVAL1 = V1
-          GOTO 10
-        ENDIF
-      ENDDO
-   10 CONTINUE
-C
-      DO LOOP = 1, NVALS2
-        V2 = ARRAY2(LOOP)
-        IF( NOTEQ(V2,MISSING) ) THEN
-          MAXVAL2 = V2
-          MINVAL2 = V2
-          GOTO 20
-        ENDIF
-      ENDDO
-   20 CONTINUE
-C
-      MAXDIFF= 0.0
-      MAXPERC= 0.0
-      MAXDV1  = MAXVAL1
-      MAXDV2  = MAXVAL2
-C
-Cjdc  DO LOOP = 1, ISEC4(1)
-      DO LOOP = 1, MIN(NVALS1,NVALS2)
-        V1 = ARRAY1(LOOP)
-        V2 = ARRAY2(LOOP)
-        IF( (NOTEQ(V1,MISSING)).AND.(NOTEQ(V2,MISSING)) ) THEN
-          IF( MAXVAL1.LT.(V1) ) MAXVAL1 = (V1)
-          IF( MAXVAL2.LT.(V2) ) MAXVAL2 = (V2)
-          IF( MINVAL1.GT.(V1) ) MINVAL1 = (V1)
-          IF( MINVAL2.GT.(V2) ) MINVAL2 = (V2)
-          DIFF = ABS((V1-V2))
-          IF( MAXDIFF.LT.DIFF ) THEN
-            MAXDIFF = DIFF
-            MAXDV1 = V1
-            MAXDV2 = V2
-            IF( V2.NE.0.0 ) THEN
-              IF( ABS(V2).LT.ABS(V1) ) THEN
-                MAXPERC = (MAXDIFF*100.0)/ABS(V2)
-              ELSE IF( V1.NE.0 ) THEN
-                MAXPERC = (MAXDIFF*100.0)/ABS(V1)
-              ELSE
-                MAXPERC = (MAXDIFF*100.0)/ABS(V2)
-              ENDIF
-            ELSE
-              MAXPERC = (MAXDIFF*100.0)/ABS(V1)
-            ENDIF
-          ENDIF
-        ENDIF
-      ENDDO
-C
-C     Margin allowed is percentage of range (max-min) given by tolerance
-C
-      MARGIN = ABS((MAXVAL1 - MINVAL1)*TOLERNC*0.01)
-C
-      LPRINT = ILEVEL.GT.0
-      IF( MAXDIFF.GT.MARGIN ) THEN
-        LPRINT = .TRUE.
-        LFAIL = .TRUE.
-        NFAILS = NFAILS + 1
-        IF( NFAIL1.EQ.0 ) NFAIL1 = ICOUNT
-Cjdc    IF( ILEVEL.LT.1 ) ILEVEL = 1
-      ENDIF
-C
-Cjdc  IF( ILEVEL.GT.0 ) THEN
-      IF( LPRINT ) THEN
-        WRITE(*,*) ' '
-        WRITE(*,*) 'GRIB products ', NEXT1, ' : ', NEXT2
-        WRITE(*,*) 'Number of data points = ', ISEC4(1)
-        WRITE(*,*) 'Parameter  = ', isec1(6)
-        WRITE(*,*) 'Level (P1) = ', isec1(8)
-        WRITE(*,*) 'Level (P2) = ', isec1(9)
-        WRITE(*,*) ' '
-        WRITE(*,*) 'MAXVAL1 = ', MAXVAL1
-        WRITE(*,*) 'MAXVAL2 = ', MAXVAL2
-        WRITE(*,*) ' '
-        WRITE(*,*) 'MINVAL1 = ', MINVAL1
-        WRITE(*,*) 'MINVAL2 = ', MINVAL2
-        WRITE(*,*) ' '
-        WRITE(*,*) 'MAXDIFF = ', MAXDIFF, ' (',MAXPERC,' %)'
-        IF( MAXDIFF.GT.0.0 )
-     X    WRITE(*,*) 'At MAXDIFF: V1 = ', MAXDV1, ', V2 = ', MAXDV2
-        WRITE(*,*) ' '
-      ENDIF
-C
-      N = 0
-      AVERAGE1 = 0.0
-      AVERAGE2 = 0.0
-C
-      DO LOOP = 1, ISEC4(1)
-        V1 = ARRAY1(LOOP)
-        V2 = ARRAY2(LOOP)
-        IF( (NOTEQ(V1,MISSING)).AND.(NOTEQ(V2,MISSING)) ) THEN
-          AVERAGE1 = AVERAGE1 + V1
-          AVERAGE2 = AVERAGE2 + V2
-          N = N + 1
-          DIFF = ABS(V1-V2)
-          IF( DIFF .GT. MARGIN ) THEN
-            LFAIL = .TRUE.
-            IF( ILEVEL.GT.1 ) WRITE(*,*) LOOP, V1, V2, DIFF, (V1/V2)
-          ENDIF
-        ELSE
-          IF( ILEVEL.GT.1 ) THEN
-            IF( .NOT.NOTEQ(V1,MISSING) ) THEN
-              IF( .NOT.NOTEQ(V2,MISSING) ) THEN
-Cjdc            WRITE(*,*) LOOP,'    *** MISSING ***    *** MISSING ***'
-              ELSE
-                WRITE(*,*) LOOP,'    *** MISSING *** ', V2
-              ENDIF
-            ELSE
-              WRITE(*,*) LOOP, V1,'    *** MISSING ***'
-            ENDIF
-          ENDIF
-        ENDIF
-      ENDDO
-C
-      AVERAGE1 = AVERAGE1 / N
-      AVERAGE2 = AVERAGE2 / N
-C
-      IF( ILEVEL.GT.0 ) THEN
-        WRITE(*,*) 'Average of field 1 = ', AVERAGE1
-        WRITE(*,*) 'Average of field 2 = ', AVERAGE2
-        WRITE(*,*) ' '
-      ENDIF
-C
-  800 CONTINUE
-C
-      IF( LFAIL.AND.LFAIL1 ) THEN
-        ISTATUS = 1
-        GOTO 990
-      ELSE
-        IF( NEXT1.LT.ITOTAL1 ) GOTO 50
-      ENDIF
-C
-C     -----------------------------------------------------------------|
-C     Closedown
-C     -----------------------------------------------------------------|
-  900 CONTINUE
-C
-      IF( ILEVEL.GT.0 ) THEN
-        WRITE(*,*) 'Total number of GRIB products = ', ICOUNT
-        WRITE(*,*) ' '
-      ENDIF
-C
-      ISTATUS = 0
-C
-      IF( NFAILS.GT.0 ) THEN
-        WRITE(*,*) 'Total number of mismatched GRIBs = ', NFAILS
-        WRITE(*,*) 'First fail in GRIB number ', NFAIL1
-        WRITE(*,*) ' '
-        ISTATUS = 1
-        GOTO 990
-      ENDIF
-C
-  990 CONTINUE
-#ifdef FUJITSU
-      CALL SETRCD(ISTATUS)
-#else
-      CALL JDCEXIT(ISTATUS)
-#endif
-C
-      STOP
-      END
diff --git a/tools/compareGribFiles/dsgnbt.c b/tools/compareGribFiles/dsgnbt.c
deleted file mode 100755
index e66265d..0000000
--- a/tools/compareGribFiles/dsgnbt.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "fortint.h"
-
-void dsgnbt_(
-  fortint * kout,
-  fortint * kin,
-  fortint * kpos,
-  fortint * kret) {
-
-fortint value = *kin;
-unsigned fortint sign = value & (1 << ((*kpos)-1));
-unsigned fortint mask = ~(-1 << ((*kpos)-1));
-fortint new = value & mask;
-
-  if( sign )
-    *kout = -new;
-  else
-    *kout = new;
-
-  *kret = 0;
-  return;
-}
-
-void dsgnbt(
-  fortint * kout,
-  fortint * kin,
-  fortint * kpos,
-  fortint * kret) {
-
-  dsgnbt_(kout,kin,kpos,kret);
-}
diff --git a/tools/compareGribFiles/fortint.h b/tools/compareGribFiles/fortint.h
deleted file mode 100755
index b14c528..0000000
--- a/tools/compareGribFiles/fortint.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#ifdef hpR64
-#define fortint long long
-#else
-#define fortint long
-#endif
-#endif
diff --git a/tools/compareGribFiles/hash.h b/tools/compareGribFiles/hash.h
deleted file mode 100755
index 171b06f..0000000
--- a/tools/compareGribFiles/hash.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef HASH_H
-#define HASH_H
-
-typedef  unsigned int  ub4;   /* unsigned 4-byte quantities */
-typedef  unsigned char ub1;   /* unsigned 1-byte quantities */
-
-#define hashsize(n) ((ub4)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-
-ub4 hash( ub1*, ub4, ub4);
-
-#endif /* end of HASH_H */
diff --git a/tools/compareGribFiles/jdcexit.c b/tools/compareGribFiles/jdcexit.c
deleted file mode 100755
index e9633e0..0000000
--- a/tools/compareGribFiles/jdcexit.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "fortint.h"
-
-void jdcexit(fortint * status) {
-  exit((int)(*status));
-}
-
-void jdcexit_(fortint * status) {
-  jdcexit(status);
-  return;
-}
diff --git a/tools/compareGribFiles/jmemcmp.c b/tools/compareGribFiles/jmemcmp.c
deleted file mode 100755
index 87786fa..0000000
--- a/tools/compareGribFiles/jmemcmp.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <string.h>
-#include "fortint.h"
-
-fortint jmemcmp(
-  unsigned char * buffer1,
-  fortint * buffer1Offset,
-  unsigned char * buffer2,
-  fortint * buffer2Offset,
-  fortint * numberOfBytesToCompare) {
-int status;
-int off1 = (int) (*buffer1Offset);
-int off2 = (int) (*buffer2Offset);
-size_t n = (size_t) *numberOfBytesToCompare;
-
-  status = memcmp((buffer1+off1),(buffer2+off2),n);
-
-  if( status != 0 )
-    return (fortint) 1;
-  else
-    return (fortint) 0;
-
-}
-
-fortint jmemcmp_(
-  unsigned char * buffer1,
-  fortint * buffer1Offset,
-  unsigned char * buffer2,
-  fortint * buffer2Offset,
-  fortint * numberOfBytesToCompare) {
-
-  return jmemcmp(buffer1,buffer1Offset,buffer2,buffer2Offset,
-                 numberOfBytesToCompare);
-}
diff --git a/tools/except.c b/tools/except.c
new file mode 100644
index 0000000..068acf1
--- /dev/null
+++ b/tools/except.c
@@ -0,0 +1,24 @@
+/**
+ * Copyright 1981-2015 ECMWF.
+ *
+ * This software is licensed under the terms of the Apache Licence 
+ * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * In applying this licence, ECMWF does not waive the privileges and immunities 
+ * granted to it by virtue of its status as an intergovernmental organisation 
+ * nor does it submit to any jurisdiction.
+ */
+
+#ifdef ENABLE_FLOATING_POINT_EXCEPTIONS
+#define _GNU_SOURCE
+#include <fenv.h>
+int feenableexcept(int excepts);
+#endif
+
+void except_()
+{
+#ifdef ENABLE_FLOATING_POINT_EXCEPTIONS
+    feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT & ~FE_UNDERFLOW);
+#endif
+}
+
diff --git a/tools/getGaussianLatitudes/Makefile b/tools/getGaussianLatitudes/Makefile
deleted file mode 100755
index 6278c2d..0000000
--- a/tools/getGaussianLatitudes/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#
-
-SRCS.F = igglat.F intlog.F igbess.F
-OBJS.F = $(SRCS.F:.F=.o)
-#
-SRCS   = $(SRCS.F)
-OBJS   = $(OBJS.F)
-#
-.SUFFIXES: .o .c .F
-#
-#
-FC      = pgf90
-FFLAGS =  -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER
-#
-.F.o:
-	$(FC) $(FFLAGS) -c $<
-#
-
-#jgetgg: jgetgg.F $(SRCS) $(OBJS)
-#	$(FC) $(FFLAGS) -o $@ jgetgg.F $(OBJS)
-
-jgetgg: jgetgg.F  $(OBJS)
-	$(FC) $(FFLAGS) -o $@ $< $(OBJS)
-
-
-
-clean:
-	\rm -rf jgetgg jgetgg.o $(OBJS) core
diff --git a/tools/getGaussianLatitudes/grfixed.h b/tools/getGaussianLatitudes/grfixed.h
deleted file mode 100755
index 1aae392..0000000
--- a/tools/getGaussianLatitudes/grfixed.h
+++ /dev/null
@@ -1,68 +0,0 @@
-C
-C**** "grfixed.h"
-C
-C     PURPOSE
-C     _______
-C
-C     This file contains all the fixed work space array definitions for
-C     grid point to grid point interpolation.
-C
-C     INTERFACE
-C     _________
-C
-C     #include "grfixed.h"
-C
-C     Common block usage
-C     __________________
-C
-C     FIXED_INTS
-C
-C     MEXPAND      - Array of length JPLG01 (see parim.h) used to
-C                    expand one latitude line of the 10 minute land
-C                    sea mask file to have one word per bit for
-C                    improved efficiency.
-C     MILLEN       - Array of length JPLAT (see parim.h) containing
-C                    a quasi regular Gaussian field latitude line
-C                    length definition. This array may be provided by
-C                    the interpolation definition routines.
-C     MWORK        - Array of length JPLONG (see parim.h) used to
-C                    read one latitude line of a standard land sea
-C                    mask file.
-C
-C     FIXED_REAL
-C
-C     RIGAUSS      - Array of length JPLAT (see parim.h) containing a
-C                    full definition of the Gaussian latitudes for an
-C                    input field Gaussian truncation.
-C     ROGAUSS      - Array of length JPLAT (see parim.h) containing a
-C                    full definition of the Gaussian latitudes for an
-C                    output field Gaussian truncation.
-C
-C     Author
-C     ______
-C
-C     K. Fielding      *ECMWF*      Jan 1994
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers     ECMWF        June 1996
-C
-C
-C     _______________________________________________________
-C
-C*    Section 1. Fixed length arrays
-C     _______________________________________________________
-C
-      INTEGER MILLEN(JPLAT), MWORK(JPLONG), MEXPAND(JPLG01)
-C
-      REAL RIGAUSS(JPLAT), ROGAUSS(JPLAT), ROREDLL(JPLAT)
-C
-      COMMON /FIXED_INTS/ MWORK, MILLEN, MEXPAND
-C
-      SAVE /FIXED_INTS/
-C
-      COMMON /FIXED_REAL/ RIGAUSS, ROGAUSS, ROREDLL
-C
-      SAVE /FIXED_REAL/
-C
diff --git a/tools/getGaussianLatitudes/igbess.F b/tools/getGaussianLatitudes/igbess.F
deleted file mode 100644
index fd1b0bb..0000000
--- a/tools/getGaussianLatitudes/igbess.F
+++ /dev/null
@@ -1,169 +0,0 @@
-      INTEGER FUNCTION IGBESS(KTRUNC, PBESJ0, KPR, KERR)
-C
-C---->
-C**** *IGBESS*
-C
-C     PURPOSE
-C     _______
-C
-C     Computes initial approximations to Gaussian latitudes.
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IGBESS(KTRUNC, PBESJ0, KPR, KERR)
-C
-C     Input parameters
-C     ________________
-C
-C     KTRUNC     - This is the number of zeros of the J0 Bessel
-C                  function required.
-C
-C
-C     KPR        - The debug print switch.
-C                  0  , No debugging output.
-C                  1  , Produce debugging output.
-C
-C     KERR       - The error control flag.
-C                  -ve, No error message. Return error code.
-C                  0  , Hard failure with error message.
-C                  +ve, Print error message. Return error code.
-C
-C     Output parameters
-C     ________________
-C
-C     PBESJ0     - The output array of zeros of the J0 Bessel function.
-C
-C     Return Value
-C     ____________
-C
-C     The error indicator (INTEGER).
-C
-C     Error and Warning Return Values
-C     _______________________________
-C
-C     None
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG(R)    - Logs messages.
-C
-C     METHOD
-C     ______
-C
-C     The first JPLOOK values are obtained from a look-up table
-C     (ZPBES). Any additional values requested are approximated by
-C     adding PI (3.14159...) to the previous value.
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C     COMMENTS
-C     ________
-C
-C     This routine is adapted from that in the old Marsint library.
-C     The interface and the variable names have been modified.
-C
-C     Program contains sections 0 to 2 and 9
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Oct 1993
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     None
-C
-C----<
-C     _______________________________________________________
-C
-C*    Section 0. Definition of variables.
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-#include "jparams.h"
-#include "parim.h"
-C
-C     Dummy arguments
-      INTEGER KTRUNC, KPR, KERR
-      REAL PBESJ0 (*)
-C
-C     Local variables
-      INTEGER ILOOK
-      INTEGER JAPPRX, JLOOK
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 24400)
-      REAL ZPBES (JPLOOK)
-      DATA ZPBES        /   2.4048255577E0,   5.5200781103E0,
-     1    8.6537279129E0,  11.7915344391E0,  14.9309177086E0,
-     2   18.0710639679E0,  21.2116366299E0,  24.3524715308E0,
-     3   27.4934791320E0,  30.6346064684E0,  33.7758202136E0,
-     4   36.9170983537E0,  40.0584257646E0,  43.1997917132E0,
-     5   46.3411883717E0,  49.4826098974E0,  52.6240518411E0,
-     6   55.7655107550E0,  58.9069839261E0,  62.0484691902E0,
-     7   65.1899648002E0,  68.3314693299E0,  71.4729816036E0,
-     8   74.6145006437E0,  77.7560256304E0,  80.8975558711E0,
-     9   84.0390907769E0,  87.1806298436E0,  90.3221726372E0,
-     A   93.4637187819E0,  96.6052679510E0,  99.7468198587E0,
-     1  102.8883742542E0, 106.0299309165E0, 109.1714896498E0,
-     2  112.3130502805E0, 115.4546126537E0, 118.5961766309E0,
-     3  121.7377420880E0, 124.8793089132E0, 128.0208770059E0,
-     4  131.1624462752E0, 134.3040166383E0, 137.4455880203E0,
-     5  140.5871603528E0, 143.7287335737E0, 146.8703076258E0,
-     6  150.0118824570E0, 153.1534580192E0, 156.2950342685E0 /
-C
-C     _______________________________________________________
-C
-C*    Section 1. Extract initial values from look up table
-C     _______________________________________________________
-C
-  100 CONTINUE
-C
-      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGBESS: Section 1.',JPQUIET)
-C
-      IGBESS = 0
-C
-      IF (KPR .GE. 1) CALL INTLOG(JP_DEBUG,
-     X  'IGBESS: No.values requested = ',KTRUNC)
-C
-      ILOOK = MIN (KTRUNC, JPLOOK)
-C
-      DO 110 JLOOK = 1, ILOOK
-        PBESJ0(JLOOK) = ZPBES(JLOOK)
-  110 CONTINUE
-C
-C     _______________________________________________________
-C
-C*    Section 2. Approximate any extra values required
-C     _______________________________________________________
-C
-  200 CONTINUE
-C
-      IF(KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGBESS: Section 2.',JPQUIET)
-C
-      DO 210 JAPPRX = ILOOK + 1, KTRUNC
-        PBESJ0(JAPPRX) = PBESJ0(JPLOOK) + PPI*(JAPPRX - ILOOK)
-  210 CONTINUE
-C
-C     _______________________________________________________
-C
-C*    Section 9. Return to calling routine. Format statements
-C     _______________________________________________________
-C
-  900 CONTINUE
-C
-      IF(KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGBESS: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/tools/getGaussianLatitudes/igglat.F b/tools/getGaussianLatitudes/igglat.F
deleted file mode 100755
index 3896780..0000000
--- a/tools/getGaussianLatitudes/igglat.F
+++ /dev/null
@@ -1,272 +0,0 @@
-      INTEGER FUNCTION IGGLAT(KLAT, PGAUSS, KPR, KERR)
-C
-C---->
-C**** *IGGLAT*
-C
-C     PURPOSE
-C     _______
-C
-C     Compute Gaussian lines of latitude for a given truncation.
-C
-C
-C     INTERFACE
-C     _________
-C
-C     IERR = IGGLAT(KLAT, PGAUSS, KPR, KERR)
-C
-C
-C     Input parameters
-C     ________________
-C
-C     KLAT - The number of lines of latitude from pole to pole.
-C
-C     KPR  - Debug print switch:
-C            0, No debugging output.
-C            1, Produce debugging output.
-C
-C     KERR - Error control flag.
-C            -ve, No error message. Return error code.
-C            0  , Hard failure with error message.
-C            +ve, Print error message. Return error code.
-C
-C
-C     Output parameters
-C     ________________
-C
-C     PGAUSS - The Gaussian lines of latitude for truncation KLAT/2
-C
-C
-C     Return value
-C     ____________
-C
-C     0     - OK
-C     24701 - The calculation of Gaussian lines of latitude failed.
-C
-C
-C     Common block usage
-C     __________________
-C
-C     None
-C
-C
-C     EXTERNALS
-C     _________
-C
-C     INTLOG(R) - Logs messages.
-C     IGBESS    - This routine is used to generate initial
-C                 approximations to the Gaussian latitudes.
-C
-C
-C     METHOD
-C     ______
-C
-C     IGBESS is used to provide zeros of the Bessel function J0,
-C     which are used as starting approximations to the Gaussian
-C     latitudes. Newton iteration is used to generate the latitudes
-C     from these approximations.
-C
-C     Calculated latitudes are stored internally and reused if a
-C     later call asks for the same calculation.
-C
-C
-C     REFERENCE
-C     _________
-C
-C     None
-C
-C
-C     COMMENTS
-C     ________
-C
-C     This routine is adapted from that in the old Marsint library.
-C     The interface and the variable names have been modified.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Oct 1993
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.Chambers        ECMWF       Aug 1998
-C     Add reuse of calculated latitudes.
-C
-C----<
-C     -------------------------------------------------------
-C*    Section 0. Definition of variables.
-C     -------------------------------------------------------
-C
-      IMPLICIT NONE
-C
-#include "jparams.h"
-#include "parim.h"
-C
-C     Function arguments
-C
-      INTEGER KLAT, KPR, KERR
-      REAL PGAUSS (*)
-C
-C     Parameters
-C
-      INTEGER JPROUTINE
-      PARAMETER (JPROUTINE = 24700)
-C     -------------------------------------------------------
-C     The convergence criteria is machine dependent
-C     -------------------------------------------------------
-C
-      REAL PACRCY
-#ifdef REAL_8
-      PARAMETER (PACRCY = 1.0E-14)
-#else
-      PARAMETER (PACRCY = 1.0E-7)
-#endif
-C
-C     Local variables
-C
-      LOGICAL LDEBUG
-      INTEGER ITRUNC, IERR
-      INTEGER JLAT, JITER, JLN, LOOP, JOLDLAT
-      REAL ZRADDEG, ZCON, ZLAT, ZROOT
-      REAL ZKM1, ZKM2, ZLN, ZFUNC, ZDERIV, ZMOVE
-      REAL ROLDGS
-      DIMENSION ROLDGS(JPGTRUNC*2)
-C
-      SAVE JOLDLAT, ROLDGS
-C
-C     Externals
-C
-      INTEGER IGBESS
-C
-C     -------------------------------------------------------
-C*    Section 1. Set constants and get initial approximation.
-C     -------------------------------------------------------
-C
-  100 CONTINUE
-C
-      IGGLAT = 0
-      LDEBUG = ( KPR.GE.1 )
-C
-      IF( LDEBUG ) THEN
-        CALL INTLOG(JP_DEBUG,'IGGLAT: Section 1.',JPQUIET)
-        CALL INTLOG(JP_DEBUG,
-     X  'IGGLAT: No.lines lat from pole to pole = ',KLAT)
-      ENDIF
-C
-C     Using previously calculated values if truncation is the same.
-C
-      IF( KLAT.EQ.JOLDLAT ) THEN
-        IF( LDEBUG ) CALL INTLOG(JP_DEBUG,
-     X    'IGGLAT: Using previously calculated values',JPQUIET)
-        DO LOOP = 1, KLAT
-          PGAUSS(LOOP) = ROLDGS(LOOP)
-        ENDDO
-        GOTO 900
-      ENDIF
-C
-      JOLDLAT = KLAT
-C
-      ZRADDEG = 180.0/PPI
-C
-      ZCON   = (PPONE - (PPTWO / PPI) ** 2) * PPQUART
-C
-      ZLAT   = KLAT
-      ITRUNC = KLAT/2
-C
-      IERR = IGBESS(ITRUNC, PGAUSS, KPR, KERR)
-C
-      IF( IERR.GT.0 ) THEN
-         IGGLAT = IERR
-         GOTO 900
-      ENDIF
-C
-C     -------------------------------------------------------
-C*    Section 2. Compute abscissae
-C     -------------------------------------------------------
-C
-  200 CONTINUE
-C
-      IF( LDEBUG ) CALL INTLOG(JP_DEBUG,'IGGLAT: Section 2.',JPQUIET)
-C
-      DO 240 JLAT = 1, ITRUNC
-C
-C       First approximation for ZROOT
-C
-        ZROOT = COS(PGAUSS(JLAT) / SQRT( (ZLAT+PPHALF)**2 + ZCON) )
-C
-C       Perform loop of Newton iterations
-C
-        DO 220 JITER = 1, JPMAXITER
-C
-          ZKM2 = PPONE
-          ZKM1 = ZROOT
-C
-C         Compute Legendre polynomial
-C
-          DO 210 JLN = 2, KLAT
-C
-            ZLN = JLN
-C
-            ZFUNC = ( (PPTWO * ZLN - PPONE) * ZROOT * ZKM1 -
-     1              (ZLN - PPONE) * ZKM2) / ZLN
-C
-            ZKM2 = ZKM1
-            ZKM1 = ZFUNC
-C
-  210     CONTINUE
-C
-C         Perform Newton iteration
-C
-          ZDERIV = (ZLAT * (ZKM2 - ZROOT * ZFUNC) ) /
-     1             (PPONE - ZROOT ** 2)
-C
-          ZMOVE = ZFUNC / ZDERIV
-          ZROOT = ZROOT - ZMOVE
-C
-C         Leave iteration loop when sufficient accuracy achieved.
-C
-          IF( ABS(ZMOVE).LE.PACRCY ) GOTO 230
-C
-  220   CONTINUE
-C
-C       Routine fails if no convergence after JPMAXITER iterations.
-C
-        IGGLAT = JPROUTINE + 1
-C
-        IF( KERR.GE.0 ) CALL INTLOG(JP_ERROR,
-     X    'IGGLAT: Calculation of Gaussian lats failed.',JPQUIET)
-C
-        IF( KERR.EQ.0 ) CALL INTLOG(JP_FATAL,
-     X    'IGGLAT: interpolation failed.',IGGLAT)
-C
-        GOTO 900
-C
-  230   CONTINUE
-C
-C*      Set North and South values using symmetry.
-C
-        PGAUSS(JLAT) = ASIN(ZROOT) * ZRADDEG
-        PGAUSS(KLAT + 1 - JLAT) = - PGAUSS(JLAT)
-C
-  240 CONTINUE
-C
-      IF( KLAT.NE.(ITRUNC*2) ) PGAUSS(ITRUNC + 1) = PPZERO
-C
-C     Store calculated values for re-use
-C
-      DO LOOP = 1, KLAT
-        ROLDGS(LOOP) = PGAUSS(LOOP)
-      ENDDO
-C
-C     -------------------------------------------------------
-C*    Section 9. Return to calling routine.
-C     -------------------------------------------------------
-C
-  900 CONTINUE
-C
-      IF( LDEBUG ) CALL INTLOG(JP_DEBUG,'IGGLAT: Section 9.',JPQUIET)
-C
-      RETURN
-      END
diff --git a/tools/getGaussianLatitudes/intf.h b/tools/getGaussianLatitudes/intf.h
deleted file mode 100755
index 5b72007..0000000
--- a/tools/getGaussianLatitudes/intf.h
+++ /dev/null
@@ -1,25 +0,0 @@
-C
-C     Parameters
-C
-      INTEGER JPEXPAND
-      PARAMETER (JPEXPAND = 1440 * 721 * 2)
-C
-C     Local variables
-C
-      INTEGER ISEC0 (JPGRIB_ISEC0), ISEC1 (JPGRIB_ISEC1)
-      INTEGER ISEC2 (JPGRIB_ISEC2), ISEC3 (JPGRIB_ISEC3)
-      INTEGER ISEC4 (JPGRIB_ISEC4)
-      REAL ZSEC2 (JPGRIB_RSEC2), ZSEC3 (JPGRIB_RSEC3)
-      INTEGER IZNJDCI
-      LOGICAL LUSEHIR
-C
-      POINTER ( IZNFLDI, ZNFELDI )
-C
-C     Pointer for dynamically allocated array:
-C
-C     REAL ZNFELDI (JPEXPAND)
-C
-      COMMON /INTFCM/ ZSEC2, ZSEC3, IZNFLDI, IZNJDCI,
-     X                ISEC0, ISEC1, ISEC2, ISEC3, ISEC4, LUSEHIR
-C
-      REAL ZNFELDI(1)
diff --git a/tools/getGaussianLatitudes/intlog.F b/tools/getGaussianLatitudes/intlog.F
deleted file mode 100755
index 3b17025..0000000
--- a/tools/getGaussianLatitudes/intlog.F
+++ /dev/null
@@ -1,191 +0,0 @@
-C Copyright 1981-2012 ECMWF.
-C
-C This software is licensed under the terms of the Apache Licence 
-C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-C
-C In applying this licence, ECMWF does not waive the privileges and immunities 
-C granted to it by virtue of its status as an intergovernmental organisation 
-C nor does it submit to any jurisdiction.
-C
-
-      SUBROUTINE INTLOG(KLEVEL, MESSAGE, KNUM)
-C
-C---->
-C**** INTLOG
-C
-C     PURPOSE
-C     _______
-C
-C     This routine logs error messages.
-C
-C
-C     INTERFACE
-C     _________
-C
-C     CALL INTLOG(KLEVEL, MESSAGE, KNUM)
-C
-C
-C     Input parameters
-C     ________________
-C
-C     KLEVEL   - Severity level for reported message
-C                = 0 for debug
-C                = 1 for information
-C                = 2 for warning
-C                = 3 for error
-C                = 4 for fatal
-C     MESSAGE  - Message text
-C     KNUM     - Message number
-C
-C
-C     Output parameters
-C     ________________
-C
-C     None.
-C
-C
-C     Common block usage
-C     __________________
-C
-C     LDEBUG in /INTLOGC/ controls display of message
-C                 = 0 for no display
-C                 = 1 to display
-C
-C
-C     Method
-C     ______
-C
-C     Prints message and number if debug flag is 'on'.
-C
-C
-C     Externals
-C     _________
-C
-C     INTLOGT  - sends any ERROR, FATAL or WARN message to the
-C                MARS server.
-C
-C
-C     Comments
-C     ________
-C
-C     LDEBUG is toggled by a call to INTLOGD.
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      *ECMWF*      Jul 1995
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers      *ECMWF*      March 1996
-C     Prepare error message for MARS server.
-C
-C
-C----<
-C     _______________________________________________________
-C
-      IMPLICIT NONE
-C
-#include "parim.h"
-C
-C     Subroutine arguments.
-C
-      INTEGER KLEVEL
-      INTEGER KNUM
-      CHARACTER *(*) MESSAGE
-C
-#include "intlog.h"
-
-#ifdef MPI_DEBUG
-#include "mpif.h" 
-#endif
-
-C
-C     Local variables.
-C
-      CHARACTER*120 NEWMESS
-      INTEGER NLEV, LOOP
-      CHARACTER*5 TITLE(JP_FATAL+1)
-      DATA TITLE/'DEBUG',
-     X           'INFO ',
-     X           'WARN ',
-     X           'ERROR',
-     X           'FATAL'/
-      INTEGER IRET, ILEN
-
-#ifdef MPI_DEBUG
-      INTEGER my_id, ierr
-      Data my_id /-1/
-      Save my_id
-#endif
-
-C
-C ------------------------------------------------------------------
-C*    Section 1.   Initialise
-C ------------------------------------------------------------------
-C
-  100 CONTINUE
-C
-C     Ensure valid level is used.
-      NLEV = KLEVEL + 1
-      IF ( KLEVEL .GT. JP_FATAL) NLEV = JP_FATAL + 1
-C
-      DO LOOP = 1, 120
-        NEWMESS(LOOP:LOOP) = ' '
-      ENDDO
-C
-C ------------------------------------------------------------------
-C*    Section 2.   Prepare ERROR or FATAL message for MARS server.
-C ------------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      ILEN = LEN(MESSAGE)
-      IF( ILEN.GT.105 ) ILEN = 105
-
-#ifdef MPI_DEBUG
-      if (my_id.eq.-1) Then
-      call MPI_COMM_RANK (MPI_COMM_WORLD, my_id, ierr)
-      my_id = my_id + 1
-      end if
-#endif
-
-      NEWMESS(1:ILEN) = MESSAGE(1:ILEN)
-      ILEN = ILEN + 1
-      IF(KNUM.NE.JPQUIET) THEN
-        IF( ABS(KNUM).LT.1000 ) THEN
-          WRITE(NEWMESS(ILEN:),'(I4)') KNUM
-        ELSE IF ( ABS(KNUM).LT.100000 ) THEN
-          WRITE(NEWMESS(ILEN:),'(I7)') KNUM
-        ELSE IF ( ABS(KNUM).LT.100000000 ) THEN
-          WRITE(NEWMESS(ILEN:),'(I10)') KNUM
-        ELSE
-          WRITE(NEWMESS(ILEN:),'(I15)') KNUM
-        ENDIF
-      ENDIF
-
-C
-C     Send the message
-C
-      IF( KLEVEL.GE.JP_WARN ) CALL INTLOGT(NEWMESS)
-C
-#ifdef MPI_DEBUG
-      IF( LDEBUG ) WRITE(*,9001) my_id,TITLE(NLEV),NEWMESS
- 9001 FORMAT(i4,' INTLOG ',A5,': ',A120)
-#else
-      IF( LDEBUG ) WRITE(*,9001) TITLE(NLEV),NEWMESS
- 9001 FORMAT('INTLOG ',A5,': ',A120)
-
-#endif
-C
-C ------------------------------------------------------------------
-C*    Section 9.   Closedown.
-C ------------------------------------------------------------------
-C
-  900 CONTINUE
-C
-      RETURN
-      END
diff --git a/tools/getGaussianLatitudes/intlog.h b/tools/getGaussianLatitudes/intlog.h
deleted file mode 100755
index a2703a2..0000000
--- a/tools/getGaussianLatitudes/intlog.h
+++ /dev/null
@@ -1,5 +0,0 @@
-C
-C     Common block.
-      COMMON /INTLOGC/ LDEBUG
-      SAVE /INTLOGC/
-      LOGICAL LDEBUG
diff --git a/tools/getGaussianLatitudes/jgetgg.F b/tools/getGaussianLatitudes/jgetgg.F
deleted file mode 100755
index 13273d1..0000000
--- a/tools/getGaussianLatitudes/jgetgg.F
+++ /dev/null
@@ -1,289 +0,0 @@
-        program JGETGG
-C      SUBROUTINE JGETGG( KNUM, HTYPE, PLAT, KPTS, KRET)
-C
-C---->
-C**** JGETGG
-C
-C     PURPOSE
-C     _______
-C
-C     This routine reads the definition of a gaussian grid.
-C
-C
-C     INTERFACE
-C     _________
-C
-C     CALL JGETGG( KNUM, HTYPE, PLAT, KPTS, KRET)
-C
-C
-C     Input parameters
-C     ________________
-C
-C     KNUM     - Gaussian grid number
-C     HTYPE    - Gaussian grid type
-C                = 'R' for reduced, 
-C                = 'F' for full
-C                = 'U' for a user defined gaussian grid
-C     KPTS     - Array giving users definition of the number of points
-C                at each gaussian latitude if HTYPE  = 'U'
-C
-C
-C     Output parameters
-C     ________________
-C
-C     PLAT     - Array of gaussian latitudes (both hemispheres)
-C     KPTS     - Array giving number of points at each gaussian 
-C                latitude, both hemispheres
-C                ( unchanged from input if HTYPE  = 'U' )
-C     KRET      - Return status code
-C                0 = OK
-C
-C
-C     Common block usage
-C     __________________
-C
-C     None.
-C
-C     Method
-C     ______
-C
-C     If HTYPE = 'U', the users definition of the grid is used.
-C     Latitudes values are calculated corresponding to KNUM.
-C
-C     An array of predefined values is used.
-C
-C
-C     Externals
-C     _________
-C
-C     GETENV   - Get value of an environment variable
-C     INTLOG   - Output log message
-C     IGGLAT   - Computes Gaussian latitude lines for given truncation.
-C     EMOSNUM  - Gives current EMOSLIB version number.
-C
-C
-C     Reference
-C     _________
-C
-C     None
-C
-C
-C     Comments
-C     ________
-C
-C     None
-C
-C
-C     AUTHOR
-C     ______
-C
-C     J.D.Chambers      ECMWF      Jan 1994
-C
-C
-C     MODIFICATIONS
-C     _____________
-C
-C     J.D.Chambers      ECMWF      Apr 1995
-C     Use predefined definition file for N80 and N160 to cope with
-C     changes in the 'standard' definition.
-C
-C     J.D.Chambers      ECMWF      Apr 1996
-C     Call JGGLAT if regular grid but not N80 or N160
-C
-C     J.D.Chambers      ECMWF      Apr 1996
-C     Fixup standard pathnames for VPPs.
-C     Read array of values from file if possible (once only).
-C
-C----<
-C     -----------------------------------------------------------------|
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------|
-C
-      IMPLICIT NONE
-C
-C     Parameters
-C
-      INTEGER JPROUTINE, JPMAXN,I,II
-      PARAMETER ( JPROUTINE = 30100 )
-      PARAMETER ( JPMAXN = 2048 )
-C                           `---> dimension for internal array for
-C                                 gaussian grid definitions
-C
-C     Subroutine arguments
-C
-      INTEGER KNUM, KPTS, KRET
-      CHARACTER*1 HTYPE
-c      DIMENSION KPTS(*)
-      DIMENSION KPTS(JPMAXN)
-      REAL PLAT
-cs      DIMENSION  PLAT(*)
-      DIMENSION  PLAT(JPMAXN)
-c      REAL QG400, QG512, QG1024
-c      DIMENSION QG400(400),QG512(512),QG1024(1024)
-C
-C     Local variables
-C
-#include "parim.h"
-#include "grfixed.h"
-#include "intf.h"
-#include "rgauss_200.h"
-#include "rgauss_320.h"
-#include "rgauss_400.h"
-#include "rgauss_640.h"
-#include "rgauss_512.h"
-#include "rgauss_1024.h"
-C
-      CHARACTER*6 YEMOSNM
-      CHARACTER*4 CARG
-      INTEGER IERR, JJPR, JJERR,PUN
-      INTEGER LOOP, NLAT, IOFFSET
-      INTEGER IMAGE, K1, INUM, NGOT
-C
-C     Externals
-C
-      INTEGER  IGGLAT
-      EXTERNAL IGGLAT
-C
-C     -----------------------------------------------------------------|
-C*    Section 1.    Set up standard latitudes
-C     -----------------------------------------------------------------|
-C
-        CALL GETARG(1,CARG)
-        READ(CARG,'(I4)')KNUM
-csinisa
-cs           HTYPE='R'
-css           KNUM=512
-csinisa
-C
-      IF( KNUM.GT.JPMAXN) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'JGETGG: Grid too big for internal array dimension ',JPMAXN)
-        GOTO 990
-      ENDIF
-C
-      INUM = KNUM*2
-C
-c      IF( (HTYPE.EQ.'R').OR.(HTYPE.EQ.'r') ) GOTO 200
-C
-C     If a regular gaussian grid, calculate the gaussian latitudes
-C
-      CALL INTLOG(JP_DEBUG,
-     X  'JGETGG: Calculate the gaussian latitudes for N = ',KNUM)
-C
-      JJPR  = 1
-      JJERR = 1
-      IERR  = IGGLAT(INUM, PLAT, JJPR, JJERR)
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR, 'JGETGG: IGGLAT call failed',IERR)
-        KRET = IERR
-        GOTO 990
-      ENDIF
-C
-C     Fill in the number of points at each latitude
-C
-      CALL INTLOG(JP_DEBUG,'JGETGG: Regular gaussian grid N ',KNUM)
-C
-c      DO LOOP = 1, INUM
-c        KPTS(LOOP) = KNUM*4
-c      ENDDO
-
-C
-CS      GOTO 930
-C
-C     -----------------------------------------------------------------|
-C*    Section 2.    Read REDUCED gaussian definitions from array
-C     -----------------------------------------------------------------|
-C
-  200 CONTINUE
-C
-C     Check that the definition is known
-C
-      IF( (KNUM.NE. 32 ).AND.
-     X    (KNUM.NE. 48 ).AND.
-     X    (KNUM.NE. 80 ).AND.
-     X    (KNUM.NE.128 ).AND.
-     X    (KNUM.NE.160 ).AND.
-     X    (KNUM.NE.200 ).AND.
-     X    (KNUM.NE.256 ).AND.
-     X    (KNUM.NE.320 ).AND.
-     X    (KNUM.NE.400 ).AND.
-     X    (KNUM.NE.512 ).AND.
-     X    (KNUM.NE.640 ).AND.
-     X    (KNUM.NE.1024 ) ) THEN
-        CALL INTLOG(JP_ERROR,
-     X    'JGETGG: unknown reduced gaussian grid definition: ', KNUM)
-        GOTO 990
-      ENDIF
-C
-C     Fill in the gaussian latitudes
-C
-      JJPR  = 1
-      JJERR = 1
-      IERR  = IGGLAT(INUM, PLAT, JJPR, JJERR)
-       PUN = KNUM*4
-      IF( IERR.NE.0 ) THEN
-        CALL INTLOG(JP_ERROR, 'JGETGG: IGGLAT call failed',IERR)
-        KRET = IERR
-        GOTO 990
-      ENDIF
-C
-C
-      IF( KNUM.EQ.400 ) THEN
-        DO LOOP = 1, KNUM
-          IMAGE       = INUM - LOOP +1
-          KPTS(LOOP)  = QG400(LOOP)
-          KPTS(IMAGE) = KPTS(LOOP)
-        ENDDO
-C
-      ELSE IF( KNUM.EQ.200 ) THEN
-        DO LOOP = 1, KNUM
-          IMAGE       = INUM - LOOP +1
-          KPTS(LOOP)  = QG200(LOOP)
-          KPTS(IMAGE) = KPTS(LOOP)
-        ENDDO
-      ELSE IF( KNUM.EQ.320 ) THEN
-        DO LOOP = 1, KNUM
-          IMAGE       = INUM - LOOP +1
-          KPTS(LOOP)  = QG320(LOOP)
-          KPTS(IMAGE) = KPTS(LOOP)
-        ENDDO
-      ELSE IF( KNUM.EQ.512 ) THEN
-        DO LOOP = 1, KNUM
-          IMAGE       = INUM - LOOP +1
-          KPTS(LOOP)  = QG512(LOOP)
-          KPTS(IMAGE) = KPTS(LOOP)
-        ENDDO
-      ELSE IF( KNUM.EQ.640 ) THEN
-        DO LOOP = 1, KNUM
-          IMAGE       = INUM - LOOP +1
-          KPTS(LOOP)  = QG640(LOOP)
-          KPTS(IMAGE) = KPTS(LOOP)
-        ENDDO
-C
-      ELSE
-        DO LOOP = 1, KNUM
-          IMAGE       = INUM - LOOP +1
-          KPTS(LOOP)  = QG1024(LOOP)
-          KPTS(IMAGE) = KPTS(LOOP)
-        ENDDO
-      ENDIF
-C
-C
-77      format(8x,i4,8x,i4,8x,i4,3x,f9.5)
-          write(*,*)'       latitude   reduced     regular  latitude'
-          write(*,*)'        number     points      points'
-          write(*,*)'       -------    -------     -------  --------'
-        DO I = 1, KNUM
-          write(*,77)I,KPTS(I),PUN,PLAT(I)
-cs          write(*,*)I,KPTS(I),PUN,PLAT(I)
-        ENDDO
-        DO II = KNUM, 1,-1
-          write(*,77)I,KPTS(II),PUN,-(PLAT(II))
-           I=I+1
-        ENDDO
-      KRET = 0
-C
- 990  CONTINUE
-cs      RETURN
-      stop
-      END
diff --git a/tools/getGaussianLatitudes/jparam2.h b/tools/getGaussianLatitudes/jparam2.h
deleted file mode 100755
index 77dc36e..0000000
--- a/tools/getGaussianLatitudes/jparam2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-C
-C     Handling of spectral -> grid interpolation coefficients memory
-C
-      LOGICAL LFREECF
-      INTEGER NFREECF, NISIZE6, NISIZE7
-      CHARACTER*15 YOLDGG
-      CHARACTER*19 YOLDLL
-      COMMON /JDCSPGP/ NFREECF,NISIZE6,NISIZE7,LFREECF,YOLDGG,YOLDLL
diff --git a/tools/getGaussianLatitudes/jparams.h b/tools/getGaussianLatitudes/jparams.h
deleted file mode 100755
index 146a7f0..0000000
--- a/tools/getGaussianLatitudes/jparams.h
+++ /dev/null
@@ -1,34 +0,0 @@
-C
-C     Parameters
-C
-      INTEGER JP32, JPLONO, J2NFFT, JPFFT, JPLOOK, JPMAX, JPMAXITER
-      INTEGER JPMXTRY, JPTRNC, JPK, JPTRP1
-      PARAMETER ( JP32 = 32 )
-C
-C     The following value for JPLONO (2560) will handle regular grids 
-C     from N1 to N720 derived from spectral truncations from T1 to
-C     T639.
-C
-Cjdc  PARAMETER ( JPLONO = 2560 , J2NFFT = 2 + JPLONO, JPFFT = 12000)
-      PARAMETER ( JPLONO = 6000 , J2NFFT = 2 + JPLONO, JPFFT = 12000)
-      PARAMETER ( JPLOOK = 50)
-      PARAMETER ( JPMAX = 2048 )
-      PARAMETER ( JPMAXITER = 10)
-      PARAMETER ( JPMXTRY = 3 )
-      PARAMETER ( JPTRNC = 2047, JPK = (JPTRNC + 1)*(JPTRNC + 4) )
-      PARAMETER ( JPTRP1 = (JPTRNC + 1) )
-C
-      REAL PPEPSA, PPQUART, PPHALF, PPTWO, PP90
-      PARAMETER ( PPEPSA = 1.0E-6)
-      PARAMETER ( PPQUART = 0.25E0)
-      PARAMETER ( PPHALF = 0.5E0)
-      PARAMETER ( PPTWO = 2.0E0)
-      PARAMETER ( PP90 = 90.0E0)
-C
-      REAL PPI
-      PARAMETER ( PPI = 3.14159265358979 )
-C
-C     Debug parameters
-C
-      INTEGER NDBG, NDBGLP
-      COMMON /JDCNDBG/ NDBG, NDBGLP
diff --git a/tools/getGaussianLatitudes/parim.h b/tools/getGaussianLatitudes/parim.h
deleted file mode 100755
index d3cc827..0000000
--- a/tools/getGaussianLatitudes/parim.h
+++ /dev/null
@@ -1,602 +0,0 @@
-c
-C**** "parim.h"
-C
-C     PURPOSE
-C     _______
-C
-C     This file contains a set of constants used during interpolation.
-C
-C     INTERFACE
-C     _________
-C
-C     #include "parim.h"
-C
-C     Common block usage
-C     __________________
-C
-C     NONE
-C
-C     METHOD
-C     ______
-C
-C     NONE
-C
-C     REFERENCE
-C     _________
-C
-C     NONE
-C
-C     COMMENTS
-C     ________
-C
-C     Contains sections 1 to 8
-C
-C     AUTHOR
-C     ______
-C
-C     K. Fielding      *ECMWF*      Oct 1993
-C
-C     Modifications
-C     -------------
-C
-C     S.Curic     ECMWF      March 2005
-C     Changed constants JPSTRUNC=2047 JPGTRUNC=2048
-C     in order to allow T2047 and N1024
-C     Changed buffer size PGRIB_ISEC1 PGRIB_ISEC2 PGRIB_ISEC4
-C
-C     _______________________________________________________
-C
-C
-C*    Section 1. Machine definition constants
-C     _______________________________________________________
-C
-C     JPBYTES       - The number of bytes in an INTEGER word.
-C     JPBITS        - The number of bits in an INTEGER word.
-C     JPILEN        - The number of heap allocation units in an
-C                     INTEGER word.
-C     JPRLEN        - The number of heap allocation units in a REAL
-C                     word.
-C
-      INTEGER JPBITS, JPBYTES, JPILEN, JPRLEN
-C
-#ifdef CRAY
-      PARAMETER (JPBYTES = 8)
-      PARAMETER (JPILEN = 1)
-      PARAMETER (JPRLEN = 1)
-#else
-#ifdef INTEGER_8
-      PARAMETER (JPBYTES = 8)
-#else
-      PARAMETER (JPBYTES = 4)
-#endif
-      PARAMETER (JPILEN = JPBYTES)
-#ifdef REAL_8
-      PARAMETER (JPRLEN = 8)
-#else
-      PARAMETER (JPRLEN = 4)
-#endif
-#endif
-      PARAMETER (JPBITS = 8 * JPBYTES)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 2. Library Limit Constants
-C     _______________________________________________________
-C
-C     JPLONG        - The maximum number of points along a line of
-C                     latitude.
-C     JPLAT         - The maximum number of lines of latitude
-C     JPGTRUNC      - The maximum Gaussian truncation allowed.
-C     JPSTRUNC      - The maximum spherical harmonic truncation
-C                     allowed.
-C
-C     JPML01        - 10 minute land sea mask - Number of values per
-C                     degree.
-C     JPLG01        - 10 minute land sea mask - Number of values long
-C                     a line of latitude.
-C     JPLT01        - 10 minute land sea mask - Number of lines of
-C                     latitude.
-C     JPPACK        - 10 minute land sea mask - Length of packed
-C                     record in words.
-C
-C     PPDEGMIN      - The minimum grid size
-C                     (Real (360) / REAL (JPLONG) ).
-C
-      INTEGER JPLONG, JPLAT, JPGTRUNC, JPSTRUNC
-C
-      PARAMETER (JPLONG = 1440)
-      PARAMETER (JPLAT  = 2048 )
-      PARAMETER (JPGTRUNC = 2048)
-      PARAMETER (JPSTRUNC = 2047)
-C
-      INTEGER JPLG01, JPLT01, JPPACK, JPML01
-C
-      PARAMETER (JPML01 = 6)
-      PARAMETER (JPLG01 = 360 * JPML01)
-      PARAMETER (JPLT01 = 180 * JPML01)
-#ifdef rs6000
-      PARAMETER (JPPACK = (JPLG01 - 1) / 32 + 1)
-#else
-      PARAMETER (JPPACK = (JPLG01 - 1) / JPBITS + 1)
-#endif
-C
-      REAL PPDEGMIN
-C
-      PARAMETER (PPDEGMIN = 0.5E0)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 3. Library Interface Constants
-C     _______________________________________________________
-C
-C
-C     Data representation type values:
-C
-C     JPGAUSSIAN - Gaussian
-C     JPFGGROT   - Rotated full (regular) gaussian
-C     JPQUASI    - Quasi-regular gaussian
-C     JPQGGROT   - Rotated quasi-regular (reduced) gaussian
-C     JPREDLL    - Quasi-regular latitude/longitude
-C     JPREDLROT  - Rotated quasi-regular latitude/longitude
-C     JPREGULAR  - Regular latitude longitude
-C     JPREGROT   - Rotated regular latitude longitude
-C     JPSPHERE   - Spherical harmonic
-C     JPSPHROT   - Rotated spherical harmonic
-C     JPSTRGG    - Streched quasi-regular gaussian
-C     JPSTRSH    - Streched spherical harmonic
-C     JPNOTYPE   - Dummy data.
-C
-C     Field parameter numbers required (All field numbers refer to
-C     ECMWF local Code Table 2 with NITABLE .eq. 128).
-C
-C     JP_U          - Wind parameter U
-C     JP_V          - Wind parameter V
-C     JP_10U        - Wind parameter 10U
-C     JP_10V        - Wind parameter 10V
-C
-C     JP_LSP        - Large scale precipitation LSP
-C     JP_CP         - Convective precipitation CP
-C     JP_SF         - Snowfall SF
-C     JP_TP         - Total precipitation TP
-C
-C     JP_MSL        - Mean sea level pressure MSL
-C     JP_LSM        - Land sea mask LSM
-C
-C     Field parameter numbers required (All field numbers refer to
-C     the standard WMO parameter number with NITABLE .eq. 1)
-C
-C     JP_WMO_U      - Wind parameter U
-C     JP_WMO_V      - Wind parameter V
-C     JP_WMO_10U    - Wind parameter 10U
-C     JP_WMO_10V    - Wind parameter 10V
-C
-C     JP_WMO_LSP    - Large scale precipitation LSP
-C     JP_WMO_CP     - Convective precipitation CP
-C     JP_WMO_SF     - Snowfall SF
-C     JP_WMO_TP     - Total precipitation TP
-C
-C     JP_WMO_MSL    - Mean sea level pressure MSL
-C     JP_WMO_LSM    - Land sea mask LSM
-C
-      INTEGER JPGAUSSIAN,JPQUASI,JPREGULAR,JPREGROT,JPSPHERE,JPSPHROT
-      INTEGER JPFGGROT, JPQGGROT, JPSTRGG, JPSTRSH
-      INTEGER JPREDLL, JPREDLROT
-      INTEGER JPNOTYPE
-C
-      PARAMETER (JPGAUSSIAN =  4)
-      PARAMETER (JPFGGROT   = 14)
-      PARAMETER (JPQUASI    = 25)
-      PARAMETER (JPQGGROT   = 27)
-      PARAMETER (JPREDLL    = 26)
-      PARAMETER (JPREDLROT  = 28)
-      PARAMETER (JPREGULAR  =  0)
-      PARAMETER (JPREGROT   = 10)
-      PARAMETER (JPSPHERE   = 50)
-      PARAMETER (JPSPHROT   = 60)
-      PARAMETER (JPSTRGG    = 24)
-      PARAMETER (JPSTRSH    = 70)
-      PARAMETER (JPNOTYPE   = 9999)
-C
-      INTEGER JP_U, JP_V, JP_10U, JP_10V
-C
-      PARAMETER (JP_U   = 131)
-      PARAMETER (JP_V   = 132)
-      PARAMETER (JP_10U = 165)
-      PARAMETER (JP_10V = 166)
-C
-      INTEGER JP_LSP, JP_CP, JP_SF, JP_TP
-C
-      PARAMETER (JP_LSP = 142)
-      PARAMETER (JP_CP  = 143)
-      PARAMETER (JP_SF  = 144)
-      PARAMETER (JP_TP  = 228)
-C
-      INTEGER JP_MSL, JP_LSM
-C
-      PARAMETER (JP_MSL = 151)
-      PARAMETER (JP_LSM = 172)
-C
-      INTEGER JP_WMO_U, JP_WMO_V
-C
-      PARAMETER (JP_WMO_U   = 33)
-      PARAMETER (JP_WMO_V   = 34)
-C
-      INTEGER JP_WMO_LSP, JP_WMO_CP, JP_WMO_SF, JP_WMO_TP, JP_WMO_WESF
-C
-      PARAMETER (JP_WMO_TP  = 61)
-      PARAMETER (JP_WMO_LSP = 62)
-      PARAMETER (JP_WMO_CP  = 63)
-      PARAMETER (JP_WMO_SF  = 64)
-      PARAMETER (JP_WMO_WESF  = 65)
-C
-      INTEGER JP_WMO_MSL, JP_WMO_LSM
-C
-      PARAMETER (JP_WMO_MSL = 2)
-      PARAMETER (JP_WMO_LSM = 81)
-C
-C
-C     _______________________________________________________
-C
-C
-C*    Section 4. Library Formulation Constants
-C
-C     These constants handle the fact that all latitudes and
-C     longitudes are represented as integer values. The values of
-C     longitude or latitude degrees are represented as
-C     NINT (real_degree * PPMULT).
-C
-C     _______________________________________________________
-C
-C     JPMULT        - The integer version of the multiplier PPMULT
-C                     (currently 10000).
-C     JP90          - The integer value (90 * JPMULT).
-C     JP180         - The integer value (180 * JPMULT).
-C     JP360         - The integer value (360 * JPMULT).
-C     JP0P5         - The integer value (JPMULT / 2).
-C     PPEPS         - Small value to force latitude rounding.
-C
-C     PPMULT        - The multiplying factor for all degree values
-C                     (REAL (JPMULT) )
-C
-C     JPMICRO       -  scale factor from micro-degrees (from GRIB)
-C                      to working scale (JPMULT).
-C
-      INTEGER JPMULT, JP90, JP180, JP360, JP0P5, JPMIN, JPMICRO
-      REAL PPEPS
-C
-      PARAMETER (JPMULT = 100000)
-      PARAMETER ( JP90 =  90 * JPMULT)
-      PARAMETER (JP180 = 180 * JPMULT)
-      PARAMETER (JP360 = 360 * JPMULT)
-      PARAMETER (JP0P5 = JPMULT / 2)
-      PARAMETER (PPEPS = 0.9)
-      PARAMETER (JPMIN = JP0P5)
-      PARAMETER (JPMICRO = (JPMULT/1000) )
-C
-      REAL PPMULT
-C
-      PARAMETER (PPMULT = 1.0E5)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 5. Grib Section Size Constants
-C
-C     All these constants are in terms of expanded arrays after
-C     GRIBEX has been used to unpack a field.
-C
-C     _______________________________________________________
-C
-C     JPENSEMBLE    - The number of ensemble forecasts (Used for
-C                     handling clusters).
-C     JPVERTICAL    - The number of model levels.
-C     JPBASE2       - The basic size of Grib Section 2.
-C
-C     JPGRIB_ISEC0  - The size of Grib integer Section 0.
-C     JPGRIB_ISEC1  - The size of Grib integer Section 1.
-C     JPGRIB_ISEC2  - The size of Grib integer Section 2.
-C     JPGRIB_ISEC3  - The size of Grib integer Section 3.
-C     JPGRIB_ISEC4  - The size of Grib integer Section 4.
-C
-C     JPGRIB_RSEC2  - The size of Grib real Section 2.
-C     JPGRIB_RSEC3  - The size of Grib real Section 3.
-C
-      INTEGER JPENSEMBLE, JPVERTICAL, JPBASE2
-C
-      PARAMETER (JPENSEMBLE = 100)
-      PARAMETER (JPVERTICAL = 100)
-      PARAMETER (JPBASE2 = 22)
-C
-      INTEGER JPGRIB_ISEC0, JPGRIB_ISEC1, JPGRIB_ISEC2, JPGRIB_ISEC3,
-     1   JPGRIB_ISEC4
-C
-      PARAMETER (JPGRIB_ISEC0 = 2)
-      PARAMETER (JPGRIB_ISEC1 = 2048 )
-      PARAMETER (JPGRIB_ISEC2 = 5000)
-      PARAMETER (JPGRIB_ISEC3 = 2)
-      PARAMETER (JPGRIB_ISEC4 = 2512)
-C
-      INTEGER JPGRIB_RSEC2, JPGRIB_RSEC3
-C
-      PARAMETER (JPGRIB_RSEC2 = 10 + 2 * (JPVERTICAL + 1) )
-      PARAMETER (JPGRIB_RSEC3 = 2)
-C
-C
-C     _______________________________________________________
-C
-C
-C*    Section 6. Grib Section 1, 2 and 4 Offsets
-C
-C     All these constants are used for expanded arrays after GRIBEX
-C     has been used to unpack a field.
-C
-C     has been used to unpack a field.  C
-C     _______________________________________________________
-C
-C     General offsets.
-C     ________________
-C
-C     JPSEC1_TABLE  - The offset of the version number of code table 2.
-C     JPSEC1_PARAM  - The offset of the parameter value in Section 1.
-C
-C     JPSEC2_REP    - The offset of the Data Representation Type in
-C                     Section 2.
-C     JPSEC2_QUASI  - The offset of the Quasi Regular Flag in
-C                     Section 2.
-C     JPSEC2_QUDEF  - The offset of the end of a standard Section 2.
-C                     This may be used to simplify access to quasi
-C                     regular Gaussian field latitude line length
-C                     definitions.
-C
-C     JPSEC4_NVALUE - The offset of the number of data values in the
-C                     field.
-C     JPSEC4_NBITS  - The offset of the number of bits used for each
-C                     data value in the field.
-C
-      INTEGER JPSEC1_PARAM, JPSEC1_TABLE
-C
-      PARAMETER (JPSEC1_TABLE = 1)
-      PARAMETER (JPSEC1_PARAM = 6)
-C
-      INTEGER JPSEC4_NVALUE, JPSEC4_NBITS
-C
-      PARAMETER (JPSEC4_NVALUE = 1)
-      PARAMETER (JPSEC4_NBITS = 2)
-C
-      INTEGER JPSEC2_REP, JPSEC2_QUASI, JPSEC2_QUDEF
-C
-      PARAMETER (JPSEC2_REP = 1)
-      PARAMETER (JPSEC2_QUASI = 17)
-      PARAMETER (JPSEC2_QUDEF = JPBASE2)
-C
-C     Offsets for Spherical Harmonic Data.
-C     ____________________________________
-C
-C     JPSEC2_STRUNC - The offset of the Triangular truncation factor
-C                     in Section 2.
-C     JPSEC2_JTRUNC - The offset of the J-Pentagonal resolution
-C                     parameter in Section 2.
-C     JPSEC2_KTRUNC - The offset of the K-Pentagonal resolution
-C                     parameter in Section 2.
-C     JPSEC2_MTRUNC - The offset of the M-Pentagonal resolution
-C                     parameter in Section 2.
-C     JPSEC2_SHRES  - The offset of the Representation Type in
-C                     Section 2.
-C     JPSEC2_SHMODE - The offset of the Representation Mode in
-C                     Section 2.
-C
-      INTEGER JPSEC2_STRUNC
-      INTEGER JPSEC2_JTRUNC
-      INTEGER JPSEC2_KTRUNC
-      INTEGER JPSEC2_MTRUNC
-      INTEGER JPSEC2_SHRES
-      INTEGER JPSEC2_SHMODE
-C
-      PARAMETER (JPSEC2_STRUNC = 2)
-      PARAMETER (JPSEC2_JTRUNC = 2)
-      PARAMETER (JPSEC2_KTRUNC = 3)
-      PARAMETER (JPSEC2_MTRUNC = 4)
-      PARAMETER (JPSEC2_SHRES = 5)
-      PARAMETER (JPSEC2_SHMODE = 6)
-C
-C     Offsets for all grid point data
-C     _______________________________
-C
-C     JPSEC2_NLONG  - The offset of the Number of points along a line
-C                     of latitude in Section 2. This value is unset
-C                     for a quasi regular Gaussian field.
-C     JPSEC2_NLAT   - The offset of the Number of lines of latitude
-C                     in Section 2.
-C     JPSEC2_NORTH  - The offset of the Northern line of latitude in
-C                     Section 2.
-C     JPSEC2_SOUTH  - The offset of the Southern line of latitude in
-C                     Section 2.
-C     JPSEC2_WEST   - The offset of the Western longitude limit in
-C                     Section 2.
-C     JPSEC2_EAST   - The offset of the Eastern longitude limit in
-C                     Section 2. This value should be ignored for a
-C                     quasi regular Gaussian field.
-C     JPSEC2_RESOL  - The offset of the Resolution flag in Section 2.
-C     JPSEC2_DLONG  - The offset of the Increment along a line of
-C                     latitude in Section 2. This value is unset for
-C                     a quasi regular Gaussian field or a field where
-C                     Grib cannot describe this value accurately
-C                     (0.5625 degrees).
-C     JPSEC2_SCAN   - The offset of the Scanning mode flag in
-C                     Section 2.
-C     JPSEC2_VERT   - The offset of the Number of vertical coordinate
-C                     parameters in Section 2.
-C
-      INTEGER JPSEC2_NLONG
-      INTEGER JPSEC2_NLAT
-      INTEGER JPSEC2_NORTH
-      INTEGER JPSEC2_WEST
-      INTEGER JPSEC2_SOUTH
-      INTEGER JPSEC2_EAST
-      INTEGER JPSEC2_RESOL
-      INTEGER JPSEC2_DLONG
-      INTEGER JPSEC2_SCAN
-      INTEGER JPSEC2_VERT
-C
-      PARAMETER (JPSEC2_NLONG = 2)
-      PARAMETER (JPSEC2_NLAT = 3)
-      PARAMETER (JPSEC2_NORTH = 4)
-      PARAMETER (JPSEC2_WEST = 5)
-      PARAMETER (JPSEC2_SOUTH = 7)
-      PARAMETER (JPSEC2_EAST = 8)
-      PARAMETER (JPSEC2_RESOL = 6)
-      PARAMETER (JPSEC2_DLONG = 9)
-      PARAMETER (JPSEC2_SCAN = 11)
-      PARAMETER (JPSEC2_VERT = 12)
-C
-C     Offset for Gaussian grids only
-C     ______________________________
-C
-C     JPSEC2_GTRUNC - The offset of Gaussian truncation value in
-C                     Section 2. This would be the number of points
-C                     between a pole and the equator for a global
-C                     grid.
-C
-      INTEGER JPSEC2_GTRUNC
-C
-      PARAMETER (JPSEC2_GTRUNC = 10)
-C
-C     Offset for latitude longitude grids only
-C     ________________________________________
-C
-C     JPSEC2_DLAT   - The offset of the Increment along a line of
-C                     meridian in Section 2. This value is unset for
-C                     a field where Grib cannot describe this value
-C                     accurately (0.5625 degrees).
-C
-      INTEGER JPSEC2_DLAT
-C
-      PARAMETER (JPSEC2_DLAT = 10)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 7. Useful constants
-C     _______________________________________________________
-C
-C     PPZERO        - The constant real zero
-C     PPONE         - The constant real one
-C
-C     JPABS         - I/O parameter to PBSEEK causing absolute file
-C                     positioning.
-C     JPEOF         - End of file return value from PBSEEK or PBREAD.
-C     JPERR         - Error return value from PBSEEK or PBREAD.
-C
-      REAL PPZERO, PPONE
-C
-      PARAMETER (PPZERO = 0.0E0)
-      PARAMETER (PPONE = 1.0E0)
-C
-      INTEGER JPABS, JPEOF, JPERR
-C
-      PARAMETER (JPABS = 0)
-      PARAMETER (JPEOF = - 1)
-      PARAMETER (JPERR = - 2)
-C
-      INTEGER JPLEVEL, JPINNER, JPGRIB_SPACE
-C
-      PARAMETER (JPLEVEL = 2)
-      PARAMETER (JPINNER = JPLEVEL)
-      PARAMETER (JPGRIB_SPACE = 1)
-C
-C     _______________________________________________________
-C
-C
-C*    Section 8. Grid to Grid Constant Definitions
-C     _______________________________________________________
-C
-C     JP_I_N        - An array index used to access the input
-C                     latitude line North of the current output
-C                     point.
-C     JP_I_S        - An array index used to access the input
-C                     latitude line South of the current output
-C                     point.
-C     JP_I_W        - An array index used to access the input points
-C                     West of the current output point.
-C     JP_I_E        - An array index used to access the input points
-C                     East of the current output point.
-C
-C     JP_I_NW       - An array index used to access the weight array
-C                     for the point North-West of the current output
-C                     point.
-C     JP_I_NE       - An array index used to access the weight array
-C                     for the point North-East of the current output
-C                     point.
-C     JP_I_SW       - An array index used to access the weight array
-C                     for the point South-West of the current output
-C                     point.
-C     JP_I_SE       - An array index used to access the weight array
-C                     for the point South-East of the current output
-C                     point.
-C
-C     JPNORTH       - An array index used to access the Northern
-C                     value of a MARS AREA definition.
-C     JPSOUTH       - An array index used to access the Southern
-C                     value of a MARS AREA definition.
-C     JPWEST        - An array index used to access the Western
-C                     value of a MARS AREA definition.
-C     JPEAST        - An array index used to access the Eastern
-C                     value of a MARS AREA definition.
-C
-C     JPWESTEP      - An array index used to access the West-East
-C                     stride of a MARS GRID definition.
-C     JPNSSTEP      - An array index used to access the North-South
-C                     stride of a MARS GRID definition.
-C
-      INTEGER JP_I_N, JP_I_S, JP_I_W, JP_I_E
-C
-      PARAMETER (JP_I_N = 1)
-      PARAMETER (JP_I_S = 2)
-      PARAMETER (JP_I_W = 1)
-      PARAMETER (JP_I_E = 2)
-C
-      INTEGER JP_I_NW, JP_I_NE, JP_I_SW, JP_I_SE
-C
-      PARAMETER (JP_I_NW = 1)
-      PARAMETER (JP_I_NE = 2)
-      PARAMETER (JP_I_SW = 3)
-      PARAMETER (JP_I_SE = 4)
-C
-      INTEGER JPNORTH, JPSOUTH, JPWEST, JPEAST
-C
-      PARAMETER (JPNORTH = 1)
-      PARAMETER (JPWEST  = 2)
-      PARAMETER (JPSOUTH = 3)
-      PARAMETER (JPEAST  = 4)
-C
-      INTEGER JPWESTEP, JPNSSTEP
-C
-      PARAMETER (JPWESTEP = 1)
-      PARAMETER (JPNSSTEP = 2)
-C
-C --------------------------------------------------------------------
-C     Values for message logging
-C
-      INTEGER JP_DEBUG, JP_INFO, JP_WARN, JP_ERROR, JP_FATAL, JPQUIET
-      PARAMETER ( JP_DEBUG = 0 )
-      PARAMETER ( JP_INFO  = 1 )
-      PARAMETER ( JP_WARN = 2 )
-      PARAMETER ( JP_ERROR = 3 )
-      PARAMETER ( JP_FATAL = 4 )
-      PARAMETER ( JPQUIET  = -999999999 )
-C
-C --------------------------------------------------------------------
-C     Values grid point generation styles
-C
-      REAL*8 JPDISTP
-      INTEGER JPSMARS, JPSDISM
-C
-C     JPSMARS => Mars style, eg area checking
-C     JPSDISM => Dissemination style, eg point selection
-C     JPDISTP = default dissemination lat/long grid step (= 0.5 degrees)
-C
-      PARAMETER ( JPSMARS = 0 )
-      PARAMETER ( JPSDISM = 1 )
-      PARAMETER ( JPDISTP = 0.5 )
diff --git a/tools/getGaussianLatitudes/rgauss_1024.h b/tools/getGaussianLatitudes/rgauss_1024.h
deleted file mode 100644
index 9c32e65..0000000
--- a/tools/getGaussianLatitudes/rgauss_1024.h
+++ /dev/null
@@ -1,207 +0,0 @@
-      REAL QG1024(1024)
-      DATA QG1024/
-     X   18 ,   25,   32,   40,   45,
-     X   50,   54,   60,   72,   72,
-     X   75,   80,   90,   90,   96,
-     X  100,  108,  120,  120,  120,
-     X  125,  135,  144,  150,  160,
-     X  160,  180,  180,  180,  192,
-     X  192,  200,  216,  216,  225,
-     X  225,  240,  240,  243,  250,
-     X  256,  270,  270,  288,  288,
-     X  288,  300,  300,  320,  320,
-     X  320,  360,  360,  360,  360,
-     X  360,  360,  375,  375,  384,
-     X  384,  400,  400,  405,  432,
-     X  432,  432,  432,  450,  450,
-     X  450,  480,  480,  480,  480,
-     X  480,  486,  500,  500,  512,
-     X  512,  540,  540,  540,  540,
-     X  576,  576,  576,  576,  576,
-     X  576,  600,  600,  600,  600,
-     X  640,  640,  640,  640,  640,
-     X  640,  648,  675,  675,  675,
-     X  675,  675,  720,  720,  720,
-     X  720,  720,  720,  720,  729,
-     X  750,  750,  750,  750,  768,
-     X  768,  800,  800,  800,  800,
-     X  800,  800,  810,  864,  864,
-     X  864,  864,  864,  864,  864,
-     X  864,  864,  900,  900,  900,
-     X  900,  900,  900,  960,  960,
-     X  960,  960,  960,  960,  960,
-     X  960,  960,  972,  972, 1000,
-     X 1000, 1000, 1000, 1000, 1024,
-     X 1024, 1024, 1024, 1080, 1080,
-     X 1080, 1080, 1080, 1080, 1080,
-     X 1080, 1080, 1125, 1125, 1125,
-     X 1125, 1125, 1125, 1125, 1152,
-     X 1152, 1152, 1152, 1152, 1200,
-     X 1200, 1200, 1200, 1200, 1200,
-     X 1200, 1215, 1215, 1215, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1296, 1296, 1350, 1350, 1350,
-     X 1350, 1350, 1350, 1350, 1350,
-     X 1350, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1458, 1458, 1458, 1500,
-     X 1500, 1500, 1500, 1500, 1500,
-     X 1500, 1500, 1536, 1536, 1536,
-     X 1536, 1536, 1536, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1620,
-     X 1620, 1620, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1800, 1800, 1800, 1800,
-     X 1800, 1800, 1800, 1800, 1800,
-     X 1800, 1800, 1800, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1875,
-     X 1875, 1920, 1920, 1920, 1920,
-     X 1920, 1920, 1920, 1920, 1944,
-     X 1944, 1944, 1944, 1944, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2025,
-     X 2025, 2025, 2025, 2048, 2048,
-     X 2048, 2048, 2048, 2160, 2160,
-     X 2160, 2160, 2160, 2160, 2160,
-     X 2160, 2160, 2160, 2160, 2160,
-     X 2160, 2160, 2160, 2160, 2160,
-     X 2160, 2160, 2160, 2187, 2187,
-     X 2187, 2187, 2187, 2250, 2250,
-     X 2250, 2250, 2250, 2250, 2250,
-     X 2250, 2250, 2250, 2250, 2250,
-     X 2304, 2304, 2304, 2304, 2304,
-     X 2304, 2304, 2304, 2304, 2304,
-     X 2400, 2400, 2400, 2400, 2400,
-     X 2400, 2400, 2400, 2400, 2400,
-     X 2400, 2400, 2400, 2400, 2400,
-     X 2400, 2400, 2400, 2400, 2430,
-     X 2430, 2430, 2430, 2430, 2500,
-     X 2500, 2500, 2500, 2500, 2500,
-     X 2500, 2500, 2500, 2500, 2500,
-     X 2500, 2500, 2500, 2500, 2560,
-     X 2560, 2560, 2560, 2560, 2560,
-     X 2560, 2560, 2560, 2560, 2560,
-     X 2560, 2592, 2592, 2592, 2592,
-     X 2592, 2592, 2700, 2700, 2700,
-     X 2700, 2700, 2700, 2700, 2700,
-     X 2700, 2700, 2700, 2700, 2700,
-     X 2700, 2700, 2700, 2700, 2700,
-     X 2700, 2700, 2700, 2700, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2880, 2880,
-     X 2880, 2880, 2880, 2916, 2916,
-     X 2916, 2916, 2916, 2916, 2916,
-     X 2916, 3000, 3000, 3000, 3000,
-     X 3000, 3000, 3000, 3000, 3000,
-     X 3000, 3000, 3000, 3000, 3000,
-     X 3000, 3000, 3000, 3000, 3000,
-     X 3072, 3072, 3072, 3072, 3072,
-     X 3072, 3072, 3072, 3072, 3072,
-     X 3072, 3072, 3072, 3072, 3072,
-     X 3072, 3072, 3125, 3125, 3125,
-     X 3125, 3125, 3125, 3125, 3125,
-     X 3125, 3125, 3125, 3125, 3125,
-     X 3200, 3200, 3200, 3200, 3200,
-     X 3200, 3200, 3200, 3200, 3200,
-     X 3200, 3200, 3200, 3200, 3200,
-     X 3200, 3200, 3200, 3240, 3240,
-     X 3240, 3240, 3240, 3240, 3240,
-     X 3240, 3240, 3240, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3375,
-     X 3375, 3375, 3375, 3375, 3456,
-     X 3456, 3456, 3456, 3456, 3456,
-     X 3456, 3456, 3456, 3456, 3456,
-     X 3456, 3456, 3456, 3456, 3456,
-     X 3456, 3456, 3456, 3456, 3456,
-     X 3456, 3456, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3600, 3600, 3600, 3600,
-     X 3600, 3645, 3645, 3645, 3645,
-     X 3645, 3645, 3645, 3645, 3645,
-     X 3645, 3645, 3645, 3645, 3645,
-     X 3645, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3750, 3750, 3750, 3750, 3750,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3840, 3840, 3840,
-     X 3840, 3840, 3888, 3888, 3888,
-     X 3888, 3888, 3888, 3888, 3888,
-     X 3888, 3888, 3888, 3888, 3888,
-     X 3888, 3888, 3888, 3888, 3888,
-     X 3888, 3888, 3888, 3888, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4000,
-     X 4000, 4000, 4000, 4000, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4050, 4050,
-     X 4050, 4050, 4050, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096, 4096,
-     X 4096, 4096, 4096, 4096 /
diff --git a/tools/getGaussianLatitudes/rgauss_200.h b/tools/getGaussianLatitudes/rgauss_200.h
deleted file mode 100644
index 0292cf2..0000000
--- a/tools/getGaussianLatitudes/rgauss_200.h
+++ /dev/null
@@ -1,52 +0,0 @@
-      REAL QG200(200)
-      DATA QG200/
-     X  18,  25,  36,  40,
-     X  45,  50,  60,  64,
-     X  72,  72,  75,  81,
-     X  90,  96, 100, 108,
-     X 120, 125, 128, 135,
-     X 144, 150, 160, 160,
-     X 180, 180, 180, 192,
-     X 192, 200, 216, 216,
-     X 225, 225, 240, 240,
-     X 243, 250, 256, 270,
-     X 270, 288, 288, 288,
-     X 300, 300, 320, 320,
-     X 320, 320, 360, 360,
-     X 360, 360, 360, 360,
-     X 375, 375, 375, 384,
-     X 400, 400, 400, 400,
-     X 432, 432, 432, 432,
-     X 432, 450, 450, 450,
-     X 480, 480, 480, 480,
-     X 480, 480, 486, 500,
-     X 500, 500, 512, 512,
-     X 512, 540, 540, 540,
-     X 540, 540, 576, 576,
-     X 576, 576, 576, 576,
-     X 576, 576, 600, 600,
-     X 600, 600, 600, 640,
-     X 640, 640, 640, 640,
-     X 640, 640, 640, 640,
-     X 640, 648, 648, 675,
-     X 675, 675, 675, 675,
-     X 675, 675, 720, 720,
-     X 720, 720, 720, 720,
-     X 720, 720, 720, 720,
-     X 720, 720, 720, 720,
-     X 729, 729, 729, 750,
-     X 750, 750, 750, 750,
-     X 750, 750, 750, 768,
-     X 768, 768, 768, 768,
-     X 768, 768, 768, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800,
-     X 800, 800, 800, 800 /
diff --git a/tools/getGaussianLatitudes/rgauss_400.h b/tools/getGaussianLatitudes/rgauss_400.h
deleted file mode 100755
index d670c59..0000000
--- a/tools/getGaussianLatitudes/rgauss_400.h
+++ /dev/null
@@ -1,82 +0,0 @@
-      REAL QG400(400)
-      DATA QG400/
-     X   18,   25,   32,   40,   45,
-     X   50,   60,   60,   72,   72,
-     X   75,   81,   90,   96,  100,
-     X  108,  120,  120,  125,  128,
-     X  144,  144,  150,  160,  160,
-     X  180,  180,  192,  192,  200,
-     X  200,  216,  216,  225,  240,
-     X  240,  240,  250,  250,  256,
-     X  270,  288,  288,  288,  300,
-     X  300,  320,  320,  320,  324,
-     X  360,  360,  360,  360,  360,
-     X  360,  375,  375,  384,  400,
-     X  400,  400,  405,  432,  432,
-     X  432,  432,  450,  450,  450,
-     X  480,  480,  480,  480,  480,
-     X  486,  500,  500,  512,  512,
-     X  540,  540,  540,  540,  540,
-     X  576,  576,  576,  576,  576,
-     X  576,  600,  600,  600,  600,
-     X  640,  640,  640,  640,  640,
-     X  640,  640,  648,  675,  675,
-     X  675,  675,  675,  720,  720,
-     X  720,  720,  720,  720,  720,
-     X  729,  729,  750,  750,  750,
-     X  750,  768,  768,  768,  800,
-     X  800,  800,  800,  800,  800,
-     X  810,  864,  864,  864,  864,
-     X  864,  864,  864,  864,  864,
-     X  864,  900,  900,  900,  900,
-     X  900,  900,  900,  960,  960,
-     X  960,  960,  960,  960,  960,
-     X  960,  960,  960,  960,  960,
-     X  972,  972, 1000, 1000, 1000,
-     X 1000, 1000, 1000, 1024, 1024,
-     X 1024, 1024, 1024, 1080, 1080,
-     X 1080, 1080, 1080, 1080, 1080,
-     X 1080, 1080, 1080, 1080, 1125,
-     X 1125, 1125, 1125, 1125, 1125,
-     X 1125, 1125, 1125, 1152, 1152,
-     X 1152, 1152, 1152, 1152, 1200,
-     X 1200, 1200, 1200, 1200, 1200,
-     X 1200, 1200, 1200, 1200, 1200,
-     X 1215, 1215, 1215, 1215, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1296, 1296, 1296, 1296, 1350,
-     X 1350, 1350, 1350, 1350, 1350,
-     X 1350, 1350, 1350, 1350, 1350,
-     X 1350, 1350, 1350, 1350, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1458, 1458, 1458,
-     X 1458, 1458, 1458, 1458, 1500,
-     X 1500, 1500, 1500, 1500, 1500,
-     X 1500, 1500, 1500, 1500, 1500,
-     X 1500, 1500, 1500, 1500, 1500,
-     X 1500, 1536, 1536, 1536, 1536,
-     X 1536, 1536, 1536, 1536, 1536,
-     X 1536, 1536, 1536, 1536, 1536,
-     X 1536, 1536, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600 /
diff --git a/tools/getGaussianLatitudes/rgauss_512.h b/tools/getGaussianLatitudes/rgauss_512.h
deleted file mode 100755
index 479507b..0000000
--- a/tools/getGaussianLatitudes/rgauss_512.h
+++ /dev/null
@@ -1,105 +0,0 @@
-      REAL QG512(512)
-      DATA QG512/
-     X   18,   25,   32,   40,   45,
-     X   50,   60,   60,   72,   72,
-     X   75,   81,   90,   96,   96,
-     X  100,  108,  120,  125,  128,
-     X  135,  144,  150,  160,  160,
-     X  180,  180,  180,  192,  192,
-     X  200,  216,  216,  225,  225,
-     X  240,  240,  243,  250,  256,
-     X  270,  270,  288,  288,  288,
-     X  300,  320,  320,  320,  320,
-     X  360,  360,  360,  360,  360,
-     X  360,  375,  375,  384,  384,
-     X  400,  400,  400,  432,  432,
-     X  432,  432,  450,  450,  450,
-     X  480,  480,  480,  480,  480,
-     X  486,  500,  500,  512,  512,
-     X  540,  540,  540,  540,  540,
-     X  576,  576,  576,  576,  576,
-     X  576,  600,  600,  600,  640,
-     X  640,  640,  640,  640,  640,
-     X  640,  648,  675,  675,  675,
-     X  675,  675,  720,  720,  720,
-     X  720,  720,  720,  720,  729,
-     X  729,  750,  750,  750,  768,
-     X  768,  768,  800,  800,  800,
-     X  800,  800,  800,  810,  864,
-     X  864,  864,  864,  864,  864,
-     X  864,  864,  864,  864,  900,
-     X  900,  900,  900,  900,  900,
-     X  960,  960,  960,  960,  960,
-     X  960,  960,  960,  960,  960,
-     X  960,  972,  972, 1000, 1000,
-     X 1000, 1000, 1000, 1024, 1024,
-     X 1024, 1024, 1080, 1080, 1080,
-     X 1080, 1080, 1080, 1080, 1080,
-     X 1080, 1080, 1125, 1125, 1125,
-     X 1125, 1125, 1125, 1125, 1125,
-     X 1125, 1152, 1152, 1152, 1152,
-     X 1152, 1200, 1200, 1200, 1200,
-     X 1200, 1200, 1200, 1200, 1200,
-     X 1215, 1215, 1215, 1280, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1280, 1280, 1280, 1280, 1280,
-     X 1280, 1296, 1296, 1296, 1350,
-     X 1350, 1350, 1350, 1350, 1350,
-     X 1350, 1350, 1350, 1350, 1350,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1440,
-     X 1440, 1440, 1440, 1440, 1458,
-     X 1458, 1458, 1458, 1500, 1500,
-     X 1500, 1500, 1500, 1500, 1500,
-     X 1500, 1500, 1500, 1536, 1536,
-     X 1536, 1536, 1536, 1536, 1536,
-     X 1536, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1600, 1600, 1600,
-     X 1600, 1600, 1620, 1620, 1620,
-     X 1620, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1728, 1728, 1728, 1728,
-     X 1728, 1800, 1800, 1800, 1800,
-     X 1800, 1800, 1800, 1800, 1800,
-     X 1800, 1800, 1800, 1800, 1800,
-     X 1800, 1800, 1800, 1800, 1800,
-     X 1800, 1800, 1800, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1875,
-     X 1875, 1875, 1875, 1875, 1920,
-     X 1920, 1920, 1920, 1920, 1920,
-     X 1920, 1920, 1920, 1920, 1920,
-     X 1920, 1920, 1920, 1920, 1920,
-     X 1920, 1920, 1944, 1944, 1944,
-     X 1944, 1944, 1944, 1944, 1944,
-     X 1944, 1944, 1944, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2000, 2000, 2000, 2000, 2000,
-     X 2025, 2025, 2025, 2025, 2025,
-     X 2025, 2025, 2025, 2025, 2025,
-     X 2025, 2025, 2025, 2025, 2025,
-     X 2025, 2025, 2025, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048, 2048, 2048, 2048,
-     X 2048, 2048 /
diff --git a/tools/getGaussianLatitudes/run b/tools/getGaussianLatitudes/run
deleted file mode 100644
index a629a60..0000000
--- a/tools/getGaussianLatitudes/run
+++ /dev/null
@@ -1,4 +0,0 @@
-# Produce output for web
-#./jgetgg 400
-
-./jgetgg $1
diff --git a/tools/gg_gridname.c b/tools/gg_gridname.c
new file mode 100644
index 0000000..17d5b89
--- /dev/null
+++ b/tools/gg_gridname.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2015-2015 ECMWF.
+ *
+ * This software is licensed under the terms of the Apache Licence Version 2.0
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+ */
+
+
+#include <assert.h>
+#include <string.h>
+#include "grib_api.h"
+#include "common/fortint.h"
+
+
+void jnumgg_(fortint *knum_, const char *htype_, int kpts_[], fortint *kret_);
+#ifdef FORTRAN_UPPERCASE
+#define jnumgg_ JNUMGG
+#endif
+#ifdef FORTRAN_NO_UNDERSCORE
+#define jnumgg_ jnumgg
+#endif
+
+
+#ifdef FORTRAN_LINKER_PGI
+#define main_ MAIN_
+#else
+#define main_ main
+#endif
+
+
+int main_(int argc, char** argv) {
+
+
+  FILE        *f = NULL;  /* file handle    */
+  grib_handle *h = NULL;  /* GRIB handle    */
+  int err;                /* error status   */
+  int i;                  /* argument index */
+
+  const char* gridNameUser = NULL;  /* gridname to expect/non-expect */
+  long gridNameExpected    = -1;    /* gridname expected/non-expected/unused (1/0/-1) */
+  long onlySupported       =  1;    /* do check for supported grids, including comparison of pl array */
+  long onlyOne             =  0;    /* do only one grib message */
+
+  unsigned c   = 0;  /* GRIB message counter */
+  long ok      = 1;  /* success state holder */
+  fortint kret = 0;  /* return code when checking supported grids */
+
+  if (argc<2) {
+      fprintf(stdout,
+          "Check for supported Gaussian grids short name (\"gridname\").\n"
+          "Usage: %s [[--eq|--ne]=gridname] [-a] [-1] file1 [file2 [...]]\n"
+          "with:\n"
+          "  --[eq|ne]:  test for equality/inequality to gridname\n"
+          "  -a:         no test for supported grids\n"
+          "  -1:         test only the first GRIB message\n"
+          "and gridname is one of the supported grids:\n"
+          "  F32    N32    O32\n"
+          "  F48    N48    O48\n"
+          "  F64    N64    O64\n"
+          "  F80    N80    O80\n"
+          "  F128   N128   O128\n"
+          "  F160   N160   O160\n"
+          "  F200   N200   O200\n"
+          "  F256   N256   O256\n"
+          "  F320   N320   O320\n"
+          "  F400   N400   O400\n"
+          "  F512   N512   O512\n"
+          "  F640   N640   O640\n"
+          "  F1280         O1280\n", argv[0] );
+      return 0;
+  }
+
+
+  /* turn on support for multi fields messages */
+  grib_multi_support_on(0);
+
+
+  /* check for gridname comparison equal/non-equal */
+  for (i=1; i<argc; ++i) {
+      const char *a = argv[i];
+      if ( strlen(a)>5 && (!strncmp("--eq=",a,5) || !strncmp("--ne=",a,5)) ) {
+          gridNameUser     = &a[5];
+          gridNameExpected = strncmp("--ne=",a,5)!=0? 1:0;
+      }
+      else if (!strncmp("-a",a,2)) { onlySupported = 0; }
+      else if (!strncmp("-1",a,2)) { onlyOne       = 1; }
+  }
+
+
+  /* for all arguments (files cannot start with "--eq=" nor "--ne=") */
+  for (i=1; ok && i<argc; ++i) {
+      const char *a = argv[i];
+      if (!strncmp("--eq=",a,5) ||
+          !strncmp("--ne=",a,5) ||
+          !strncmp("-a",a,2) ||
+          !strncmp("-1",a,2)) {
+          continue;
+      }
+
+      /* initialize and open file */
+      f   = NULL;
+      h   = NULL;
+      err = 0;
+      if ((NULL==(f = fopen(a,"r")))) {
+          fprintf(stderr,"unable to open file \"%s\" (argument #%i).\n", a, i);
+          return 2;
+      }
+
+      /* iterate on file grib_handle messages, while failures don't happen */
+      while ((NULL!=(h = grib_handle_new_from_file(0,f,&err))) && ok) {
+          GRIB_CHECK(err,0);
+          ok = 0;
+          ++c;
+
+          char
+              gridName[ 6] = "",  /* accomodate "[FNO][0-9]{1,4}" */
+              gridType[80] = "";  /* grib internal gridType */
+          size_t size = sizeof(gridType);
+          if ((err = grib_get_string(h,"gridType",gridType,&size))) {
+              fprintf(stderr,"cannot get gridType, %s\n",grib_get_error_message(err));
+              break;
+          }
+
+          /* handle only rotated/non-rotated regular/reduced Gaussian grids */
+          const long
+              isRegularGG = (!strcmp(gridType,"regular_gg") || !strcmp(gridType,"rotated_gg"))?         1:0,
+              isReducedGG = (!strcmp(gridType,"reduced_gg") || !strcmp(gridType,"reduced_rotated_gg"))? 1:0;
+          if (isRegularGG || isReducedGG) {
+
+              /* get grid N and type */
+              long N = 0;
+              char T = 'F';
+
+              GRIB_CHECK(grib_get_long(h, "N", &N), 0);
+              assert(N > 0);
+
+              if (isReducedGG) {
+                  long isOctahedral = 0;
+                  GRIB_CHECK(grib_get_long(h, "isOctahedral", &isOctahedral), 0);
+                  T = isOctahedral? 'O':'N';
+              }
+
+              /* check support of known Nxxx grids */
+              /* (grib_api does the check for Oxxx, above) */
+              fortint kret = 0;
+              if (onlySupported && T=='N') {
+                  fortint knum = (fortint) N;
+                  char htype[] = {T=='N'? 'R':T,' '};
+                  int kpts[4000] = {0,};
+                  jnumgg_(&knum,htype,kpts,&kret);
+                  if ((kret==0)) {
+
+                      /* get pl array */
+                      size_t pl_len = 0;
+                      GRIB_CHECK(grib_get_size(h, "pl", &pl_len), 0);
+                      assert(pl_len > 0);
+                      if (pl_len != 2*N) {
+                          fprintf(stderr, "ERROR: pl array length is %ld but should be 2*N (%ld)!\n", pl_len, 2*N);
+                          kret = -1;
+                          break;
+                      }
+                      long *pl = (long*)malloc(pl_len * sizeof(long));
+                      assert(pl);
+                      GRIB_CHECK(grib_get_long_array(h, "pl", pl, &pl_len), 0);
+
+                      /* compare to pl array of supported grid */
+                      int j;
+                      for (j=0; kret==0 && j<2*N; ++j)
+                          kret = (kpts[j]!=pl[j]);
+
+                  }
+              }
+
+              /* set gridname */
+              if (kret==0) {
+                  snprintf(gridName,6,"%c%li",T,N);
+              }
+
+          }
+
+          /* handle success/failure */
+          ok = gridNameExpected==1? (strncmp(gridName,gridNameUser,6)==0)
+             : gridNameExpected==0? (strncmp(gridName,gridNameUser,6)!=0)
+             : 1;
+          if (gridNameExpected==-1) {
+              fprintf(stdout,"%s\n",gridName);
+          }
+          if (onlyOne) {
+              break;
+          }
+
+      }
+
+      /* close handle & file */
+      grib_handle_delete(h);
+      fclose(f);
+
+  }
+
+
+  /* return success if all (!) went as expected, warn if not */
+  ok = ok && c;
+  if (!ok) {
+      fprintf(stderr, "%s failure\n", argv[0]);
+  }
+  return !ok;
+
+}
diff --git a/tools/gg_latitudes.F b/tools/gg_latitudes.F
new file mode 100644
index 0000000..bc4523e
--- /dev/null
+++ b/tools/gg_latitudes.F
@@ -0,0 +1,131 @@
+C Copyright 1981-2012 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      PROGRAM gg_latitudes
+C
+C---->
+C**** gg_latitudes
+C
+C     Purpose
+C     -------
+C
+C     Command-line interface to JGETGG (interpolation).
+C
+C
+C     Externals
+C     ---------
+C
+C     JGETGG - Reads the definition of a gaussian grid.
+C
+C----<
+C
+
+C     Declarations
+      IMPLICIT NONE
+      INTEGER IARGC
+
+      ! local variables
+      INTEGER I, J, K
+      CHARACTER*5 ARG, GRID
+
+      ! global variables (all this to get to NGSPEC)
+      INTEGER
+     X  NILOCAL, NISTREM, NGSPEC ,
+     X  NIFORM , NIREPR , NIGRID , NIAREA , NIGAUSS, NIRESO ,
+     X  NIWE   , NINS   , NISCNM , NIPARAM, NITABLE, NIACC  ,
+     X  NJDCDOT, NIPCNT , NILEVEL, NILEVT , NIDATE , NICOMP ,
+     X  NISLSCP, NIPOGRS, NIPNGRS, NIMATR
+      REAL RISTRET, RMISSGV
+      DIMENSION NIGRID(2)
+      DIMENSION NIAREA(4)
+      COMMON /JDNIFLD/
+     X  RISTRET, RMISSGV,
+     X  NILOCAL, NISTREM, NGSPEC ,
+     X  NIFORM , NIREPR , NIGAUSS, NIRESO ,
+     X  NIWE   , NINS   , NISCNM , NIPARAM, NITABLE, NIACC  ,
+     X  NJDCDOT, NIPCNT , NILEVEL, NILEVT , NIDATE , NICOMP ,
+     X  NISLSCP, NIPOGRS, NIPNGRS, NIGRID , NIAREA , NIMATR
+      SAVE /JDNIFLD/
+
+      ! JGETGG arguments
+      INTEGER KNUM, KRET
+      CHARACTER*1 HTYPE
+      INTEGER KPTS(4000) ! (in parim.h, JPLAT = 4000)
+      REAL    PLAT(4000) ! ...
+
+
+C     Check arguments count
+      IF (IARGC() < 1) THEN
+          PRINT *,
+     X'Usage -- gg_latitudes [|-12] [[N|O|F]KNUM] ...'
+          PRINT *, '  -12     -- force RGG specification (NGSPEC=12)'
+          PRINT *, '  [N|O|F] -- Gaussian grid type(s)'
+          PRINT *, '             N: "quasi-regular" (default)'
+          PRINT *, '             O: octahedral'
+          PRINT *, '             F: non-reduced'
+          PRINT *, '  KNUM    -- Gaussian grid number(s), up to 2000'
+          STOP
+      END IF
+
+
+C     Process arguments in order
+      NGSPEC = 0
+      DO J = 1, IARGC()
+          CALL GETARG(J,ARG)
+          IF (ARG=='-12') THEN
+
+C             Force RGG specification
+              NGSPEC = 12
+
+          ELSE IF (ARG(1:1).NE.'N' .AND.
+     X             ARG(1:1).NE.'O' .AND.
+     X             ARG(1:1).NE.'F') THEN
+
+C             Gaussian grid type has to be specified
+              PRINT *,'Error: ARG="',ARG,'", ARG(1:1)!="[N|O|F]"'
+              CALL EXIT(-1)
+
+          ELSE
+
+C             Set Gaussian grid type (HTYPE) & number (KNUM)
+C             (read ([NOF])([0-9]{4}), HTYPE=$1, KNUM=$2)
+              KNUM = 0
+              READ (ARG,'(A1,I4)') HTYPE, KNUM
+              IF (HTYPE=='N') HTYPE = 'R'
+              IF (KNUM.GT.2000) THEN
+                  PRINT *,'Error: ARG="',ARG,'" KNUM>2000'
+                  CALL EXIT(-1)
+              END IF
+
+C             Call JGETGG
+              KPTS = 0
+              PLAT = 0.
+              CALL JGETGG(KNUM,HTYPE,PLAT,KPTS,KRET)
+              IF (KRET.NE.0) THEN
+                  PRINT *,'Error: ARG="',ARG,'" JGETGG KRET=',KRET
+                  CALL EXIT(KRET)
+              END IF
+
+C             Output
+76            FORMAT(8X,A5,8X,A4,8X,A12)
+77            FORMAT(8X,I5,8X,I4,8X,F12.5)
+              IF (HTYPE.EQ.'R') WRITE(GRID,'(A,I0)') 'N',   KNUM
+              IF (HTYPE.NE.'R') WRITE(GRID,'(A,I0)') HTYPE, KNUM
+              WRITE(*,76) GRID,    'KPTS',  'PLAT        '
+              WRITE(*,76) '-----', '----',  '------------'
+              DO I = 1, KNUM*2
+              WRITE(*,77) I,       KPTS(I), PLAT(I)
+              END DO
+
+          END IF
+      END DO
+
+      END PROGRAM
+
diff --git a/tools/grib1profile/GRIB_profile.c b/tools/grib1profile/GRIB_profile.c
deleted file mode 100644
index d16aef3..0000000
--- a/tools/grib1profile/GRIB_profile.c
+++ /dev/null
@@ -1,168 +0,0 @@
-#include <stdio.h>
-#include "grib.h"
-#include "gdecode.h"
-
-#define BUFLEN 32000000
-
-#ifdef REAL_8
-typedef double FORTRAN_real;
-#else
-typedef float FORTRAN_real;
-#endif
-
-fortint getIntegerValue(gribProduct**,unsigned char*);
-
-#ifdef __uxp__
-MAIN__( int argc, char ** argv)
-#else
-main( int argc, char ** argv)
-#endif
-{
-FILE * in;
-fortint status;
-unsigned char buffer[BUFLEN];
-fortint bufferlen;
-fortint oldpos= 0, pos, prodlen;
-fortint GRIBcount = 0;
-fortint type, table, param, levty, level1, level2, level, date;
-fortint time, step;
-union {
-  fortint number;
-  char characters[5];
-} expver;
-char * months[12] = { " January ",
-                      " February",
-                      "  March  ",
-                      "  April  ",
-                      "   May   ",
-                      "   June  ",
-                      "   July  ",
-                      "  August ",
-                      "September",
-                      " October ",
-                      " November",
-                      " December"};
-
-  if ( argc != 2 ) {
-    printf(" Usage: GRIB_profile filename\n");
-    exit(1);
-  }
-
-  in = fopen( argv[1], "r");
-  if ( in == NULL ) {
-    perror("GRIB_profile: fopen failed!");
-    exit(1);
-  }
-
-/*
-printf("Number Type    Offset   Length  Param    Level      Date    Time  Step Expver\n");
-printf("------ ----    ------   ------ -------  -----  --------   ----  ---- ------\n");
-*/
-
-/*
-// Loop through products in the file
-*/
-  do {
-    bufferlen = sizeof(buffer);
-    status = readany( in, buffer, &bufferlen);
-
-/*
-// Accept product if OK or if only problem is 'buffer too small'
-*/
-    if ( status == -1 ) exit(0);
-/*
-// Note the product byte offset in the file
-*/
-    pos = ftell( in );
-    prodlen = bufferlen;
-    oldpos = pos - prodlen;
-    GRIBcount++;
-
-/*
-// If it's a GRIB product, pick up more information (parameter,level,..)
-*/
-    if ( strncmp( buffer, "GRIB", 4) == 0 ) {
-      gribProduct * grib;
-
-      GDECODE(&grib,buffer);
-      printf("%5d  ", GRIBcount);
-      type   = getIntegerValue(&grib,"ecmwfType");
-      param  = getIntegerValue(&grib,"parameter");
-      levty  = getIntegerValue(&grib,"typeOfLevel");
-      level1 = getIntegerValue(&grib,"topLayer");
-      level2 = getIntegerValue(&grib,"bottomLayer");
-      level  = getIntegerValue(&grib,"pressureLevel");
-      date   = getIntegerValue(&grib,"date");
-      time   = getIntegerValue(&grib,"time");
-      step   = getIntegerValue(&grib,"timeStep");
-      table  = getIntegerValue(&grib,"codeTable");
-
-      if( type != -999999)
-        printf(" %02d   %8d %8d", type, oldpos, prodlen);
-      else
-        printf(" --   %8d %8d", oldpos, prodlen);
-
-      printf("  %03d.%03d  ", param, table);
-
-      switch( (int) levty ) {
-
-        case 101:
-        case 104:
-        case 106:
-        case 108:
-        case 110:
-        case 112:
-        case 114:
-        case 116:
-        case 120:
-        case 121:
-        case 128:
-        case 141:
-          printf("%03d-%03d", level1, level2);
-          if( date < 13 )
-            printf(" %10.9s",months[date-1]);
-          else
-            printf("   %08d", date);
-          break;
-
-        default:
-          printf(" %5d", level);
-          if( date < 13 )
-            printf(" %10.9s",months[date-1]);
-          else
-            printf("   %08d", date);
-          break;
-
-      }
-      if( time == -1 )
-        printf("  ----", time);
-      else
-        printf("  %04d", time);
-      printf("  %4d", step);
-      if( type != -999999) {
-        expver.number = getIntegerValue(&grib,"ecmwfExperimentVersionNumber");
-#ifdef LITTLE_ENDIAN
-        swap4_(&expver);
-#endif
-        expver.characters[4] = '\0';
-        printf("  %4s", &expver.characters);
-      }
-      else
-        printf("  ----");
-    }
-    else
-    {
-      buffer[4] = '\0';
-      printf("%5d  ", GRIBcount);
-      printf("%4s  %8d %8d", buffer, oldpos, prodlen);
-    }
-
-    if( (status != 0) && (status != -3) )
-      printf("  (%2d)\n", status);
-    else
-      printf("\n");
-        
-  } while ( (! feof(in)) && ( status != -1) );
-
-    fclose(in);
-}
diff --git a/tools/grib1profile/Makefile.cluster b/tools/grib1profile/Makefile.cluster
deleted file mode 100644
index 927a23e..0000000
--- a/tools/grib1profile/Makefile.cluster
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-VERSION = 000220
-FINAL   = FINAL
-#
-# This is old path for Linux
-#EMOSLIB = -L/home/ma/emos/lib/linux/$(VERSION) -lemos.R64.D64.I32
-EMOSLIB = -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-
-BIN_DIR = /home/ecmwf/emos_sms/bin/linux
-#
-INCLUDE = -I/usr/X11R6/include/Xm -I/usr/X11R6/include
-LIBS    = -L/usr/X11R6/lib -lXm -lXp -lXext -lXt -lX11 $(EMOSLIB)
-CLIBS   = -L/usr/local/apps/pgi/current/linux86/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgc -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-CC      = gcc
-FC      = pgf90
-FFLAGS  = -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER
-#CFLAGS  = -D$(FINAL) -g -DREAL_8=1
-#CFLAGS  = -D$(FINAL) -Dlinux -DREAL_8=1
-CFLAGS  = -D$(FINAL) -Dlinux -DREAL_8=1 -Wl,-rpath /usr/local/apps/pgi/current/linux86/lib
-#
-.F.o:
-	$(FC) $(FFLAGS) $<
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(INCLUDE) $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-	$(CC) $(CFLAGS) -c $(CALLB.c) $(INCLUDE)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-	$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/Makefile.hpia64 b/tools/grib1profile/Makefile.hpia64
deleted file mode 100644
index e0f2973..0000000
--- a/tools/grib1profile/Makefile.hpia64
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-VERSION = 000160
-FINAL   = FINAL
-#
-#EMOSLIB = /home/ma/emos/lib/hpia64/$(VERSION)/libemos.R64.D64.I64.a
-EMOSLIB = /usr/local/lib/metaps/lib/$(VERSION)/libemos.R64.D64.I64.a
-BIN_DIR = /home/ecmwf/emos_sms/bin/hpia64
-#
-LIBS    = -lXm -lXt -lX11 $(EMOSLIB)
-CLIBS   = -lcl -lF90 -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-AR      = ar
-ARFLAGS = rv
-#
-CPPFLAGS= -Dhp -DhpiaR64 -DREAL_8 -DINTEGER_8 -DJBPW_64 -DPOINTER_64
-#
-CC      = cc 
-CFLAGS  = +DD64 -Ae -D_XPG2 -Dhp -DhpiaR64 -DREAL_8 -DINTEGER_8 -DPOINTER_64 +Z -O
-#
-FC      = /opt/fortran90/bin/f90
-FFLAGS  = +DD64 -g +autodbl +O0 +pic=long +real_constant=double
-#
-LDFLAGS   = -Wl,-B,immediate,-B,nonfatal,+s +s -L . -l emos
-RANLIB  = /usr/bin/ranlib
-CT      = /bin/true
-#
-.F.o:
-	/usr/ccs/lbin/cpp -P $(CPPFLAGS) $< > $*.f
-	$(FC) $(FFLAGS) -c $*.f
-	\rm -f $*.f
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-	$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/Makefile.hppa b/tools/grib1profile/Makefile.hppa
deleted file mode 100644
index 6caa4aa..0000000
--- a/tools/grib1profile/Makefile.hppa
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-VERSION = 000160
-FINAL   = FINAL
-#
-EMOSLIB = /home/ma/emos/lib/hppa/$(VERSION)/libemos.R32.D64.I32.a
-BIN_DIR = /home/ecmwf/emos_sms/bin/hppa
-#
-LIBS    = -lXm -lXt -lX11 $(EMOSLIB)
-CLIBS   = -lcl /opt/fortran90/lib/libF90.a -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-AR      = ar
-ARFLAGS = rv
-#
-CPPFLAGS= -Dhp
-#
-CC      = cc 
-CFLAGS  = -Aa -D$(FINAL) -D_INCLUDE_HPUX_SOURCE -D_INCLUDE_XOPEN_SOURCE \
--D_INCLUDE_AES_SOURCE -D_INCLUDE_POSIX_SOURCE -D_XPG2 \
--DFORTRAN_NO_UNDERSCORE -Dhp +z -O
-#
-FC      = /opt/fortran/bin/f77
-FFLAGS  = +z +U77 +O2 +T -w66 -Dhp +FPD
-#
-LDFLAGS   = -Wl,-B,immediate,-B,nonfatal,+s +s -L . -l emos
-RANLIB  = /usr/bin/ranlib
-CT      = /bin/true
-#
-.F.o:
-	/usr/ccs/lbin/cpp -P $(CPPFLAGS) $< > $*.f
-	$(FC) $(FFLAGS) -c $*.f
-	\rm -f $*.f
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-	$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/Makefile.ibm_power4 b/tools/grib1profile/Makefile.ibm_power4
deleted file mode 100644
index 4d0b02f..0000000
--- a/tools/grib1profile/Makefile.ibm_power4
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-VERSION = 000170
-FINAL   = FINAL
-#
-#EMOSLIB = -L/home/ma/emos/lib/rs6000/$(VERSION) -lemos.R64.D64.I32
-EMOSLIB = -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-BIN_DIR = /home/ecmwf/emos_sms/bin/rs6000
-#
-LIBS    = -lXm -lXt -lX11 $(EMOSLIB)
-#CLIBS   = -lftn -lm -lc
-CLIBS   = -lxlf -lxlf90 -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-AR      = ar
-ARFLAGS = rv
-#
-CC      = cc
-CFLAGS  = -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DFORTRAN_NO_UNDERSCORE -DIBM -DRS6000 -D$(FINAL) -g
-FASTCFLAGS = -O -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DFORTRAN_NO_UNDERSCORE -DIBM -DRS6000 -D$(FINAL) -g
-#
-FC      = xlf
-FFLAGS = -qnoextname -qrealsize=8 -qintsize=4 -qalign=4k -qnosource -g
-VECTFFLAGS  = $(FFLAGS)
-#
-RANLIB  = /bin/ranlib
-CT      = /bin/true
-#
-#
-.SUFFIXES: .o .F .c
-
-.c.o:
-	rm -f $@
-	cc $(CFLAGS) -c $<
-
-.F.o:
-	- cc $(CFLAGS) -P -C -c $<
-	mv $*.i $*.f 
-	$(FC) $(FFLAGS) -qintlog -c $*.f
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-#$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/Makefile.linux b/tools/grib1profile/Makefile.linux
deleted file mode 100644
index 927a23e..0000000
--- a/tools/grib1profile/Makefile.linux
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-VERSION = 000220
-FINAL   = FINAL
-#
-# This is old path for Linux
-#EMOSLIB = -L/home/ma/emos/lib/linux/$(VERSION) -lemos.R64.D64.I32
-EMOSLIB = -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-
-BIN_DIR = /home/ecmwf/emos_sms/bin/linux
-#
-INCLUDE = -I/usr/X11R6/include/Xm -I/usr/X11R6/include
-LIBS    = -L/usr/X11R6/lib -lXm -lXp -lXext -lXt -lX11 $(EMOSLIB)
-CLIBS   = -L/usr/local/apps/pgi/current/linux86/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgc -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-CC      = gcc
-FC      = pgf90
-FFLAGS  = -i4 -r8 -Dlinux -DR64=1 -DREAL_8=1 -DREAL_BIGGER_THAN_INTEGER
-#CFLAGS  = -D$(FINAL) -g -DREAL_8=1
-#CFLAGS  = -D$(FINAL) -Dlinux -DREAL_8=1
-CFLAGS  = -D$(FINAL) -Dlinux -DREAL_8=1 -Wl,-rpath /usr/local/apps/pgi/current/linux86/lib
-#
-.F.o:
-	$(FC) $(FFLAGS) $<
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(INCLUDE) $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-	$(CC) $(CFLAGS) -c $(CALLB.c) $(INCLUDE)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-	$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/Makefile.rs6000 b/tools/grib1profile/Makefile.rs6000
deleted file mode 100644
index 4d0b02f..0000000
--- a/tools/grib1profile/Makefile.rs6000
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-VERSION = 000170
-FINAL   = FINAL
-#
-#EMOSLIB = -L/home/ma/emos/lib/rs6000/$(VERSION) -lemos.R64.D64.I32
-EMOSLIB = -L/usr/local/lib/metaps/lib/$(VERSION) -lemos.R64.D64.I32
-BIN_DIR = /home/ecmwf/emos_sms/bin/rs6000
-#
-LIBS    = -lXm -lXt -lX11 $(EMOSLIB)
-#CLIBS   = -lftn -lm -lc
-CLIBS   = -lxlf -lxlf90 -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-AR      = ar
-ARFLAGS = rv
-#
-CC      = cc
-CFLAGS  = -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DFORTRAN_NO_UNDERSCORE -DIBM -DRS6000 -D$(FINAL) -g
-FASTCFLAGS = -O -DREAL_BIGGER_THAN_INTEGER -DREAL_8 -DFORTRAN_NO_UNDERSCORE -DIBM -DRS6000 -D$(FINAL) -g
-#
-FC      = xlf
-FFLAGS = -qnoextname -qrealsize=8 -qintsize=4 -qalign=4k -qnosource -g
-VECTFFLAGS  = $(FFLAGS)
-#
-RANLIB  = /bin/ranlib
-CT      = /bin/true
-#
-#
-.SUFFIXES: .o .F .c
-
-.c.o:
-	rm -f $@
-	cc $(CFLAGS) -c $<
-
-.F.o:
-	- cc $(CFLAGS) -P -C -c $<
-	mv $*.i $*.f 
-	$(FC) $(FFLAGS) -qintlog -c $*.f
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-#$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/Makefile.sgimips b/tools/grib1profile/Makefile.sgimips
deleted file mode 100644
index ee843d3..0000000
--- a/tools/grib1profile/Makefile.sgimips
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-VERSION = 000160
-FINAL   = FINAL
-#
-EMOSLIB = /home/ma/emos/lib/sgimips_n32/$(VERSION)/libemos.R32.D64.I32.a
-BIN_DIR = /home/ecmwf/emos_sms/bin/sgimips
-#
-LIBS    = -lXm -lXt -lX11 $(EMOSLIB)
-CLIBS   = -lftn -lm -lc
-GRIB.h  = grib1profile.h
-CALLB.c = callbacks.c
-CALLB.o = $(CALLB.c:.c=.o)
-#
-FFLAGS  = -g
-CFLAGS  = -D$(FINAL) -g
-#
-.F.o:
-	$(FC) $(FFLAGS) $<
-
-all: grib1profile GRIB_profile pseudoprt pgrib
-
-grib1profile: grib1profile.c $(CALLB.o)
-	$(CC) $(CFLAGS) -o grib1profile grib1profile.c $(CALLB.o) $(LIBS) $(CLIBS)
-
-$(CALLB.o): $(CALLB.c) $(GRIB.h)
-
-GRIB_profile: GRIB_profile.c
-	$(CC) $(CFLAGS) -o GRIB_profile GRIB_profile.c $(EMOSLIB) $(CLIBS)
-
-pgrib: grprs4n.o
-	$(CC) $(CFLAGS) -o pgrib jpgrib.c grprs4n.o $(EMOSLIB) $(CLIBS)
-
-grprs4n.o: grprs4n.F
-	$(FC) $(FFLAGS) -c grprs4n.F
-
-pseudoprt:
-	$(CC) $(CFLAGS) -o pseudoprt pseudoprt.c $(EMOSLIB) $(CLIBS)
-
-clean:
-	\rm -f $(CALLB.o) jpgrib.o grprs4n.o grib1profile.o GRIB_profile.o pgrib pseudoprt GRIB_profile grib1profile
-
-#
-install:
-#       cp ${BIN_DIR}/pgrib ${BIN_DIR}/pgrib.old
-#       cp pgrib ${BIN_DIR}/pgrib
-#       cp ${BIN_DIR}/pseudoprt ${BIN_DIR}/pseudoprt.old
-#       cp pseudoprt ${BIN_DIR}/pseudoprt
-#       cp ${BIN_DIR}/GRIB_profile ${BIN_DIR}/GRIB_profile.old
-#       cp GRIB_profile ${BIN_DIR}/GRIB_profile
-#       cp ${BIN_DIR}/grib1profile ${BIN_DIR}/grib1profile.old
-#       cp grib1profile ${BIN_DIR}/grib1profile
-#       cp ${BIN_DIR}/grib1profile_help ${BIN_DIR}/grib1profile_help.old
-#       cp grib1profile_help ${BIN_DIR}/grib1profile_help
diff --git a/tools/grib1profile/callbacks.c b/tools/grib1profile/callbacks.c
deleted file mode 100644
index f6bda56..0000000
--- a/tools/grib1profile/callbacks.c
+++ /dev/null
@@ -1,853 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <Xm/Xm.h>
-#include <Xm/CascadeB.h>
-#include <Xm/DialogS.h>
-#include <Xm/FileSB.h>
-#include <Xm/Form.h>
-#include <Xm/Label.h>
-#include <Xm/List.h>
-#include <Xm/PanedW.h>
-#include <Xm/PushB.h>
-#include <Xm/RowColumn.h>
-#include <Xm/ScrollBar.h>
-#include <Xm/SelectioB.h>
-#ifdef sgimips
-#include <Xm/SgiP.h>
-#endif
-#include <Xm/Text.h>
-#include <Xm/TextF.h>
-#include <Xm/LabelG.h>
-#include <Xm/PushBG.h>
-#include <Xm/SeparatoG.h>
-#include <stdio.h>
- 
-#include "grib1profile_externs.c"
-#include "grib1profile.h"
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#define fortint long
-#endif
-
-#ifdef FINAL
-/*
-// The 'bin' directory for the final utility.
-*/
-#ifdef __uxp__
-static char gDirectory[] = "/home/ma/emos/bin/";
-#elif (defined linux)
-static char gDirectory[] = "/home/ma/emos/bin/linux";
-#elif (defined RS6000)
-static char gDirectory[] = "/home/ma/emos/bin/rs6000";
-#elif (defined hp)
-static char gDirectory[] = "/home/ma/emos/bin/hppa";
-#else
-static char gDirectory[] = "/home/ma/emos/bin/sgimips";
-#endif
-#else
-/*
-// The development directory for the utility.
-*/
-static char gDirectory[] = ".";
-#endif
-
-/*
-// Global names begin with "g"
-// Callback names end with "_cb"
-*/
-
-/*
-// Callback prototypes
-*/
-void file_open_cb ();
-void file_quit_cb ();
-void help_about_cb ();
-void help_about_quit_cb ();
-void help_help_cb ();
-void help_help_quit_cb ();
-void file_select_ok_cb ();
-void filenameCreate_cb (int);
-XtInputCallbackProc profile_cb( FILE * fin, int * fid, XtInputId * id);
-XtInputCallbackProc gentext_cb( int * , int * , XtInputId * );
-
-/*
-// Local prototypes.
-*/
-int giveNextAvailableWidgetSlot(void) ;
-void setInitialFileState( char ** , int );
-void setText(char ** , Widget );
-void setString(char ** , Widget );
-static fortint fileRead(char *, fortint , void * stream);
-void setup( char * filename, int);
-void genText2( char *, long, int);
-void genProfile2( );
-XtWorkProc gentextWork( int * );
-XtWorkProc profileWork( );
-void clearGenProfile(void);
-void clearGenText(int next);
-
-static int gFirst = 0;
-static int gFirstItem = 0;
-static int gInitialise = 0;
-static int gNext = -1;
-static int gFree[MAXW];
-static int gIndex[MAXW];
-char * gSelectedGrib;
-char * gOpenFile = NULL;
-int gOpenFlag;
-int gFullPrintFlag = 0;
-
-#define MAX_IN_PROFILE 1000
-static long gMaxInProfile;
-long gRecNum;
-/*
-// The following will be dynamically increased if necessary
-*/
-static long * gRecordOffsets = NULL;
-static char * gRecordTypes;
-
-extern XtAppContext app_context;
- 
-XmTextPosition gTextCount;
-
-char * gText = NULL;
-char * gBuffer = NULL;
-static char * gTextEmpty = "";
-char * gWorking = "Working...";
-char * gHeading = NULL;
-char * gListLabel =
-  "Number Type    Offset   Length Parameter   Level    Date    Time  Step Expver";
-char * gBlankLabel = " ";
-
-FILE * gProfileFin = NULL;
-FILE * gGentextFin[MAXW];
-
-XtInputId gGentextInput[MAXW];
-XtInputId gProfileInput = NULL;
-XtWorkProcId gGentextWorkId[MAXW];
-XtWorkProcId gProfileWorkId = NULL;
-
-
-void file_open_cb() {
-/*
-// Unleash the file select widget
-*/
-    XtRealizeWidget( file_select);
-    XtManageChild( file_select);
-} 
-
-void file_quit_cb() {
-/*
-// Quit from the application.
-*/
-    exit(0);
-}
-
-void file_select_ok_cb(
-  Widget w,
-  XtPointer client_data,
-  XmFileSelectionBoxCallbackStruct * call_data ) {
-/*
-// Respond to file selection.
-*/
-Widget file_text;
-
-    switch( call_data->reason ) {
-
-      case XmCR_OK:                             /* Open file */
-        if ( gBuffer != NULL ) {
-          XtFree( gBuffer );                     /* Free any existing buffer */
-          gBuffer = NULL;
-        }
-        file_text = XmFileSelectionBoxGetChild( w, XmDIALOG_TEXT);
-        gText = XmTextGetString( file_text );
-        gTextCount = XmTextGetLastPosition( file_text );
-        setInitialFileState( &gText , (int) gTextCount);
-        XtFree(gText);
-        XtUnrealizeWidget( w );
-        break;
-
-      case XmCR_CANCEL:                         /* Don't open file */
-      case XmCR_HELP:
-      case XmCR_NO_MATCH:
-        XtUnrealizeWidget( w );
-        break;
-
-      default:
-        break;
-    }
-    return;
-}
-
-void help_about_cb(
-  Widget w,
-  XtPointer client_data,
-  XmAnyCallbackStruct * call_data) {
-/*
-// Display information about the application.
-*/
-    XtRealizeWidget( help_about_dialog);
-    XtManageChild( help_about_dialog );
-} 
-
-void help_about_quit_cb(
-  Widget w,
-  XtPointer client_data,
-  XmAnyCallbackStruct * call_data0) {
-/*
-// Quit 'help about'.
-*/
-    XtUnmanageChild( help_about_dialog );
-} 
-
-void help_help_cb(
-  Widget w,
-  XtPointer client_data,
-  XmAnyCallbackStruct * call_data) {
-/*
-// Display help for the application from a text file.
-*/
-char * help_news;
-FILE * news_in;
-long nitems;
-/*
-// Open text file and read it.
-*/
-char directory[256];
-
-    strcpy(directory, gDirectory);
-    strcat(directory, "/grib1profile_help");
-    news_in = fopen( directory, "r");
-    if ( news_in == NULL ) {
-      perror("help_help_cb failed to open grib1profile_help");
-      exit(1);
-    }
-
-    help_news = (char *) XtMalloc( HELPNEWSLEN+1 );
-    if ( help_news == NULL ) {
-      perror("help_help_cb failed in XtMalloc");
-      exit(1);
-    }
-
-    nitems = fread( help_news, 1, HELPNEWSLEN, news_in);
-    help_news[nitems] = '\0';
-
-    fclose( news_in );
-/*
-// Fire up the help widget.
-*/
-    setText( &help_news, help_help_text);
-    XtFree( help_news );
-
-    XtManageChild( help_help_dialog );
-} 
-
-void help_help_quit_cb(
-  Widget w,
-  XtPointer client_data,
-  XmAnyCallbackStruct * call_data) {
-/*
-// Quit help screen.
-*/
-    XtUnmanageChild( help_help_dialog );
-} 
-
-void setText(char ** text, Widget w) {
-/*
-// Put text into a text widget.
-*/
-Arg arg[2];
-Cardinal ac;
-
-    if( w == NULL ) return;
-    ac = 0;
-    XtSetArg( arg[ac], XmNvalue, *text); ac++;
-    XtSetValues( w, arg, ac);
-    XmUpdateDisplay( w );
- 
-    return;
-}
-
-void setString(char ** text, Widget w) {
-/*
-// Put string into a label widget.
-*/
-XmString labeltext;
-Arg arg[2];
-Cardinal ac;
-
-    if( w == NULL ) return;
-
-    labeltext =
-      XmStringCreateLtoR( *text, (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
-    ac = 0;
-    XtSetArg( arg[ac], XmNlabelString, labeltext); ac++;
-    XtSetValues( w, arg, ac);
-    XmStringFree( labeltext );
-    XmUpdateDisplay( w );
- 
-    return;
-}
-
-void setInitialFileState( char ** filename, int num_chars ) {
-/*
-// Prepares widgets after a new file has been 'selected'.
-*/
-/*
-// Clear the list widget showing the one-liners for the individual products.
-*/
-    XmListDeleteAllItems( list );
-/*
-// Fill in information for the new file.
-*/
-    setup( *filename, num_chars );
-    clearGenProfile();
-    genProfile2( );                           /* Generate the one-liners */
-    gText = (char *) XtMalloc( strlen(gOpenFile)+1 );
-    strcpy( gText, gOpenFile );
-    gOpenFlag = 1;
-
-    return;
-}
-
-int giveNextAvailableWidgetSlot(void) {
-int loop;
-/*
-// First time only, set slots to 'unused'
-*/
-    if( gInitialise == 0 ) {
-      for( loop = 0; loop < MAXW ; loop++ ) {
-        gFree[loop] = 0;
-        gIndex[loop] = loop;
-      }
-      gInitialise = 1;
-    }
-
-    for( loop = 0; loop < MAXW ; loop++ ) {
-      if( gFree[loop] == 0 ) {
-        gFree[loop] = 1;
-        return (int) loop;
-      }
-    }
-/*
-// Fall through if all slots are full: use slot 0
-*/
-    XtDestroyWidget( pgrib1Listing[0] );
-    return (int) 0;
-}
-
-XtInputCallbackProc profile_cb( FILE * fin, int * fid, XtInputId * id) {
-/*
-// Fire off the work procedure to fill in the profile of one-liners
-// for the selected file.
-*/
-    clearGenProfile();
-    gProfileWorkId =
-      XtAppAddWorkProc( app_context, (XtWorkProc) profileWork, NULL);
-
-    return 0; 
-}
- 
-XtWorkProc profileWork( void ) {
-/*
-// The work procedure to build a profile of one-liners for a selected file.
-*/
-char buffer[GETLEN];
-XmString item;
-char * next;
-long loop = 0;
-char * pfilename = gOpenFile;
-/*
-//int itemCount;
-//Arg al[64];
-//register int ac = 0;
-*/
-
-/*
-// First time through only, allocate space and set headings over list.
-*/
-    if ( gFirst == 0 ) {
-      if( gRecordOffsets == NULL ) {
-        gMaxInProfile = MAX_IN_PROFILE;
-        gRecordOffsets =
-              (long *) XtMalloc( (size_t) gMaxInProfile * sizeof(long));
-        gRecordTypes =
-              (char *) XtMalloc( (size_t) gMaxInProfile * sizeof(char *));
-      }
-      gRecNum = 0;
-      gFirst = 1;
-      setString( &gListLabel, scrolled_list_label);
-    }
-/*
-// Not end of input, so add upto 500 lines a time to profile list.
-*/
-    if ( gProfileFin != NULL ) {
-      while( (loop < 500) &&
-             ((next = fgets(buffer, sizeof(buffer), gProfileFin)) != NULL) &&
-             !feof(gProfileFin) ) {
-        loop++;
-        setString( &gWorking, current_filename);
-/*
-// Store type and offset for each product in the file.
-*/
-        sscanf( &buffer[6], "%4s%10d",
-                    &gRecordTypes[gRecNum*4], &gRecordOffsets[gRecNum]);
-        gRecNum++;
-        if( gRecNum == gMaxInProfile ) {
-          gMaxInProfile = gMaxInProfile * 2;
-          gRecordOffsets =
-            (long *) XtRealloc((char *) gRecordOffsets,
-            (size_t) gMaxInProfile * sizeof(long));
-          gRecordTypes =
-            (char *) XtRealloc(gRecordTypes, (size_t) gMaxInProfile * 4);
-        }
-/*
-// Add product description to list.
-*/
-        buffer[strlen(buffer)-1] = '\0';
-        item = XmStringCreateSimple( buffer);
-        XmListAddItem( list, item, (int) 0);
-        if ( gRecNum == 1) XmListSelectItem( list, item, False);
-        XmStringFree( item );
-      }
-/*
-// Decode the first product in the list.
-*/
-      if ( gFirstItem == 0 ) {
-        gFirstItem = 1;
-        XmListSelectPos(list,gFirstItem,TRUE);
-      }
-    }
-/*
-// Check for end of input.
-*/
-    if( (gProfileFin == NULL) || ( (next == NULL) && feof(gProfileFin) ) ) {
-      clearGenProfile();
-      gFirst = 0;
-      gFirstItem = 0;
-
-      setString( &pfilename, current_filename);
-      return (XtWorkProc) True;
-    }
-    else
-      return (XtWorkProc) False;
-}
-
-void setup( char * filename, int num_chars) {
-/*
-// Inintialise for a new 'selected' file.
-*/
-    if( gOpenFile == NULL )
-      gOpenFile = (char *) XtMalloc(num_chars+1);
-    else 
-      gOpenFile = (char *) XtRealloc(gOpenFile,(num_chars+1));
-
-    if( gOpenFile == NULL ) {
-      perror("XtMalloc/XtRealloc failed for gOpenFile");
-      exit(1);
-    }
-    strcpy( gOpenFile, filename );
-    gOpenFile[num_chars] = '\0';
-    gRecNum = 0;
-    gOpenFlag = 1;
-  
-    return;
-}
-
-static fortint fileRead(char * buff, fortint leng, void * file) {
-/*  
-//  Returns the number of bytes read.
-//  On EOF, returns negative value for number of bytes read .
-//
-//  buff = buffer to fill,
-//  leng = size of buff in bytes,
-//  file = FILE *.
-*/
-fortint nbytes;
-
-    nbytes = (fortint) fread( buff, 1, leng, (FILE *) file);
-/*
-// If EOF, return negative number of bytes read.
-*/
-    if ( feof((FILE *) file ) ) {
-      clearerr( (FILE *) file );
-      return (-nbytes);
-    }
-
-    return nbytes;
-}
-
-void genProfile2( ) {
-/*
-// Starts a process to generate the file profile.
-*/
-static char command[512];
-/*
-// Construct the process command.
-*/
-    strcpy(command, gDirectory);
-    strcat(command, "/GRIB_profile ");
-    strcat(command, gOpenFile );
-/*
-// Start process and a work procedure to receive its output down a pipe.
-*/
-    if ( gProfileFin != NULL ) pclose( gProfileFin );
-    gProfileFin = popen( command, "r");
-    gProfileInput =
-      XtAppAddInput( app_context, fileno(gProfileFin),
-                     (XtPointer)XtInputReadMask,
-                     (XtInputCallbackProc)profile_cb,
-                     (XtPointer)gProfileFin);
-
-}
-
-void genText2( char * type, long offset, int next) {
-/*
-// Prepare decoded text for a selected product.
-*/
-static char command[512];
-char digits[20];
-/*
-// Empty the text widget.
-*/
-    clearGenText(next);
-/*
-// Starts a process to generate the decoded product.
-*/
-    strcpy(command, gDirectory);
-    strcat(command, "/pgrib ");
-    strcat(command, gOpenFile );
-
-    sprintf(digits, " %10d", offset);
-    digits[11] = '\0';
-    strcat( command, digits );
-
-    if( gHeading == NULL ) {
-      gHeading = (char *) XtMalloc(256);
-      if( gHeading == NULL ) {
-        perror("XtMalloc failed for gHeading");
-        exit(1);
-      }
-    }
-    strcpy(gHeading,gOpenFile);
-    strcat(gHeading,"\n\n");
-    strcat(gHeading,gListLabel);
-    strcat(gHeading,"\n");
-    strcat(gHeading,gSelectedGrib);
-
-/*
-// Start process and a work procedure to receive its output down a pipe.
-*/
-    if ( gGentextFin[next] != NULL ) pclose( gGentextFin[next] );
-    gGentextFin[next] = popen( command, "r");
-    gGentextInput[next] =
-      XtAppAddInput( app_context, fileno(gGentextFin[next]),
-                     (XtPointer)XtInputReadMask,
-                     (XtInputCallbackProc)gentext_cb,
-                     (int*) &gIndex[next]  );
-}
-
-XtInputCallbackProc gentext_cb(
-  int * next,
-  int * source,
-  XtInputId * id ) {
-/*
-// Fire off the work procedure to fill text widget with the decoded product.
-*/
-    gGentextWorkId[*next] =
-      XtAppAddWorkProc( app_context, (XtWorkProc) gentextWork, next );
-
-    return 0; 
-}
-
-XtWorkProc gentextWork( int * nextWidget ) {
-/*
-// Work procedure to fill text widget with the decoded product.
-*/
-char buffer[READLEN+1];
-XmTextPosition lastpos;
-long loop = 0;
-long count;
-int next = *nextWidget;
-/*
-// Not end of input, so add lines to end of text.
-*/
-    loop = 0;
-    while( (loop < 1000) &&
-           (gGentextFin[next] != NULL) &&
-           (count = fread( buffer, 1, READLEN, gGentextFin[next] ) ) != 0 ) {
-      loop++;
-      buffer[count] = '\0';
-      if( fileListing[next] != NULL ) {
-        lastpos = XmTextGetLastPosition( fileListing[next] );
-        XmTextInsert( fileListing[next], lastpos, buffer);
-        XmTextSetInsertionPosition( fileListing[next], (XmTextPosition) 0);
-      }
-    }
-/*
-// Check for end of input.
-*/
-    if( (gGentextFin[next] == NULL ) || (feof(gGentextFin[next])) ) {
-      clearGenText(next);
-      setString(&gHeading,filenameLabel[next]);
-      {
-       char * string = XmTextGetString(fileListing[next]);
-       long last = XmTextGetLastPosition(fileListing[next]);
-       long loop, start = last - 5;
-       char * p;
-
-       for( loop = 0 ; loop < last; loop++ ) {
-         if( strncmp("max =",&string[start],5) == 0 ) {
-           break;
-         }
-         start--;
-       }
-       string[last-1] = '\0';
-       p = &string[start];
-       setString(&p,maxminLabel[next]);
-
-       XtFree(string);
-      }
-      return (XtWorkProc) True;
-    }
-    else {
-      return (XtWorkProc) False;
-    }
-}
-
-void list_select_cb(
-  Widget w,
-  XtPointer client_data,
-  XmListCallbackStruct * call_data) {
-/*
-// Handle selection of a product by clicking on the list of products.
-*/
-long current;
-
-    switch( call_data->reason ) {
-      case XmCR_SINGLE_SELECT:
-        if ( gOpenFlag == 0 ) return;
-/*
-// Get selected item from list.
-*/
-        XmListSelectItem( list, call_data->item, False);
-        current = (long) call_data->item_position - 1;
-
-        XmStringGetLtoR(call_data->item,
-                        (XmStringCharSet)XmFONTLIST_DEFAULT_TAG,
-                        &gSelectedGrib);
-
-        if ( current < 0 ) return;
-/*
-// Generate decoded text for the product.
-*/
-        gNext = giveNextAvailableWidgetSlot();
-        filenameCreate_cb(gNext);
-        setText( &gTextEmpty, fileListing[gNext]);
-        clearGenText(gNext);
-        genText2( &gRecordTypes[current*4], gRecordOffsets[current], gNext);
-        break;
-
-        default:
-            break;
-    }
-}
-
-void clearGenProfile(void) {
-/*
-// Clean up after work procedure generating the file profile.
-*/
-    if ( gProfileInput != NULL ) XtRemoveInput( gProfileInput );
-    gProfileInput = NULL;
-
-    if ( gProfileWorkId != NULL ) XtRemoveWorkProc( gProfileWorkId );
-    gProfileWorkId = NULL;
-
-}
-
-void clearGenText(int next) {
-/*
-// Clean up after work procedure generating the text for a decoded product.
-*/
-  if ( gGentextInput[next] != NULL ) XtRemoveInput( gGentextInput[next] );
-  gGentextInput[next] = NULL;
-
-  if ( gGentextWorkId[next] != NULL ) XtRemoveWorkProc( gGentextWorkId[next] );
-  gGentextWorkId[next] = NULL;
-
-}
-
-void filenameCreate_cb (int next) {
-char digits[20];
-Arg arg[2];
-Cardinal ac;
-char t[5];
-int n, o, len, p, l;
-
-    create_pgrib1Listing (grib1profile, next);
-
-    sscanf(gSelectedGrib,"%d %s %d %d %d %d", &n, t, &o, &len, &p, &l);
-
-    if( strcmp(t,"GRIB") == 0 )
-      sprintf(digits, "%d/%d", p, l);
-    else
-      sprintf(digits,"%s",t);
-
-    ac = 0;
-    XtSetArg( arg[ac], XmNiconName, digits); ac++;
-    XtSetValues( pgrib1Listing[next], arg, ac);
-
-    XtPopup(pgrib1Listing[next],XtGrabNone);
-}
-
-XtCallbackProc textQuit_cb (
-  Widget w,
-  int * next,
-  XmPushButtonCallbackStruct call_data) {
-
-    clearGenText(*next);
-    if( gGentextWorkId[*next] != NULL ) XtRemoveWorkProc(gGentextWorkId[*next]);
-    gGentextWorkId[*next] = NULL;
-    gGentextFin[*next] = NULL;
-    fileListing[*next] = NULL;
-    XtDestroyWidget( pgrib1Listing[*next]);
-    gFree[*next] = 0;
-
-    return (XtCallbackProc) 0;
-}
-
-static Widget pgrib1Listing_dialog[MAXW];
-static Widget pgrib1Listing[MAXW];
-static Widget maxminLabel[MAXW];
-static Widget filenameLabel[MAXW];
-static Widget fileListing[MAXW];
-static Widget textQuit[MAXW];
-static Widget scrolledText1[MAXW];
-
-
-void create_pgrib1Listing (Widget parent, int next)
-{
-Widget children[5];            /* Children to manage */
-Arg al[64];                    /* Arg List */
-register int ac = 0;           /* Arg Count */
-XmString xmstrings[16];        /* temporary storage for XmStrings */
-
-    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
-    XtSetArg(al[ac], XmNminWidth, 400); ac++;
-    XtSetArg(al[ac], XmNminHeight, 400); ac++;
-    XtSetArg(al[ac], XmNinput, FALSE); ac++;
-    XtSetArg(al[ac], XmNbaseWidth, 600); ac++;
-    XtSetArg(al[ac], XmNbaseHeight, 400); ac++;
-
-
-    pgrib1Listing[next] = XtCreatePopupShell (
-      "pgrib1Listing",
-      topLevelShellWidgetClass,
-      parent,
-      al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNautoUnmanage, TRUE); ac++;
-    XtSetArg(al[ac], XmNinitialResourcesPersistent, FALSE); ac++;
-    pgrib1Listing_dialog[next] =
-      XmCreateForm ( pgrib1Listing[next], "pgrib1Listing_dialog", al, ac );
-
-    ac = 0;
-    xmstrings[0] =
-      XmStringCreateLtoR("Working ...",
-                         (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    XtSetArg(al[ac], XmNrecomputeSize, TRUE); ac++;
-    filenameLabel[next] =
-      XmCreateLabel ( pgrib1Listing_dialog[next], "filenameLabel", al, ac );
-
-    ac = 0;
-    xmstrings[0] =
-      XmStringCreateLtoR("",
-                         (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    XtSetArg(al[ac], XmNrecomputeSize, TRUE); ac++;
-    maxminLabel[next] =
-      XmCreateLabel ( pgrib1Listing_dialog[next], "maxminLabel", al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNeditable, FALSE); ac++;
-    XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
-    fileListing[next] =
-      XmCreateScrolledText ( pgrib1Listing_dialog[next], "fileListing", al, ac);
-
-    ac = 0;
-    scrolledText1[next] = XtParent ( fileListing[next] );
-
-    ac = 0;
-    xmstrings[0] =
-      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    textQuit[next] =
-      XmCreatePushButton ( pgrib1Listing_dialog[next], "textQuit", al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetValues ( textQuit[next],al, ac );
-
-    ac = 0;
-/*
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNtopWidget, scrolledText1[next]); ac++;
-*/
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNleftOffset,15); ac++;
-    XtSetArg(al[ac], XmNleftWidget, textQuit[next]); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 10); ac++;
-    XtSetValues ( maxminLabel[next],al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( filenameLabel[next],al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNtopWidget, filenameLabel[next]); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 35); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( scrolledText1[next],al, ac );
-
-    ac = 0;
-    XtManageChild(pgrib1Listing_dialog[next]);
-    XtAddCallback( textQuit[next],
-                   XmNactivateCallback ,
-                   (XtCallbackProc) textQuit_cb,
-                   (int*) &gIndex[next] );
-    children[ac++] = textQuit[next];
-    children[ac++] = maxminLabel[next];
-    children[ac++] = filenameLabel[next];
-    children[ac++] = scrolledText1[next];
-    XtManageChildren(children, ac);
-
-    ac = 0;
-    XtManageChild(scrolledText1[next]);
-    children[ac++] = fileListing[next];
-    XtManageChildren(children, ac);
-
-    ac = 0;
-
-}
-
diff --git a/tools/grib1profile/fortint.h b/tools/grib1profile/fortint.h
deleted file mode 100644
index c79ce46..0000000
--- a/tools/grib1profile/fortint.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef FORTINT_H
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#define JPointer int *
-#else
-#if defined hpR64 || defined hpiaR64
-#define fortint long long
-#define JPointer long long *
-#else
-#define fortint long
-#define JPointer long *
-#endif
-#endif
-
-#ifdef REAL_8
-#define fortreal double
-#else
-#define fortreal float
-#endif
-
-#define fortdouble double
-
-#endif /* End of FORTINT_H */
diff --git a/tools/grib1profile/gdecode.h b/tools/grib1profile/gdecode.h
deleted file mode 100644
index 901af1a..0000000
--- a/tools/grib1profile/gdecode.h
+++ /dev/null
@@ -1,422 +0,0 @@
-#ifndef GDECODE_H
-#define GDECODE_H
-#include <stdio.h>
-#include <stdlib.h>
-#include "fortint.h"
-
-#include "gdecodeStruct.h"
-
-#include "sencode1.h"
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define IGGLAT  igglat
-#define GBYTE   gbyte
-#define GDECODE gdecode
-#define IGLNGTH iglngth
-#define IGTABLE igtable
-#define IGCENTR igcentr
-#define IGPARAM igparam
-#define IGLEVEL iglevel
-#define IGLEVL1 iglevl1
-#define IGLEVL2 iglevl2
-#define IGDATE  igdate
-#define IGTIME  igtime
-#define IGSTEP  igstep
-#define IGSTEP1 igstep1
-#define IGSTEP2 igstep2
-#define IGDEFIN igdefin
-#define IGCLASS igclass
-#define IGTYPE  igtype
-#define IGSTREM igstrem
-#define IGEXPVR igexpvr
-#define IGNUMPV ignumpv
-#define GPV     gpv
-#define GPL     gpl
-#define IGREPRS igreprs
-#define IGNI    igni
-#define IGNJ    ignj
-#define RGNWLAT rgnwlat
-#define RGNWLON rgnwlon
-#define IGRESCO igresco
-#define RGSELAT rgselat
-#define RGSELON rgselon
-#define RGDI    rgdi
-#define RGDJ    rgdj
-#define IGGAUSS iggauss
-#define IGSCANM igscanm
-#define IGJ     igj
-#define IGK     igk
-#define IGM     igm
-#define IGREPMO igrepmo
-#define RGIP    rgip
-#define IGTJ    igtj
-#define IGTK    igtk
-#define IGTM    igtm
-#define RGLATRP rglatrp
-#define RGLONRP rglonrp
-#define RGROTAT rgrotat
-#define RGLATSP rglatsp
-#define RGLONSP rglonsp
-#define RGSFACT rgsfact
-#define RGREFVL rgrefvl
-#define IGBTSPV igbtspv
-#define RGDSCAL rgdscal
-#define IGUNUSD igunusd
-#define IGNVALU ignvalu
-#define GVALUES gvalues
-#define GVINIT  gvinit
-#define GVECTOR gvector
-#define GVEND   gvend
-#define IGLEVTY iglevty
-#define RGLEVTY rglevty
-#define IGNUMAV ignumav
-#define RGNUMAV rgnumav
-#define IGNUMMS ignumms
-#define RGNUMMS rgnumms
-#define IGSUBID igsubid
-#define RGSUBID rgsubid
-#else
-#define IGGLAT  igglat_
-#define GBYTE   gbyte_
-#define GDECODE gdecode_
-#define IGLNGTH iglngth_
-#define IGTABLE igtable_
-#define IGCENTR igcentr_
-#define IGPARAM igparam_
-#define IGLEVEL iglevel
-#define IGLEVL1 iglevl1
-#define IGLEVL2 iglevl2
-#define IGDATE  igdate_
-#define IGTIME  igtime_
-#define IGSTEP  igstep_
-#define IGSTEP1 igstep1_
-#define IGSTEP2 igstep2_
-#define IGDEFIN igdefin_
-#define IGCLASS igclass_
-#define IGTYPE  igtype_
-#define IGSTREM igstrem_
-#define IGEXPVR igexpvr_
-#define IGNUMPV ignumpv_
-#define GPV     gpv_
-#define GPL     gpl_
-#define IGREPRS igreprs_
-#define IGNI    igni_
-#define IGNJ    ignj_
-#define RGNWLAT rgnwlat_
-#define RGNWLON rgnwlon_
-#define IGRESCO igresco_
-#define RGSELAT rgselat_
-#define RGSELON rgselon_
-#define RGDI    rgdi_
-#define RGDJ    rgdj_
-#define IGGAUSS iggauss_
-#define IGSCANM igscanm_
-#define IGJ     igj_
-#define IGK     igk_
-#define IGM     igm_
-#define IGREPMO igrepmo_
-#define RGIP    rgip_
-#define IGTJ    igtj_
-#define IGTK    igtk_
-#define IGTM    igtm_
-#define RGLATRP rglatrp_
-#define RGLONRP rglonrp_
-#define RGROTAT rgrotat_
-#define RGLATSP rglatsp_
-#define RGLONSP rglonsp_
-#define RGSFACT rgsfact_
-#define RGREFVL rgrefvl_
-#define IGBTSPV igbtspv_
-#define RGDSCAL rgdscal_
-#define IGUNUSD igunusd_
-#define IGNVALU ignvalu_
-#define GVALUES gvalues_
-#define GVINIT  gvinit_
-#define GVECTOR gvector_
-#define GVEND   gvend_
-#define IGLEVTY iglevty_
-#define RGLEVTY rglevty_
-#define IGNUMAV ignumav_
-#define RGNUMAV rgnumav_
-#define IGNUMMS ignumms_
-#define RGNUMMS rgnumms_
-#define IGSUBID igsubid_
-#define RGSUBID rgsubid_
-#endif
-
-#define MOVE1BYTE(p,n)  ( *(p)     = ((*(n)>> 0) & 0xFF) ) 
-#define MOVE2BYTES(p,n) ( *(p)     = ((*(n)>> 8) & 0xFF) ) , \
-                        ( *((p)+1) = ((*(n)>> 0) & 0xFF) )
-#define MOVE3BYTES(p,n) ( *(p)     = ((*(n)>>16) & 0xFF) ) , \
-                        ( *((p)+1) = ((*(n)>> 8) & 0xFF) ) , \
-                        ( *((p)+2) = ((*(n)>> 0) & 0xFF) )
-#define MOVE4BYTES(p,n) ( *(p)     = ((*(n)>>24) & 0xFF) ) , \
-                        ( *((p)+1) = ((*(n)>>16) & 0xFF) ) , \
-                        ( *((p)+2) = ((*(n)>> 8) & 0xFF) ) , \
-                        ( *((p)+3) = ((*(n)>> 0) & 0xFF) )
-
-#define MOD(a,b) ((a) - ((a)/(b))*(b))
-#define MULTIPLE(a,b) ( MOD(a,b) == 0 )
-
-#define ONEBYTEINT(a)   (fortint) ( *(a) )
-#define TWOBYTEINT(a)   (fortint) ( (*(a))<<8 | (*((a)+1))<<0 )
-#define THREEBYTEINT(a) (fortint) (TWOBYTEINT((a))<<8 | (*((a)+2))<<0 )
-#define FOURBYTEINT(a)  (fortint) (THREEBYTEINT((a))<<8 | (*((a)+3))<<0 )
-/*
-// Section 0
-*/
-#define g0_length(a)  THREEBYTEINT((a->g0)->totalGRIBlength)
-#define g0_edition(a) ONEBYTEINT((a->g0)->editionNumber)
-/*
-// Section 1
-*/
-#define g1_length(a)      THREEBYTEINT((a->g1)->sectionLength)
-#define g1_table(a)       ONEBYTEINT((a->g1)->tableVersionNumber)
-#define g1_centre(a)      ONEBYTEINT((a->g1)->originatingCentre)
-#define g1_process(a)     ONEBYTEINT((a->g1)->generatingProcessId)
-#define g1_grid(a)        ONEBYTEINT((a->g1)->gridDefinition)
-#define g1_flag(a)        ONEBYTEINT((a->g1)->section2and3PresentFlag)
-#define g1_parameter(a)   ONEBYTEINT((a->g1)->parameter)
-#define g1_typeOfLevel(a) ONEBYTEINT((a->g1)->typeOfLevel)
-#define g1_level1(a)      ONEBYTEINT((a->g1)->level1)
-#define g1_level2(a)      ONEBYTEINT((a->g1)->level2)
-#define g1_year(a)        ONEBYTEINT((a->g1)->year)
-#define g1_month(a)       ONEBYTEINT((a->g1)->month)
-#define g1_day(a)         ONEBYTEINT((a->g1)->day)
-#define g1_hour(a)        ONEBYTEINT((a->g1)->hour)
-#define g1_minute(a)      ONEBYTEINT((a->g1)->minute)
-#define g1_timeunit(a)    ONEBYTEINT((a->g1)->unitOfTimeRange)
-#define g1_P1(a)          ONEBYTEINT((a->g1)->P1)
-#define g1_P2(a)          ONEBYTEINT((a->g1)->P2)
-#define g1_timerange(a)   ONEBYTEINT((a->g1)->timeRangeIndicator)
-#define g1_number(a)      TWOBYTEINT((a->g1)->numberInAverage)
-#define g1_missing(a)     ONEBYTEINT((a->g1)->numberMissing)
-#define g1_century(a)     ONEBYTEINT((a->g1)->century)
-#define g1_subcentre(a)   ONEBYTEINT((a->g1)->subCentreId)
-#define g1_scale(a)       TWOBYTEINT((a->g1)->unitsDecimalScaleFactor)
-#define g1_definition(a)  ONEBYTEINT((a->g1)->local.mars.definition)
-#define g1_class(a)       ONEBYTEINT((a->g1)->local.mars.ecmwfClass)
-#define g1_type(a)        ONEBYTEINT((a->g1)->local.mars.type)
-#define g1_stream(a)      TWOBYTEINT((a->g1)->local.mars.stream)
-#define g1_expver(a)      FOURBYTEINT((a->g1)->local.mars.experimentVersionNumber)
-
-#define centreUsingECMWFLocalDefinition(a) \
-            ((g1_subcentre(a)==98)&&(g1_length(a)>=40))
-
-#define ecmwfLocalDefinitionPresent(a) ((g1_centre(a)==98)&&(g1_length(a)>=40))
-
-#define ecmwfLocalDefinition1Present(a) \
-                    ( ecmwfLocalDefinitionPresent(a) && (g1_definition(a)==1) )
-#define ecmwfLocalDefinition2Present(a) \
-                    ( ecmwfLocalDefinitionPresent(a) && (g1_definition(a)==2) )
-
-#define g1_1_number(a) ONEBYTEINT((a->g1)->local.contents.def1.number)
-#define g1_1_total(a)  ONEBYTEINT((a->g1)->local.contents.def1.total)
-
-#define g1_2_number(a)  ONEBYTEINT((a->g1)->local.contents.def2.number)
-#define g1_2_total(a)   ONEBYTEINT((a->g1)->local.contents.def2.total)
-#define g1_2_method(a)  ONEBYTEINT((a->g1)->local.contents.def2.method)
-#define g1_2_start(a)   TWOBYTEINT((a->g1)->local.contents.def2.startTimestep)
-#define g1_2_end(a)     TWOBYTEINT((a->g1)->local.contents.def2.endTimestep)
-#define g1_2_control(a) ONEBYTEINT((a->g1)->local.contents.def2.controlForecastCluster)
-#define g1_2_operational(a)   ONEBYTEINT((a->g1)->local.contents.def2.operationalForecastCluster)
-#define g1_2_count(a)   ONEBYTEINT((a->g1)->local.contents.def2.numberInCluster)
-#define g1_2_domainN(a) THREEBYTEINT((a->g1)->local.contents.def2.domainNorthLatitude)
-#define g1_2_domainW(a) THREEBYTEINT((a->g1)->local.contents.def2.domainWestLongitude)
-#define g1_2_domainS(a) THREEBYTEINT((a->g1)->local.contents.def2.domainSouthLatitude)
-#define g1_2_domainE(a) THREEBYTEINT((a->g1)->local.contents.def2.domainEastLongitude)
-/*
-// Section 2
-*/
-#define g2_length(a)           THREEBYTEINT((a->g2)->sectionLength)
-#define g2_NV(a)               ONEBYTEINT((a->g2)->NV)
-#define g2_PV_PL(a)            ONEBYTEINT((a->g2)->PV_PL)
-#define g2_datatype(a)         ONEBYTEINT((a->g2)->dataRepresentationType)
-#define g2_ni(a)               TWOBYTEINT((a->g2)->grid.latlon.numberOfPointsAlongParallel)
-#define g2_nj(a)               TWOBYTEINT((a->g2)->grid.latlon.numberOfPointsAlongMeridian)
-#define g2_firstLat(a)         THREEBYTEINT((a->g2)->grid.latlon.latitudeOfFirstPoint)
-#define g2_firstLon(a)         THREEBYTEINT((a->g2)->grid.latlon.longitudeOfFirstPoint)
-#define g2_lastLat(a)          THREEBYTEINT((a->g2)->grid.latlon.latitudeOfLastPoint)
-#define g2_lastLon(a)          THREEBYTEINT((a->g2)->grid.latlon.longitudeOfLastPoint)
-#define g2_resAndComp(a)       ONEBYTEINT((a->g2)->grid.latlon.resolutionAndComponentsFlag)
-#define g2_scan(a)             ONEBYTEINT((a->g2)->grid.latlon.scanningMode)
-#define g2_di(a)               TWOBYTEINT((a->g2)->grid.latlon.iDirectionIncrement)
-#define g2_dj(a)               TWOBYTEINT((a->g2)->grid.latlon.jDirectionIncrement)
-#define g2_gaussNumber(a)      TWOBYTEINT((a->g2)->grid.gaussian.numberOfParallelsBetweenPoleAndEquator)
-#define g2_latSouthPole(a)     THREEBYTEINT((a->g2)->grid.latlon.latitudeOfSouthPole)
-#define g2_lonSouthPole(a)     THREEBYTEINT((a->g2)->grid.latlon.longitudeOfSouthPole)
-#define g2_rotOrStretch(a)     FOURBYTEINT((a->g2)->grid.latlon.angleOfRotationOrStretchingFactor)
-#define g2_latStretching(a)    THREEBYTEINT((a->g2)->grid.latlon.latitudeOfPoleOfStretching)
-#define g2_lonStretching(a)    THREEBYTEINT((a->g2)->grid.latlon.longitudeOfPoleOfStretching)
-#define g2_stretchingFactor(a) FOURBYTEINT((a->g2)->grid.latlon.stretchingFactor)
-#define g2_J(a)                TWOBYTEINT((a->g2)->grid.spectral.J)
-#define g2_K(a)                TWOBYTEINT((a->g2)->grid.spectral.K)
-#define g2_M(a)                TWOBYTEINT((a->g2)->grid.spectral.M)
-#define g2_repmode(a)          ONEBYTEINT((a->g2)->grid.spectral.representationMode)
-
-#define basicSpectralField(a)               (g2_datatype(a)==50)
-#define rotatedSpectralField(a)             (g2_datatype(a)==60)
-#define stretchedSpectralField(a)           (g2_datatype(a)==70)
-#define rotatedAndStretchedSpectralField(a) (g2_datatype(a)==80)
-#define anySpectralField(a) (basicSpectralField(a)||\
-                             rotatedSpectralField(a)||\
-                             stretchedSpectralField(a)||\
-                             rotatedAndStretchedSpectralField(a))
-
-#define basicGaussianGrid(a)               (g2_datatype(a)== 4)
-#define rotatedGaussianGrid(a)             (g2_datatype(a)==14)
-#define stretchedGaussianGrid(a)           (g2_datatype(a)==24)
-#define rotatedAndStretchedGaussianGrid(a) (g2_datatype(a)==34)
-#define anyGaussianGrid(a) (basicGaussianGrid(a)||\
-                            rotatedGaussianGrid(a)||\
-                            stretchedGaussianGrid(a)||\
-                            rotatedAndStretchedGaussianGrid(a))
-
-#define basicLatLonGrid(a)               (g2_datatype(a)== 0)
-#define rotatedLatLonGrid(a)             (g2_datatype(a)==10)
-#define stretchedLatLonGrid(a)           (g2_datatype(a)==20)
-#define rotatedAndStretchedLatLonGrid(a) (g2_datatype(a)==30)
-#define anyLatLonGrid(a) (basicLatLonGrid(a)||\
-                          rotatedLatLonGrid(a)||\
-                          stretchedLatLonGrid(a)||\
-                          rotatedAndStretchedLatLonGrid(a))
-
-#define generalLatLonGrid(a) (anyGaussianGrid(a)||anyLatLonGrid(a))
-#define generalRotatedGrid(a) (rotatedLatLonGrid(a)||\
-                               rotatedAndStretchedLatLonGrid(a)||\
-                               rotatedGaussianGrid(a)||\
-                               rotatedAndStretchedGaussianGrid(a)||\
-                               rotatedSpectralField(a)||\
-                               rotatedAndStretchedSpectralField(a))
-#define generalStretchedGrid(a) (stretchedLatLonGrid(a)||\
-                                 rotatedAndStretchedLatLonGrid(a)||\
-                                 stretchedGaussianGrid(a)||\
-                                 rotatedAndStretchedSpectralField(a)||\
-                                 stretchedSpectralField(a)||\
-                                 rotatedAndStretchedGaussianGrid(a))
-#define generalStretchedAndRotatedGrid(a) (rotatedAndStretchedLatLonGrid(a)||\
-                                           rotatedAndStretchedGaussianGrid(a))
-#define directionIncrementsGiven(a) ((g2_resAndComp(a)&0x80)&&(g2_di(a)!=0xffff))
-/*
-// Section 3
-*/
-#define g3_length(a)             THREEBYTEINT((a->g3)->sectionLength)
-#define g3_table(a)              ONEEBYTEINT((a->g3)->tableReference)
-#define primaryBitmapPresent(a)  ( g1_flag(a) & 0x40 )
-/*
-// Section 4
-*/
-#define g4_length(a)        THREEBYTEINT((a->g4)->sectionLength)
-#define g4_flag(a)          ONEBYTEINT((a->g4)->flag)
-#define g4_scale(a)         TWOBYTEINT((a->g4)->scaleFactor)
-#define g4_reference(a)     FOURBYTEINT((a->g4)->referenceValue)
-#define g4_bits(a)          ONEBYTEINT((a->g4)->numberOfBitsPerValue)
-#define g4_n(a)             TWOBYTEINT((a->g4)->data.complexSpectral.N)
-#define g4_ip(a)            TWOBYTEINT((a->g4)->data.complexSpectral.IP)
-#define g4_j(a)             ONEBYTEINT((a->g4)->data.complexSpectral.J)
-#define g4_k(a)             ONEBYTEINT((a->g4)->data.complexSpectral.K)
-#define g4_m(a)             ONEBYTEINT((a->g4)->data.complexSpectral.M)
-#define g4_n1(a)            TWOBYTEINT((a->g4)->data.complexGrid.n1)
-#define g4_extendedFlags(a) ONEBYTEINT((a->g4)->data.complexGrid.extendedFlags)
-#define g4_n2(a)            TWOBYTEINT((a->g4)->data.complexGrid.n2)
-#define g4_p1(a)            TWOBYTEINT((a->g4)->data.complexGrid.p1)
-#define g4_p2(a)            TWOBYTEINT((a->g4)->data.complexGrid.p2)
-
-#define gridPoint(a)                      ( (g4_flag(a)&0x80) == 0 )
-#define simplePacking(a)                  ( (g4_flag(a)&0x40) == 0 )
-#define floatingPoint(a)                  ( (g4_flag(a)&0x20) == 0 )
-#define noAdditionalFlags(a)              ( (g4_flag(a)&0x10) == 0 )
-#define matrixAtGridPoint(a)              (g4_extendedFlags(a)&0x40)
-#define secondaryBitmapPresent(a)         (g4_extendedFlags(a)&0x20)
-#define differentWidths(a)                (g4_extendedFlags(a)&0x10)
-#define generalExtendedSecondOrder(a)     (g4_extendedFlags(a)&0x08)
-#define boustrophedonicOrdering(a)        (g4_extendedFlags(a)&0x04)
-#define firstOrderSpatialDifferencing(a)  ( (g4_extendedFlags(a)&0x03) == 1 )
-#define secondOrderSpatialDifferencing(a) ( (g4_extendedFlags(a)&0x03) == 2 )
-#define thirdOrderSpatialDifferencing(a)  ( (g4_extendedFlags(a)&0x03) == 3 )
-
-#define anyComplexPackedSpectralField(a) \
-                                      (anySpectralField(a) && !simplePacking(a))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
-// Function prototypes
-*/
-void GBYTE(void*,void*,fortint*,fortint*);
-fortint IGGLAT(fortint*,fortdouble*,fortint*,fortint*);
-double pow(double,double);
-void *memcpy(void*,const void*,size_t);
-
-fortint findSectionOffsets(unsigned char*,fortint*,fortint*,fortint*,fortint*,fortint*,fortint*);
-fortint prepareGrib(gribProduct**,unsigned char*);
-fortint convertGRIBFloatToIEEE(unsigned char*);
-fortdouble realValue(unsigned char*);
-fortdouble referenceValue(gribProduct*);
-fortdouble RGREFVL(gribProduct**);
-fortint IGBTSPV(gribProduct**);
-fortdouble RGDSCAL(gribProduct**);
-fortint IGUNUSD(gribProduct**);
-fortint GDECODE(gribProduct**,unsigned char*);
-fortint IGLNGTH(gribProduct**);
-fortint IGDATE(gribProduct**);
-fortint IGTIME(gribProduct**);
-fortint GSTEP(gribProduct**);
-fortint IGTABLE(gribProduct**);
-fortint IGCENTR(gribProduct**);
-fortint IGPARAM(gribProduct**);
-fortint IGLEVEL(gribProduct**);
-fortint IGLEVL1(gribProduct**);
-fortint IGLEVL2(gribProduct**);
-fortint IGDEFIN(gribProduct**);
-fortint IGCLASS(gribProduct**);
-fortint IGTYPE(gribProduct**);
-fortint IGSTREM(gribProduct**);
-fortint IGEXPVR(gribProduct**);
-fortint IGREPRS(gribProduct**);
-fortint IGNUMPV(gribProduct**);
-fortint GPV(gribProduct**,fortdouble*,fortint*);
-fortint GPL(gribProduct**,fortint*,fortint*);
-fortint IGNI(gribProduct**);
-fortint IGNJ(gribProduct**);
-fortdouble RGNWLAT(gribProduct**);
-fortdouble RGNWLON(gribProduct**);
-fortdouble RGSELAT(gribProduct**);
-fortdouble RGSELON(gribProduct**);
-fortint IGRESCO(gribProduct**);
-fortdouble RGDI(gribProduct**);
-fortdouble RGDJ(gribProduct**);
-fortint IGGAUSS(gribProduct**);
-fortint IGSCANM(gribProduct**);
-fortint IGJ(gribProduct**);
-fortint IGK(gribProduct**);
-fortint IGM(gribProduct**);
-fortint IGREPMO(gribProduct**);
-fortdouble RGIP(gribProduct**);
-fortint IGTJ(gribProduct**);
-fortint IGTK(gribProduct**);
-fortint IGTM(gribProduct**);
-fortdouble RGLATRP(gribProduct**);
-fortdouble RGLONRP(gribProduct**);
-fortdouble RGROTAT(gribProduct**);
-fortdouble RGLATSP(gribProduct**);
-fortdouble RGLONSP(gribProduct**);
-fortdouble RGSFACT(gribProduct**);
-fortint numberOfValuesInSection4(gribProduct*);
-fortint g4_offset(gribProduct*);
-fortint IGNVALU(gribProduct**);
-fortint GVALUES( gribProduct**,fortdouble*,fortint*,fortint*,fortdouble*);
-void GVEND(gribProduct**);
-fortint setupIrregularLongitudeIncrements(gribProduct**,fortint);
-fortint GVINIT(gribProduct**,fortdouble*);
-fortint GVECTOR( gribProduct**,fortdouble*,fortdouble*,fortdouble*);
-fortint getSingleMapBit(unsigned char*,fortint);
-void * allocateMemory(size_t);
-void freeMemory(void*);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* End of GDECODE_H */
diff --git a/tools/grib1profile/gdecodeStruct.h b/tools/grib1profile/gdecodeStruct.h
deleted file mode 100644
index ee4f1a0..0000000
--- a/tools/grib1profile/gdecodeStruct.h
+++ /dev/null
@@ -1,356 +0,0 @@
-#ifndef GDECODESTRUCT_H
-#define GDECODESTRUCT_H
-
-typedef struct gribSection0 {
-unsigned char GRIB[4];
-unsigned char totalGRIBlength[3];
-unsigned char editionNumber[1];
-} gribSection0;
-
-typedef struct ECMWFdefinition1 {
-unsigned char number[1];
-unsigned char total[1];
-unsigned char spare[1];
-} ECMWFdefinition1;
-
-typedef struct ECMWFdefinition2 {
-unsigned char number[1];
-unsigned char total[1];
-unsigned char spare[1];
-unsigned char method[1];
-unsigned char startTimestep[2];
-unsigned char endTimestep[2];
-unsigned char domainNorthLatitude[3];
-unsigned char domainWestLongitude[3];
-unsigned char domainSouthLatitude[3];
-unsigned char domainEastLongitude[3];
-unsigned char operationalForecastCluster[1];
-unsigned char controlForecastCluster[1];
-unsigned char numberInCluster[1];
-unsigned char forecastNumberList[256];
-} ECMWFdefinition2;
-
-typedef struct ECMWFdefinition3 {
-unsigned char band[1];
-unsigned char functionCode[1];
-unsigned char spare[1];
-} ECMWFdefinition3;
-
-typedef struct ECMWFdefinition5 {
-unsigned char number[1];
-unsigned char total[1];
-unsigned char unitsDecimalScaleFactor[1];
-unsigned char thresholdIndicator[1];
-unsigned char lowerThreshold[2];
-unsigned char upperThreshold[2];
-unsigned char spare[1];
-} ECMWFdefinition5;
-
-typedef struct ICEField {
-unsigned char date[3];
-unsigned char satelliteNumber[1];
-} ICEField;
-
-typedef struct ECMWFdefinition6 {
-unsigned char zero[2];
-unsigned char SSTFieldDate[3];
-unsigned char typeOfSSTField[1];
-unsigned char countOfICEFields[1];
-unsigned char lowerThreshold[2];
-unsigned char upperThreshold[2];
-ICEField ICEFieldList[20];
-} ECMWFdefinition6;
-
-typedef struct ECMWFdefinition7 {
-unsigned char number[1];
-unsigned char totalNumberOfDiagnostics[1];
-unsigned char domain[1];
-unsigned char diagnosticNumber[1];
-unsigned char spare[1];
-} ECMWFdefinition7;
-
-typedef struct ECMWFdefinition8 {
-unsigned char interval[1];
-unsigned char unsignedIntegers[12];
-} ECMWFdefinition8;
-
-typedef struct ECMWFdefinition9 {
-unsigned char number[2];
-unsigned char numberOfIterations[2];
-unsigned char numberOfSingularVectorsComputed[2];
-unsigned char initialNorm[1];
-unsigned char finalNorm[1];
-unsigned char multiplicationFactor[4];
-unsigned char northWestLatitude[4];
-unsigned char northWestLongitude[4];
-unsigned char southEastLatitude[4];
-unsigned char southEastLongitude[4];
-unsigned char accuracy[4];
-unsigned char numberOfSingularVectorsEvolved[2];
-unsigned char ritzNumber1[4];
-unsigned char ritzNumber2[4];
-unsigned char spare[1];
-} ECMWFdefinition9;
-
-typedef struct ECMWFdefinition10 {
-unsigned char number[1];
-unsigned char total[1];
-unsigned char centralClusterDefinition[1];
-unsigned char parameter[1];
-unsigned char levelType[1];
-unsigned char domainNorth[3];
-unsigned char domainWest[3];
-unsigned char domainSouth[3];
-unsigned char domainEast[3];
-unsigned char operationalForcastTubeNumber[1];
-unsigned char controlForcastTubeNumber[1];
-unsigned char level[2];
-unsigned char referenceStep[2];
-unsigned char radiusOfCentralCluster[2];
-unsigned char ensembleStandardDeviation[2];
-unsigned char distanceOfExtremeToMean[2];
-unsigned char numberOfForecastsInTube[1];
-unsigned char ensembleForecastList[255];
-} ECMWFdefinition10;
-
-typedef struct ECMWFdefinition11 {
-unsigned char analysisClass[1];
-unsigned char analysisType[1];
-unsigned char analysisStream[2];
-unsigned char analysisExpver[4];
-unsigned char analysisYear[1];
-unsigned char analysisMonth[1];
-unsigned char analysisDay[1];
-unsigned char analysisHour[1];
-unsigned char analysisMinute[1];
-unsigned char analysisCentury[1];
-unsigned char analysisOriginatingCentre[1];
-unsigned char analysisSubCentre[1];
-unsigned char spare[7];
-} ECMWFdefinition11;
-
-typedef struct ECMWFdefinition20 {
-unsigned char iteration[1];
-unsigned char total[1];
-unsigned char spare[1];
-} ECMWFdefinition20;
-
-typedef union localContent {
-ECMWFdefinition1  def1;
-ECMWFdefinition2  def2;
-ECMWFdefinition3  def3;
-ECMWFdefinition5  def5;
-ECMWFdefinition6  def6;
-ECMWFdefinition7  def7;
-ECMWFdefinition8  def8;
-ECMWFdefinition9  def9;
-ECMWFdefinition10 def10;
-ECMWFdefinition11 def11;
-ECMWFdefinition20 def20;
-} localContent;
-
-typedef struct marsHeader {
-unsigned char definition[1];
-unsigned char ecmwfClass[1];
-unsigned char type[1];
-unsigned char stream[2];
-unsigned char experimentVersionNumber[4];
-} marsHeader;
-
-typedef struct localDefinition {
-marsHeader mars;
-localContent contents;
-} localDefinition;
-
-typedef struct gribSection1 {
-unsigned char sectionLength[3];
-unsigned char tableVersionNumber[1];
-unsigned char originatingCentre[1];
-unsigned char generatingProcessId[1];
-unsigned char gridDefinition[1];
-unsigned char section2and3PresentFlag[1];
-unsigned char parameter[1];
-unsigned char typeOfLevel[1];
-unsigned char level1[1];
-unsigned char level2[1];
-unsigned char year[1];
-unsigned char month[1];
-unsigned char day[1];
-unsigned char hour[1];
-unsigned char minute[1];
-unsigned char unitOfTimeRange[1];
-unsigned char P1[1];
-unsigned char P2[1];
-unsigned char timeRangeIndicator[1];
-unsigned char numberInAverage[2];
-unsigned char numberMissing[1];
-unsigned char century[1];
-unsigned char subCentreId[1];
-unsigned char unitsDecimalScaleFactor[2];
-unsigned char reserved[12];
-localDefinition local;
-} gribSection1;
-
-typedef struct latitudeLongitudeGrid {
-unsigned char numberOfPointsAlongParallel[2];
-unsigned char numberOfPointsAlongMeridian[2];
-unsigned char latitudeOfFirstPoint[3];
-unsigned char longitudeOfFirstPoint[3];
-unsigned char resolutionAndComponentsFlag[1];
-unsigned char latitudeOfLastPoint[3];
-unsigned char longitudeOfLastPoint[3];
-unsigned char iDirectionIncrement[2];
-unsigned char jDirectionIncrement[2];
-unsigned char scanningMode[1];
-unsigned char setToZero[4];
-unsigned char latitudeOfSouthPole[3];
-unsigned char longitudeOfSouthPole[3];
-unsigned char angleOfRotationOrStretchingFactor[4];
-unsigned char latitudeOfPoleOfStretching[3];
-unsigned char longitudeOfPoleOfStretching[3];
-unsigned char stretchingFactor[4];
-} latitudeLongitudeGrid;
-
-typedef struct gaussianGrid {
-unsigned char numberOfPointsAlongParallel[2];
-unsigned char numberOfPointsAlongMeridian[2];
-unsigned char latitudeOfFirstPoint[3];
-unsigned char longitudeOfFirstPoint[3];
-unsigned char resolutionAndComponentsFlag[1];
-unsigned char latitudeOfLastPoint[3];
-unsigned char longitudeOfLastPoint[3];
-unsigned char iDirectionIncrement[2];
-unsigned char numberOfParallelsBetweenPoleAndEquator[2];
-unsigned char scanningMode[1];
-unsigned char setToZero[4];
-unsigned char latitudeOfSouthPole[3];
-unsigned char longitudeOfSouthPole[3];
-unsigned char angleOfRotationOrStretchingFactor[4];
-unsigned char latitudeOfPoleOfStretching[3];
-unsigned char longitudeOfPoleOfStretching[3];
-unsigned char stretchingFactor[4];
-} gaussianGrid;
-
-
-typedef struct sphericalHarmonicCoefficients {
-unsigned char J[2];
-unsigned char K[2];
-unsigned char M[2];
-unsigned char representationType[1];
-unsigned char representationMode[1];
-unsigned char setToZero[18];
-unsigned char latitudeOfSouthPole[3];
-unsigned char longitudeOfSouthPole[3];
-unsigned char angleOfRotationOrStretchingFactor[4];
-unsigned char latitudeOfPoleOfStretching[3];
-unsigned char longitudeOfPoleOfStretching[3];
-unsigned char stretchingFactor[4];
-} sphericalHarmonicCoefficients;
-
-typedef union gridDefinition {
-latitudeLongitudeGrid latlon;
-gaussianGrid gaussian;
-sphericalHarmonicCoefficients spectral;
-} gridDefinition;
-
-typedef struct gribSection2 {
-unsigned char sectionLength[3];
-unsigned char NV[1];
-unsigned char PV_PL[1];
-unsigned char dataRepresentationType[1];
-gridDefinition grid;
-} gribSection2;
-
-typedef struct gribSection3 {
-unsigned char sectionLength[3];
-unsigned char numberOfUnusedBits[1];
-unsigned char tableReference[2];
-unsigned char bitmap;
-} gribSection3;
-
-typedef struct simplePackingGridPoint {
-unsigned char dataBits;
-} simplePackingGridPoint;
-
-typedef struct secondOrderPackingGridPoint {
-unsigned char n1[2];
-unsigned char extendedFlags[1];
-unsigned char n2[2];
-unsigned char p1[2];
-unsigned char p2[2];
-unsigned char reserved[1];
-unsigned char dataBits;
-} secondOrderPackingGridPoint;
-
-typedef struct simplePackingSpectral {
-unsigned char realPartOf0_0Coefficient[4];
-unsigned char dataBits;
-} simplePackingSpectral;
-
-typedef struct complexPackingSpectral {
-unsigned char N[2];
-unsigned char IP[2];
-unsigned char J[1];
-unsigned char K[1];
-unsigned char M[1];
-unsigned char dataBits;
-} complexPackingSpectral;
-
-typedef union binaryData {
-simplePackingGridPoint simpleGrid;
-secondOrderPackingGridPoint complexGrid;
-simplePackingSpectral simpleSpectral;
-complexPackingSpectral complexSpectral;
-} binaryData;
-
-typedef struct gribSection4 {
-unsigned char sectionLength[3];
-unsigned char flag[1];
-unsigned char scaleFactor[2];
-unsigned char referenceValue[4];
-unsigned char numberOfBitsPerValue[1];
-binaryData data;
-} gribSection4;
-
-typedef struct gribSection5 {
-unsigned char end7777[4];
-} gribSection5;
-
-typedef struct latLongValueVector {
-fortdouble * latitude;
-fortdouble * longitudeIncrement;
-fortdouble * gridPointValue;
-} latLongValueVector;
-
-typedef struct gribProduct {
-gribSection0 * g0;
-gribSection1 * g1;
-gribSection2 * g2;
-gribSection3 * g3;
-gribSection4 * g4;
-gribSection5 * g5;
-fortint currentPointIndex;
-fortint numberOfValues;
-unsigned char * value;
-unsigned char * bitStart;
-fortint bitsPerValue;
-fortint bitmapped;
-fortint nextValueFirstBit;
-fortint nextBit;
-fortint northSet;
-fortint southSet;
-fortint westSet;
-fortint eastSet;
-fortint northSouthIncrementSet;
-fortint westEastIncrementSet;
-fortint northSouthNumberOfPointsSet;
-fortint westEastNumberOfPointsSet;
-fortdouble scale;
-fortdouble minimum;
-fortdouble missingValue;
-fortint * latitudeOffsets;
-fortdouble * expandedValues;
-latLongValueVector currentPoint;
-} gribProduct;
-
-#endif /* End of GDECODESTRUCT_H */
diff --git a/tools/grib1profile/grib.h b/tools/grib1profile/grib.h
deleted file mode 100644
index 2862d2c..0000000
--- a/tools/grib1profile/grib.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- *
- * These are array offsets associated with arrays generated from
- * the MARS routine GRIBEX
- *
- * These are the limits required for return arrays of GRIBEX call
- */
-
-#define		ISECTION_0		2
-#define         ISECTION_1              2048
-#define		ISECTION_2		2048		
-#define		ISECTION_3		512
-#define		ISECTION_4		512
-
-#define		RSECTION_2		512	
-#define		RSECTION_3		2
-#define		RSECTION_4		1
-
diff --git a/tools/grib1profile/grib1profile.c b/tools/grib1profile/grib1profile.c
deleted file mode 100644
index 8970924..0000000
--- a/tools/grib1profile/grib1profile.c
+++ /dev/null
@@ -1,618 +0,0 @@
-/*
-** Generated by X-Designer 
-*/
-/*
-**LIBS: -lXm -lXt -lX11
-*/
-
-#include <X11/Xatom.h>
-#include <X11/Intrinsic.h>
-#include <X11/Shell.h>
-
-#include <Xm/Xm.h>
-#include <Xm/CascadeB.h>
-#include <Xm/DialogS.h>
-#include <Xm/FileSB.h>
-#include <Xm/Form.h>
-#include <Xm/Label.h>
-#include <Xm/List.h>
-#include <Xm/ToggleB.h>
-#include <Xm/PushB.h>
-#include <Xm/RowColumn.h>
-#include <Xm/ScrollBar.h>
-#include <Xm/SelectioB.h>
-#include <Xm/Text.h>
-#include <Xm/TextF.h>
-#include <Xm/LabelG.h>
-#include <Xm/PushBG.h>
-#include <Xm/SeparatoG.h>
-#include <stdio.h>
-
-#include "grib1profile.h"
-
-extern void help_help_quit_cb ();
-extern void help_about_quit_cb ();
-extern void file_open_cb ();
-extern void file_select_ok_cb ();
-extern void list_select_cb ();
-extern void file_quit_cb ();
-extern void help_about_cb ();
-extern void help_help_cb ();
-extern void file_toggle_cb ();
-extern void setInitialFileState ( char ** , int );
-
-void XDmanage_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtManageChild ( *(Widget *)client_data );
-}
-
-void XDunmanage_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtUnmanageChild ( *(Widget *)client_data );
-}
-
-void XDpopup_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtPopup ( *(Widget *)client_data, XtGrabNone );
-}
-
-void XDpopdown_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtPopdown ( *(Widget *)client_data );
-}
-
-void XDmap_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtMapWidget (*(Widget *)client_data);
-}
-
-void XDunmap_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtUnmapWidget (*(Widget *)client_data);
-}
-
-void XDenable_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtSetSensitive (*(Widget *)client_data, TRUE);
-}
-
-void XDdisable_link(
-  Widget w,
-  XtPointer client_data,
-  XtPointer call_data) {
-
-    XtSetSensitive (*(Widget *)client_data, FALSE);
-}
-
-
-Widget help_help_toplevel = (Widget) NULL;
-Widget help_help_dialog = (Widget) NULL;
-Widget help_help_scroll_text = (Widget) NULL;
-Widget help_help_text = (Widget) NULL;
-Widget help_help_quit = (Widget) NULL;
-Widget help_about_toplevel = (Widget) NULL;
-Widget help_about_dialog = (Widget) NULL;
-Widget help_about_quit = (Widget) NULL;
-Widget help_about_text = (Widget) NULL;
-Widget file_select_dialog = (Widget) NULL;
-Widget file_select = (Widget) NULL;
-Widget file_text = (Widget) NULL;
-Widget grib1profile = (Widget) NULL;
-Widget frame = (Widget) NULL;
-Widget scrolled_list_label = (Widget) NULL;
-Widget scrolled_list = (Widget) NULL;
-Widget list = (Widget) NULL;
-Widget scrolled_text = (Widget) NULL;
-Widget current_filename = (Widget) NULL;
-Widget menubar = (Widget) NULL;
-Widget file = (Widget) NULL;
-Widget file_pulldown_menu = (Widget) NULL;
-Widget file_open = (Widget) NULL;
-Widget file_quit = (Widget) NULL;
-Widget help = (Widget) NULL;
-Widget help_pulldown_menu = (Widget) NULL;
-Widget help_about = (Widget) NULL;
-Widget help_help = (Widget) NULL;
-Widget full_toggle = (Widget) NULL;
-
-
-
-void create_help_help_toplevel (Widget parent) {
-Display *display = XtDisplay ( parent );
-Widget children[5];            /* Children to manage */
-Arg al[64];                    /* Arg List */
-register int ac = 0;           /* Arg Count */
-XmString xmstrings[16];        /* temporary storage for XmStrings */
-
-    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
-    XtSetArg(al[ac], XmNtitle, "Grib1profile Help"); ac++;
-    XtSetArg(al[ac], XmNminWidth, 400); ac++;
-    XtSetArg(al[ac], XmNminHeight, 400); ac++;
-    XtSetArg(al[ac], XmNmaxWidth, 800); ac++;
-    XtSetArg(al[ac], XmNmaxHeight, 1000); ac++;
-    XtSetArg(al[ac], XmNinput, FALSE); ac++;
-    XtSetArg(al[ac], XmNbaseWidth, 600); ac++;
-    XtSetArg(al[ac], XmNbaseHeight, 750); ac++;
-    help_help_toplevel =
-      XmCreateDialogShell ( parent, "help_help_toplevel", al, ac );
-    ac = 0;
-
-    XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
-    help_help_dialog =
-      XmCreateForm ( help_help_toplevel, "help_help_dialog", al, ac );
-    ac = 0;
-
-    XtSetArg(al[ac], XmNeditable, FALSE); ac++;
-    XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
-    help_help_text =
-      XmCreateScrolledText ( help_help_dialog, "help_help_text", al, ac );
-    ac = 0;
-
-    help_help_scroll_text = XtParent ( help_help_text );
-
-    xmstrings[0] =
-      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    help_help_quit =
-      XmCreatePushButton ( help_help_dialog, "help_help_quit", al, ac );
-    ac = 0;
-
-    XmStringFree ( xmstrings [ 0 ] );
-
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
-    XtSetArg(al[ac], XmNbottomWidget, help_help_quit); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( help_help_scroll_text,al, ac );
-    ac = 0;
-
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
-    XtSetValues ( help_help_quit,al, ac );
-    ac = 0;
-
-    XtManageChild(help_help_text);
-    XtAddCallback (help_help_quit, XmNactivateCallback, help_help_quit_cb,NULL);
-    children[ac++] = help_help_quit;
-    XtManageChildren(children, ac);
-    ac = 0;
-}
-
-
-void create_help_about_toplevel ( Widget parent) {
-Display *display = XtDisplay ( parent );
-Widget children[5];            /* Children to manage */
-Arg al[64];                    /* Arg List */
-register int ac = 0;           /* Arg Count */
-XmString xmstrings[16];        /* temporary storage for XmStrings */
-
-    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
-    XtSetArg(al[ac], XmNtitle, "About grib1profile"); ac++;
-    XtSetArg(al[ac], XmNminWidth, 400); ac++;
-    XtSetArg(al[ac], XmNminHeight, 300); ac++;
-    XtSetArg(al[ac], XmNmaxWidth, 400); ac++;
-    XtSetArg(al[ac], XmNmaxHeight, 300); ac++;
-    XtSetArg(al[ac], XmNbaseWidth, 400); ac++;
-    XtSetArg(al[ac], XmNbaseHeight, 300); ac++;
-    help_about_toplevel =
-      XmCreateDialogShell ( parent, "help_about_toplevel", al, ac );
-    ac = 0;
-
-    XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
-    help_about_dialog =
-      XmCreateForm ( help_about_toplevel, "help_about_dialog", al, ac );
-    ac = 0;
-
-    xmstrings[0] =
-      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
-    help_about_quit =
-      XmCreatePushButton ( help_about_dialog, "help_about_quit", al, ac );
-    ac = 0;
-
-    XmStringFree ( xmstrings [ 0 ] );
-    XtSetArg(al[ac], XmNeditable, FALSE); ac++;
-    XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
-    help_about_text =
-      XmCreateText ( help_about_dialog, "help_about_text", al, ac );
-    ac = 0;
-
-    XmTextSetString ( help_about_text,
-      "\n\n\n"
-      "  GRIB1 product file viewer\n"
-      "  -------------------------\n\n\n"
-      "  John Chambers\n\n"
-      "  Meteorological Applications Section, ECMWF\n\n"
-      "  August, 2001\n\n" );
-
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
-    XtSetValues ( help_about_quit,al, ac );
-    ac = 0;
-
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
-    XtSetArg(al[ac], XmNbottomWidget, help_about_quit); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( help_about_text,al, ac );
-    ac = 0;
-
-    XtAddCallback(help_about_quit,XmNactivateCallback,help_about_quit_cb,NULL);
-    children[ac++] = help_about_quit;
-    children[ac++] = help_about_text;
-    XtManageChildren(children, ac);
-    ac = 0;
-}
-
-
-void create_file_select_dialog ( Widget parent) {
-Display *display = XtDisplay ( parent );
-Arg al[64];                    /* Arg List */
-register int ac = 0;           /* Arg Count */
-Widget widget26;
-
-    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
-    XtSetArg(al[ac], XmNtitle, "File_select"); ac++;
-    file_select_dialog =
-      XmCreateDialogShell ( parent, "file_select_dialog", al, ac );
-    ac = 0;
-
-    XtAddCallback (file_select_dialog, XmNpopupCallback, file_open_cb,NULL);
-    file_select =
-      XmCreateFileSelectionBox ( file_select_dialog, "file_select", al, ac );
-    file_text = XmSelectionBoxGetChild ( file_select, XmDIALOG_TEXT );
-    widget26 =
-      XmFileSelectionBoxGetChild ( file_select, XmDIALOG_FILTER_TEXT );
-
-    XtAddCallback (file_select, XmNokCallback, file_select_ok_cb,NULL);
-    XtAddCallback (file_select, XmNapplyCallback, file_select_ok_cb,NULL);
-    XtAddCallback (file_select, XmNcancelCallback, file_select_ok_cb,NULL);
-    XtAddCallback (file_select, XmNnoMatchCallback, file_select_ok_cb,NULL);
-}
-
-
-void create_grib1profile (
-  Display *display,
-  char *app_name,
-  int app_argc,
-  char **app_argv) {
-Widget children[5];            /* Children to manage */
-Arg al[64];                    /* Arg List */
-register int ac = 0;           /* Arg Count */
-XrmValue from_value, to_value; /* For resource conversion */
-XmString xmstrings[16];        /* temporary storage for XmStrings */
-
-    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
-    XtSetArg(al[ac], XmNtitle, "Xgrib1profile"); ac++;
-    XtSetArg(al[ac], XmNminWidth, 700); ac++;
-    XtSetArg(al[ac], XmNbaseWidth, 700); ac++;
-    XtSetArg(al[ac], XmNinput, FALSE); ac++;
-    XtSetArg(al[ac], XmNargc, app_argc); ac++;
-    XtSetArg(al[ac], XmNargv, app_argv); ac++;
-    grib1profile =
-      XtAppCreateShell ( app_name, "XGrib1profile", applicationShellWidgetClass,
-                         display, al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
-    frame = XmCreateForm ( grib1profile, "frame", al, ac );
-
-    ac = 0;
-    xmstrings[0] =
-      XmStringCreateLtoR(" ", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
-    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
-    from_value.addr = "9x15";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (frame, XmRString, &from_value, XmRFontList, &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNfontList, *(unsigned int *)to_value.addr); ac++;
-    }
-    scrolled_list_label =
-      XmCreateLabel ( frame, "scrolled_list_label", al, ac );
-
-    ac = 0; 
-    XmStringFree ( xmstrings [ 0 ] );
-    XtSetArg(al[ac], XmNvisibleItemCount, 10); ac++;
-    from_value.addr = "9x15";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (frame, XmRString, &from_value, XmRFontList,
-                       &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNfontList, *(unsigned int *)to_value.addr); ac++;
-    }
-    XtSetArg(al[ac], XmNselectionPolicy, XmSINGLE_SELECT); ac++;
-    XtSetArg(al[ac], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); ac++;
-    list = XmCreateScrolledList ( frame, "list", al, ac );
-
-    ac = 0;
-    scrolled_list = XtParent ( list );
-
-    ac = 0;
-    xmstrings[0] =
-      XmStringCreateLtoR("No file open.",
-                         (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
-    current_filename = XmCreateLabel ( frame, "current_filename", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    menubar = XmCreateMenuBar ( frame, "menubar", al, ac );
-    xmstrings[0] =
-      XmStringCreateLtoR("File", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    from_value.addr = "F";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
-    }
-    file = XmCreateCascadeButton ( menubar, "file", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    file_pulldown_menu =
-      XmCreatePulldownMenu ( menubar, "file_pulldown_menu", al, ac );
-    xmstrings[0] =
-      XmStringCreateLtoR("Open", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    from_value.addr = "O";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (file_pulldown_menu, XmRString, &from_value, XmRKeySym,
-                       &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
-    }
-    file_open =
-      XmCreatePushButton ( file_pulldown_menu, "file_open", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    xmstrings[0] =
-      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    from_value.addr = "Q";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (file_pulldown_menu, XmRString, &from_value, XmRKeySym,
-                       &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
-    }
-    file_quit =
-      XmCreatePushButton ( file_pulldown_menu, "file_quit", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    xmstrings[0] =
-      XmStringCreateLtoR("Help", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    from_value.addr = "H";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
-    }
-    help = XmCreateCascadeButton ( menubar, "help", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    help_pulldown_menu =
-      XmCreatePulldownMenu ( menubar, "help_pulldown_menu", al, ac );
-    xmstrings[0] =
-      XmStringCreateLtoR("About", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    from_value.addr = "A";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (help_pulldown_menu, XmRString, &from_value, XmRKeySym,
-                       &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
-    }
-    help_about =
-      XmCreatePushButton ( help_pulldown_menu, "help_about", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    xmstrings[0] =
-      XmStringCreateLtoR("Help", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
-    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
-    from_value.addr = "H";
-    from_value.size = strlen( from_value.addr ) + 1;
-    to_value.addr = NULL;
-    XtConvertAndStore (help_pulldown_menu, XmRString, &from_value, XmRKeySym,
-                       &to_value);
-    if ( to_value.addr ) {
-      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
-    }
-    help_help =
-      XmCreatePushButton ( help_pulldown_menu, "help_help", al, ac );
-
-    ac = 0;
-    XmStringFree ( xmstrings [ 0 ] );
-    XtSetArg(al[ac], XmNmenuHelpWidget, help); ac++;
-    XtSetValues ( menubar,al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNheight, 50); ac++;
-    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
-    XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
-    XtSetArg(al[ac], XmNhighlightThickness, 0); ac++;
-
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( menubar,al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNtopWidget, menubar); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( current_filename,al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNtopWidget, current_filename); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( scrolled_list_label,al, ac );
-
-    ac = 0;
-    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
-    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
-    XtSetArg(al[ac], XmNtopWidget, scrolled_list_label); ac++;
-    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
-    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
-    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
-    XtSetValues ( scrolled_list,al, ac );
-
-    ac = 0;
-    XtAddCallback (list, XmNsingleSelectionCallback, list_select_cb,NULL);
-    XtManageChild(list);
-    children[ac++] = scrolled_list_label;
-    XtManageChildren(children, ac);
-
-    ac = 0;
-    XtAddCallback (file_open, XmNactivateCallback, file_open_cb,NULL);
-    XtAddCallback (file_quit, XmNactivateCallback, file_quit_cb,NULL);
-    children[ac++] = file_open;
-    children[ac++] = file_quit;
-    XtManageChildren(children, ac);
-
-    ac = 0;
-    XtSetArg(al[ac], XmNsubMenuId, file_pulldown_menu); ac++;
-    XtSetValues ( file, al, ac );
-
-    ac = 0;
-    XtAddCallback (help_about, XmNactivateCallback, help_about_cb,NULL);
-    XtAddCallback (help_help, XmNactivateCallback, help_help_cb,NULL);
-    children[ac++] = help_about;
-    children[ac++] = help_help;
-    XtManageChildren(children, ac);
-
-    ac = 0;
-    XtSetArg(al[ac], XmNsubMenuId, help_pulldown_menu); ac++;
-    XtSetValues ( help, al, ac );
-
-    ac = 0;
-    children[ac++] = file;
-    children[ac++] = help;
-    XtManageChildren(children, ac);
-
-    ac = 0;
-    children[ac++] = scrolled_list;
-    children[ac++] = current_filename;
-    children[ac++] = menubar;
-    XtManageChildren(children, ac);
-
-    ac = 0;
-    XtManageChild ( frame);
-}
-
-
-
-XtAppContext app_context;
-Display *display;       /*  Display             */
-static String fallbacks [] =
-{
-"XGrib1profile*fontList: 7x13bold",
-NULL
-};
-
-int main (argc,argv)
-int    argc;
-char            **argv;
-{
-#ifndef SUN
-    XtSetLanguageProc((XtAppContext)NULL,(XtLanguageProc)NULL,(XtPointer)NULL);
-#endif
-    XtToolkitInitialize ();
-    app_context = XtCreateApplicationContext ();
-    XtAppSetFallbackResources(app_context,fallbacks);
-    display =
-      XtOpenDisplay (app_context, NULL, argv[0], "XGrib1profile",
-                     NULL, 0, &argc, argv);
-    if (!display) {
-      printf("%s: can't open display, exiting...\n", argv[0]);
-      exit (-1);
-    }
-    create_grib1profile ( display, argv[0], argc, argv );
-    create_help_help_toplevel ( grib1profile );
-    create_help_about_toplevel ( grib1profile );
-    create_file_select_dialog ( grib1profile );
-
-    XtRealizeWidget (grib1profile);
-/*
-//  If filename given on the control line, use it.
-*/
-    if( argc == 2 ) setInitialFileState( argv+1, (int) strlen(*(argv+1)) );
-
-
-    XtAppMainLoop (app_context);
-    exit (0);
-}
-
diff --git a/tools/grib1profile/grib1profile.h b/tools/grib1profile/grib1profile.h
deleted file mode 100644
index 5189844..0000000
--- a/tools/grib1profile/grib1profile.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#define GRIB 0x47524942
-#define BUFR 0x42554652
-#define BUDG 0x42554447
-#define DIAG 0x44494147
-#define TIDE 0x54494445
-
-#define NOT_KNOWN 0
-#define GRIB_CODED 1
-#define BUFR_CODED 2
-#define TIDE_CODED 3
-#define BUDG_CODED 4
-#define DIAG_CODED 5
-#define DISPLAYTEXT 8000000
-#define HELPNEWSLEN 20000
-#define GETLEN 120
-#define READLEN 20480
-#define RESOL 120
-
-#ifdef SUN
-#define XmFONTLIST_DEFAULT_TAG XmSTRING_DEFAULT_CHARSET
-#endif
-
diff --git a/tools/grib1profile/grib1profile_externs.c b/tools/grib1profile/grib1profile_externs.c
deleted file mode 100644
index 0d33548..0000000
--- a/tools/grib1profile/grib1profile_externs.c
+++ /dev/null
@@ -1,57 +0,0 @@
-extern Widget help_help_toplevel;
-extern Widget help_help_dialog;
-extern Widget help_help_scroll_text;
-extern Widget help_help_text;
-extern Widget help_help_quit;
-
-extern Widget help_about_toplevel;
-extern Widget help_about_dialog;
-extern Widget help_about_quit;
-extern Widget help_about_text;
-
-extern Widget file_select_dialog;
-extern Widget file_select;
-extern Widget file_text;
-
-extern Widget grib1profile;
-extern Widget frame;
-extern Widget paned_window;
-extern Widget scrolled_list_label;
-extern Widget scolled_list;
-extern Widget list;
-extern Widget scrolled_text;
-extern Widget text_text;
-extern Widget current_filename;
-extern Widget menubar;
-extern Widget file;
-extern Widget file_pulldown_menu;
-extern Widget file_open;
-extern Widget file_quit;
-extern Widget help;
-extern Widget help_pulldown_menu;
-extern Widget help_about;
-extern Widget help_help;
-extern Widget quit;
-
-#define MAXW 50
-
-extern Widget pgrib1Listing_dialog[MAXW];
-extern Widget pgrib1Listing[MAXW];
-extern Widget maxminLabel[MAXW];
-extern Widget filenameLabel[MAXW];
-extern Widget fileListing[MAXW];
-extern Widget textQuit[MAXW];
-extern Widget scrolledText1[MAXW];
-
-
-extern void create_help_help_toplevel ();
-
-extern void create_help_about_toplevel ();
-
-extern void create_file_select_dialog ();
-
-extern void create_grib1profile ();
-
-extern void create_pgrib1Listing ();
-
-extern XtCallbackProc textQuit_cb (Widget ,int * ,XmPushButtonCallbackStruct );
diff --git a/tools/grib1profile/grib1profile_help b/tools/grib1profile/grib1profile_help
deleted file mode 100644
index de268ca..0000000
--- a/tools/grib1profile/grib1profile_help
+++ /dev/null
@@ -1,63 +0,0 @@
-
-1.  Introduction.
-    -------------
-
-    grib1profile works with GRIB edition 1 products in pure binary files
-    with no blocking structure.
-
-    Run the profiler:
-      /home/ma/emos/bin/sgimips/grib1profile &    (SGI)
-      /home/ma/emos/bin/linux/grib1profile &      (linux)
-      /home/ma/emos/bin/rs6000/grib1profile &     (rs6000 and hpcx)
-      /home/ma/emos/bin/grib1profile &            (VPP)
-
-
-2.  Starting.
-    ---------
-
-    Use the 'File' option on the menu bar, select 'Open' and choose a file
-    from the file selection box.
-
-    Alternatively, start the viewer and give a file name on the command
-    line:
-      /home/ma/emos/bin/sgimips/grib1profile filename &    (SGI)
-      /home/ma/emos/bin/linux/grib1profile filename &      (linux)
-      /home/ma/emos/bin/rs6000/grib1profile filename &     (rs6000)
-      /home/ma/emos/bin/grib1profile filename &                   (VPP)
-
-    The viewer opens the selected file and reads through it, looking for
-    GRIB products.  If none are found, the file is ignored.
-
-    Information about products recognized in the current file is displayed
-    as a list. The first product in the file is decoded and displayed in a
-    popup window.  Examine other products in the file by selecting them from
-    the list.
-
-    Regular latitude/longitude grids and regular gaussian grids are displayed
-    in an array layout as scrollable rows and columns numbered along the top
-    and left sides.
-
-
-3.  Stopping.
-    ---------
-
-    To quit the viewer, choose the 'File' option on the menu bar and select 
-    'Quit'.
-
-
-4.  More information.
-    -----------------
-
-    For more information about handling GRIB products, see:
-
-     The ECMWF on-line documentation WWW pages.
-     (http://wms.ecmwf.int/documents/manuals/libraries/gribex/index.html)
-
-     "Encoding and decoding GRIB data (GRIBEX)"    ECMWF Met.Bulletin 1.9/3
-
-     "Accessing GRIB and BUFR data"                ECMWF Met.Bulletin 1.9/4
-
-     WMO publication no. 306 - Manual on Codes.
-
-
-    J.D.Chambers ECMWF August 2002.
diff --git a/tools/grib1profile/grprs1.F.dead b/tools/grib1profile/grprs1.F.dead
deleted file mode 100644
index 40d0b57..0000000
--- a/tools/grib1profile/grprs1.F.dead
+++ /dev/null
@@ -1,1084 +0,0 @@
-      SUBROUTINE GRPRS1(KSEC0,KSEC1)
-C
-C---->
-C**** GRPRS1
-C
-C     Purpose.
-C     --------
-C
-C     Print the information in the Product Definition
-C     Section (Section 1) of decoded GRIB data.
-C
-C**   Interface.
-C     ----------
-C
-C     CALL GRPRS1(KSEC0,KSEC1)
-C
-C
-C     Input Parameters.
-C     -----------------
-C
-C     KSEC0 - Array of decoded parameters from Section 0.
-C
-C     KSEC1 - Array of decoded parameters from Section 1.
-C
-C
-C     Output Parameters.
-C     ------------------
-C
-C     None.
-C
-C
-C     Method.
-C     -------
-C
-C     Flag fields are printed in binary representation.
-C     Other fields as integers.
-C     Fields printed depend on GRIB Edition.
-C
-C
-C     Externals.
-C     ----------
-C
-C     PRTBIN  - Print binary value in character format.
-C     KWPRS1  - Print Washington ensemble products.
-C     CHKTAB2 - Looks up a parameter in a given ECMWF local table 2.
-C
-C
-C     Reference.
-C     ----------
-C
-C     WMO Manual on Codes re GRIB Code.
-C     See also routine GRIBEX.
-C
-C
-C     Comments.
-C     ---------
-C
-C     When decoding data from Experimental Edition or Edition 0,
-C     routine GRIBEX adds the additional fields available in
-C     Edition 1.
-C
-C
-C
-C     Author.
-C     -------
-C
-C     J. Hennessy    ECMWF 18.06.91
-C
-C
-C     Modifications.
-C     --------------
-C
-C     J. Hennessy    ECMWF 30.08.91
-C     Different print for GRIB Editions up to Edition 1
-C     removed.
-C
-C     J. Hennessy    ECMWF 07.01.92
-C     Different print for GRIB Editions up to Edition 1
-C     added for centres other than ECMWF.
-C
-C     J. Hennessy    ECMWF 27.07.92
-C     Print added for satellite identifiers.
-C
-C     J. Hennessy    ECMWF 03.11.92
-C     Print of local ECMWF use  1 of section 1 added.
-C
-C     J. Hennessy    ECMWF 03.12.92
-C     Version number changed to character print.
-C
-C     J. Hennessy    ECMWF 20.05.93
-C     Print of local ECMWF use 2,3 and 4 of section 1 added.
-C
-C     J.D.Chambers   ECMWF 18.10.93
-C     Print of local ECMWF use 5 of section 1 added.
-C
-C     J.D.Chambers   ECMWF 10.05.94
-C     Fix print of version number
-C
-C     J.D.Chambers   ECMWF 02.06.94
-C     Fix print of total number of forecasts and forecast number
-C     for MARS labelling
-C
-C     J.D.Chambers   ECMWF 19.01.95
-C     Allow printing of ECMWF local use definition 8.
-C
-C     J.D.Chambers   ECMWF 14.02.95
-C     Modify printing of ECMWF local use definition 7.
-C
-C     J.D.Chambers   ECMWF 09.10.95
-C     Add handling of Washington ensemble products.
-C
-C     J.D.Chambers     ECMWF      27.02.96
-C     Allow for ECMWF local use definition 6.
-C
-C     J.D.Chambers     ECMWF      13.02.98
-C     Allow for ECMWF local use definition 10 (EPS tubes).
-C
-C     J.D.Chambers     ECMWF      16.02.98
-C     Allow for ECMWF local use definition 11 (Supplementary data
-C     used by analysis).
-C
-C     J.D.Chambers     ECMWF      April 1998
-C     Allow for ECMWF local use definition 13
-C
-C     J.D.Chambers     ECMWF      November 1998
-C     Allow for ECMWF local use definition 12
-C
-C     J. Clochard, Meteo France, for ECMWF - June 1999.
-C     Replace LOCAL2K call by CHKTAB2 call.
-C
-C----<
-C     -----------------------------------------------------------------
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------
-C
-C
-      IMPLICIT NONE
-C
-C     Parameters
-C
-      INTEGER KSEC0
-      INTEGER KSEC1
-      DIMENSION KSEC0(*)
-      DIMENSION KSEC1(*)
-C
-C     Local variables
-C
-      INTEGER IPREV, ICURR, ICOUNT, IOFFSET, IOFF2, IOFF3
-      INTEGER IBIT, IERR, IOUT, IYEAR
-      INTEGER JLOOP, JILOOP
-      REAL VALUE
-C
-      CHARACTER*8 HVERSION
-      CHARACTER*121 HFIRST, HSECOND, HTHIRD, HFOURTH
-C
-C     Externals
-C
-      INTEGER CHKTAB2
-      EXTERNAL CHKTAB2
-C
-C     -----------------------------------------------------------------
-C*    Section 1 . Print required information.
-C     -----------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WRITE(*,9000)
-      WRITE(*,9001)
-      WRITE(*,9002)
-C
-      WRITE(*,9100) KSEC1(1)
-      WRITE(*,9101) KSEC1(2)
-      WRITE(*,9102) KSEC1(3)
-      WRITE(*,9103) KSEC1(4)
-      IBIT = 8
-      CALL PRTBIN (KSEC1(5),IBIT,IOUT,IERR)
-      WRITE(*,9104) IOUT
-      WRITE(*,9105) KSEC1(6)
-      IERR = CHKTAB2(KSEC1,HFIRST,HSECOND,HTHIRD,HFOURTH)
-      IF( IERR .EQ. 0 ) THEN
-        IOFF2 = 121
-        DO JLOOP = 121, 1, -1
-          IF( HSECOND(JLOOP:JLOOP).NE.' ' ) THEN
-            IOFF2 = JLOOP
-            GOTO 110
-          ENDIF
-        ENDDO
-        GOTO 130
- 110    CONTINUE
-        IOFF3 = 121
-        DO JLOOP = 121, 1, -1
-          IF( HTHIRD(JLOOP:JLOOP).NE.' ' ) THEN
-            IOFF3 = JLOOP
-            GOTO 120
-          ENDIF
-        ENDDO
-        GOTO 130
- 120    CONTINUE
-        WRITE(*,*) '('//HSECOND(1:IOFF2)//': '//HTHIRD(1:IOFF3)//')'
-C
- 130    CONTINUE
-      ENDIF
-C
-      IF (KSEC1(6).NE.127) THEN
-        WRITE(*,9106) KSEC1(7)
-        WRITE(*,9107) KSEC1(8)
-        WRITE(*,9108) KSEC1(9)
-      ELSE
-        WRITE(*,9206) KSEC1(7)
-        WRITE(*,9207) KSEC1(8)
-      ENDIF
-C
-      IYEAR = KSEC1(10)
-      IF( IYEAR.NE.255 ) THEN
-        IYEAR  = ((KSEC1(21)-1)*100 + KSEC1(10))
-        WRITE(*,9109) KSEC1(10), IYEAR
-      ELSE
-        WRITE(*,*) 'Year of reference time of data MISSING  (=255)'
-      ENDIF
-      WRITE(*,9110) KSEC1(11)
-      WRITE(*,9111) KSEC1(12)
-      WRITE(*,9112) KSEC1(13)
-      WRITE(*,9113) KSEC1(14)
-      WRITE(*,9114) KSEC1(15)
-      WRITE(*,9115) KSEC1(16)
-      WRITE(*,9116) KSEC1(17)
-      WRITE(*,9117) KSEC1(18)
-      WRITE(*,9118) KSEC1(19)
-      WRITE(*,9119) KSEC1(20)
-C
-C     All ECMWF data in GRIB Editions before Edition 1 is decoded
-C     as 20th century data. Other centres are decoded as missing.
-C
-      IF (KSEC0(2).LT.1.AND.KSEC1(2).NE.98) THEN
-        WRITE(*,9122)
-      ELSE
-        WRITE(*,9120) KSEC1(21)
-      ENDIF
-C
-C     Print sub-centre
-      WRITE(*,9123) KSEC1(22)
-C
-C     Decimal scale factor
-      WRITE(*,9121) KSEC1(23)
-C
-C     -----------------------------------------------------------------
-C*    Section 2 . Print local ECMWF information.
-C     -----------------------------------------------------------------
-C
-  200 CONTINUE
-C
-C     Regular MARS labelling, or reformatted Washington EPS products.
-C
-      IF ((KSEC1(2).EQ.98.AND.KSEC1(24).EQ.1) .OR.
-     X    (KSEC1(22).EQ.98.AND.KSEC1(24).EQ.1) .OR.
-     X    (KSEC1(2).EQ. 7.AND.KSEC1(22).EQ.98)) THEN
-C
-C       Parameters common to all definitions.
-C
-        WRITE(*,9301) KSEC1(37)
-        IF(KSEC1(37).EQ.1)
-     X    WRITE(*,*) '(Mars labelling or ensemble forecast)'
-        IF(KSEC1(37).EQ.2)
-     X    WRITE(*,*) '(Cluster means and standard deviations)'
-        IF(KSEC1(37).EQ.3)
-     X    WRITE(*,*) '(Satellite image data)'
-        IF(KSEC1(37).EQ.4)
-     X    WRITE(*,*) '(Ocean model data)'
-        IF(KSEC1(37).EQ.5)
-     X    WRITE(*,*) '(Forecast probability data)'
-        IF(KSEC1(37).EQ.6)
-     X    WRITE(*,*) '(Surface temperature data)'
-        IF(KSEC1(37).EQ.7)
-     X    WRITE(*,*) '(Sensitivity data)'
-        IF(KSEC1(37).EQ.8)
-     X    WRITE(*,*) '(ECMWF re-analysis data)'
-        IF(KSEC1(37).EQ.9)
-     X    WRITE(*,*) '(Singular vectors and ensemble perturbations)'
-        IF(KSEC1(37).EQ.10)
-     X    WRITE(*,*) '(EPS tubes)'
-        IF(KSEC1(37).EQ.11)
-     X    WRITE(*,*) '(Supplementary data used by analysis)'
-        IF(KSEC1(37).EQ.13)
-     X    WRITE(*,*) '(Wave 2D spectra direction and frequency)'
-        IF(KSEC1(37).EQ.14)
-     X    WRITE(*,*) '(Brightness temperature)'
-        IF(KSEC1(37).EQ.15)
-     X    WRITE(*,*) '(Ocean ensemble seasonal forecast)'
-        IF(KSEC1(37).EQ.16)
-     X    WRITE(*,*) '(Seasonal forecast monthly mean atmosphere data)'
-        IF(KSEC1(37).EQ.17)
-     X    WRITE(*,*) '(Sst or sea-ice used by analysis)'
-        IF(KSEC1(37).EQ.18)
-     X    WRITE(*,*) '(Multi-analysis ensemble data)'
-C
-        WRITE(*,9302) KSEC1(38)
-        WRITE(*,9303) KSEC1(39)
-        WRITE(*,9304) KSEC1(40)
-        WRITE(HVERSION, '(A8)' ) KSEC1(41)
-#ifdef linux
-        WRITE(*,9305)
-     X    HVERSION(8:8),
-     X    HVERSION(7:7),
-     X    HVERSION(6:6),
-     X    HVERSION(5:5)
-#else
-        WRITE(*,9305) HVERSION(5:8)
-#endif
-C
-C       ECMWF Local definition 1.
-C       (MARS labelling or ensemble forecast data)
-C
-        IF (KSEC1(37).EQ.1) THEN
-          WRITE(*,9310) KSEC1(42)
-          IF( KSEC1(40).NE.1090 ) WRITE(*,9311) KSEC1(43)
-          GOTO 900
-        ENDIF
-C
-C       ECMWF Local definition 2.
-C       (Cluster means and standard deviations)
-C
-        IF (KSEC1(37).EQ.2) THEN
-          WRITE(*,9312) KSEC1(42)
-          WRITE(*,9313) KSEC1(43)
-          WRITE(*,9314) KSEC1(44)
-          WRITE(*,9315) KSEC1(45)
-          WRITE(*,9316) KSEC1(46)
-          WRITE(*,9317) KSEC1(47)
-          WRITE(*,9318) KSEC1(48)
-          WRITE(*,9319) KSEC1(49)
-          WRITE(*,9320) KSEC1(50)
-          WRITE(*,9321) KSEC1(51)
-          WRITE(*,9324) KSEC1(52)
-          WRITE(*,9322) KSEC1(53)
-          DO 210 JLOOP = 1,KSEC1(53)
-            WRITE(*,9323) KSEC1(JLOOP+53)
-  210     CONTINUE
-          GOTO 900
-        ENDIF
-C
-C       ECMWF Local definition 3.
-C       (Satellite image data)
-C
-        IF (KSEC1(37).EQ.3) THEN
-          WRITE(*,9306) KSEC1(42)
-          WRITE(*,9307) KSEC1(43)
-          GOTO 900
-        ENDIF
-C
-C       ECMWF Local definition 4.
-C       (Ocean model data)
-C
-        IF (KSEC1(37).EQ.4) THEN
-          WRITE(*,9310) KSEC1(42)
-          IF( KSEC1(40).NE.1090 ) WRITE(*,9311) KSEC1(43)
-          WRITE(*,9400)
-          WRITE(*,9401) KSEC1(44)
-          WRITE(*,9402) KSEC1(45)
-          WRITE(*,9403) KSEC1(46)
-          WRITE(*,9404) KSEC1(47)
-          WRITE(*,9405) KSEC1(48)
-          WRITE(*,9406) KSEC1(49)
-          WRITE(*,9407) KSEC1(50)
-          WRITE(*,9410)
-          WRITE(*,9411) KSEC1(51)
-          WRITE(*,9412) KSEC1(52)
-          WRITE(*,9413) KSEC1(53)
-          WRITE(*,9414) KSEC1(54)
-          WRITE(*,9415) KSEC1(55)
-          WRITE(*,9416) KSEC1(56)
-          WRITE(*,9413) KSEC1(57)
-          WRITE(*,9414) KSEC1(58)
-          WRITE(*,9415) KSEC1(59)
-          WRITE(*,9420)
-          WRITE(*,9421) KSEC1(60)
-          WRITE(*,9422) KSEC1(61)
-          WRITE(*,9423) KSEC1(62)
-          WRITE(*,9424) KSEC1(63)
-          WRITE(*,9425) KSEC1(64)
-          WRITE(*,9426) KSEC1(65)
-          WRITE(*,9427) KSEC1(66)
-          WRITE(*,9428) KSEC1(67)
-          WRITE(*,9429) KSEC1(68)
-          WRITE(*,9430) KSEC1(69)
-          WRITE(*,9440)
-          WRITE(*,9441) KSEC1(70)
-          WRITE(*,9450)
-          WRITE(*,9451) KSEC1(71)
-          WRITE(*,9452) KSEC1(72)
-          WRITE(*,9453) KSEC1(73)
-          WRITE(*,9454) KSEC1(74)
-C
-C        Horizontal coordinate supplement.
-C
-          WRITE(*,9460)
-          IF( KSEC1(71).EQ.0 ) THEN
-            WRITE(*,*) '(None).'
-          ELSE
-            WRITE(*,*) 'Number of items = ', KSEC1(71)
-            DO JLOOP = 1,KSEC1(71)
-              WRITE(*,9461) KSEC1(74+JLOOP)
-            ENDDO
-          ENDIF
-C
-C        Mixed coordinate definition.
-C
-          WRITE(*,9470)
-          IF( KSEC1(72).EQ.0 ) THEN
-            WRITE(*,*) '(None).'
-          ELSE
-            WRITE(*,*) 'Number of items = ', KSEC1(72)
-            IOFFSET = 74 + KSEC1(71)
-            DO JLOOP = 1,KSEC1(72)
-              WRITE(*,9461) KSEC1(IOFFSET+JLOOP)
-            ENDDO
-          ENDIF
-C
-C        Grid coordinate list.
-C
-          WRITE(*,9480)
-          IF( KSEC1(73).EQ.0 ) THEN
-            WRITE(*,*) '(None).'
-          ELSE
-            WRITE(*,*) 'Number of items = ', KSEC1(73)
-            IOFFSET = 74 + KSEC1(71) + KSEC1(72)
-            DO JLOOP = 1,KSEC1(73)
-              WRITE(*,9461) KSEC1(IOFFSET+JLOOP)
-            ENDDO
-          ENDIF
-C
-C        Auxiliary array.
-C
-          WRITE(*,9490)
-          IF( KSEC1(74).EQ.0 ) THEN
-            WRITE(*,*) '(None).'
-          ELSE
-            WRITE(*,*) 'Number of items = ', KSEC1(74)
-            IOFFSET = 74 + KSEC1(71) + KSEC1(72) + KSEC1(73)
-            DO JLOOP = 1,KSEC1(74)
-              WRITE(*,9461) KSEC1(IOFFSET+JLOOP)
-            ENDDO
-          ENDIF
-C
-C        Post-auxiliary array.
-C
-          WRITE(*,9495)
-          IOFFSET = 74 + KSEC1(71) + KSEC1(72) + KSEC1(73) + KSEC1(74)
-          IF( KSEC1(IOFFSET+1).EQ.0 ) THEN
-            WRITE(*,*) '(None).'
-          ELSE
-            WRITE(*,*) 'Number of items = ', KSEC1(IOFFSET+1)
-            DO JLOOP = 2, KSEC1(IOFFSET+1)
-              WRITE(*,9461) KSEC1(IOFFSET+JLOOP)
-            ENDDO
-          ENDIF
-C
-          GOTO 900
-        ENDIF
-C
-C       ECMWF Local definition 5.
-C       (Forecast probability data)
-C
-        IF (KSEC1(37).EQ.5) THEN
-          WRITE(*,9500) KSEC1(42)
-          WRITE(*,9501) KSEC1(43)
-          WRITE(*,9502) KSEC1(44)
-          WRITE(*,9503) KSEC1(45)
-          IF ( KSEC1(45) .NE. 2 ) WRITE(*,9504) KSEC1(46)
-          IF ( KSEC1(45) .NE. 1 ) WRITE(*,9505) KSEC1(47)
-          GOTO 900
-        ENDIF
-C
-C       ECMWF Local definition 6.
-C       (Surface temperature data)
-C
-        IF (KSEC1(37).EQ.6) THEN
-C
-          IYEAR = KSEC1(44)
-          IF( IYEAR.GT.100 ) THEN
-            IF( IYEAR.LT.19000000 ) IYEAR = IYEAR + 19000000
-            WRITE(*,9601) IYEAR
-          ELSE
-            WRITE(*,*)
-     X        'Date of SST field used               Not given'
-          ENDIF
-          IF(KSEC1(45).EQ.0) WRITE(*,9602) KSEC1(45)
-          IF(KSEC1(45).EQ.1) WRITE(*,9603) KSEC1(45)
-          IF(KSEC1(45).EQ.2) WRITE(*,9604) KSEC1(45)
-C
-          WRITE(*,9605) KSEC1(46)
-C
-          DO 260 JLOOP = 1, KSEC1(46)
-            IYEAR = KSEC1(45+(JLOOP*2))
-            IF( IYEAR.GT.100 ) THEN
-              IF( IYEAR.LT.19000000 ) IYEAR = IYEAR + 19000000
-              WRITE(*,9606) JLOOP, IYEAR
-              WRITE(*,9607) JLOOP, KSEC1(46+(JLOOP*2))
-            ELSE
-              WRITE(*,*)
-     X          'Date of SST field used               Not given'
-            ENDIF
-C
-  260     CONTINUE
-C
-        ENDIF
-C
-C       ECMWF Local definition 7.
-C       (Sensitivity data)
-C
-        IF (KSEC1(37).EQ.7) THEN
-          IF ( KSEC1(39) .EQ. 51 ) WRITE(*,9700) KSEC1(42)
-          IF ( KSEC1(39) .NE. 51 ) WRITE(*,9701) KSEC1(42)
-          IF ( KSEC1(39) .NE. 52 ) WRITE(*,9702) KSEC1(43)
-          IF ( KSEC1(39) .EQ. 52 ) WRITE(*,9703) KSEC1(43)
-          WRITE(*,9704) KSEC1(44) 
-          WRITE(*,9705) KSEC1(45)
-        ENDIF
-C
-C
-C       ECMWF Local definition 8.
-C       (ECMWF re-analysis data)
-C
-        IF (KSEC1(37).EQ.8) THEN
-          IF( (KSEC1(40).EQ.1043).OR.
-     X        (KSEC1(40).EQ.1070).OR.
-     X        (KSEC1(40).EQ.1071) ) THEN
-            WRITE(*,9801) KSEC1(42)
-            DO JLOOP = 43, 54
-              JILOOP = JLOOP + 8
-              WRITE(*,9800) JILOOP, KSEC1(JLOOP)
-            ENDDO
-          ELSE
-            DO JLOOP = 42, 54
-              JILOOP = JLOOP + 8
-              WRITE(*,9800) JILOOP, KSEC1(JLOOP)
-            ENDDO
-          ENDIF
-          GOTO 900
-        ENDIF
-C
-        IF (KSEC1(39).GT.4.AND.KSEC1(39).LT.9) THEN
-          WRITE(*,9308) KSEC1(42)
-          WRITE(*,9309) KSEC1(43)
-        ENDIF
-C
-C
-C       ECMWF Local definition 9.
-C       (Singular vectors and ensemble perturbations)
-C
-        IF (KSEC1(37).EQ.9) THEN
-          IF(KSEC1(39).EQ.60)
-     X      WRITE(*,9960) KSEC1(42)
-          IF(KSEC1(39).EQ.61)
-     X      WRITE(*,9961) KSEC1(42)
-          IF(KSEC1(39).EQ.62)
-     X      WRITE(*,9962) KSEC1(42)
-          IF(KSEC1(39).EQ.62) THEN
-            WRITE(*,9943) KSEC1(43)
-            WRITE(*,9944) KSEC1(44)
-            WRITE(*,9945) KSEC1(45)
-            WRITE(*,9946) KSEC1(46)
-            WRITE(*,9947) KSEC1(47)
-            WRITE(*,9948) KSEC1(48)
-            WRITE(*,9949) KSEC1(49)
-            WRITE(*,9950) KSEC1(50)
-            WRITE(*,9951) KSEC1(51)
-            WRITE(*,9952) KSEC1(52)
-            WRITE(*,9953) KSEC1(53)
-            WRITE(*,9954) KSEC1(54)
-            WRITE(*,9955) KSEC1(55)
-          ENDIF
-        ENDIF
-C
-C
-C       ECMWF Local definition 10.
-C       (EPS tubes)
-C
-        IF (KSEC1(37).EQ.10) THEN
-          WRITE(*,1001) KSEC1(42)
-          WRITE(*,1002) KSEC1(43)
-          WRITE(*,1003) KSEC1(44)
-          WRITE(*,1004) KSEC1(45)
-          WRITE(*,1005) KSEC1(46)
-          WRITE(*,1006) KSEC1(47)
-          WRITE(*,1007) KSEC1(48)
-          WRITE(*,1008) KSEC1(49)
-          WRITE(*,1009) KSEC1(50)
-          WRITE(*,1010) KSEC1(51)
-          WRITE(*,1011) KSEC1(52)
-          WRITE(*,1012) KSEC1(53)
-          WRITE(*,1013) KSEC1(54)
-          WRITE(*,1014) KSEC1(55)
-          WRITE(*,1015) KSEC1(56)
-          WRITE(*,1016) KSEC1(57)
-          WRITE(*,1017) KSEC1(58)
-C
-          WRITE(*,1018)
-          DO 280 JLOOP = 1, KSEC1(58)
-            WRITE(*,1019) KSEC1(58+JLOOP)
-  280     CONTINUE
-        ENDIF
-C
-C
-C       ECMWF Local definition 11.
-C       (Supplementary data used by the analysis)
-C
-        IF (KSEC1(37).EQ.11) THEN
-          WRITE(*,1101)
-          WRITE(*,1103) KSEC1(42)
-          WRITE(*,1104) KSEC1(43)
-          WRITE(*,1105) KSEC1(44)
-          WRITE(HVERSION, '(A8)' ) KSEC1(45)
-#ifdef linux
-          WRITE(*,1106)
-     X      HVERSION(8:8),
-     X      HVERSION(7:7),
-     X      HVERSION(6:6),
-     X      HVERSION(5:5)
-#else
-          WRITE(*,1106) HVERSION(5:8)
-#endif
-          IYEAR = KSEC1(46)
-          IF( IYEAR.GT.50 ) THEN
-            IYEAR = IYEAR + 1900
-          ELSE
-            IYEAR = IYEAR + 2000
-          ENDIF
-          WRITE(*,1107) IYEAR
-          WRITE(*,1108) KSEC1(47)
-          WRITE(*,1109) KSEC1(48)
-          WRITE(*,1110) KSEC1(49)
-          WRITE(*,1111) KSEC1(50)
-          WRITE(*,1112) KSEC1(51)
-          WRITE(*,1113) KSEC1(52)
-          WRITE(*,1114) KSEC1(53)
-        ENDIF
-C
-C
-C       ECMWF Local definition 12.
-C
-        IF (KSEC1(37).EQ.12) THEN
-          WRITE(*,1201)
-          WRITE(*,1203) KSEC1(42)
-          WRITE(*,1204) KSEC1(43)
-          WRITE(*,1205) KSEC1(44)
-          WRITE(*,1206) KSEC1(45)
-          WRITE(*,1207) KSEC1(46)
-          WRITE(*,1208) KSEC1(47)
-          WRITE(*,1209) KSEC1(48)
-          WRITE(*,1210) KSEC1(49)
-          WRITE(*,1211)
-          IPREV  = KSEC1(50)
-          ICURR  = 0
-          ICOUNT = 0
-          DO JLOOP = 1, KSEC1(49)
-            ICURR = KSEC1(49+JLOOP)
-            IF( ICURR.NE.IPREV ) THEN
-              IF( ICOUNT.EQ.1 ) WRITE(*,1212) IPREV
-              IF( ICOUNT.EQ.2 ) WRITE(*,1213) IPREV
-              IF( ICOUNT.GT.2 ) WRITE(*,1214) IPREV, ICOUNT
-              IPREV  = ICURR
-              ICOUNT = 1
-            ELSE
-              ICOUNT = ICOUNT + 1
-            ENDIF
-          ENDDO
-          IF( ICOUNT.EQ.1 ) WRITE(*,1212) IPREV
-          IF( ICOUNT.EQ.2 ) WRITE(*,1213) IPREV
-          IF( ICOUNT.GT.2 ) WRITE(*,1214) IPREV, ICOUNT
-        ENDIF
-C
-C
-C       ECMWF Local definition 13.
-C       (Wave 2D spectra direction and frequency)
-C
-        IF (KSEC1(37).EQ.13) THEN
-          WRITE(*,1301) KSEC1(44)
-          WRITE(*,1302) KSEC1(45)
-          WRITE(*,1303) KSEC1(46)
-          WRITE(*,1304) KSEC1(47)
-          WRITE(*,1305) KSEC1(48)
-          WRITE(*,1306) KSEC1(49)
-          WRITE(*,1307)
-          DO 290 JLOOP = 1, KSEC1(46)
-            VALUE = REAL(KSEC1(49+JLOOP))/REAL(KSEC1(48))
-            IF( KSEC1(44).EQ.JLOOP ) THEN
-              WRITE(*,1308) JLOOP, VALUE
-            ELSE
-              WRITE(*,1309) JLOOP, VALUE
-            ENDIF
-  290     CONTINUE
-          WRITE(*,1310)
-          DO 295 JLOOP = 1, KSEC1(47)
-            VALUE = REAL(KSEC1(49+KSEC1(46)+JLOOP))/REAL(KSEC1(49))
-            IF( KSEC1(45).EQ.JLOOP ) THEN
-              WRITE(*,1308) JLOOP, VALUE
-            ELSE
-              WRITE(*,1309) JLOOP, VALUE
-            ENDIF
-  295     CONTINUE
-          IF( KSEC1(50+KSEC1(46)+KSEC1(47)).NE.0 ) THEN
-            WRITE(*,1311) KSEC1(50+KSEC1(46)+KSEC1(47))
-            WRITE(*,1312) KSEC1(51+KSEC1(46)+KSEC1(47))
-          ENDIF
-        ENDIF
-C
-C       ECMWF Local definition 14.
-C       (Brightness temperature)
-C
-        IF (KSEC1(37).EQ.14) THEN
-          WRITE(*,1401) KSEC1(44)
-          WRITE(*,1402) KSEC1(45)
-          WRITE(*,1403) KSEC1(46)
-          WRITE(*,1404)
-          DO 296 JLOOP = 1, KSEC1(46)
-            VALUE = REAL(KSEC1(46+JLOOP))/REAL(KSEC1(45))
-            IF( KSEC1(44).EQ.JLOOP ) THEN
-              WRITE(*,1405) JLOOP, VALUE
-            ELSE
-              WRITE(*,1406) JLOOP, VALUE
-            ENDIF
-  296     CONTINUE
-        ENDIF
-C
-C       ECMWF Local definition 15.
-C       (Ocean ensemble seasonal forecast)
-C
-        IF (KSEC1(37).EQ.15) THEN
-          WRITE(*,1501) KSEC1(42)
-          WRITE(*,1502) KSEC1(44)
-          WRITE(*,1503) KSEC1(45)
-        ENDIF
-C
-C       ECMWF Local definition 16.
-C       (Seasonal forecast monthly mean atmosphere data)
-C
-        IF (KSEC1(37).EQ.16) THEN
-          WRITE(*,1501) KSEC1(42)
-          WRITE(*,1502) KSEC1(44)
-          WRITE(*,1503) KSEC1(45)
-          WRITE(*,1601) KSEC1(46)
-          WRITE(*,1602) KSEC1(47)
-        ENDIF
-C
-C       ECMWF Local definition 17.
-C       (Sst or sea-ice used by analysis)
-C
-        IF (KSEC1(37).EQ.17) THEN
-C
-          IYEAR = KSEC1(44)
-          IF( IYEAR.GT.100 ) THEN
-            IF( IYEAR.LT.19000000 ) IYEAR = IYEAR + 19000000
-            WRITE(*,1701) IYEAR
-          ELSE
-            WRITE(*,*)
-     X        'Date of sst/ice field used           Not given'
-          ENDIF
-          IF(KSEC1(45).EQ.0) WRITE(*,1702) KSEC1(45)
-          IF(KSEC1(45).EQ.1) WRITE(*,1703) KSEC1(45)
-          IF(KSEC1(45).EQ.2) WRITE(*,1704) KSEC1(45)
-C
-          WRITE(*,1705) KSEC1(46)
-C
-          DO JLOOP = 1, KSEC1(46)
-            IYEAR = KSEC1(45+(JLOOP*2))
-            IF( IYEAR.GT.100 ) THEN
-              IF( IYEAR.LT.19000000 ) IYEAR = IYEAR + 19000000
-              WRITE(*,1706) JLOOP, IYEAR
-              WRITE(*,1707) JLOOP, KSEC1(46+(JLOOP*2))
-            ELSE
-              WRITE(*,*)
-     X          'Date of sst/ice field used           Not given'
-            ENDIF
-C
-          ENDDO
-C
-        ENDIF
-C
-C       ECMWF Local definition 18.
-C       (Multi-analysis ensemble data)
-C
-        IF (KSEC1(37).EQ.18) THEN
-          WRITE(*,1801) KSEC1(42)
-          WRITE(*,1802) KSEC1(43)
-          WRITE(*,1803) KSEC1(44)
-          WRITE(*,1804) KSEC1(45)
-          WRITE(*,1805) KSEC1(46)
-          WRITE(*,*) '  WMO centre analyses used:'
-          WRITE(*,*) '  ------------------------'
-          DO JLOOP = 1, KSEC1(46)
-            WRITE(*,1806) KSEC1(46+JLOOP)
-          ENDDO
-        ENDIF
-C
-C
-      ENDIF
-C
-C     -----------------------------------------------------------------
-C*    Section 3 . Print Washington ensemble product information.
-C     -----------------------------------------------------------------
-C
-  300 CONTINUE
-C
-C     Washington EPS products (but not reformatted Washington EPS
-C     products.
-      IF ((KSEC1(2).EQ.7.AND.KSEC1(24).EQ.1).AND.
-     X    (.NOT.KSEC1(22).EQ.98) ) THEN
-        CALL KWPRS1 (KSEC0,KSEC1)
-      ENDIF
-C
-C
-C     -----------------------------------------------------------------
-C*    Section 9 . Format statements. Return to calling routine.
-C     -----------------------------------------------------------------
-C
-  900 CONTINUE
-C
-      RETURN
-C
- 9000 FORMAT(' ')
- 9001 FORMAT(' Section 1 - Product Definition Section.')
- 9002 FORMAT(' ---------------------------------------')
- 9100 FORMAT(' Code Table 2 Version Number.         ',I9)
- 9101 FORMAT(' Originating centre identifier.       ',I9)
- 9102 FORMAT(' Model identification.                ',I9)
- 9103 FORMAT(' Grid definition.                     ',I9)
- 9104 FORMAT(' Flag (Code Table 1)                   ',I8.8)
- 9105 FORMAT(' Parameter identifier (Code Table 2). ',I9)
- 9106 FORMAT(' Type of level (Code Table 3).        ',I9)
- 9107 FORMAT(' Value 1 of level (Code Table 3).     ',I9)
- 9108 FORMAT(' Value 2 of level (Code Table 3).     ',I9)
- 9109 FORMAT(' Year of reference time of data.      ',I9,'  (',I4,')' )
- 9110 FORMAT(' Month of reference time of data.     ',I9)
- 9111 FORMAT(' Day of reference time of data.       ',I9)
- 9112 FORMAT(' Hour of reference time of data.      ',I9)
- 9113 FORMAT(' Minute of reference time of data.    ',I9)
- 9114 FORMAT(' Time unit (Code Table 4).            ',I9)
- 9115 FORMAT(' Time range one.                      ',I9)
- 9116 FORMAT(' Time range two.                      ',I9)
- 9117 FORMAT(' Time range indicator (Code Table 5)  ',I9)
- 9118 FORMAT(' Number averaged.                     ',I9)
- 9119 FORMAT(' Number missing from average.         ',I9)
- 9120 FORMAT(' Century of reference time of data.   ',I9)
- 9121 FORMAT(' Units decimal scaling factor.        ',I9)
- 9122 FORMAT(' Century of reference time of data.   Not given')
- 9123 FORMAT(' Sub-centre identifier.               ',I9)
- 9206 FORMAT(' Satellite identifier.                ',I9)
- 9207 FORMAT(' Spectral band.                       ',I9)
-C
- 9301 FORMAT(' ECMWF local usage identifier.        ',I9)
- 9302 FORMAT(' Class.                               ',I9)
- 9303 FORMAT(' Type.                                ',I9)
- 9304 FORMAT(' Stream.                              ',I9)
- 9305 FORMAT(' Version number or Experiment identifier.  ',A1,A1,A1,A1)
- 9306 FORMAT(' Satellite spectral band.             ',I9)
- 9307 FORMAT(' Function code.                       ',I9)
- 9308 FORMAT(' Simulation number.                   ',I9)
- 9309 FORMAT(' Total number of simulations.         ',I9)
- 9310 FORMAT(' Forecast number.                     ',I9)
- 9311 FORMAT(' Total number of forecasts.           ',I9)
- 9312 FORMAT(' Cluster number.                      ',I9)
- 9313 FORMAT(' Total number of clusters.            ',I9)
- 9314 FORMAT(' Clustering method.                   ',I9)
- 9315 FORMAT(' Start time step when clustering.     ',I9)
- 9316 FORMAT(' End time step when clustering.       ',I9)
- 9317 FORMAT(' Northern latitude of domain.         ',I9)
- 9318 FORMAT(' Western longitude of domain.         ',I9)
- 9319 FORMAT(' Southern latitude of domain.         ',I9)
- 9320 FORMAT(' Eastern longitude of domain.         ',I9)
- 9321 FORMAT(' Operational forecast in cluster      ',I9)
- 9322 FORMAT(' Number of forecasts in cluster.      ',I9)
- 9323 FORMAT(' Forecast number                      ',I9)
- 9324 FORMAT(' Control forecast in cluster          ',I9)
-C
-C       ECMWF Local definition 4.
-C
- 9400 FORMAT(' Coordinate structure definition.')
- 9401 FORMAT(' System number.                       ',I9)
- 9402 FORMAT(' Method number.                       ',I9)
- 9403 FORMAT(' Space unit flag.                     ',I9)
- 9404 FORMAT(' Vertical coordinate definition.      ',I9)
- 9405 FORMAT(' Horizontal coordinate definition.    ',I9)
- 9406 FORMAT(' Time unit flag.                      ',I9)
- 9407 FORMAT(' Time coordinate definition.          ',I9)
- 9408 FORMAT(' Method used for analysis or forecast.',I9)
-C
- 9410 FORMAT(' Position definition.     ')
- 9411 FORMAT(' Mixed coordinate field flag.         ',I9)
- 9412 FORMAT(' Coordinate 1 flag.                   ',I9)
- 9413 FORMAT(' Averaging flag.                      ',I9)
- 9414 FORMAT(' Position of level 1.                 ',I9)
- 9415 FORMAT(' Position of level 2.                 ',I9)
- 9416 FORMAT(' Coordinate 2 flag.                   ',I9)
-C
- 9420 FORMAT(' Grid Definition.')
- 9421 FORMAT(' Coordinate 3 flag (x-axis)           ',I9)
- 9422 FORMAT(' Coordinate 4 flag (y-axis)           ',I9)
- 9423 FORMAT(' Coordinate 4 of first grid point.    ',I9)
- 9424 FORMAT(' Coordinate 3 of first grid point.    ',I9)
- 9425 FORMAT(' Coordinate 4 of last grid point.     ',I9)
- 9426 FORMAT(' Coordinate 3 of last grid point.     ',I9)
- 9427 FORMAT(' i - increment.                       ',I9)
- 9428 FORMAT(' j - increment.                       ',I9)
- 9429 FORMAT(' Flag for irregular grid coordinates. ',I9)
- 9430 FORMAT(' Flag for normal or staggered grids.  ',I9)
-C
- 9440 FORMAT(' Further information.')
- 9441 FORMAT(' Further information flag.            ',I9)
-C
- 9450 FORMAT(' Auxiliary information.')
- 9451 FORMAT(' No. entries in horizontal coordinate ',I9)
- 9452 FORMAT(' No. entries in mixed coordinate defn.',I9)
- 9453 FORMAT(' No. entries in grid coordinate list. ',I9)
- 9454 FORMAT(' No. entries in auxiliary array.      ',I9)
-C
- 9460 FORMAT(' Horizontal coordinate supplement.')
- 9461 FORMAT('         ',I12)
- 9470 FORMAT(' Mixed coordinate definition.')
- 9480 FORMAT(' Grid coordinate list. ')
- 9490 FORMAT(' Auxiliary array.      ')
- 9495 FORMAT(' Post-auxiliary array. ')
-C
-C       ECMWF Local definition 5.
-C
- 9500 FORMAT(' Forecast probability number          ',I9)
- 9501 FORMAT(' Total number of forecast probabilities ',I7)
- 9502 FORMAT(' Threshold units decimal scale factor ',I9)
- 9503 FORMAT(' Threshold indicator(1=lower,2=upper,3=both) ',I2)
- 9504 FORMAT(' Lower threshold value                ',I9)
- 9505 FORMAT(' Upper threshold value                ',I9)
-C
-C       ECMWF Local definition 6.
-C
- 9601 FORMAT(' Date of SST field used               ',I9)
- 9602 FORMAT(' Type of SST field (= climatology)    ',I9)
- 9603 FORMAT(' Type of SST field (= 1/1 degree)     ',I9)
- 9604 FORMAT(' Type of SST field (= 2/2 degree)     ',I9)
- 9605 FORMAT(' Number of ICE fields used:           ',I9)
- 9606 FORMAT(' Date of ICE field',I3,'                 ',I9)
- 9607 FORMAT(' Satellite number (ICE field',I3,')      ',I9)
-C
-C       ECMWF Local definition 7.
-C
- 9700 FORMAT(' Forecast number                      ',I9)
- 9701 FORMAT(' Iteration number                     ',I9)
- 9702 FORMAT(' Total number of diagnostics          ',I9)
- 9703 FORMAT(' No.interations in diag. minimisation ',I9)
- 9704 FORMAT(' Domain(0=Global,1=Europe,2=N.Hem.,3=S.Hem.) ',I2)
- 9705 FORMAT(' Diagnostic number                    ',I9)
-C
-C       ECMWF Local definition 8.
-C
- 9800 FORMAT(' ERA section 1 octet ',I2,'.              ',I9)
- 9801 FORMAT(' Interval between reference times     ',I9)
-C
-C       ECMWF Local definition 9.
-C
- 9943 FORMAT(' Number of iterations                 ',I9)
- 9944 FORMAT(' Number of singular vectors computed  ',I9)
- 9945 FORMAT(' Norm used at initial time            ',I9)
- 9946 FORMAT(' Norm used at final time              ',I9)
- 9947 FORMAT(' Multiplication factor                ',I9)
- 9948 FORMAT(' Latitude of north-west corner        ',I9)
- 9949 FORMAT(' Longitude of north-west corner       ',I9)
- 9950 FORMAT(' Latitude of south-east corner        ',I9)
- 9951 FORMAT(' Longitude of south-east corner       ',I9)
- 9952 FORMAT(' Accuracy                             ',I9)
- 9953 FORMAT(' Number of singular vectors evolved   ',I9)
- 9954 FORMAT(' Ritz number one                      ',I9)
- 9955 FORMAT(' Ritz number two                      ',I9)
- 9960 FORMAT(' Perturbed ensemble forecast number   ',I9)
- 9961 FORMAT(' Initial state perturbation number    ',I9)
- 9962 FORMAT(' Singular vector number               ',I9)
-C
-C       ECMWF Local definition 10.
-C
- 1001 FORMAT(' Tube number                          ',I9)
- 1002 FORMAT(' Total number of tubes                ',I9)
- 1003 FORMAT(' Central cluster definition           ',I9)
- 1004 FORMAT(' Parameter                            ',I9)
- 1005 FORMAT(' Type of level                        ',I9)
- 1006 FORMAT(' Northern latitude of domain of tubing',I9)
- 1007 FORMAT(' Western longitude of domain of tubing',I9)
- 1008 FORMAT(' Southern latitude of domain of tubing',I9)
- 1009 FORMAT(' Eastern longitude of domain of tubing',I9)
- 1010 FORMAT(' Tube number of operational forecast  ',I9)
- 1011 FORMAT(' Tube number of control forecast      ',I9)
- 1012 FORMAT(' Height/pressure of level             ',I9)
- 1013 FORMAT(' Reference step                       ',I9)
- 1014 FORMAT(' Radius of central cluster            ',I9)
- 1015 FORMAT(' Ensemble standard deviation          ',I9)
- 1016 FORMAT(' Dist.of tube extreme to ensemble mean',I9)
- 1017 FORMAT(' Number of forecasts in the tube      ',I9)
- 1018 FORMAT(' List of ensemble forecast numbers:')
- 1019 FORMAT('    ',I9)
-C
-C       ECMWF Local definition 11.
-C
- 1101 FORMAT(' Details of analysis which used the supplementary data:')
- 1103 FORMAT('   Class                              ',I9)
- 1104 FORMAT('   Type                               ',I9)
- 1105 FORMAT('   Stream                             ',I9)
- 1106 FORMAT('   Version number/experiment identifier:   ',A1,A1,A1,A1)
- 1107 FORMAT('   Year                               ',I9)
- 1108 FORMAT('   Month                              ',I9)
- 1109 FORMAT('   Day                                ',I9)
- 1110 FORMAT('   Hour                               ',I9)
- 1111 FORMAT('   Minute                             ',I9)
- 1112 FORMAT('   Century                            ',I9)
- 1113 FORMAT('   Originating centre                 ',I9)
- 1114 FORMAT('   Sub-centre                         ',I9)
-C
-C       ECMWF Local definition 12.
-C
- 1201 FORMAT(' (Mean, average, etc)') 
- 1203 FORMAT(' Start date of the period              ', I8)
- 1204 FORMAT(' Start time of the period                  ', I4.4)
- 1205 FORMAT(' Finish date of the period             ', I8)
- 1206 FORMAT(' Finish time of the period                 ', I4.4)
- 1207 FORMAT(' Verifying date of the period          ', I8)
- 1208 FORMAT(' Verifying time of the period              ', I4.4)
- 1209 FORMAT(' Code showing method                   ', I8)
- 1210 FORMAT(' Number of different time intervals used  ', I5)
- 1211 FORMAT(' List of different time intervals used:')
- 1212 FORMAT('  - interval ',I5.4, ' used       once')
- 1213 FORMAT('  - interval ',I5.4, ' used       twice')
- 1214 FORMAT('  - interval ',I5.4, ' used ', I5, ' times')
-
-C
-C       ECMWF Local definition 13.
-C
- 1301 FORMAT(' Direction number                     ',I9)
- 1302 FORMAT(' Frequency number                     ',I9)
- 1303 FORMAT(' Total number of directions           ',I9)
- 1304 FORMAT(' Total number of frequencies          ',I9)
- 1305 FORMAT(' Scale factor applied to directions   ',I9)
- 1306 FORMAT(' Scale factor applied to frequencies  ',I9)
- 1307 FORMAT(' List of directions:')
- 1308 FORMAT(' ', I2.2,':', F15.7, '   <-- this field value')
- 1309 FORMAT(' ', I2.2,':', F15.7)
- 1310 FORMAT(' List of frequencies:')
- 1311 FORMAT(' System number (65535 = missing)      ',I9)
- 1312 FORMAT(' Method number (65535 = missing)      ',I9)
-C
-C       ECMWF Local definition 14.
-C
- 1401 FORMAT(' Channel number                       ',I9)
- 1402 FORMAT(' Scale factor applied to frequencies  ',I9)
- 1403 FORMAT(' Total number of frequencies          ',I9)
- 1404 FORMAT(' List of frequencies:')
- 1405 FORMAT(' ', I3,':', F15.9, '   <-- this channel')
- 1406 FORMAT(' ', I3,':', F15.9)
-C
-C       ECMWF Local definition 15.
-C
- 1501 FORMAT(' Ensemble member number               ',I9)
- 1502 FORMAT(' System number                        ',I9)
- 1503 FORMAT(' Method number                        ',I9)
-C
-C       ECMWF Local definition 16.
-C
- 1601 FORMAT(' Verifying month                      ',I9)
- 1602 FORMAT(' Averaging period                     ',I9)
-C
-C       ECMWF Local definition 17.
-C
- 1701 FORMAT(' Date of sst/ice field used           ',I9)
- 1702 FORMAT(' Type of sst/ice field (= climatology)',I9)
- 1703 FORMAT(' Type of sst/ice field (= 1/1 degree) ',I9)
- 1704 FORMAT(' Type of sst/ice field (= 2/2 degree) ',I9)
- 1705 FORMAT(' Number of ICE fields used:           ',I9)
- 1706 FORMAT(' Date of ICE field',I3,'                 ',I9)
- 1707 FORMAT(' Satellite number (ICE field',I3,')      ',I9)
-C
-C       ECMWF Local definition 18.
-C
- 1801 FORMAT(' Ensemble forecast number             ',I9)
- 1802 FORMAT(' Number of forecasts in ensemble      ',I9)
- 1803 FORMAT(' Data origin                          ',I9)
- 1804 FORMAT(' Model identifier of forecast used         ',A4)
- 1805 FORMAT(' Number of analyses in start analysis ',I9)
- 1806 FORMAT('   ',A4)
-C
-      END
diff --git a/tools/grib1profile/grprs4n.F b/tools/grib1profile/grprs4n.F
deleted file mode 100644
index 3535355..0000000
--- a/tools/grib1profile/grprs4n.F
+++ /dev/null
@@ -1,305 +0,0 @@
-      SUBROUTINE GRPRS4N(KSEC0,KSEC2,KSEC4,PSEC4)
-C
-C**** GRPRS4N - Print information from Section 4 of GRIB code.
-C
-C     Purpose.
-C     --------
-C
-C           Print the information in the Binary data section
-C           Section (Section 4) of decoded GRIB data.
-C
-C**   Interface.
-C     ----------
-C
-C           CALL GRPRS4N(KSEC0,KSEC2,KSEC4,PSEC4)
-C
-C           Integer    K.
-C           Real       P.
-C           Logical    O.
-C           Character  H.
-C
-C               Input Parameters.
-C               -----------------
-C
-C               KSEC0 - Array of decoded integers from Section 0.
-C
-C               KSEC2 - Array of decoded integers from Section 2.
-C
-C               KSEC4 - Array of decoded integers from Section 4.
-C
-C               PSEC4 - Array of decoded reals from Section 4.
-C
-C               Output Parameters.
-C               ------------------
-C
-C               None.
-C
-C     Method.
-C     -------
-C
-C           Fields printed as integers or reals.
-C
-C     Externals.
-C     ----------
-C
-C           SETPAR
-C           INXBIT.
-C
-C     Reference.
-C     ----------
-C
-C           WMO Manual on Codes re GRIB Code.
-C           See also routine GRIBEX.
-C
-C     Comments.
-C     ---------
-C
-C           Routine contains Sections 0 to 1 and Section 9.
-C
-C     Author.
-C     -------
-C
-C           J. Hennessy    ECMWF 11.09.91
-C
-C     Modifications.
-C     --------------
-C
-C
-C     J. Hennessy    ECMWF 21.07.92
-C
-C     J.D.Chambers   ECMWF 20.10.93
-C     Distinguish between real and integer values
-C     in print of gridpoint values
-C
-C     J.D.Chambers   ECMWF 09.05.94
-C     Print complex packing information
-C
-C     J.D.Chambers   ECMWF 14.06.95
-C     Change format for printing missing data indicator to
-C     allow for MAGICS value (-1.5E+21)
-C
-C     J. Clochard, Meteo France, for ECMWF - January 1998.
-C     Take into account second-order packing for grid-point data.
-C
-C     -----------------------------------------------------------------
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------
-C
-      IMPLICIT NONE
-C
-      INTEGER INUM
-C
-      INTEGER IVALUE, IBIT, IDUM, INSPT, IRET
-#ifdef REAL_8
-      INTEGER*8 JDCVAL(5)
-      REAL RJDCVAL(5)
-      EQUIVALENCE (JDCVAL(1),RJDCVAL(1))
-#else
-      INTEGER JDCVAL(5)
-#endif
-C
-      INTEGER KSEC0
-      INTEGER KSEC2
-      INTEGER KSEC4
-C
-      DIMENSION KSEC0(*)
-      DIMENSION KSEC2(*)
-      DIMENSION KSEC4(*)
-C
-      REAL PSEC4(*)
-C
-      INTEGER LOOP1, LOOP2, START, IEND, IREST
-      LOGICAL LMATRIX
-C
-C     -----------------------------------------------------------------
-C*    Section 1 . Print integer information from KSEC4.
-C     -----------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WRITE (*,9000)
-      WRITE (*,9001)
-      WRITE (*,9002)
-C
-      WRITE (*,9003) KSEC4(1)
-      WRITE (*,9004) KSEC4(2)
-      WRITE (*,9005) KSEC4(3)
-      WRITE (*,9006) KSEC4(4)
-      WRITE (*,9007) KSEC4(5)
-      WRITE (*,9008) KSEC4(6)
-      WRITE (*,9009) KSEC4(7)
-      WRITE (*,9010) KSEC4(8)
-      WRITE (*,9011) KSEC4(9)
-      WRITE (*,9012) KSEC4(10)
-C
-C     If complex packing ..
-C
-      IF ( KSEC4(4).EQ.64 ) THEN
-C
-        IF ( KSEC4(3).EQ.128 ) THEN
-          WRITE (*,9116) KSEC4(16)
-          WRITE (*,9117) KSEC4(17)
-          WRITE (*,9118) KSEC4(18)
-          WRITE (*,9119) KSEC4(19)
-          WRITE (*,9120) KSEC4(20)
-        ELSE
-          WRITE (*,9013) KSEC4(11)
-          WRITE (*,9014) KSEC4(12)
-          WRITE (*,9015) KSEC4(13)
-          WRITE (*,9016) KSEC4(14)+KSEC4(15)
-        ENDIF
-C
-      ENDIF
-C
-C     Number of non-missing values
-C
-      IF ( KSEC4(21).NE.0 )  WRITE (*,9017) KSEC4(21)
-C
-C     Information on matrix of values , if present.
-C
-      LMATRIX = (KSEC4(8).EQ.64)
-      IF ( LMATRIX ) THEN
-        WRITE (*,9020) KSEC4(50)
-        WRITE (*,9021) KSEC4(51)
-        WRITE (*,9022) KSEC4(52)
-        WRITE (*,9023)
-        WRITE (*,9024) KSEC4(53)
-        WRITE (*,9025) KSEC4(54)
-        WRITE (*,9023)
-        WRITE (*,9026) KSEC4(55)
-        WRITE (*,9027) KSEC4(56)
-        WRITE (*,9028) KSEC4(57)
-      ENDIF
-C
-C     -----------------------------------------------------------------
-C*    Section 2. Print values from PSEC4.
-C     -----------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      WRITE (*,9000)
-C
-      INUM = KSEC4(1)
-      IF (INUM.LT.0)  INUM = - INUM
-      IF (INUM.GT.600000) INUM = 600000
-C
-C     Print first INUM values.
-C
-      WRITE (*,*) ' First ',INUM,' data values.'
-      WRITE (*,*)
-C
-C
-      IF ( KSEC4(5) .EQ. 0 ) THEN
-C
-C     Print real values ...
-C
-        IEND = (INUM/5)*5
-        DO LOOP1 = 1, IEND, 5
-          WRITE(*,5000) PSEC4(LOOP1),PSEC4(LOOP1+1),
-     X                  PSEC4(LOOP1+2),PSEC4(LOOP1+3),
-     X                  PSEC4(LOOP1+4)
-        ENDDO
-C
-        IREST = INUM - IEND
-        IF( IREST.EQ.4 ) THEN
-          WRITE(*,5000) PSEC4(IEND+1),PSEC4(IEND+2),
-     X                  PSEC4(IEND+3),PSEC4(IEND+4)
-        ELSE IF( IREST.EQ.3 ) THEN
-          WRITE(*,5000) PSEC4(IEND+1),PSEC4(IEND+2),PSEC4(IEND+3)
-        ELSE IF( IREST.EQ.2 ) THEN
-          WRITE(*,5000) PSEC4(IEND+1),PSEC4(IEND+2)
-        ELSE IF( IREST.EQ.1 ) THEN
-          WRITE(*,5000) PSEC4(IEND+1)
-        ENDIF
-C
-      ELSE
-C
-C       Print integer values ...
-C
-        IBIT = 32
-        IEND = (INUM/5)*5
-        DO LOOP1 = 1, IEND, 5
-          DO LOOP2 = 1, 5
-#ifdef REAL_8
-            RJDCVAL(LOOP2) = PSEC4(LOOP1+LOOP2-1)
-#else
-            INSPT = 0
-            CALL INXBIT(JDCVAL(LOOP2),5,INSPT,PSEC4(LOOP1+LOOP2-1),1,
-     X                  IBIT,IBIT,'C',IRET)
-#endif
-          ENDDO
-          WRITE(*,5001)
-     X      JDCVAL(1),JDCVAL(2),JDCVAL(3),JDCVAL(4),JDCVAL(5)
-        ENDDO
-C
-        IREST = INUM - IEND
-        DO LOOP2 = 1, IREST
-#ifdef REAL_8
-          RJDCVAL(LOOP2) = PSEC4(LOOP1+LOOP2-1)
-#else
-          INSPT = 0
-          CALL INXBIT(JDCVAL(LOOP2),5,INSPT,PSEC4(LOOP1+LOOP2-1),1,
-     X                IBIT,IBIT,'C',IRET)
-#endif
-C
-        ENDDO
-        IF( IREST.EQ.4 ) THEN
-          WRITE(*,5001) JDCVAL(1),JDCVAL(2),JDCVAL(3),JDCVAL(4)
-        ELSE IF( IREST.EQ.3 ) THEN
-          WRITE(*,5001) JDCVAL(1),JDCVAL(2),JDCVAL(3)
-        ELSE IF( IREST.EQ.2 ) THEN
-          WRITE(*,5001) JDCVAL(1),JDCVAL(2)
-        ELSE IF( IREST.EQ.1 ) THEN
-          WRITE(*,5001) JDCVAL(1)
-        ENDIF
-C
-      ENDIF
-C
-C     -----------------------------------------------------------------
-C*    Section 9 . Format statements. Return to calling routine.
-C     -----------------------------------------------------------------
-C
-  900 CONTINUE
-C
- 5000 FORMAT(5(1X,F20.12))
- 5001 FORMAT(5(1X,I20))
- 9000 FORMAT(' ')
- 9001 FORMAT(' Section 4 - Binary Data  Section.')
- 9002 FORMAT(' -------------------------------------')
- 9003 FORMAT(' Number of data values coded/decoded.         ',I9)
- 9004 FORMAT(' Number of bits per data value.               ',I9)
- 9005 FORMAT(' Type of data       (0=grid pt, 128=spectral).',I9)
- 9006 FORMAT(' Type of packing    (0=simple, 64=complex).   ',I9)
- 9007 FORMAT(' Type of data       (0=float, 32=integer).    ',I9)
- 9008 FORMAT(' Additional flags   (0=none, 16=present).     ',I9)
- 9009 FORMAT(' Reserved.                                    ',I9)
- 9010 FORMAT(' Number of values   (0=single, 64=matrix).    ',I9)
- 9011 FORMAT(' Secondary bit-maps (0=none, 32=present).     ',I9)
- 9012 FORMAT(' Values width       (0=constant, 16=variable).',I9)
- 9013 FORMAT(' Bits number of 2nd order values    (none=>0).',I9)
- 9014 FORMAT(' General extend. 2-order packing (0=no,8=yes).',I9)
- 9015 FORMAT(' Boustrophedonic ordering        (0=no,4=yes).',I9)
- 9016 FORMAT(' Spatial differencing order          (0=none).',I9)
- 9017 FORMAT(' Number of non-missing values                 ',I9)
- 9120 FORMAT(' Pentagonal resolution parameter M for subset.',I9)
- 9020 FORMAT(' First dimension (rows) of each matrix.       ',I9)
- 9021 FORMAT(' Second dimension (columns) of each matrix.   ',I9)
- 9022 FORMAT(' First dimension coordinate values definition.',I9)
- 9023 FORMAT(' (Code Table 12)')
- 9024 FORMAT(' NC1 - Number of coefficients for 1st dimension.',I7)
- 9025 FORMAT(' Second dimension coordinate values definition.',I8)
- 9026 FORMAT(' NC2 - Number of coefficients for 2nd dimension.',I7)
- 9027 FORMAT(' 1st dimension physical signifance (Table 13). ',I8)
- 9028 FORMAT(' 2nd dimension physical signifance (Table 13). ',I8)
- 9031 FORMAT(' First ',I4,' data values.')
- 9032 FORMAT(' ',F30.15)
-C
- 9033 FORMAT(' ',I15)
-C
- 9116 FORMAT(' Byte offset of start of packed data (N).     ',I9)
- 9117 FORMAT(' Power (P * 1000).                            ',I9)
- 9118 FORMAT(' Pentagonal resolution parameter J for subset.',I9)
- 9119 FORMAT(' Pentagonal resolution parameter K for subset.',I9)
-      RETURN
-C
-      END
diff --git a/tools/grib1profile/grprs4n.f.dead b/tools/grib1profile/grprs4n.f.dead
deleted file mode 100644
index 94941de..0000000
--- a/tools/grib1profile/grprs4n.f.dead
+++ /dev/null
@@ -1,271 +0,0 @@
-      SUBROUTINE GRPRS4N(KSEC0,KSEC2,KSEC4,PSEC4)
-C
-C**** GRPRS4N - Print information from Section 4 of GRIB code.
-C
-C     Purpose.
-C     --------
-C
-C           Print the information in the Binary data section
-C           Section (Section 4) of decoded GRIB data.
-C
-C**   Interface.
-C     ----------
-C
-C           CALL GRPRS4N(KSEC0,KSEC2,KSEC4,PSEC4)
-C
-C           Integer    K.
-C           Real       P.
-C           Logical    O.
-C           Character  H.
-C
-C               Input Parameters.
-C               -----------------
-C
-C               KSEC0 - Array of decoded integers from Section 0.
-C
-C               KSEC2 - Array of decoded integers from Section 2.
-C
-C               KSEC4 - Array of decoded integers from Section 4.
-C
-C               PSEC4 - Array of decoded reals from Section 4.
-C
-C               Output Parameters.
-C               ------------------
-C
-C               None.
-C
-C     Method.
-C     -------
-C
-C           Fields printed as integers or reals.
-C
-C     Externals.
-C     ----------
-C
-C           SETPAR
-C           INXBIT.
-C
-C     Reference.
-C     ----------
-C
-C           WMO Manual on Codes re GRIB Code.
-C           See also routine GRIBEX.
-C
-C     Comments.
-C     ---------
-C
-C           Routine contains Sections 0 to 1 and Section 9.
-C
-C     Author.
-C     -------
-C
-C           J. Hennessy    ECMWF 11.09.91
-C
-C     Modifications.
-C     --------------
-C
-C
-C     J. Hennessy    ECMWF 21.07.92
-C
-C     J.D.Chambers   ECMWF 20.10.93
-C     Distinguish between real and integer values
-C     in print of gridpoint values
-C
-C     J.D.Chambers   ECMWF 09.05.94
-C     Print complex packing information
-C
-C     J.D.Chambers   ECMWF 14.06.95
-C     Change format for printing missing data indicator to
-C     allow for MAGICS value (-1.5E+21)
-C
-C     J. Clochard, Meteo France, for ECMWF - January 1998.
-C     Take into account second-order packing for grid-point data.
-C
-C     -----------------------------------------------------------------
-C*    Section 0. Definition of variables.
-C     -----------------------------------------------------------------
-C
-      IMPLICIT NONE
-C
-      INTEGER INUM
-C
-      INTEGER J210, J211, J212, IVALUE, IBIT, IDUM, INSPT, IRET
-      INTEGER JDCVAL
-      DIMENSION JDCVAL(5)
-C
-      INTEGER KSEC0
-      INTEGER KSEC2
-      INTEGER KSEC4
-C
-      REAL PSEC4
-C
-      DIMENSION KSEC0(*)
-      DIMENSION KSEC2(*)
-      DIMENSION KSEC4(*)
-C
-      DIMENSION PSEC4(*)
-C
-      INTEGER LOOP1, LOOP2, START, END
-      LOGICAL LQUASI, LMATRIX, LLLORGG
-C
-C     -----------------------------------------------------------------
-C*    Section 1 . Print integer information from KSEC4.
-C     -----------------------------------------------------------------
-C
-  100 CONTINUE
-C
-      WRITE (*,9000)
-      WRITE (*,9001)
-      WRITE (*,9002)
-C
-      WRITE (*,9003) KSEC4(1)
-      WRITE (*,9004) KSEC4(2)
-      WRITE (*,9005) KSEC4(3)
-      WRITE (*,9006) KSEC4(4)
-      WRITE (*,9007) KSEC4(5)
-      WRITE (*,9008) KSEC4(6)
-      WRITE (*,9009) KSEC4(7)
-      WRITE (*,9010) KSEC4(8)
-      WRITE (*,9011) KSEC4(9)
-      WRITE (*,9012) KSEC4(10)
-C
-C     If complex packing ..
-C
-      IF ( KSEC4(4).EQ.64 ) THEN
-C
-        IF ( KSEC4(3).EQ.128 ) THEN
-          WRITE (*,9116) KSEC4(16)
-          WRITE (*,9117) KSEC4(17)
-          WRITE (*,9118) KSEC4(18)
-          WRITE (*,9119) KSEC4(19)
-          WRITE (*,9120) KSEC4(20)
-        ELSE
-          WRITE (*,9013) KSEC4(11)
-          WRITE (*,9014) KSEC4(12)
-          WRITE (*,9015) KSEC4(13)
-          WRITE (*,9016) KSEC4(14)+KSEC4(15)
-        ENDIF
-C
-      ENDIF
-C
-C     Number of non-missing values
-C
-      IF ( KSEC4(21).NE.0 )  WRITE (*,9017) KSEC4(21)
-C
-C     Information on matrix of values , if present.
-C
-      LMATRIX = (KSEC4(8).EQ.64)
-      IF ( LMATRIX ) THEN
-        WRITE (*,9020) KSEC4(50)
-        WRITE (*,9021) KSEC4(51)
-        WRITE (*,9022) KSEC4(52)
-        WRITE (*,9023)
-        WRITE (*,9024) KSEC4(53)
-        WRITE (*,9025) KSEC4(54)
-        WRITE (*,9023)
-        WRITE (*,9026) KSEC4(55)
-        WRITE (*,9027) KSEC4(56)
-        WRITE (*,9028) KSEC4(57)
-      ENDIF
-C
-C     -----------------------------------------------------------------
-C*    Section 2. Print values from PSEC4.
-C     -----------------------------------------------------------------
-C
-  200 CONTINUE
-C
-      WRITE (*,9000)
-C
-      INUM = KSEC4(1)
-      IF (INUM.LT.0)  INUM = - INUM
-      IF (INUM.GT.600000) INUM = 600000
-C
-C     Print first INUM values.
-C
-      WRITE (*,*) ' First ',INUM,' data values.'
-      WRITE (*,*)
-C
-C
-      LQUASI = (KSEC2(17) .EQ. 1)
-      LLLORGG = ((KSEC2(1) .EQ. 0 ) .OR. (KSEC2(1) .EQ. 4 ))
-      IF ( KSEC4(5) .EQ. 0 ) THEN
-C
-C     Print real values ...
-C
-        IF ( LLLORGG .AND. (.NOT. LQUASI ) .AND. (.NOT. LMATRIX ) ) THEN
-          WRITE(*,'(7X,320(8X,I6,7X))') (LOOP1, LOOP1 = 1, KSEC2(2))
-          WRITE(*,*)
-
-          DO LOOP1 = 1, KSEC2(3)
-            START = (LOOP1-1)*KSEC2(2)+1
-            END   = START + KSEC2(2) -1
-            WRITE(*,'(I4,3X,320(1X,F20.12))')
-     X        LOOP1,(PSEC4(LOOP2), LOOP2=START,END )
-          ENDDO
-C
-        ELSE
-          WRITE(*, '(5(1X,F20.12))' ) (PSEC4(J210), J210=1,INUM )
-        ENDIF
-C
-      ELSE
-C
-C     Print integer values ...
-C
-        IBIT = 32
-        CALL SETPAR(IBIT,IDUM,IDUM)
-        DO 212 J212=1,INUM,5
-           DO 211 J211 = 1, 5
-           INSPT = 32
-           CALL INXBIT(PSEC4(J212+j211-1),2,INSPT,JDCVAL(J211),1,IBIT,
-     X                 IBIT, 'D',IRET)
-211        CONTINUE
-           WRITE (*,'(5(1X,I12))') (JDCVAL(J211), J211=1,5)
-  212   CONTINUE
-      ENDIF
-C
-C     -----------------------------------------------------------------
-C*    Section 9 . Format statements. Return to calling routine.
-C     -----------------------------------------------------------------
-C
-  900 CONTINUE
-C
- 9000 FORMAT(' ')
- 9001 FORMAT(' Section 4 - Binary Data  Section.')
- 9002 FORMAT(' -------------------------------------')
- 9003 FORMAT(' Number of data values coded/decoded.         ',I9)
- 9004 FORMAT(' Number of bits per data value.               ',I9)
- 9005 FORMAT(' Type of data       (0=grid pt, 128=spectral).',I9)
- 9006 FORMAT(' Type of packing    (0=simple, 64=complex).   ',I9)
- 9007 FORMAT(' Type of data       (0=float, 32=integer).    ',I9)
- 9008 FORMAT(' Additional flags   (0=none, 16=present).     ',I9)
- 9009 FORMAT(' Reserved.                                    ',I9)
- 9010 FORMAT(' Number of values   (0=single, 64=matrix).    ',I9)
- 9011 FORMAT(' Secondary bit-maps (0=none, 32=present).     ',I9)
- 9012 FORMAT(' Values width       (0=constant, 16=variable).',I9)
- 9013 FORMAT(' Bits number of 2nd order values    (none=>0).',I9)
- 9014 FORMAT(' General extend. 2-order packing (0=no,8=yes).',I9)
- 9015 FORMAT(' Boustrophedonic ordering        (0=no,4=yes).',I9)
- 9016 FORMAT(' Spatial differencing order          (0=none).',I9)
- 9017 FORMAT(' Number of non-missing values                 ',I9)
- 9120 FORMAT(' Pentagonal resolution parameter M for subset.',I9)
- 9020 FORMAT(' First dimension (rows) of each matrix.       ',I9)
- 9021 FORMAT(' Second dimension (columns) of each matrix.   ',I9)
- 9022 FORMAT(' First dimension coordinate values definition.',I9)
- 9023 FORMAT(' (Code Table 12)')
- 9024 FORMAT(' NC1 - Number of coefficients for 1st dimension.',I7)
- 9025 FORMAT(' Second dimension coordinate values definition.',I8)
- 9026 FORMAT(' NC2 - Number of coefficients for 2nd dimension.',I7)
- 9027 FORMAT(' 1st dimension physical signifance (Table 13). ',I8)
- 9028 FORMAT(' 2nd dimension physical signifance (Table 13). ',I8)
- 9031 FORMAT(' First ',I4,' data values.')
- 9032 FORMAT(' ',F30.15)
-C
- 9033 FORMAT(' ',I15)
-C
- 9116 FORMAT(' Byte offset of start of packed data (N).     ',I9)
- 9117 FORMAT(' Power (P * 1000).                            ',I9)
- 9118 FORMAT(' Pentagonal resolution parameter J for subset.',I9)
- 9119 FORMAT(' Pentagonal resolution parameter K for subset.',I9)
-      RETURN
-C
-      END
diff --git a/tools/grib1profile/jpgrib.c b/tools/grib1profile/jpgrib.c
deleted file mode 100644
index b717145..0000000
--- a/tools/grib1profile/jpgrib.c
+++ /dev/null
@@ -1,391 +0,0 @@
-#include "mars.h"
-#include "grib.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define GRIBEX gribex
-#define GRPRS0 grprs0
-#define GRPRS1 grprs1
-#define GRPRS2 grprs2
-#define GRPRS3 grprs3
-#define GRPRS4 grprs4
-#define GRPRS4N grprs4n
-#define GRPRS4W grprs4w
-#else
-#define GRIBEX gribex_
-#define GRPRS0 grprs0_
-#define GRPRS1 grprs1_
-#define GRPRS2 grprs2_
-#define GRPRS3 grprs3_
-#define GRPRS4 grprs4_
-#define GRPRS4N grprs4n_
-#define GRPRS4W grprs4w_
-#endif
-
-long isec0[2];
-long isec1[1024];
-long isec2[3048];
-long isec3[2];
-long isec4[1024];
-#ifdef REAL_8
-double zsec2[2048];
-double zsec3[2];
-double zsec4[RSECTION_4+ 8000000];
-#else
-float zsec2[2048];
-float zsec3[2];
-float zsec4[RSECTION_4+ 8000000];
-#endif
-
-#define LEN 2048
-#define BUFLEN (10*1024*1024)
-#define ENDFILE -1
-#define TOOBIG -3
-
-#ifdef __uxp__
-MAIN__( int argc, char ** argv)
-#else
-main( int argc, char ** argv)
-#endif
-{
-static char * buffer;
-static long bufferSize = BUFLEN;
-long length;
-long ipunp,ierr,jpack,iword;
-int status;
-long position;
-FILE *f;
-int loop;
-int missing, first, countNonMissing;
-
-long imax, imin, iaverage;
-#if (defined REAL_8) && (defined RS6000)
-long ivalue[2];
-#else
-long ivalue;
-#endif
-long intMissingValue;
-
-#ifdef REAL_8
-double max, min, average;
-double floatMissingValue;
-#else
-float max, min, average;
-float floatMissingValue;
-#endif
-int maxIndex = 0, minIndex = 0;
-
-  if(argc < 2) {
-    printf("Usage: pgrib filename\nOr:    pgrib filename offset\n");
-    exit(0);
-  }
-
-  buffer = (char *) malloc(bufferSize);
-  if( buffer == NULL ) {
-    perror("Problem mallocing buffer space");
-    exit(1);
-  }
-/*
-// Open file.
-*/
-  f = fopen(argv[1],"r");
-  if( f == NULL ) {
-    perror("Unable to open requested file");
-    exit(1);
-  }
-/*
-// Position to the required byte offset, if any.
-*/
-  if(argc > 2) {
-    status = fseek(f,atol(argv[2]),0);
-    if( status != 0 ) {
-      perror("Problem positioning file");
-      exit(1);
-    }
-  }
-/*
-// Read product.
-*/
-  do {
-    position = ftell(f);
-    length = bufferSize;
-    status = readany(f,buffer,&length);
-/*
-// If product too big for the buffer...
-*/
-    while ( status == TOOBIG ) {
-      bufferSize *= 2;
-      buffer = (char *) realloc(buffer, bufferSize);
-      if( buffer == NULL ) {
-        perror("Problem reallocing buffer space");
-        exit(1);
-      }
-      status = fseek(f,position,0);
-      if( status != 0 ) {
-        perror("Problem positioning file");
-        exit(1);
-      }
-      length = bufferSize;
-      status = readany(f,buffer,&length);
-    }
-/*
-// If not end-of-file
-*/
-    if ( status != ENDFILE ) {
-      ipunp  = NUMBER(zsec4);
-      ierr   = 1;
-      jpack  = (length+sizeof(long)-1) / sizeof(long);
-
-      isec3[0] = 0;
-      isec3[1] = LONG_MIN;
-#ifdef REAL_8
-      zsec3[1] = (double) LONG_MIN;
-#else
-      zsec3[1] = (float) LONG_MIN;
-#endif
-/*
-// Decode the product.
-*/
-      GRIBEX(isec0,isec1,isec2,zsec2,isec3,zsec3,isec4,
-             zsec4,&ipunp,buffer,&jpack,&iword,"D",&ierr,1);
-/*
-// Print sections 0 and 1.
-*/
-      GRPRS0(isec0);
-      GRPRS1(isec0,isec1);
-/*
-// Print sections 2 and 3, if they exist.
-*/
-      if (isec1[4] == 0 || isec1[4] == 64) {
-        printf("\n No section 2 in grib message\n");
-        printf(" ----------------------------\n");
-      }
-      else
-        GRPRS2(isec0,isec2,zsec2);
-
-      if (isec1[4] == 0 || isec1[4] == 128) {
-        printf("\n No section 3 in grib message\n");
-        printf(" ----------------------------\n");
-        missing = 0;
-      }
-      else {
-        GRPRS3(isec0,isec3,zsec3);
-        missing = 1;
-      }
-/*
-// Print section 4.
-*/
-      GRPRS4N(isec0,isec2,isec4,zsec4);
-/*
-// If wave 2D spectra, print extra coefficients
-*/
-      if( (isec1[0]==140) && (isec1[1]==98) &&
-        ( (isec1[5] == 250) || (isec1[5] == 251) ) )
-        GRPRS4W(isec4);
-
-      printf("\n\n----------------- End of product ----------------------------\n\n");
-
-/*
-// Calculate max/min/average for field
-*/
-      if( isec4[4] == 0 ) {
-/*
-//      Floating point values ...
-*/
-        if( missing ) {
-          floatMissingValue = zsec3[1];
-          first = 0;
-          while ( (zsec4[first] == floatMissingValue) && (first < isec4[0]) )
-            first++;
-
-          if( first == (isec4[0]-1) )
-            printf("max = undefined (all values in the field are missing)\n");
-          else {
-            average = zsec4[first];
-            max = min = zsec4[first];
-            maxIndex = minIndex = first;
-            countNonMissing = 1;
-
-            for( loop = (first+1); loop < isec4[0]; loop++ ) {
-              if( zsec4[loop] != floatMissingValue ) {
-                countNonMissing++;
-                average += zsec4[loop];
-                if( zsec4[loop] > max ) {
-                  max = zsec4[loop];
-                  maxIndex = loop;
-                }
-                if( zsec4[loop] < min ) {
-                  min = zsec4[loop];
-                  minIndex = loop;
-                }
-              }
-            }
-            average /= countNonMissing;
-            printf("max = %f (value %d), min = %f (value %d), average = %f\n",max,(maxIndex+1),min,(minIndex+1),average);
-          }
-        }
-        else {
-          average = zsec4[0];
-          max = min = zsec4[0];
-
-            for( loop = 1; loop < isec4[0]; loop++ ) {
-              average += zsec4[loop];
-              if( zsec4[loop] > max ) {
-                max = zsec4[loop];
-                maxIndex = loop;
-              }
-              if( zsec4[loop] < min ) {
-                min = zsec4[loop];
-                minIndex = loop;
-              }
-            }
-            average /= isec4[0];
-            printf("max = %f (value %d), min = %f (value %d), average = %f\n",max,(maxIndex+1),min,(minIndex+1),average);
-         }
-       }
-
-      else {
-/*
-//      Integer values ...
-*/
-#if (defined REAL_8) && (defined RS6000)
-        if( missing ) {
-          intMissingValue = isec3[1];
-
-          for( first = 0; first < isec4[0]; first++ ) {
-            memcpy(ivalue,&zsec4[first],8);
-            if( ivalue[1] != intMissingValue ) break;
-          }
-
-          if( first == (isec4[0]-1) )
-            printf("max = undefined (all values in the field are missing)\n");
-          else {
-            iaverage = ivalue[first];
-            imax = imin = ivalue[first];
-            countNonMissing = 1;
-
-            for( loop = (first+1); loop < isec4[0]; loop++ ) {
-              memcpy(ivalue,&zsec4[loop],8);
-              if( ivalue[1] != intMissingValue ) {
-                countNonMissing++;
-                iaverage += ivalue[1];
-                if( ivalue[1] > imax ) {
-                  imax = ivalue[1];
-                  maxIndex = loop;
-                }
-                if( ivalue[1] < imin ) {
-                  imin = ivalue[1];
-                  minIndex = loop;
-                }
-              }
-              }
-#ifdef REAL_8
-            average = (double) iaverage / (double) countNonMissing;
-#else
-            average = (float) iaverage / (float) countNonMissing;
-#endif
-          }
-        }
-        else {
-          memcpy(ivalue,&zsec4[0],8);
-          iaverage = ivalue[1];
-          imax = imin = ivalue[1];
-          for( loop = 1; loop < isec4[0]; loop++ ) {
-            memcpy(ivalue,&zsec4[loop],8);
-            iaverage += ivalue[1];
-            if( ivalue[1] > imax ) {
-              imax = ivalue[1];
-              maxIndex = loop;
-            }
-            if( ivalue[1] < imin ) {
-              imin = ivalue[1];
-              minIndex = loop;
-            }
-          }
-#ifdef REAL_8
-          average = (double) iaverage / (double) isec4[0];
-#else
-          average = (float) iaverage / (float) isec4[0];
-#endif
-        }
-#else
-        if( missing) {
-          intMissingValue = isec3[1];
-
-          for( first = 0; first < isec4[0]; first++ ) {
-            memcpy(&ivalue,&zsec4[first],sizeof(ivalue));
-            if( ivalue != intMissingValue ) break;
-          }
-
-          if( first == (isec4[0]-1) )
-            printf("max = undefined (all values in the field are missing)\n");
-          else {
-            iaverage = ivalue;
-            imax = imin = ivalue;
-            maxIndex = minIndex = first;
-            countNonMissing = 1;
-
-            for( loop = (first+1); loop < isec4[0]; loop++ ) {
-              memcpy(&ivalue,&zsec4[loop],sizeof(ivalue));
-              if( ivalue != intMissingValue ) {
-                countNonMissing++;
-                iaverage += ivalue;
-                if( ivalue > imax ) {
-                  imax = ivalue;
-                  maxIndex = loop;
-                }
-                if( ivalue < imin ) {
-                  imin = ivalue;
-                  minIndex = loop;
-                }
-              }
-            }
-#ifdef REAL_8
-            average = (double) iaverage / (double) countNonMissing;
-#else
-            average = (float) iaverage / (float) countNonMissing;
-#endif
-          }
-        }
-        else {
-          memcpy(&ivalue,&zsec4[0],sizeof(ivalue));
-          iaverage = ivalue;
-          imax = imin = ivalue;
-          for( loop = 1; loop < isec4[0]; loop++ ) {
-            memcpy(&ivalue,&zsec4[loop],sizeof(ivalue));
-            iaverage += ivalue;
-            if( ivalue > imax ) {
-              imax = ivalue;
-              maxIndex = loop;
-            }
-            if( ivalue < imin ) {
-              imin = ivalue;
-              minIndex = loop;
-            }
-          }
-#ifdef REAL_8
-          average = (double) iaverage / (double) isec4[0];
-#else
-          average = (float) iaverage / (float) isec4[0];
-#endif
-        }
-#endif
-        printf("max = %d (value %d), min = %d (value %d), average = %f\n",imax,(maxIndex+1),imin,(minIndex+1),average);
-      }
-    }
-/*
-// If offset given, exit after one product.
-*/
-    if(argc>2) break;
-
-  } while ( status != ENDFILE);      /* loop back if not end-of-file */
-
-/*
-// Unexpected error, print status.
-*/
-  if(status && (status != ENDFILE)) printf("Unexpected error = %d\n",status);
-
-}
diff --git a/tools/grib1profile/mars.h b/tools/grib1profile/mars.h
deleted file mode 100644
index 1944579..0000000
--- a/tools/grib1profile/mars.h
+++ /dev/null
@@ -1,2 +0,0 @@
-typedef int  fortint;    /* fortran integer */
-#define NUMBER(a)    (sizeof(a)/sizeof(a[0])) /* number of elem. of an array */
diff --git a/tools/grib1profile/mygribex.F b/tools/grib1profile/mygribex.F
deleted file mode 100644
index b73e56d..0000000
--- a/tools/grib1profile/mygribex.F
+++ /dev/null
@@ -1,21 +0,0 @@
-      subroutine mygribex( isec0, isec1, isec2, zsec2, isec3, zsec3,
-     x                     isec4, zsec4, ipunp, inbuff, ilenb, iword,
-     x                     ierr)
-C
-C     An inteface to Fortran subroutine GRIBEX to get round any
-C     problem passing the 'I' character parameter from C to Fortran.
-C
-      integer isec0, isec1, isec2, isec3,  isec4
-      integer ipunp, inbuff, ilenb, iword, ierr
-      dimension isec0(*), isec1(*), isec2(*), isec3(*),  isec4(*)
-      dimension inbuff(*)
-
-      real zsec2, zsec3, zsec4
-      dimension zsec2(*), zsec3(*), zsec4(*)
-
-      call gribex( isec0, isec1, isec2, zsec2, isec3, zsec3, isec4,
-     x             zsec4, ipunp, inbuff, ilenb, iword, 'I', ierr)
-
-      return
-      end
-
diff --git a/tools/grib1profile/pseudoprt.c b/tools/grib1profile/pseudoprt.c
deleted file mode 100644
index 0615162..0000000
--- a/tools/grib1profile/pseudoprt.c
+++ /dev/null
@@ -1,299 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <ctype.h>
-#include <memory.h>
-
-#define GRIB 0x47524942
-#define BUFR 0x42554652
-#define BUDG 0x42554447
-#define DIAG 0x44494147
-#define TIDE 0x54494445
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define DECOPS2  decops2
-#else
-#define DECOPS2  decops2_
-#endif
-
-#define SIZE 20000
-#define BLOCK_1_LEN 18
-#ifdef CRAY
-#define BITS_PER_WORD 64
-#else
-#define BITS_PER_WORD 32
-#endif
- 
-void decode_data( char * type, char * buffer, long * prodsize);
-
-static long file_read(char * buff, long leng, void * file)
-/*
-    buff = buffer to fill,
-    leng = size of buff in bytes,
-    file = FILE *.
- 
-    Returns the number of bytes read.
-    On EOF, returns negative value for number of bytes read .
-*/
-{
-long nbytes;
- 
-    nbytes = (long) fread( buff, 1, leng, (FILE *) file);
- 
-/* If EOF, return negative number of bytes read */
-    if ( feof((FILE *) file ) )
-    {
-        clearerr( (FILE *) file );
-        return (-nbytes);
-    }
- 
-    return nbytes;
-}
-
-#ifdef __uxp__
-MAIN__( int argc, char ** argv)
-#else
-main( int argc, char ** argv)
-#endif
-{
-FILE * fin;
-long status, offset = 0;
-long prodsize;
-char * buffer;
-long startpos;
-char * p;
-char type[5];
-long ident = 0;
-int i;
-
-    if ( argc < 2 )
-    {
-        printf("usage: pseudoprt filename [offset]\n");
-        exit (1);
-    }
-
-/*  Open the file. */
-    fin = fopen( argv[1], "r");
-    if ( fin == NULL )
-    {
-        perror(" fopen failed");
-        exit(1);
-    }
-
-/*  If a byte offset given, position the file. */
-    if ( argc >2 )
-    {
-        for ( p = argv[2] ; *p; p++ )
-            if ( ! isdigit( *p) )
-            {
-                printf("Bad offset given in second argument = %s\n", argv[2]);
-                exit(1);
-            }
-        offset = atol( argv[2] );
-    }
-
-    status = fseek( fin, offset, 0L );
-    if (status != 0 )
-    {
-        perror("fseek failed");
-        exit(1);
-    }
-        
-/*  read the next product. */
-    status = readnext( NULL, &prodsize, file_read, fin); 
-    if ( status == -3 )
-    {
-        status = fseek( fin, -prodsize, 1L );
-        if (status != 0 )
-        {
-            perror("fseek after readnext failed");
-            exit(1);
-        }
-
-        startpos = ftell( fin );
-        buffer = (char *) malloc( prodsize );
-        if ( buffer == NULL )
-        {
-            perror("malloc error");
-            exit(1);
-        }
-
-        status = readnext( buffer, &prodsize, file_read, fin);
-        if ( status != 0 )
-        {
-            printf("readnext failed!!\n");
-            exit(1);
-        }
-
-/*      Extract the product type, and handle accordingly.
-        GRIB should not occur here!                       */
-
-        memcpy( type, buffer, 4);
-        type[4] = '\0';
-
-        for ( i = 0; i < 4; i++ )
-            ident = ( (ident << 8) + *(type+i) ) & 0xFFFFFFFF;
-
-        switch ( ident )
-        {
-            case GRIB:
-                printf("GRIB found\n");
-                break;
-
-            case BUDG:
-                decode_data( type, buffer, &prodsize);
-                break;
-
-            case TIDE:
-                decode_data( type, buffer, &prodsize);
-                break;
-
-            case DIAG:
-                decode_data( type, buffer, &prodsize);
-                break;
-
-            case BUFR:
-                printf("BUFR found\n");
-                break;
-
-            default:
-                printf("No recognized type found: type = %s\n", type);
-                break;
-        }
-
-    }
-
-    free( buffer );
-    fclose( fin );
-
-}
-
-void decode_data( char * type, char * buffer, long * bufsize)
-{
-char chdata[SIZE];
-float fpdata[SIZE];
-int indata[SIZE];
-int lgdata[SIZE];
-int ilench = SIZE, ilenfp = SIZE, ilenin = SIZE, ilenlg = SIZE;
-int nbyte = sizeof(int);
-int ib1par[BLOCK_1_LEN];
-int nbit = BITS_PER_WORD;
-int jlench, jlenfp,jlenin,jlenlg, irserv, iword, ierr;
-int i, num_per_line, num_per_line_m1;
-
-     DECOPS2( type, chdata, &ilench, fpdata, &ilenfp, indata, &ilenin,
-             &nbyte, lgdata, &ilenlg, ib1par, buffer, bufsize,
-             &jlench, &jlenfp, &jlenin, &jlenlg, &irserv, &nbit, &iword,
-             &ierr);
-
-     if ( ierr != 0 )
-     {
-         printf("DECOPS2 returned status code %d\n", ierr);
-         exit(1);
-     }
-
-     printf("\n");
-     printf("Product type is %s\n", type);
-     printf("--------------------\n\n");
-
-     printf("Number of words decoded = %d\n\n", iword);
-
-     printf("Product definition block information.\n");
-     printf("-------------------------------------\n\n");
-
-     printf("Orginating centre identifier        = %d\n", ib1par[0]);
-     printf("Model identification                = %d\n", ib1par[1]);
-     printf("Grid definition                     = %d\n", ib1par[2]);
-     printf("Flag (code table 1)                 = %x\n", ib1par[3]);
-     printf("Parameter identifier (code table 2) = %d\n", ib1par[4]);
-     printf("Type of level (code table 3)        = %d\n", ib1par[5]);
-     printf("Level 1 (code table 3)              = %d\n", ib1par[6]);
-     printf("Level 2 (code table 3)              = %d\n", ib1par[7]);
-     printf("Year of data                        = %d\n", ib1par[8]);
-     printf("Month of data                       = %d\n", ib1par[9]);
-     printf("Day of data                         = %d\n", ib1par[10]);
-     printf("Hour of data                        = %d\n", ib1par[11]);
-     printf("Minute of data                      = %d\n", ib1par[12]);
-     printf("Time unit (code table 4)            = %d\n", ib1par[13]);
-     printf("Time range one                      = %d\n", ib1par[14]);
-     printf("Time range two                      = %d\n", ib1par[15]);
-     printf("Time range flag (code table 5)      = %x\n", ib1par[16]);
-     printf("Number averaged                     = %d\n", ib1par[17]);
-
-     printf("\n\n");
-     printf("Binary data block information.\n");
-     printf("------------------------------\n");
-
-     printf("\n");
-
-     printf("Character data.\n");
-     printf("---------------\n");
-     num_per_line = 40;
-     num_per_line_m1 = num_per_line-1;
-     if ( jlench < 0 ) printf("Missing data code.\n\n");
-     if ( jlench == 0 ) printf("None.\n");
-     if ( jlench > 0 )
-     {
-         printf("Number of values = %d\n\n", jlench);
-         for ( i = 0; i < jlench; i++ )
-         {
-             printf("%c", chdata[i]);
-             if( (i%num_per_line) == num_per_line_m1 ) printf("\n");
-         }
-     }
-
-     printf("\n\n");
-
-     printf("Floating point data.\n");
-     printf("--------------------\n");
-     num_per_line = 5;
-     num_per_line_m1 = num_per_line-1;
-     if ( jlenfp < 0 ) printf("Missing data code.\n\n");
-     if ( jlenfp == 0 ) printf("None.\n");
-     if ( jlenfp > 0 )
-     {
-         printf("Number of values = %d\n\n", jlenfp);
-         for ( i = 0; i < jlenfp; i++ )
-         {
-             printf("%30.15f ", fpdata[i]);
-             if( (i%num_per_line) == num_per_line_m1 ) printf("\n");
-         }
-     }
-
-     printf("\n\n");
-
-     printf("Integer data.\n");
-     printf("-------------\n");
-     num_per_line = 8;
-     num_per_line_m1 = num_per_line-1;
-     if ( jlenin < 0 ) printf("Missing data code.\n\n");
-     if ( jlenin == 0 ) printf("None.\n");
-     if ( jlenin > 0 )
-     {
-         printf("Number of values = %d\n\n", jlenin);
-         for ( i = 0; i < jlenin; i++ )
-         {
-             printf("%9i ", indata[i]);
-             if( (i%num_per_line) == num_per_line_m1 ) printf("\n");
-         }
-     }
-
-     printf("\n\n");
-
-     printf("Logical data.\n");
-     printf("-------------\n");
-     num_per_line = 40;
-     num_per_line_m1 = num_per_line-1;
-     if ( jlenlg < 0 ) printf("Missing data code.\n\n");
-     if ( jlenlg == 0 ) printf("None.\n");
-     if ( jlenlg > 0 )
-     {
-         printf("Number of values = %d\n\n", jlenlg);
-         for ( i = 0; i < jlenlg; i++ )
-         {
-             printf("%1i ", lgdata[i]);
-             if( (i%num_per_line) == num_per_line_m1 ) printf("\n");
-         }
-     }
-
-}
diff --git a/tools/grib1profile/sencode1.h b/tools/grib1profile/sencode1.h
deleted file mode 100644
index 78e1fd2..0000000
--- a/tools/grib1profile/sencode1.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef SENCODE1_H
-#define SENCODE1_H
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define IS1NUMB is1numb
-#define RS1NUMB rs1numb
-#define IS1TOTL is1totl
-#define RS1TOTL rs1totl
-#else
-#define IS1NUMB is1numb_
-#define RS1NUMB rs1numb_
-#define IS1TOTL is1totl_
-#define RS1TOTL rs1totl_
-#endif
-
-fortint IS1NUMB(gribProduct **, fortint *);
-fortint RS1NUMB(gribProduct **, fortdouble *);
-fortint IS1TOTL(gribProduct **, fortint *);
-fortint RS1TOTL(gribProduct **, fortdouble *);
-
-#endif /* end of SENCODE1_H */
diff --git a/tools/int.F b/tools/int.F
new file mode 100644
index 0000000..cc7fa8e
--- /dev/null
+++ b/tools/int.F
@@ -0,0 +1,343 @@
+C Copyright 1981-2015 ECMWF.
+C
+C This software is licensed under the terms of the Apache Licence
+C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+C
+C In applying this licence, ECMWF does not waive the privileges and immunities
+C granted to it by virtue of its status as an intergovernmental organisation
+C nor does it submit to any jurisdiction.
+C
+
+      PROGRAM TEST_INTERPOLATION
+      IMPLICIT NONE
+
+
+C     Parameters
+      INTEGER JPGRIB                 ! GRIB size
+C     PARAMETER (JPGRIB =  2000000)
+C     PARAMETER (JPGRIB =  4284076)  ! for R640/O640 output
+C     PARAMETER (JPGRIB =  7000000)  ! for INTUVP2 (requires 2 fields)
+      PARAMETER (JPGRIB = 33190420)  ! for R1280/O1280 = 1/16 deg (INTUVP2 not tested)
+      INTEGER JPBYTES                ! bytes/integer (8 on 64-bit architecture)
+#ifdef INTEGER_8
+      PARAMETER (JPBYTES = 8)
+#else
+      PARAMETER (JPBYTES = 4)
+#endif
+      LOGICAL IN, OUT
+      PARAMETER (IN=.TRUE., OUT=.FALSE.)
+
+
+C     Locals
+      INTEGER R, I
+      CHARACTER*256 ARG, KEY, VAL, F1, F2
+      CHARACTER*1 N
+      PARAMETER (N = CHAR(10))
+
+
+C     Internals & externals
+      LOGICAL SPLITARGS
+      INTEGER WRAP_INT, WRAP_INTF2, WRAP_INTUVP2
+      INTEGER IARGC
+
+
+C     Initialize
+      R = 0
+      F1 = ''
+      F2 = ''
+
+
+C     Process command line, calling INTOUT as necessary
+      DO I = 1, IARGC()
+        CALL GETARG(I,ARG)
+        R = -1
+        IF (SPLITARGS(ARG,KEY,VAL)) THEN
+
+          IF (KEY.EQ.'input')         F1 = VAL
+          IF (KEY.EQ.'output')        F2 = VAL
+
+C         TODO: distinguish INTIN/OUT proper from the command line
+          IF (KEY.EQ. 'in:truncation') THEN
+            KEY = 'truncation'
+            R = WRAP_INT(IN,  KEY,VAL,1,0)
+          ELSEIF (KEY.EQ.'out:truncation') THEN
+            KEY = 'truncation'
+            R = WRAP_INT(OUT, KEY,VAL,1,0)
+          ENDIF
+          IF (KEY.EQ.'grid')          R=WRAP_INT(OUT,KEY,VAL,0,2)
+          IF (KEY.EQ.'gridname')      R=WRAP_INT(OUT,KEY,VAL,0,0)
+          IF (KEY.EQ.'interpolation') R=WRAP_INT(OUT,KEY,VAL,0,0)
+          IF (KEY.EQ.'12-point')      R=WRAP_INT(OUT,KEY,VAL,0,0)
+          IF (KEY.EQ.'accuracy')      R=WRAP_INT(OUT,KEY,VAL,1,0)
+          IF (KEY.EQ.'area')          R=WRAP_INT(OUT,KEY,VAL,0,4)
+          IF (KEY.EQ.'autoresol')     R=WRAP_INT(OUT,KEY,VAL,1,0)
+          IF (KEY.EQ.'reduced')       R=WRAP_INT(OUT,KEY,VAL,1,0)
+          IF (KEY.EQ.'regular')       R=WRAP_INT(OUT,KEY,VAL,1,0)
+          IF (KEY.EQ.'rotation')      R=WRAP_INT(OUT,KEY,VAL,0,2)
+          IF (KEY.EQ.'regular')       R=WRAP_INT(OUT,KEY,VAL,1,0)
+
+          IF (KEY.EQ.'int'.AND.F1(1:1).NE.' '.AND.F2(1:1).NE.' ') THEN
+            IF (VAL.EQ.'intf2')   R=WRAP_INTF2  (F1,F2,JPGRIB,JPBYTES)
+            IF (VAL.EQ.'intuvp2') R=WRAP_INTUVP2(F1,F2,JPGRIB,JPBYTES)
+          ENDIF
+
+        ENDIF
+        IF ( R.NE.0 .AND. KEY.NE.'input' .AND. KEY.NE.'output' ) THEN
+          PRINT *, 'Problem with option "'//ARG(1:INDEX(ARG,' ')-1)//'"'
+          PRINT *, '  key:   "'//KEY(1:INDEX(KEY,' ')-1)//'"'
+          PRINT *, '  value: "'//VAL(1:INDEX(VAL,' ')-1)//'"'
+          CALL EXIT(1)
+        ENDIF
+      ENDDO
+
+      IF (F1(1:1).EQ.' ' .OR. F2(1:1).EQ.' ') THEN
+  666     PRINT *,N
+     .//'Usage: int --input=a.grib --output=b.grib [options] ...'//N
+     .//'where in/output files and interpolation grid are mandatory:'//N
+     .//'  --input=C            input file'//N
+     .//'  --output=C           output file'//N
+     .//'  --grid=R/R:          regular lat-lon, or'//N
+     .//'  --gridname=[F|N|O]I: specific grid, with:'//N
+     .//'    F: regular Gaussian'//N
+     .//'    N: reduced Gaussian/"quasi-regular"'//N
+     .//'    O: reduced Gaussian/"octahedral"'//N
+     .//'    I: points between equator and poles (N)'//N
+     .//N
+     .//'with the interpolation function:'//N
+     .//'  --int=[intf2,intuvp2]: with:'//N
+     .//'    intf2:   general interpolation'//N
+     .//'             (allows multiple GRIB input)'//N
+     .//'    intuvp2: u/v fields interpolation'//N
+     .//'             (requires vo/d or u/v pair on GRIB input)'//N
+     .//N
+     .//'and any of the INTIN/INTOUT options (interpreted in order,'//N
+     .//'some combinations are inconsistent):'//N
+     .//'  --in:truncation=I:  SH truncation (input)'//N
+     .//'  --out:truncation=I: SH truncation (output)'//N
+     .//'  --interpolation=C:  interpolation method (ref. code)'//N
+     .//'  --12-point=C:       12-point bilinear int. ([yes|no])'//N
+     .//'  --accuracy=I:       packing accuracy ([16|24|...)'//N
+     .//'  --area=R/R/R/R:     geographical area (N/W/S/E)'//N
+     .//'  --autoresol=I:      SH auto truncation on/off ([1|0])'//N
+     .//'  --reduced=I:        reduced Gaussian grid (alternate)'//N
+     .//'  --regular=I:        regular Gaussian grid (alternate)'//N
+     .//'  --rotation=R/R:     South pole new position (lat/lon)'//N
+     .//N
+     .//'with the following abbreviations:'//N
+     .//'  I: integer number'//N
+     .//'  R: real number'//N
+     .//'  C: text string'//N
+        STOP
+      ENDIF
+
+
+      STOP
+      ENDPROGRAM
+
+
+C     ------------------------------------------------------------------
+      LOGICAL FUNCTION SPLITARGS(ARG,KEY,VAL)
+      IMPLICIT NONE
+      CHARACTER*256 ARG, KEY, VAL
+
+      KEY = ''
+      VAL = ''
+      SPLITARGS = (ARG(1:2).EQ.'--' .AND. INDEX(ARG,'=').GT.3)
+      IF (SPLITARGS) THEN
+        KEY = ARG(3:INDEX(ARG,'=')-1)
+        VAL = ARG(INDEX(ARG,'=')+1:)
+      ENDIF
+      ENDFUNCTION
+
+
+C     ------------------------------------------------------------------
+      INTEGER FUNCTION WRAP_INT(IN,K,C,NI,NR)
+      IMPLICIT NONE
+      LOGICAL IN
+      CHARACTER*256 K, C
+      INTEGER NI, NR
+
+      CHARACTER*256 M
+      INTEGER I(4)
+      REAL R(4)
+
+      INTEGER INTIN, INTOUT
+      EXTERNAL INTIN, INTOUT
+
+      I = 0
+      R = 0.
+      IF (IN) THEN
+        M = 'intin'
+      ELSE
+        M = 'intout'
+      ENDIF
+      M = M(1:INDEX(M,' ')-1)//'("'//K(1:INDEX(K,' ')-1)//'")'
+      IF (NI.LT.0 .OR. NI.GT.4) NI = 0
+      IF (NR.LT.0 .OR. NR.GT.4) NR = 0
+      IF (NI.GE.1) THEN
+        DO WHILE (INDEX(C,'/').GT.0)
+          C(INDEX(C,'/'):INDEX(C,'/')) = ' '
+        ENDDO
+        READ (C,*) I(1:NI)
+        C = ''
+        PRINT *, M(1:INDEX(M,' ')-1), I(1:NI)
+      ELSEIF (NR.GE.1) THEN
+        DO WHILE (INDEX(C,'/').GT.0)
+          C(INDEX(C,'/'):INDEX(C,'/')) = ' '
+        ENDDO
+        READ (C,*) R(1:NR)
+        C = ''
+        PRINT *, M(1:INDEX(M,' ')-1), R(1:NR)
+      ELSE
+        PRINT *, M(1:INDEX(M,' ')-1), ' "'//C(1:INDEX(C,' ')-1)//'"'
+      ENDIF
+      IF (IN) THEN
+        WRAP_INT = INTIN (K,I,R,C)
+      ELSE
+        WRAP_INT = INTOUT(K,I,R,C)
+      ENDIF
+      IF (WRAP_INT.NE.0) PRINT *, M(1:INDEX(M,' ')-1)//' failed.'
+      ENDFUNCTION
+
+
+C     ------------------------------------------------------------------
+      INTEGER FUNCTION WRAP_INTF2(INFILE,OUTFILE,LENGRIB,LENBYTES)
+      IMPLICIT NONE
+      CHARACTER*256 INFILE, OUTFILE
+      INTEGER LENGRIB, LENBYTES
+
+      INTEGER INGRIB(LENGRIB), NEWFLD(LENGRIB)
+      INTEGER U1, U2, N, LENINT, IREC, IRET
+
+      INTEGER INTF2
+      EXTERNAL INTF2
+
+C     Initialize
+      INGRIB = 0
+      NEWFLD = 0
+      CALL EXCEPT()
+
+C     Open input and output files
+      IRET = 0
+      CALL PBOPEN(U1, INFILE, 'r', IRET)
+      CALL CHECK(IRET.NE.0, 'PBOPEN failed (r).')
+      CALL PBOPEN(U2, OUTFILE, 'w', IRET)
+      CALL CHECK(IRET.NE.0, 'PBOPEN failed (w).')
+
+C     Start of loop on input fields
+      N = 0
+  120 CONTINUE
+      N = N + 1
+
+C     Read next field
+      CALL PBGRIB(U1, INGRIB, LENGRIB*LENBYTES, IREC, IRET)
+      IF (IRET.EQ.-1) THEN
+        IRET = 0
+        GOTO 190
+      ENDIF
+      CALL CHECK(IRET.NE.0, 'PBGRIB failed.')
+
+C     Interpolate
+      PRINT *, 'Interpolate field #', N
+      LENINT = LENGRIB
+      IRET = INTF2(INGRIB,IREC,NEWFLD,LENINT)
+      CALL CHECK(IRET.NE.0, 'INTF2 failed')
+
+C     Write the new field to file
+      IF (LENINT.GT.0) THEN
+        CALL PBWRITE(U2, NEWFLD, LENINT, IRET)
+      ELSE
+        PRINT *, 'Output same as input'
+        CALL PBWRITE(U2, INGRIB, IREC, IRET)
+      ENDIF
+      CALL CHECK(IRET.LT.0, 'PBWRITE failed')
+      IRET = 0
+
+C     Loop back for next field
+      IF (IRET.EQ.0) GOTO 120
+
+C     Closedown
+  190 CONTINUE
+      WRAP_INTF2 = IRET
+      CALL PBCLOSE(U1, IRET)
+      CALL PBCLOSE(U2, IRET)
+      PRINT *, 'All done.'
+      ENDFUNCTION
+
+
+C     ------------------------------------------------------------------
+      INTEGER FUNCTION WRAP_INTUVP2(INFILE,OUTFILE,LENGRIB,LENBYTES)
+      IMPLICIT NONE
+      CHARACTER*256 INFILE, OUTFILE
+      INTEGER LENGRIB, LENBYTES
+
+      INTEGER IVOGRIB(LENGRIB), IDVGRIB(LENGRIB)
+      INTEGER IUGRIB(LENGRIB), IVGRIB(LENGRIB)
+      INTEGER U1, U2, N, LENINT, IREC, IRET
+
+      INTEGER INTUVP2
+      EXTERNAL INTUVP2
+
+C     Open input and output files
+      CALL PBOPEN(U1, INFILE, 'r', IRET)
+      CALL CHECK(IRET.NE.0, 'PBOPEN failed (r).')
+      CALL PBOPEN(U2, OUTFILE, 'w', IRET)
+      CALL CHECK(IRET.NE.0, 'PBOPEN failed (w).')
+
+C     Start of loop on input vo/d fields
+      N = 0
+  220 CONTINUE
+      N = N + 1
+
+C     Read next vo/d
+      CALL PBGRIB(U1, IVOGRIB, LENGRIB*LENBYTES, IREC, IRET)
+      IF (IRET.EQ.-1) THEN
+        IRET = 0
+        GOTO 290
+      ENDIF
+      CALL CHECK(IRET.NE.0, 'PBGRIB failed (vo).')
+      CALL PBGRIB(U1, IDVGRIB, LENGRIB*LENBYTES, IREC, IRET)
+      IF (IRET.EQ.-1) THEN
+        IRET = 0
+        GOTO 290
+      ENDIF
+      CALL CHECK(IRET.NE.0, 'PBGRIB failed (d).')
+
+C     Interpolate
+      PRINT *, 'Interpolate vo/d #', N
+      LENINT = LENGRIB
+      IRET = INTUVP2(IVOGRIB, IDVGRIB, LENGRIB, IUGRIB, IVGRIB, LENINT)
+      CALL CHECK(IRET.NE.0, 'INTUVP2 failed.')
+
+C     Write the new u/v fields to file
+      IF (LENINT.GT.0) THEN
+        CALL PBWRITE(U2, IUGRIB, LENINT, IRET)
+        CALL CHECK(IRET.LT.LENINT, 'PBWRITE failed.')
+        CALL PBWRITE(U2, IVGRIB, LENINT, IRET)
+        CALL CHECK(IRET.LT.LENINT, 'PBWRITE failed.')
+        IRET = 0
+      ENDIF
+
+C     Loop back for next field
+      IF (IRET.EQ.0) GOTO 220
+
+C     Closedown
+  290 CONTINUE
+      WRAP_INTUVP2 = IRET
+      CALL PBCLOSE(U1, IRET)
+      CALL PBCLOSE(U2, IRET)
+      PRINT *, 'All done.'
+      ENDFUNCTION
+
+
+C     ------------------------------------------------------------------
+      SUBROUTINE CHECK(OOPS,MSG)
+      IMPLICIT NONE
+      LOGICAL OOPS
+      CHARACTER MSG*(*)
+      IF (OOPS) THEN
+        PRINT *, MSG(1:INDEX(MSG,' ')-1)
+        CALL EXIT(3)
+      ENDIF
+      ENDSUBROUTINE
+
diff --git a/tools/loadReducedGaussian.pl b/tools/loadReducedGaussian.pl
index 513119f..1c46faf 100755
--- a/tools/loadReducedGaussian.pl
+++ b/tools/loadReducedGaussian.pl
@@ -1,42 +1,37 @@
 #!/usr/local/bin/perl56
 use strict;
 
-die("Usage:loadReducedGaussian.pl  <input> <number> \n") if $#ARGV < 1;
+die("Usage:loadReducedGaussian.pl <input> <number> \n") if $#ARGV < 1;
 
 my $input  = $ARGV[0];
 my $number = $ARGV[1];
 
+print "\t  REAL QG$number($number) \n \t  DATA QG$number/";
 
 my @gaussian;
+my $count = 0;
+open(IN, "<$input");
+while (<IN>) {
+    if (/(\d+)\,$/) {
+        $count++;
+        if($count > $number){
+            last;
+        }
+        push @gaussian, $1;
+    }
+}
+
+close(IN);
 
-				   print "\t  REAL QG$number($number) \n \t  DATA QG$number/";
-
-        my $count = 0;
-		open(IN,"<$input");
-		   while(<IN>)
-		   {
-			   if(/(\d+)\,$/)
-			   {
-			        $count++;
-                    if($count > $number){
-					      last;
-				    }
-			   		push @gaussian, $1;
-			   }
-
-	       }
-
-	   	close(IN);
 my $g = 5;
 my @s;
-
-	foreach my $n ( @gaussian )
-	{
-		if ($g == 5) {
-  			print "\n","     X";
-			$g = 0;
-			}
-		print " $n,";
-		$g++;
-	}
+foreach my $n(@gaussian)
+{
+    if ($g == 5) {
+        print "\n","     X";
+        $g = 0;
+    }
+    print " $n,";
+    $g++;
+}
 
diff --git a/tools/lsmReducedGaussian/CMakeLists.txt b/tools/lsmReducedGaussian/CMakeLists.txt
new file mode 100644
index 0000000..629c03f
--- /dev/null
+++ b/tools/lsmReducedGaussian/CMakeLists.txt
@@ -0,0 +1,9 @@
+
+# configure Fortran-based targets for double precision (compilation & linking)
+ecbuild_add_fortran_flags(${emos_double_precision_flags})
+
+ecbuild_add_executable(
+  TARGET  ginout_c2 NOINSTALL
+  SOURCES ginout_c2.f90
+  LIBS    emos )
+
diff --git a/tools/lsmReducedGaussian/LSM_GG_xxxx.generate.sh b/tools/lsmReducedGaussian/LSM_GG_xxxx.generate.sh
deleted file mode 100755
index 1c5cd06..0000000
--- a/tools/lsmReducedGaussian/LSM_GG_xxxx.generate.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-set -eux
-
-
-#for grib in LSM_GG_0640*.grib
-#do
-#  out="$(basename $grib .grib)_CY41R1"
-#  ./ginout_c "$grib" "$out"
-#done
-#
-#md5sum /usr/local/apps/libemos/tables/interpolation/LSM_GG_* LSM_GG_0640* | sort
-
-
-#for T in 95 159 255 319 399 511 639 799 1279 2047
-#do
-#  N=$(( $(grib_get -p Nj "41r1/climate.v012/${T}l_2/lsm")/2 ))
-#  in="41r1/climate.v012/${T}l_2/lsm"
-#  out="LSM_GG_"$(printf "%04d" $N)"_CY41R1"
-#  ./ginout_c "$in" "$out"
-#done
-
-
-./ginout_c2 40/climate/1023l_2/lsm            40/LSM_GG_0510
-./ginout_c2 40/climate/1279l_2/lsm            40/LSM_GG_0640
-./ginout_c2 40/climate/159l_2/lsm             40/LSM_GG_0080
-./ginout_c2 40/climate/2047l_2/lsm            40/LSM_GG_1024
-./ginout_c2 40/climate/255l_2/lsm             40/LSM_GG_0128
-./ginout_c2 40/climate/319l_2/lsm             40/LSM_GG_0160
-./ginout_c2 40/climate/3999l_2/lsm            40/LSM_GG_2000
-./ginout_c2 40/climate/399l_2/lsm             40/LSM_GG_0200
-./ginout_c2 40/climate/511l_2/lsm             40/LSM_GG_0256
-./ginout_c2 40/climate/639l_2/lsm             40/LSM_GG_0320
-./ginout_c2 40/climate/799l_2/lsm             40/LSM_GG_0400
-./ginout_c2 40/climate/95l_2/lsm              40/LSM_GG_0048
-./ginout_c2 41r1/climate.v012/1279l_2/lsm   41r1/LSM_GG_0640
-./ginout_c2 41r1/climate.v012/159l_2/lsm    41r1/LSM_GG_0080
-./ginout_c2 41r1/climate.v012/2047l_2/lsm   41r1/LSM_GG_1024
-./ginout_c2 41r1/climate.v012/255l_2/lsm    41r1/LSM_GG_0128
-./ginout_c2 41r1/climate.v012/319l_2/lsm    41r1/LSM_GG_0160
-./ginout_c2 41r1/climate.v012/399l_2/lsm    41r1/LSM_GG_0200
-./ginout_c2 41r1/climate.v012/511l_2/lsm    41r1/LSM_GG_0256
-./ginout_c2 41r1/climate.v012/639l_2/lsm    41r1/LSM_GG_0320
-./ginout_c2 41r1/climate.v012/799l_2/lsm    41r1/LSM_GG_0400
-./ginout_c2 41r1/climate.v012/95l_2/lsm     41r1/LSM_GG_0048
-
diff --git a/tools/lsmReducedGaussian/Makefile b/tools/lsmReducedGaussian/Makefile
deleted file mode 100644
index d029da4..0000000
--- a/tools/lsmReducedGaussian/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-#                                 Makefile for example programs
-#
-ARCH=linux
-CNAME=_gfortran
-R64=R64
-
-
-R64=R64
-LIBPATH = ../../libemosR64.a
-CYCLE=000395
-LIBPATH = /usr/local/apps/libemos/$(CYCLE)/lib/libemos.R64.D64.I32.a
-#
-#
-#
-TARGETS = all clean
-EXECS   = ginout ginout_c ginout_c2
-FFLAGS=-DFOPEN64 -DINTEGER_IS_INT -DLITTLE_ENDIAN -DPOINTER_64 -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -Dgfortran -Dlinux -ffixed-line-length-none -fcray-pointer -fno-second-underscore -fdefault-real-8 -fdefault-double-8 
-#
-#
-all: $(EXECS)
-
-ginout: ginout.o
-	$(FC) $(FFLAGS) -o $@ ginout.o $(LIBPATH)
-
-ginout_c: ginout_c.o
-	$(FC) $(FFLAGS) -o $@ ginout_c.o $(LIBPATH)
-
-ginout_c2: ginout_c2.f90
-	$(FC) $(FFLAGS) -o $@ ginout_c2.f90 -Wall $(LIBPATH) $(GRIB_API_LIB) $(GRIB_API_INCLUDE)
-
-
-
-clean:
-	@for name in $(EXECS) ; do\
-	(rm -f $$name $$name.o $$name.f); \
-	done
diff --git a/tools/lsmReducedGaussian/broj.F b/tools/lsmReducedGaussian/broj.F
deleted file mode 100644
index 31b89d1..0000000
--- a/tools/lsmReducedGaussian/broj.F
+++ /dev/null
@@ -1,130 +0,0 @@
-#define MISSING_VALUE -9999999
-
-      PROGRAM DECODING
-      IMPLICIT NONE
-C
-      INTEGER JPACK, JPBYTES
-      PARAMETER (JPACK = 500000)
-C
-C     JPBYTES is the number of bytes per INTEGER
-C
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER ISEC0, ISEC1, ISEC2, ISEC3, ISEC4, INBUFF, IOS, ISTR 
-      DIMENSION ISEC0(2)
-      DIMENSION ISEC1(1024)
-      DIMENSION ISEC2(1024)
-      DIMENSION ISEC3(2)
-      DIMENSION ISEC4(1024)
-C
-      REAL ZSEC2, ZSEC3, ZSEC4, USEC4, ZZZ, ZZY
-      DIMENSION ZSEC2(1024)
-      DIMENSION ZSEC3(2)
-      DIMENSION ZSEC4(JPACK*4),ZZZ(JPACK*4)
-      DIMENSION USEC4(JPACK*4)
-      DIMENSION INBUFF(JPACK)
-      INTEGER IRET, FILE1, FILE2, JCOUNT
-      INTEGER ILENB, LENOUT, IPUNP, IWORD, loop, NUMBER
-C
-      CHARACTER*128 INFILE, OUTFILE
-      INTEGER IJDC, IARGC, PBGTOTL
-      EXTERNAL IARGC, GETENV, PBGTOTL
-C
-      IJDC = IARGC()
-      IF( IJDC.LT.2 ) STOP 'Usage: ginout inputfile outputfile'
-      CALL GETARG(1,INFILE)
-      CALL GETARG(2,OUTFILE)
-C
-C     Open the input file
-C
-      CALL PBOPEN(FILE1, INFILE(1:INDEX(INFILE,' ')-1), "R", IRET)
-      IF( IRET.NE.0 ) THEN
-        WRITE(*, *) 'Return code from PBOPEN = ',IRET
-        CALL PBCLOSE(FILE1, IRET)
-        STOP 'Fault in PBOPEN'
-      ENDIF
-
-      NUMBER = PBGTOTL(INFILE(1:INDEX(INFILE,' ')-1))
-      WRITE(*,*) '****************************************'
-      WRITE(*,*) 'Number of GRIBs in the file = ', NUMBER
-      WRITE(*,*) '****************************************'
-      IF( NUMBER.EQ.0 ) STOP 'No Gribs found'
-        
-C     Open the output file to write decoded products
-        ISTR=INDEX(OUTFILE,' ')
-      OPEN (UNIT=16,FILE=OUTFILE(1:ISTR-1),STATUS='UNKNOWN',
-c     &          IOSTAT=IOS)
-     &          FORM='UNFORMATTED',IOSTAT=IOS)
-            IF (IOS.EQ.0) THEN
-                WRITE(*,*)'File:',OUTFILE(1:ISTR-1),' opened'
-            ELSE
-               WRITE(*,*)'File:',OUTFILE(1:ISTR-1),' not opened'
-               WRITE(*,*)'Input/output status = ',IOS
-               WRITE(*,*)'Program will stop'
-               STOP
-            END IF
-
-C     Lengths of INBUFF and PSEC4
-      ILENB = JPACK*JPBYTES
-C
-C     Start of loop through products
-      JCOUNT = 0
-
-   50 CONTINUE
-      JCOUNT = JCOUNT + 1
-C
-C     Read packed field into INBUFF.
-C
-      CALL PBGRIB(FILE1, INBUFF, ILENB, LENOUT, IRET )
-      IF( IRET.LT.0 ) THEN
-           WRITE (*, *) 'Return code from pbgrib = ',IRET
-
-           IF( IRET.EQ.-1 ) THEN
-             WRITE(*, *) 'End of file. Number of products decoded ='
-     &          , (JCOUNT-1)
-             CALL PBCLOSE(FILE1, IRET)
-             CLOSE(16)
-             STOP 'EOF'
-           ELSE
-             CALL PBCLOSE(FILE1, IRET)
-             CLOSE(16)
-             WRITE(*, *) 'Fault in PBGRIB. trying with product:', JCOUNT
-             WRITE(*, *) 'Number of products decoded =', (JCOUNT-1)
-             STOP 'Fault in PBGRIB'
-           ENDIF
-      ENDIF
-C
-C     Unpack GRIB message.
-C
-      ZSEC3(2) = MISSING_VALUE
-      ISEC3(2) = NINT(ZSEC3(2))
-      IRET     = 1
-      IPUNP    = JPACK * JPBYTES
-      ILENB    = (LENOUT + (JPBYTES-1))/JPBYTES
-      CALL GRIBEX( ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,INBUFF,ILENB,IWORD,'D',IRET)
-
-      WRITE (*,*) ' GRDEMO : GRIBEX return code = ', IRET
-      WRITE (*,*) ' Product number= ', JCOUNT
-      WRITE (*,*) '-------------------------------' 
-      IF (IRET .EQ. - 6) WRITE (*,*) ' GRDEMO : Pseudo-grib data found.'
-      IF( IRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX return code = ',IRET
-        STOP 'GRIBEX error'
-      ENDIF
-C
-C
-cs  Number of data values in array PSEC4
-      IPUNP = ISEC4(1)
-cs write decoded values to outfile
-c      WRITE (16)(ZSEC4(LOOP),LOOP=1,IPUNP)
-c      READ (16)(ZZZ(LOOP),LOOP=1,IPUNP)
-      READ (16)(ZZZ(LOOP),LOOP=1,10)
-c      READ (16)ZZY
-      WRITE (*,*)(ZZZ(LOOP),LOOP=1,10)
-C
-C     Go back for more products
-C
-      GOTO 50
-C
-      END
diff --git a/tools/lsmReducedGaussian/ginout.F b/tools/lsmReducedGaussian/ginout.F
deleted file mode 100644
index 4d8674e..0000000
--- a/tools/lsmReducedGaussian/ginout.F
+++ /dev/null
@@ -1,125 +0,0 @@
-#define MISSING_VALUE -9999999
-
-      PROGRAM GINOUT
-      IMPLICIT NONE
-C
-      INTEGER JPACK, JPBYTES
-      PARAMETER (JPACK = 500000)
-C
-C     JPBYTES is the number of bytes per INTEGER
-C
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER ISEC0, ISEC1, ISEC2, ISEC3, ISEC4, INBUFF, IOS, ISTR 
-      DIMENSION ISEC0(2)
-      DIMENSION ISEC1(1024)
-      DIMENSION ISEC2(1024)
-      DIMENSION ISEC3(2)
-      DIMENSION ISEC4(1024)
-C
-      REAL ZSEC2, ZSEC3, ZSEC4, USEC4
-      DIMENSION ZSEC2(1024)
-      DIMENSION ZSEC3(2)
-      DIMENSION ZSEC4(JPACK*4)
-      DIMENSION USEC4(JPACK*4)
-      DIMENSION INBUFF(JPACK)
-      INTEGER IRET, FILE1, FILE2, JCOUNT
-      INTEGER ILENB, LENOUT, IPUNP, IWORD, loop, NUMBER
-C
-      CHARACTER*128 INFILE, OUTFILE
-      INTEGER IJDC, IARGC, PBGTOTL
-      EXTERNAL GETENV, PBGTOTL
-C
-      IJDC = IARGC()
-      IF( IJDC.LT.2 ) STOP 'Usage: ginout inputfile outputfile'
-      CALL GETARG(1,INFILE)
-      CALL GETARG(2,OUTFILE)
-C
-C     Open the input file
-C
-      CALL PBOPEN(FILE1, INFILE(1:INDEX(INFILE,' ')-1), "R", IRET)
-      IF( IRET.NE.0 ) THEN
-        WRITE(*, *) 'Return code from PBOPEN = ',IRET
-        CALL PBCLOSE(FILE1, IRET)
-        STOP 'Fault in PBOPEN'
-      ENDIF
-
-      NUMBER = PBGTOTL(INFILE(1:INDEX(INFILE,' ')-1))
-      WRITE(*,*) '****************************************'
-      WRITE(*,*) 'Number of GRIBs in the file = ', NUMBER
-      WRITE(*,*) '****************************************'
-      IF( NUMBER.EQ.0 ) STOP 'No Gribs found'
-        
-C     Open the output file to write decoded products
-        ISTR=INDEX(OUTFILE,' ')
-      OPEN (UNIT=16,FILE=OUTFILE(1:ISTR-1),STATUS='UNKNOWN',
-     &          FORM='UNFORMATTED',IOSTAT=IOS)
-            IF (IOS.EQ.0) THEN
-                WRITE(*,*)'File:',OUTFILE(1:ISTR-1),' opened'
-            ELSE
-               WRITE(*,*)'File:',OUTFILE(1:ISTR-1),' not opened'
-               WRITE(*,*)'Input/output status = ',IOS
-               WRITE(*,*)'Program will stop'
-               STOP
-            END IF
-
-C     Lengths of INBUFF and PSEC4
-      ILENB = JPACK*JPBYTES
-C
-C     Start of loop through products
-      JCOUNT = 0
-
-   50 CONTINUE
-      JCOUNT = JCOUNT + 1
-C
-C     Read packed field into INBUFF.
-C
-      CALL PBGRIB(FILE1, INBUFF, ILENB, LENOUT, IRET )
-      IF( IRET.LT.0 ) THEN
-           WRITE (*, *) 'Return code from pbgrib = ',IRET
-
-           IF( IRET.EQ.-1 ) THEN
-             WRITE(*, *) 'End of file. Number of products decoded ='
-     &          , (JCOUNT-1)
-             CALL PBCLOSE(FILE1, IRET)
-             CLOSE(16)
-             STOP 'EOF'
-           ELSE
-             CALL PBCLOSE(FILE1, IRET)
-             CLOSE(16)
-             WRITE(*, *) 'Fault in PBGRIB. trying with product:', JCOUNT
-             WRITE(*, *) 'Number of products decoded =', (JCOUNT-1)
-             STOP 'Fault in PBGRIB'
-           ENDIF
-      ENDIF
-C
-C     Unpack GRIB message.
-C
-      ZSEC3(2) = MISSING_VALUE
-      ISEC3(2) = NINT(ZSEC3(2))
-      IRET     = 1
-      IPUNP    = JPACK * JPBYTES
-      ILENB    = (LENOUT + (JPBYTES-1))/JPBYTES
-      CALL GRIBEX( ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,INBUFF,ILENB,IWORD,'D',IRET)
-
-      WRITE (*,*) ' GRDEMO : GRIBEX return code = ', IRET
-      WRITE (*,*) ' Product number= ', JCOUNT
-      WRITE (*,*) '-------------------------------' 
-      IF (IRET .EQ. - 6) WRITE (*,*) ' GRDEMO : Pseudo-grib data found.'
-      IF( IRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX return code = ',IRET
-        STOP 'GRIBEX error'
-      ENDIF
-C
-C
-cs  Number of data values in array PSEC4
-      IPUNP = ISEC4(1)
-cs write decoded values to outfile
-      WRITE (16)(ZSEC4(LOOP),LOOP=1,IPUNP)
-C
-C     Go back for more products
-C
-      GOTO 50
-C
-      END
diff --git a/tools/lsmReducedGaussian/ginout_c.F b/tools/lsmReducedGaussian/ginout_c.F
deleted file mode 100755
index 62550b1..0000000
--- a/tools/lsmReducedGaussian/ginout_c.F
+++ /dev/null
@@ -1,160 +0,0 @@
-#define MISSING_VALUE -9999999
-
-
-      PROGRAM ginout
-      IMPLICIT NONE
-C
-      INTEGER*8 JPACK
-      INTEGER   JPBYTES
-      PARAMETER (JPACK = 7000000)
-C
-C     JPBYTES is the number of bytes per INTEGER
-C
-      PARAMETER (JPBYTES = 4)
-C
-      INTEGER ISEC0, ISEC1, ISEC2, ISEC3, ISEC4, INBUFF, IOS, ISTR 
-      DIMENSION ISEC0(2)
-      DIMENSION ISEC1(1024)
-      DIMENSION ISEC2(1024*2)
-      DIMENSION ISEC3(2)
-      DIMENSION ISEC4(1024)
-C
-C      REAL*8 ZSEC2, ZSEC3, ZSEC4, USEC4
-      REAL ZSEC2, ZSEC3, ZSEC4, USEC4
-      DIMENSION ZSEC2(9024*2)
-      DIMENSION ZSEC3(2)
-      DIMENSION ZSEC4(JPACK*4)
-      DIMENSION USEC4(JPACK*4)
-      DIMENSION INBUFF(JPACK)
-      INTEGER IRET, FILE1, FILE2, JCOUNT
-      INTEGER ILENB, LENOUT, IPUNP, IWORD, loop, NUMBER
-	  INTEGER i
-C
-      INTEGER JPRLEN, KSIZE
-#ifdef REAL_8
-      PARAMETER (JPRLEN = 8)
-#else
-      PARAMETER (JPRLEN = 4)
-#endif
-
-      CHARACTER*128 INFILE, OUTFILE
-      INTEGER IJDC, IARGC, PBGTOTL
-      EXTERNAL GETENV, PBGTOTL
-C
-      IJDC = IARGC()
-      IF( IJDC.LT.2 ) STOP 'Usage: ginout inputfile outputfile'
-      CALL GETARG(1,INFILE)
-      CALL GETARG(2,OUTFILE)
-C
-C     Open the input file
-C
-      CALL PBOPEN(FILE1, INFILE(1:INDEX(INFILE,' ')-1), "R", IRET)
-      IF( IRET.NE.0 ) THEN
-        WRITE(*, *) 'Return code from PBOPEN = ',IRET
-        CALL PBCLOSE(FILE1, IRET)
-        STOP 'Fault in PBOPEN'
-      ENDIF
-
-      NUMBER = PBGTOTL(INFILE(1:INDEX(INFILE,' ')-1))
-      WRITE(*,*) '****************************************'
-      WRITE(*,*) 'Number of GRIBs in the file = ', NUMBER
-      WRITE(*,*) '****************************************'
-      IF( NUMBER.EQ.0 ) STOP 'No Gribs found'
-        
-C     Open the output file to write decoded products
-        ISTR=INDEX(OUTFILE,' ')
-      OPEN (UNIT=16,FILE=OUTFILE(1:ISTR-1),STATUS='UNKNOWN',
-     &          FORM='UNFORMATTED',IOSTAT=IOS)
-            IF (IOS.EQ.0) THEN
-                WRITE(*,*)'File:',OUTFILE(1:ISTR-1),' opened'
-            ELSE
-               WRITE(*,*)'File:',OUTFILE(1:ISTR-1),' not opened'
-               WRITE(*,*)'Input/output status = ',IOS
-               WRITE(*,*)'Program will stop'
-               STOP
-            END IF
-
-C     Lengths of INBUFF and PSEC4
-C
-C     Start of loop through products
-      JCOUNT = 0
-
-   50 CONTINUE
-      JCOUNT = JCOUNT + 1
-C
-C     Read packed field into INBUFF.
-
-      ILENB = JPACK*JPBYTES
-      print*,'ANNA ', ILENB
-C
-      CALL PBGRIB(FILE1, INBUFF, ILENB, LENOUT, IRET )
-      IF( IRET.LT.0 ) THEN
-           WRITE (*, *) 'Return code from pbgrib = ',IRET
-
-           IF( IRET.EQ.-1 ) THEN
-             WRITE(*, *) 'End of file. Number of products decoded ='
-     &          , (JCOUNT-1)
-             CALL PBCLOSE(FILE1, IRET)
-             CLOSE(16)
-             STOP 'EOF'
-           ELSE
-             CALL PBCLOSE(FILE1, IRET)
-             CLOSE(16)
-             WRITE(*, *) 'Fault in PBGRIB. trying with product:', JCOUNT
-             WRITE(*, *) 'Number of products decoded =', (JCOUNT-1)
-             STOP 'Fault in PBGRIB'
-           ENDIF
-      ENDIF
-C
-C     Unpack GRIB message.
-C
-      ZSEC3(2) = MISSING_VALUE
-      ISEC3(2) = NINT(ZSEC3(2))
-      IRET     = 1
-      IPUNP    = JPACK * JPBYTES
-      ILENB    = (LENOUT + (JPBYTES-1))/JPBYTES
-      CALL GRIBEX( ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
-     X             ZSEC4,IPUNP,INBUFF,ILENB,IWORD,'D',IRET)
-
-      WRITE (*,*) ' GRDEMO : GRIBEX return code = ', IRET
-      WRITE (*,*) ' Product number= ', JCOUNT
-      WRITE (*,*) '-------------------------------' 
-      IF (IRET .EQ. - 6) WRITE (*,*) ' GRDEMO : Pseudo-grib data found.'
-      IF( IRET.GT.0 ) THEN
-        WRITE(*,*) 'GRIBEX return code = ',IRET
-        STOP 'GRIBEX error'
-      ENDIF
-C
-C
-cs  Number of data values in array PSEC4
-      IPUNP = ISEC4(1)
-cs write decoded values to outfile
-      print*,'IPUNP ',IPUNP
-
-C     -----------------------------------------------------------------|
-C     Section 3.  Read the land-sea mask values
-C     -----------------------------------------------------------------|
-C
-cs      print*,'JPRLEN ',JPRLEN
-cs      do i=1,ipunp
-cs           if(ZSEC4(i).gt.0) then
-cs                print*,'ZSEC4 ',i,ZSEC4(i)
-cs           endif
-cs      enddo
-
-C
-      KSIZE = IPUNP*JPRLEN
-      CALL PBOPEN(FILE2, OUTFILE(1:INDEX(OUTFILE,' ')-1), "W", IRET)
-C
-      CALL PBWRITE(FILE2,ZSEC4,KSIZE,IRET)
-
-      CALL PBCLOSE(FILE2,IRET)
-
-c      write(*,17)(ZSEC4(LOOP),LOOP=1,IPUNP)
-17     format(15(1x,f7.4))
-C
-C     Go back for more products
-C
-      GOTO 50
-C
-      END
diff --git a/tools/lsmReducedGaussian/land-sea-mask.mars b/tools/lsmReducedGaussian/land-sea-mask.mars
deleted file mode 100644
index dea2c27..0000000
--- a/tools/lsmReducedGaussian/land-sea-mask.mars
+++ /dev/null
@@ -1,19 +0,0 @@
-retrieve,
-	stream=oper,
-	time=00,
-	levtype=sfc,
-	expver=1,
-	param=172,
-	class=od,
-#	date=20080224,
-	date=20050224,
-#	date=19950824,
-#	date=-1,
-	type=an,
-#   grid=200,
-#   grid=256,
-#  grid=80,
-#  grid=400,
-#  gaussian=reduced,
-#  target=lsm.N400.2008
-  target=lsm.oper.2005
diff --git a/tools/lsmReducedGaussian/lsm.mars b/tools/lsmReducedGaussian/lsm.mars
new file mode 100644
index 0000000..faf57d7
--- /dev/null
+++ b/tools/lsmReducedGaussian/lsm.mars
@@ -0,0 +1,85 @@
+retrieve,
+	stream=oper,
+	time=00,
+	levtype=sfc,
+	expver=1,
+	param=172,
+	class=od,
+#	date=20080224,
+	date=20050224,
+#	date=19950824,
+#	date=-1,
+	type=an,
+#   grid=200,
+#   grid=256,
+#  grid=80,
+#  grid=400,
+#  gaussian=reduced,
+#  target=lsm.N400.2008
+  target=lsm.oper.2005
+
+RETRIEVE,
+    CLASS      = rd,
+    TYPE       = fc,
+    STREAM     = oper,
+    EXPVER     = g0t6,
+    REPRES     = SH,
+    LEVTYPE    = sfc,
+    LEVELIST   = 1,
+#    PARAM      = lsm,
+    PARAM      = 172,
+    DATE       = 2014-01-01,
+    TIME       = 00,
+    STEP       = 00,
+    DOMAIN     = G,
+    TARGET     = "lsmN1024.grib",
+    PROCESS    = LOCAL
+
+RETRIEVE,
+    CLASS      = OD,
+    TYPE       = CF,
+    STREAM     = EF,
+    EXPVER     = 0045,
+    REPRES     = SH,
+    LEVTYPE    = SFC,
+    PARAM      = 172,
+    DATE       = 20090718,
+    TIME       = 0000,
+    STEP       = 3,
+    DOMAIN     = G,
+    TARGET     = "lsmN320",
+    PROCESS    = LOCAL 
+
+RETRIEVE,
+    CLASS      = OD,
+    TYPE       = AN,
+    STREAM     = DA,
+    REPRES     = SH,
+    LEVTYPE    = sfc,
+    LEVELIST   = 1,
+#    PARAM      = lsm,
+    PARAM      = 172,
+    DATE       = 20090601,
+    TIME       = 0600,
+    STEP       = 00,
+    DOMAIN     = G,
+    TARGET     = "lsmN400.grib",
+    PROCESS    = LOCAL
+
+RETRIEVE,
+    CLASS      = OD,
+    TYPE       = AN,
+    STREAM     = DA,
+    EXPVER     = 9045,
+    REPRES     = SH,
+    LEVTYPE    = sfc,
+    LEVELIST   = 1,
+#    PARAM      = lsm,
+    PARAM      = 172,
+    DATE       = 20090601,
+    TIME       = 0600,
+    STEP       = 00,
+    DOMAIN     = G,
+    TARGET     = "lsmN640.grib",
+    PROCESS    = LOCAL
+
diff --git a/tools/lsmReducedGaussian/lsmN1024.mars b/tools/lsmReducedGaussian/lsmN1024.mars
deleted file mode 100644
index 5e65a41..0000000
--- a/tools/lsmReducedGaussian/lsmN1024.mars
+++ /dev/null
@@ -1,17 +0,0 @@
-RETRIEVE,
-    CLASS      = rd,
-    TYPE       = fc,
-    STREAM     = oper,
-    EXPVER     = g0t6,
-    REPRES     = SH,
-    LEVTYPE    = sfc,
-    LEVELIST   = 1,
-#    PARAM      = lsm,
-    PARAM      = 172,
-    DATE       = 2014-01-01,
-    TIME       = 00,
-    STEP       = 00,
-    DOMAIN     = G,
-    TARGET     = "lsmN1024.grib",
-    PROCESS    = LOCAL
-
diff --git a/tools/lsmReducedGaussian/lsmN320.mars b/tools/lsmReducedGaussian/lsmN320.mars
deleted file mode 100644
index 0a2440a..0000000
--- a/tools/lsmReducedGaussian/lsmN320.mars
+++ /dev/null
@@ -1,14 +0,0 @@
-RETRIEVE,
-    CLASS      = OD,
-    TYPE       = CF,
-    STREAM     = EF,
-    EXPVER     = 0045,
-    REPRES     = SH,
-    LEVTYPE    = SFC,
-    PARAM      = 172,
-    DATE       = 20090718,
-    TIME       = 0000,
-    STEP       = 3,
-    DOMAIN     = G,
-    TARGET     = "lsm.320",
-    PROCESS    = LOCAL 
diff --git a/tools/lsmReducedGaussian/lsmN400.mars b/tools/lsmReducedGaussian/lsmN400.mars
deleted file mode 100644
index 836bc6f..0000000
--- a/tools/lsmReducedGaussian/lsmN400.mars
+++ /dev/null
@@ -1,16 +0,0 @@
-RETRIEVE,
-    CLASS      = OD,
-    TYPE       = AN,
-    STREAM     = DA,
-    REPRES     = SH,
-    LEVTYPE    = sfc,
-    LEVELIST   = 1,
-#    PARAM      = lsm,
-    PARAM      = 172,
-    DATE       = 20090601,
-    TIME       = 0600,
-    STEP       = 00,
-    DOMAIN     = G,
-    TARGET     = "lsmN400.grib",
-    PROCESS    = LOCAL
-
diff --git a/tools/lsmReducedGaussian/lsmN640.mars b/tools/lsmReducedGaussian/lsmN640.mars
deleted file mode 100644
index 61d7a0f..0000000
--- a/tools/lsmReducedGaussian/lsmN640.mars
+++ /dev/null
@@ -1,17 +0,0 @@
-RETRIEVE,
-    CLASS      = OD,
-    TYPE       = AN,
-    STREAM     = DA,
-    EXPVER     = 9045,
-    REPRES     = SH,
-    LEVTYPE    = sfc,
-    LEVELIST   = 1,
-#    PARAM      = lsm,
-    PARAM      = 172,
-    DATE       = 20090601,
-    TIME       = 0600,
-    STEP       = 00,
-    DOMAIN     = G,
-    TARGET     = "lsmN640.grib",
-    PROCESS    = LOCAL
-
diff --git a/tools/lsmReducedGaussian/run b/tools/lsmReducedGaussian/run
deleted file mode 100644
index 00ad9ea..0000000
--- a/tools/lsmReducedGaussian/run
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-./ginout_c lsmN$1 LSM_GG_0$1
-#./ginout lsm.N$1 LSM_GG_0$1
diff --git a/tools/lsmReducedGaussian/run.sh b/tools/lsmReducedGaussian/run.sh
new file mode 100755
index 0000000..41dee89
--- /dev/null
+++ b/tools/lsmReducedGaussian/run.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+set -eux
+
+
+#./ginout_c lsmN$1 LSM_GG_0$1
+##./ginout lsm.N$1 LSM_GG_0$1
+
+
+#for grib in LSM_GG_0640*.grib
+#do
+#  out="$(basename $grib .grib)_CY41R1"
+#  ./ginout_c "$grib" "$out"
+#done
+#
+#md5sum /usr/local/apps/libemos/tables/interpolation/LSM_GG_* LSM_GG_0640* | sort
+
+
+#for T in 95 159 255 319 399 511 639 799 1279 2047
+#do
+#  N=$(( $(grib_get -p Nj "41r1/climate.v012/${T}l_2/lsm")/2 ))
+#  in="41r1/climate.v012/${T}l_2/lsm"
+#  out="LSM_GG_"$(printf "%04d" $N)"_CY41R1"
+#  ./ginout_c "$in" "$out"
+#done
+
+
+./ginout_c2 40/climate/1023l_2/lsm            40/LSM_GG_0510
+./ginout_c2 40/climate/1279l_2/lsm            40/LSM_GG_0640
+./ginout_c2 40/climate/159l_2/lsm             40/LSM_GG_0080
+./ginout_c2 40/climate/2047l_2/lsm            40/LSM_GG_1024
+./ginout_c2 40/climate/255l_2/lsm             40/LSM_GG_0128
+./ginout_c2 40/climate/319l_2/lsm             40/LSM_GG_0160
+./ginout_c2 40/climate/3999l_2/lsm            40/LSM_GG_2000
+./ginout_c2 40/climate/399l_2/lsm             40/LSM_GG_0200
+./ginout_c2 40/climate/511l_2/lsm             40/LSM_GG_0256
+./ginout_c2 40/climate/639l_2/lsm             40/LSM_GG_0320
+./ginout_c2 40/climate/799l_2/lsm             40/LSM_GG_0400
+./ginout_c2 40/climate/95l_2/lsm              40/LSM_GG_0048
+./ginout_c2 41r1/climate.v012/1279l_2/lsm   41r1/LSM_GG_0640
+./ginout_c2 41r1/climate.v012/159l_2/lsm    41r1/LSM_GG_0080
+./ginout_c2 41r1/climate.v012/2047l_2/lsm   41r1/LSM_GG_1024
+./ginout_c2 41r1/climate.v012/255l_2/lsm    41r1/LSM_GG_0128
+./ginout_c2 41r1/climate.v012/319l_2/lsm    41r1/LSM_GG_0160
+./ginout_c2 41r1/climate.v012/399l_2/lsm    41r1/LSM_GG_0200
+./ginout_c2 41r1/climate.v012/511l_2/lsm    41r1/LSM_GG_0256
+./ginout_c2 41r1/climate.v012/639l_2/lsm    41r1/LSM_GG_0320
+./ginout_c2 41r1/climate.v012/799l_2/lsm    41r1/LSM_GG_0400
+./ginout_c2 41r1/climate.v012/95l_2/lsm     41r1/LSM_GG_0048
+
diff --git a/tools/modify_grib/Makefile.old b/tools/modify_grib/Makefile.old
deleted file mode 100755
index 11b9cd3..0000000
--- a/tools/modify_grib/Makefile.old
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-include	config.$(arch)
-include	options
-#
-modify_grib: modify_grib.o chgrib.o
-	$(LD)  modify_grib.o chgrib.o $(LD_FLAGS) $(EMOSLIB) $(ECLIB)
-modify_grib.o:	modify_grib.F90
-	$(FC) $(FFLAGS) -c modify_grib.F90
-
-chgrib.o: chgrib.c
-	$(CC) $(CFLAGS) -c chgrib.c
-
-clean:
-	\rm -f modify_grib *.o core
diff --git a/tools/modify_grib/chgrib.c b/tools/modify_grib/chgrib.c
deleted file mode 100755
index 5159d8e..0000000
--- a/tools/modify_grib/chgrib.c
+++ /dev/null
@@ -1,515 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifndef FORTINT_H
-
-#define FORTINT_H
-
-#ifdef INTEGER_IS_INT
-#define fortint int
-#else
-#ifdef hpR64
-#define fortint long long
-#else
-#define fortint long
-#endif
-#endif
-
-#endif /* end of  FORTINT_H */
-
-#define SECTION0 8
-
-#define TABLE2 1
-#define TABLE2OCTET SECTION0+3
-#define CENTRE 2
-#define CENTREOCTET SECTION0+4
-#define GENPID 3
-#define GENPIDOCTET SECTION0+5
-#define GRID 4
-#define GRIDOCTET SECTION0+6
-#define PARAM 6
-#define PARAMOCTET SECTION0+8
-#define LEVELIND 7
-#define LEVELINDOCTET SECTION0+9
-#define LEVEL1 8
-#define LEVEL1OCTET SECTION0+10
-#define LEVEL2 9
-#define LEVEL2OCTET SECTION0+11
-#define YEAR 10
-#define YEAROCTET SECTION0+12
-#define MONTH 11
-#define MONTHOCTET SECTION0+13
-#define DAY 12
-#define DAYOCTET SECTION0+14
-#define HOUR 13
-#define HOUROCTET SECTION0+15
-#define MINUTE 14
-#define MINUTEOCTET SECTION0+16
-#define TIMEUNIT 15
-#define TIMEUNITOCTET SECTION0+17
-#define TIME1 16
-#define TIME1OCTET SECTION0+18
-#define TIME2 17
-#define TIME2OCTET SECTION0+19
-#define TIMERANGE 18
-#define TIMERANGEOCTET SECTION0+20
-#define NUMINAV 19
-#define NUMINAVOCTET SECTION0+21
-#define NUMMISSING 20
-#define NUMMISSINGOCTET SECTION0+23
-#define CENTURY 21
-#define CENTURYOCTET SECTION0+24
-#define SUBCENTRE 22
-#define SUBCENTREOCTET SECTION0+25
-#define DECSCALE 23
-#define DECSCALEOCTET SECTION0+26
-#define LOCALUSE 37
-#define LOCALUSEOCTET SECTION0+40
-#define CLASS 38
-#define CLASSOCTET SECTION0+41
-#define TYPE 39
-#define TYPEOCTET SECTION0+42
-#define STREAM 40
-#define STREAMOCTET SECTION0+43
-#define EXPVER 41
-#define EXPVEROCTET SECTION0+45
-
-#define BUFFLEN 1000000
-#define OK 0
-#define ENDOFFILE -1
-#define BUFFERTOOSMALL -3
-
-#define NAMEBUFFLEN 256
-
-typedef struct Changes {
-  int * types;
-  int * values;
-  int numberOfValues;
-} Changes;
-
-void patchHeader(unsigned char *, Changes *, long, long);
-int readChanges(FILE * , Changes ** );
-fortint readgrib( FILE * , unsigned char * ,fortint * );
-
-#ifdef FORTRAN_NO_UNDERSCORE
-#define CHGRIB chgrib
-#else
-#define CHGRIB chgrib_
-#endif
-
-int CHGRIB(
-  char * originalChangeListName,
-  char * originalSourceFileName,
-  char * originalTargetFileName,
-  int l1,
-  int l2,
-  int l3 ) {
-
-char changeListName[NAMEBUFFLEN];
-char sourceFileName[NAMEBUFFLEN];
-char targetFileName[NAMEBUFFLEN];
-FILE * changeList, * sourceFile, * targetFile;
-int status;
-Changes * changes = NULL;
-unsigned char * buffer, * section1Start;
-long section1Length, ecmwfLocalUsage;
-long size, position, bufsize = BUFFLEN;
-fortint buflen;
-long productNumber = 0;
-
-/*
-//
-// Called from FORTRAN:
-//
-//    IRET = CHGRIB(NLIST, IFILE, OFILE)
-//
-// NLIST is formattted as a Fortran-style NAMELIST:
-//
-//   &USHEAD\n");
-//     IUSEC1(10)=99,
-//     IUSEC1(11)=12,
-//     IUSEC1(12)=25,
-//     IUSEC1(13)=23,
-//     IUSEC1(41)=jdc1,
-//  /
-//
-// IFILE: input file of GRIB products
-//
-// OFILE: output file of modified GRIB products
-//
-// Returns 0 if all OK, otherwise 1.
-//
-*/
-
-/*
-// Copy the filenames and put in a null terminator
-*/
-  {
-   int n;
-   char * p;
-
-   n = (l1 > NAMEBUFFLEN) ? NAMEBUFFLEN : l1;
-   strncpy( changeListName, originalChangeListName, n);
-   changeListName[n] = '\0';
-   p  = changeListName + strlen(changeListName) - 1 ;
-   while(*p == ' ') {
-     *p = 0;
-     p--;
-   }
-
-   n = (l2 > NAMEBUFFLEN) ? NAMEBUFFLEN : l2;
-   strncpy( sourceFileName, originalSourceFileName, n);
-   sourceFileName[n] = '\0';
-   p  = sourceFileName + strlen(sourceFileName) - 1 ;
-   while(*p == ' ') {
-     *p = 0;
-     p--;
-   }
-
-   n = (l3 > NAMEBUFFLEN) ? NAMEBUFFLEN : l3;
-   strncpy( targetFileName, originalTargetFileName, n);
-   targetFileName[n] = '\0';
-   p  = targetFileName + strlen(targetFileName) - 1 ;
-   while(*p == ' ') {
-     *p = 0;
-     p--;
-   }
-  }
-
-
-  if( (changeList = fopen(changeListName,"r")) == NULL ) {
-    printf("Problem opening file %s for reading\n",changeListName);
-    return (fortint) 1;
-  }
-/*
-// Read required changes
-*/
-  status = readChanges(changeList, &changes);
-  if( status != 0 ) {
-    printf("Problem reading required changes from file %s\n",changeListName);
-    return (fortint) 1;
-  }
-
-  if( ( sourceFile = fopen(sourceFileName,"r")) == NULL ) {
-    printf("Problem opening file %s for reading\n",sourceFileName);
-    return (fortint) 1;
-  }
-
-  if( (targetFile = fopen(targetFileName,"w")) == NULL ) {
-    printf("Problem opening file %s for writing\n",targetFileName);
-    return (fortint) 1;
-  }
-/*
-// Allocate buffer for reading GRIB products
-*/
-   buffer = (unsigned char *) malloc(bufsize);
-   if( buffer == NULL ) {
-    printf("Problem with malloc for GRIB buffer\n");
-    return (fortint) 1;
-  }
-
-/*
-// Loop through GRIB products:
-//  - read GRIB from sourceFile
-//  - patch section 1
-//  - write GRIB to targetFile
-*/
-
-  do {
-    buflen = bufsize;
-    position = ftell(sourceFile);
-    status = (int) readgrib(sourceFile,buffer,&buflen);
-
-    switch( status ) {
-
-      case OK:
-        section1Start = buffer+SECTION0;
-        section1Length = ((*section1Start)<<16) +
-                         (*(section1Start+1)<<8) +
-                         (*(section1Start+2));
-        ecmwfLocalUsage = ( section1Length > 28 );
-        productNumber++;
-        patchHeader(buffer,changes,ecmwfLocalUsage,productNumber);
-        size = fwrite(buffer, (size_t) 1, (size_t) buflen, targetFile);
-        if( size != buflen ) {
-          printf("Problem writing to file %s\n", targetFileName);
-          return (fortint) 1;
-        }
-        break;
-
-      case ENDOFFILE:
-        break;
-
-      case BUFFERTOOSMALL:
-        bufsize *= 10;
-        buffer = (unsigned char *) realloc(buffer,(size_t) bufsize);
-        buflen = bufsize;
-        status = fseek(sourceFile,position,0);
-        if( status < 0 ) {
-          perror("Error repositioning file");
-          return (fortint) 1;
-        }
-        status = (int) readgrib(sourceFile,buffer,&buflen);
-        if( status == BUFFERTOOSMALL ) {
-          printf("Buffer size still too small at %d bytes\n",bufsize);
-          return (fortint) 1;
-        }
-
-        section1Start = buffer+SECTION0;
-        section1Length = ((*section1Start)<<16) +
-                         (*(section1Start+1)<<8) +
-                         (*(section1Start+2));
-        ecmwfLocalUsage = ( section1Length > 28 );
-        productNumber++;
-        patchHeader(buffer,changes,ecmwfLocalUsage,productNumber);
-        size = fwrite(buffer, (size_t) 1, (size_t) buflen, targetFile);
-        if( size != buflen ) {
-          printf("Problem writing to file %s\n", targetFileName);
-          return (fortint) 1;
-        }
-        break;
-
-      default:
-        printf("Problem reading GRIB product; status = %d\n", status);
-        return (fortint) 1;
-
-    }
-
-  } while( status == 0 );
-
-/*
-// That's all
-*/
-  free(changes);
-  fclose(sourceFile);
-  fclose(targetFile);
-
-  return (fortint) 0;
-
-}
-
-int readChanges(FILE * changeList, Changes ** realChanges) {
-char line[80], expver[5];
-int type, value;
-Changes * changes;
-
-  fscanf(changeList,"%s",line);
-  if( strcmp(line,"&USHEAD") != 0 ) {
-    printf("changeList does not start with &USHEAD\n");
-    return 1;
-  }
-
-  changes = (Changes *) malloc(sizeof(Changes));
-  changes->numberOfValues = 0;
-  changes->types = NULL;
-  changes->values  = NULL;
-
-  do {
-    fscanf(changeList,"%s",line);
-    if( strcmp(line,"/") != 0 ) {
-      if(  sscanf(line,"CNMEXP='%4s',",expver) == 1 )     /* single quotes */
-        type = EXPVER;
-      else
-        if(  sscanf(line,"CNMEXP=\"%4s\",",expver) == 1 ) /* double quotes */
-          type = EXPVER;
-        else
-          if(  sscanf(line,"CNMEXP=%4s,",expver) == 1 )   /* no quotes */
-            type = EXPVER;
-          else
-            sscanf(line,"IUSEC1(%d)=%d,",&type,&value);
-
-      changes->numberOfValues++;
-      changes->types =
-        (int *) realloc(changes->types,changes->numberOfValues*sizeof(int));
-      changes->types[changes->numberOfValues-1] = type;
-
-      changes->values =
-        (int *) realloc(changes->values,changes->numberOfValues*sizeof(int));
-
-      if( type == EXPVER ) {
-        sscanf(line,"IUSEC1(%d)=%s,",&type,expver);
-        memcpy(&(changes->values[changes->numberOfValues-1]),expver,4);
-      }
-      else
-        changes->values[changes->numberOfValues-1]  = value;
-
-    }
-  } while( !feof(changeList) );
-
-  fclose(changeList);
-  *realChanges = changes;
-  return 0;
-}
-
-void patchHeader(
-  unsigned char * buffer,
-  Changes * changes,
-  long ecmwfLocalUsage,
-  long productNumber)
-{
-int next, value;
-
-  for( next = 0; next < (changes->numberOfValues); next++ ) {
-    switch( changes->types[next] ) {
-
-      case YEAR:
-        buffer[YEAROCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case MONTH:
-        buffer[MONTHOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case DAY:
-        buffer[DAYOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case HOUR:
-        buffer[HOUROCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case MINUTE:
-        buffer[MINUTEOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case CENTURY:
-        buffer[CENTURYOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TABLE2:
-        buffer[TABLE2OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case CENTRE:
-        buffer[CENTREOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case GENPID:
-        buffer[GENPIDOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case GRID:
-        buffer[GRIDOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case PARAM:
-        buffer[PARAMOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case LEVELIND:
-        buffer[LEVELINDOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case LEVEL1:
-        buffer[LEVEL1OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case LEVEL2:
-        buffer[LEVEL2OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIMEUNIT:
-        buffer[TIMEUNITOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIME1:
-        buffer[TIME1OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIME2:
-        buffer[TIME2OCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case TIMERANGE:
-        buffer[TIMERANGEOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case NUMINAV:
-        value = changes->values[next];
-        buffer[NUMINAVOCTET] = (unsigned char) ( (value >> 8 ) & 0xff);
-        buffer[NUMINAVOCTET+1] = (unsigned char) ( value & 0xff);
-        break;
-
-      case NUMMISSING:
-        buffer[NUMMISSINGOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case SUBCENTRE:
-        buffer[SUBCENTREOCTET] = (unsigned char) changes->values[next];
-        break;
-
-      case DECSCALE:
-        value = changes->values[next];
-        buffer[DECSCALEOCTET] = (unsigned char) ( (value >> 8 ) & 0xff);
-        buffer[DECSCALEOCTET+1] = (unsigned char) ( value & 0xff);
-        break;
-
-      case LOCALUSE:
-/*
-//      buffer[LOCALUSEOCTET] = (unsigned char) changes->values[next];
-*/
-        printf("Following change ignored for product %d\n", productNumber);   
-        printf(" IUSEC1(%d)=%d,\n",changes->types[next], changes->values[next]);
-        printf("Not allowed to change ECMWF local usage definition number\n");
-        break;
-
-      case CLASS:
-        if( ecmwfLocalUsage )
-          buffer[CLASSOCTET] = (unsigned char) changes->values[next];
-        else {
-          printf("Following change ignored for product %d\n", productNumber);   
-          printf(" IUSEC1(%d)=%d,\n",changes->types[next], changes->values[next]);
-          printf("Cannot change CLASS, no ECMWF local definition in GRIB\n");
-        }
-        break;
-
-      case TYPE:
-        if( ecmwfLocalUsage )
-          buffer[TYPEOCTET] = (unsigned char) changes->values[next];
-        else {
-          printf("Following change ignored for product %d\n", productNumber);   
-          printf(" IUSEC1(%d)=%d,\n",changes->types[next], changes->values[next]);
-          printf("Cannot change TYPE, no ECMWF local definition in GRIB\n");
-        }
-        break;
-
-      case STREAM:
-        if( ecmwfLocalUsage ) {
-          value = changes->values[next];
-          buffer[STREAMOCTET] = (unsigned char) ( (value >> 8 ) & 0xff);
-          buffer[STREAMOCTET+1] = (unsigned char) ( value & 0xff);
-        }
-        else {
-          printf("Following change ignored for product %d\n", productNumber);
-          printf(" IUSEC1(%d)=%d,\n",changes->types[next], changes->values[next]);
-          printf("Cannot change STREAM, no ECMWF local definition in GRIB\n");
-        }
-        break;
-
-      case EXPVER:
-        if( ecmwfLocalUsage )
-          memcpy(&buffer[EXPVEROCTET],&(changes->values[next]),4);
-        else {
-          printf("Following change ignored for product %d\n", productNumber);
-          {
-           char expver[5];
-             memcpy(expver,&(changes->values[next]),4);
-             expver[4] = 0;
-             printf(" IUSEC1(%d)=%s,\n",changes->types[next], expver);
-          }
-          printf("Cannot change EXPVER, no ECMWF local definition in GRIB\n");
-        }
-        break;
-
-      default:
-        printf("Following change ignored for product %d\n", productNumber);
-        printf(" IUSEC1(%d)=%d,\n",changes->types[next], changes->values[next]);
-        printf("Requested change not suitable for section 1 in the GRIB\n");
-        printf("Only bytes found in ECMWF local definition 1 can be changed\n");
-        break;
-
-    }
-
-  }
-  return;
-}
diff --git a/tools/modify_grib/modify_grib.F90 b/tools/modify_grib/modify_grib.F90
deleted file mode 100755
index ef47d29..0000000
--- a/tools/modify_grib/modify_grib.F90
+++ /dev/null
@@ -1,411 +0,0 @@
-PROGRAM MODIFY_GRIB
-!
-!     CHANGES THE HEADERS OF ALL GRIB FIELDS CONTAINED IN A FILE
-!
-!     Written by D.Dent  (20/11/2001)
-
-!     Interface:  modify_grib -i input_file -o output_file -n namelist_file [-d]
-
-!     Parameters:
-!                 -i   input_file, containing GRIB fields
-!                 -o   output_file, contains the same GRIB fields
-!                                   with modified headers
-!                 -n   namelist_file, containing Fortran namelist format data
-!                      namelist USHEAD
-!                      allows details ofchanges to header fields to be specified
-!                 -d   optional flag to force decoding/recoding
-
-!     This program is derived from:
-!        change_grib    (Pedro Viterbo)
-!        changeGrib     (John Chambers)
-!        fix_local_grib (Jan Haseler)
-!     and combines all of the requirements in one application.
-!
-!     Features:
-!      (1) Do not decode/encode unless necessary
-!          This is achieved by calling the C-coded routine 'chgrib'
-!      (2) The input fields are decode/recoded:
-!            if the namelist input requires a change in packing density
-!            if a command line flag is provided (-d)
-!          This option also imposes an ECMWF local GRIB definition
-!          The output is GRIB coded using option 'M' to ensure that
-!          fields which contain missing data are kept to a constant length
-!          
-
-PARAMETER(JPPKLEN=0,JPUNPKLEN=2000000, &
-    JPMAXLEV=200,JD1=1024,JD2=4096,JD4=1024,JLV=10+JPMAXLEV)
-
-!  IMPLICIT NONE
-
-INTEGER :: IOPTVAL
-LOGICAL :: LLDECODE
-CHARACTER*16  :: CLOPTP='i:o:n:d'
-CHARACTER*64  :: CL_USAGE
-CHARACTER*128 :: CLARG
-CHARACTER*128 :: CL_NAMELIST_FILE,CL_INPUT_FILE,CL_OUTPUT_FILE
-CHARACTER*1   :: CLOPT
-
-INTEGER ISEC0(2),ISEC1(JD1),ISEC2(JD2),ISEC3(2),ISEC4(JD4)
-INTEGER IUSEC0(2),IUSEC1(JD1),IUSEC2(JD2),IUSEC3(2), IUSEC4(JD4)
-INTEGER,ALLOCATABLE :: IGRIB(:)
-INTEGER :: IPPKLEN=JPPKLEN
-INTEGER :: IUNPKLEN=JPUNPKLEN
-INTEGER GETOPT
-INTEGER CHGRIB
-
-REAL*8,ALLOCATABLE :: ZUNP(:)
-REAL*8  ZSEC2(JLV),ZSEC3(2)
-
-CHARACTER*4 CNMEXP
-NAMELIST /USHEAD/IUSEC0,IUSEC1,IUSEC2,IUSEC3,IUSEC4,CNMEXP
-
-!
-!    read input parameters
-!
-CL_NAMELIST_FILE=""
-CL_INPUT_FILE=""
-CL_OUTPUT_FILE=""
-CL_USAGE='Usage: modify_grib -i input_file -o output_file -n namelist_file [-d]'
-IBYTES=4
-LLDECODE=.FALSE.
-IOPTVAL=GETOPT(CLOPTP,CLARG)
-
-DO WHILE (IOPTVAL > 0)
-  CLOPT=CHAR(IOPTVAL)
-  IF(CLOPT == 'n') THEN
-    CL_NAMELIST_FILE=CLARG
-  ELSEIF(CLOPT == 'i') THEN
-    CL_INPUT_FILE=CLARG
-  ELSEIF(CLOPT == 'o') THEN
-    CL_OUTPUT_FILE=CLARG
-  ELSEIF(CLOPT == 'd') THEN
-    LLDECODE=.TRUE.
-  ELSE
-    WRITE(0,'(A,A)') 'Invalid parameter ',CLOPT
-    CALL ABORT
-  ENDIF
-  IOPTVAL=GETOPT(CLOPTP,CLARG)
-ENDDO
-
-IF(CL_NAMELIST_FILE == "") THEN
-  WRITE(0, *) 'namelist file missing'
-  WRITE(0, *) CL_USAGE
-  CALL ABORT
-ENDIF
-IF(CL_INPUT_FILE == "") THEN
-  WRITE(0, *) 'input file missing'
-  WRITE(0, *) CL_USAGE
-  CALL ABORT
-ENDIF
-IF(CL_OUTPUT_FILE == "") THEN
-  WRITE(0, *) 'output file missing'
-  WRITE(0, *) CL_USAGE
-  CALL ABORT
-ENDIF
-IF(CL_INPUT_FILE == CL_OUTPUT_FILE) THEN
-  WRITE(0, *) 'modify_grib: output file cannot be the same as the input file'
-  WRITE(0, *) CL_USAGE
-  CALL ABORT
-ENDIF
-
-!  Initialize namelist, and read namelist file
-!
-DO JP =1,2
-  IUSEC3(JP)=-999
-ENDDO
-!
-DO JP=1,JD1
-  IUSEC1(JP)=-999
-ENDDO
-!
-DO JP=1,JD2
-  IUSEC2(JP)=-999
-ENDDO
-!
-DO JP=1,JD4
-  IUSEC4(JP)=-999
-ENDDO
-!
-CNMEXP='9999'
-!
-OPEN(12,FILE=CL_NAMELIST_FILE,FORM='FORMATTED',STATUS='OLD',ERR=900)
-!
-READ(12,USHEAD)
-!
-DO JP=1,JD1
-  IF(IUSEC1(JP).NE.-999) THEN
-    WRITE(*,*) &
-   "Element ",JP," of header 1 changed to ",IUSEC1(JP)
-  ENDIF
-ENDDO
-!
-IF (CNMEXP(1:4).NE.'9999') THEN
-  WRITE(*,*) &
-    "EXPVER (element 41 of header 1) changed to ",CNMEXP(1:4)
-ENDIF
-!
-DO JP=1,JD2
-  IF(IUSEC2(JP).NE.-999) THEN
-    WRITE(*,*) &
-      "Element ",JP," of header 2 changed to ",IUSEC2(JP)
-  ENDIF
-ENDDO
-DO JP=1,2
-  IF(IUSEC3(JP).NE.-999) THEN
-    WRITE(*,*) &
-    "Element ",JP," of header 3 changed to ",IUSEC3(JP)
-  ENDIF
-ENDDO
-!
-DO JP=1,JD4
-  IF(IUSEC4(JP).NE.-999) THEN
-    WRITE(*,*) &
-      "Element ",JP," of header 4 changed to ",IUSEC4(JP)
-   ENDIF
-ENDDO
-!
-IF(IUSEC4(2) /= -999) LLDECODE=.TRUE.
-
-IF(LLDECODE) THEN
-
-  WRITE(*, *) 'Grib fields will be re-coded '
-!
-!      Open input GRIB file
-!
-  CALL PBOPEN(FILE1, CL_INPUT_FILE, "R", IRET)
-  IF( IRET.NE.0 ) THEN
-    WRITE(*, *) 'Return code from PBOPEN = ',IRET,' for file ',CL_INPUT_FILE
-    CALL ABORT
-  ENDIF
-!
-!      Open output GRIB file
-!
-  CALL PBOPEN(FILE2, CL_OUTPUT_FILE, "w", IRET)
-  IF( IRET.NE.0 ) THEN
-    WRITE (*, *) 'Return code from PBOPEN = ',IRET,' for file ',CL_OUTPUT_FILE
-    CALL ABORT
-  ENDIF
-
-!    allocate space
-
-  IF(IPPKLEN > 0) ALLOCATE(IGRIB(IPPKLEN))
-  IF(IUNPKLEN > 0) ALLOCATE(ZUNP(IUNPKLEN))
-
-!    decode and recode each field
-
-  IFLD=0
-  READ_LOOP:DO
-
-!     Read packed field
-!
-    CALL PBSIZE(FILE1, IRET )
-    IF( IRET <= 0 ) THEN
-      IF(IRET < 0)  write(*,*)'PBSIZE RETURNED ',IRET
-      EXIT READ_LOOP
-    ELSE
-      IF(IRET > IPPKLEN) THEN
-!     write(*,*) ' re-allocate IGRIB from ',IPPKLEN,' to ',IRET
-        IF(ALLOCATED(IGRIB)) DEALLOCATE(IGRIB)
-        IPPKLEN=IRET
-        ALLOCATE(IGRIB(IPPKLEN))
-      ENDIF
-    ENDIF
-    CALL PBGRIB(FILE1, IGRIB, IBYTES*IPPKLEN , ILENOUT, IRET )
-!
-    IF(IRET == -3 ) THEN
-!     IGRIB array is too small
-
-      write(*,*)' IGRIB array too small ',IPPKLEN
-      CALL ABORT
-  
-    ELSE IF(IRET < -1 ) THEN
-      write(*,*) ' problems reading the grib file  iret= ',iret
-      CALL ABORT
-    ENDIF
-!
-    IFLD = IFLD + 1
-
-!     find size of field to be decoded and allocate space for it
-
-!     Unpack GRIB headers
-!
-    IRET = 0
-    CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4, &
-                 ZUNP,IUNPKLEN,IGRIB,IPPKLEN,IWORD,'J',IRET)
-    IF( IRET.GT.0 ) THEN
-        WRITE(0,*) 'GRIBEX problem decoding headers for ',IFLD
-        WRITE(0,*) 'GRIBEX return code = ',IRET
-        CALL ABORT
-    ENDIF
-!
-    IFIELD_SIZE=ABS(ISEC4(1))
-    IF(SIZE(ZUNP) < IFIELD_SIZE) THEN
-      IUNPKLEN=IFIELD_SIZE
-!     write(*,*)' ZUNP too small ',SIZE(ZUNP),IFIELD_SIZE
-    ENDIF
-    IF(ALLOCATED(ZUNP) .AND. SIZE(ZUNP) < IFIELD_SIZE) THEN
-      DEALLOCATE(ZUNP)
-!     write(*,*)' ZUNP de-allocated ',IUNPKLEN
-    ENDIF
-    IF(.NOT.ALLOCATED(ZUNP)) THEN
-      ALLOCATE(ZUNP(IUNPKLEN))
-!     write(*,*)' ZUNP allocated ',IUNPKLEN
-    ENDIF
-!
-!     The missing data value must be specified in case the field
-!     contains a bit mask
-
-    ISEC3(2) = -999999999
-    ZSEC3(2) = -999999999.0
-
-!     Unpack GRIB message.
-!
-    IRET = 0
-    CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4, &
-                 ZUNP,IUNPKLEN,IGRIB,IPPKLEN,IWORD,'D',IRET)
-    IF( IRET.GT.0 ) THEN
-        WRITE(0,*) 'GRIBEX problem decoding product ',IFLD
-        WRITE(0,*) 'GRIBEX return code = ',IRET
-        CALL ABORT
-    ENDIF
-!
-!     -----------------------------------------------------------------|
-!
-!     Repack the field and write to results file
-!
-!
-!     Changes the header, according to user requests
-!
-    DO JP=1,JD1
-      IF(IUSEC1(JP).NE.-999) THEN
-        ISEC1(JP)=IUSEC1(JP)
-      ENDIF
-    ENDDO
-!
-    IF (CNMEXP(1:4).NE.'9999') THEN
-        READ(CNMEXP,'(A4)') ISEC1(41)
-    ENDIF
-!
-    DO JP=1,JD2
-      IF(IUSEC2(JP).NE.-999) THEN
-        ISEC2(JP)=IUSEC2(JP)
-      ENDIF
-    ENDDO
-    DO JP=1,2
-      IF(IUSEC3(JP).NE.-999) THEN
-        ISEC3(JP)=IUSEC3(JP)
-      ENDIF
-    ENDDO
-!
-    DO JP=1,JD4
-      IF(IUSEC4(JP).NE.-999) THEN
-        ISEC4(JP)=IUSEC4(JP)
-       ENDIF
-    ENDDO
-
-!     Add local GRIB definition, if it is missing for invariant fields
-!
-    IF (ISEC1(24) == 0) then
-      WRITE(*,*) ' Add local GRIB definition for parameter',ISEC1(6)
-      ISEC1(24)=1
-     
-      DO J=25,36
-        IF(IUSEC1(J).NE.-999) THEN
-          ISEC1(J)=IUSEC1(J)
-        ELSE
-          ISEC1(J)=0
-        ENDIF
-      ENDDO
-
-      DO J=37,43
-        IF (IUSEC1(j) == -999) then
-          localdef:  SELECT CASE(J)
-            CASE(37)            !  local definition type 1
-              ISEC1(37)=1
-            CASE(38)            !  class (default rd)
-              ISEC1(38)=2
-            CASE(39)            !  type (default an)
-              ISEC1(39)=2
-            CASE(40)            !  stream (default daily archive)
-              ISEC1(40)=1025
-            CASE(41)            !  expver
-              IF (CNMEXP(1:4).NE.'9999') THEN
-                READ(CNMEXP,'(A4)') ISEC1(41)
-              ENDIF
-            CASE(42)            !  mars labelling (default simple)
-              ISEC1(42)=0
-            CASE(43)            !  ensemble (default no)
-              ISEC1(43)=0
-          END SELECT localdef
-        ELSE
-          ISEC1(J)=IUSEC1(J)
-        ENDIF
-      ENDDO
-
-      DO J=44,JD1
-        IF(IUSEC1(J).NE.-999) THEN
-          ISEC1(J)=IUSEC1(J)
-        ELSE
-          ISEC1(J)=0
-        ENDIF
-      ENDDO
-
-    ENDIF
-!
-    IRET = 1
-    IPUNP = ISEC4(1)
-    CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4, &
-      ZUNP,IPUNP,IGRIB,IPPKLEN,IWORD,'M',IRET)
-    IF( IRET.GT.0 ) THEN
-      WRITE(*,*) 'GRIBEX problem encoding product ',IFLD
-      WRITE(*,*) 'GRIBEX return code = ',IRET
-      CALL ABORT
-    ENDIF
-!
-    ILENOUT = IWORD * IBYTES
-    CALL PBWRITE(FILE2, IGRIB, ILENOUT, IRET)
-    IF( IRET.LT.ILENOUT ) THEN
-      WRITE(*,*) 'Problem writing product ',IFLD
-      WRITE(*,*) 'Return code from PBWRITE = ',IRET
-      CALL ABORT
-    ENDIF
-
-  ENDDO READ_LOOP
-
-  CALL PBCLOSE(FILE2, IRET)
-  IF( IRET.LT.0 ) THEN
-    WRITE(*, *) 'Return code from PBCLOSE = ',IRET
-    CALL ABORT
-  ENDIF
-!
-  WRITE(*, *) 'Number of GRIB products changed = ',IFLD
-  CALL PBCLOSE(FILE1, IRET)
-  IF( IRET.LT.0 ) THEN
-    WRITE (*, *) 'Return code from PBGRIB = ',IRET
-    CALL PBCLOSE(FILE1, IRET)
-    WRITE(*,*) 'Fault in PBGRIB reading product number ', IFLD
-    CALL ABORT
-  ENDIF
-
-  STOP
-
-ELSE
-
-!   no decoding/encoding
-
-  WRITE(*, *) 'Grib fields will NOT be re-coded '
-  IRET = CHGRIB(CL_NAMELIST_FILE,CL_INPUT_FILE,CL_OUTPUT_FILE)
-  WRITE(0,'(A,I4)') ' CHGRIB return code ',IRET
-  IF(IRET /= 0) THEN
-    WRITE(0,'(A,I4)') ' CHGRIB return code ',IRET
-    CALL ABORT
-  ENDIF
-ENDIF
-
-STOP
-
-900 CONTINUE
-WRITE(*, *) 'Namelist OPEN failed for file ',CL_NAMELIST_FILE
-CALL ABORT
-!
-END
diff --git a/tools/singlePointInterpolation/CMakeLists.txt b/tools/singlePointInterpolation/CMakeLists.txt
index f7783b5..f8d094e 100644
--- a/tools/singlePointInterpolation/CMakeLists.txt
+++ b/tools/singlePointInterpolation/CMakeLists.txt
@@ -1,11 +1,11 @@
 
 # configure Fortran-based targets for double precision (compilation & linking)
-set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${emos_double_precision_flags}")
+ecbuild_add_fortran_flags(${emos_double_precision_flags})
 
 
 # executable
 ecbuild_add_executable(
   TARGET  singlePointInterpolation
   SOURCES singlePointInterpolation.F
-  LIBS    emos ${GRIB_API_LIBRARIES} )
+  LIBS    emos )
 
diff --git a/tools/singlePointInterpolation/singlePointInterpolation.F b/tools/singlePointInterpolation/singlePointInterpolation.F
index 6a3b705..ab51245 100644
--- a/tools/singlePointInterpolation/singlePointInterpolation.F
+++ b/tools/singlePointInterpolation/singlePointInterpolation.F
@@ -13,12 +13,12 @@ C
       INTEGER ISEC4(1024)
       INTEGER INBUFF(JPACK), OUTGRIB(JPACK)
       INTEGER KPTS(1024)
-      INTEGER  NSIZE, OUTLEN
-      INTEGER IRET, FILE1, FILE2, JCOUNT
+      INTEGER NSIZE, OUTLEN
+      INTEGER IRET, FILE1, FILE2
       INTEGER ILENB, LENOUT, IPUNP, IWORD, LOOP, LOOPO
-      INTEGER NLON, NLAT, NPTS, NGAUSS, NLATLON, IJDC
-      INTEGER  IFILEN, IOS, J, NARGS
-    
+      INTEGER NLON, NLAT, NPTS, NGAUSS, NLATLON
+      INTEGER IFILEN, IOS, NARGS
+
 C
       REAL ZSEC2(1024)
       REAL ZSEC3(2)
@@ -26,15 +26,16 @@ C
       REAL USEC4(JPACK*4)
 
       LOGICAL ASCII
+      CHARACTER*1 HTYPE
 C
       REAL AREA(4), GRID(2), POLE(2), LATS(1000), LONS(1000)
       REAL PLATS(1024), REALV(4), DUMMY(1)
 C
       CHARACTER*10 CHARV(1)
-      CHARACTER*128 POINTS, INFILE, OUTFILE, CARG(4), TEMP
+      CHARACTER*128 POINTS, INFILE, OUTFILE
 C
-      INTEGER  IARGC, HRG2LL, HIRLSM, HSP2GG, INTOUT, INTF
-      EXTERNAL HRG2LL, HIRLSM, HSP2GG, INTOUT, INTF
+      INTEGER  HRG2LL, HIRLSM, HSH2GG, INTOUT, INTF, IARGC
+      EXTERNAL HRG2LL, HIRLSM, HSH2GG, INTOUT, INTF
 C
 C     Commented out for gfortran
 C
@@ -72,7 +73,7 @@ C
         CALL GETARG(3,OUTFILE)
 
          if(NARGS.eq.4) ASCII = .TRUE.
-            
+
 C
 C     Open the input GRIB file
 C
@@ -101,11 +102,11 @@ C
             END IF
       END IF
 
-       	 CALL PBOPEN(FILE2, outfile, "w", IRET)
-         IF( IRET.NE.0 ) THEN
-           WRITE (*, *) 'Return code from PBOPEN = ',IRET
-           STOP 'Fault in PBOPEN for output file'
-         ENDIF
+      CALL PBOPEN(FILE2, outfile, "w", IRET)
+      IF( IRET.NE.0 ) THEN
+        WRITE (*, *) 'Return code from PBOPEN = ',IRET
+        STOP 'Fault in PBOPEN for output file'
+      ENDIF
 C
 C     Open the file of lat/longs
 C
@@ -187,7 +188,9 @@ C     gaussian grid before interpolation
 C
       IF( ISEC2(1).EQ.50 ) THEN
 C
-        IRET = HSP2GG(ISEC2(2),NGAUSS,KPTS,PLATS,NSIZE)
+        NGAUSS = 0
+        HTYPE  = ''
+        IRET = HSH2GG(0,0,ISEC2(2),NGAUSS,HTYPE,KPTS,PLATS,NSIZE)
         IF( IRET.NE.0 ) THEN
           WRITE(*,*) 'Failed to find suitable gaussian grid for the'
           WRITE(*,*) 'spectral input GRIB'
diff --git a/version.c b/version.c
index 0b04ad3..7edfec9 100644
--- a/version.c
+++ b/version.c
@@ -1,13 +1,21 @@
+
 #include "stdio.h"
 
 #include "libemos_version.h"
 
-int main()
+#ifdef FORTRAN_LINKER_PGI
+#define main_ MAIN_
+#else
+#define main_ main
+#endif
+
+
+int main_()
 {
-	printf("libemos\n");
-	printf("version : %s\n", libemos_version_str() );
-	printf("cycle : %d\n", libemos_version_int() );
-	printf("sha1 : %s\n", libemos_git_sha1() );
-	return 0;
+    printf("libemos\n");
+    printf("version : %s\n", libemos_version_str() );
+    printf("cycle : %d\n", libemos_version_int() );
+    printf("sha1 : %s\n", libemos_git_sha1() );
+    return 0;
 }
 

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



More information about the debian-science-commits mailing list