Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/Doxyfile
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/Doxyfile	(revision 7025)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/Doxyfile	(revision 7025)
@@ -0,0 +1,2331 @@
+# Doxyfile 1.8.8
+
+# 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           = "SIREN"
+
+# 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         = "NEMO 3.6"
+
+# 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          = "System and Interface for oceanic RElocatable Nesting"
+
+# With the PROJECT_LOGO tag one can specify an logo or 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           = ./src/docsrc/Image/logoSirenNemo.png
+
+# 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       = ./doc
+
+# 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               = 3
+
+# 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   = NO
+
+# 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      = 
+
+# 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 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            = NO
+
+# 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         = NO
+
+# 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. When 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  = NO
+
+# 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       = YES
+
+# 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 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                  = ./src ./src/docsrc
+
+# 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          = 
+
+# 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              = NO
+
+# 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                =
+
+# 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             = ./src/docsrc/Image
+
+# 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         = NO
+
+# 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
+
+#---------------------------------------------------------------------------
+# 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     = NO
+
+# 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            = html
+
+# 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 therefor more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra stylesheet files is of importance (e.g. the last
+# stylesheet 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 stylesheet 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 stylesheets (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
+
+# When 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 prerendered 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         = YES
+
+# 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 empy string,
+# for the replacement values of the other commands the user is refered 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_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    =
+
+#---------------------------------------------------------------------------
+# 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 includes 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               = NO
+
+# 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               = YES
+
+# 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             = NO
+
+# 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           = NO
+
+# 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.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+PLANTUML_JAR_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 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
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/README
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/README	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/README	(revision 7025)
@@ -1,50 +1,7 @@
-This is a first release of SIREN.
 
-To create SIREN documentation, go to ./src and run doxygen 
+To create SIREN documentation, run doxygen in TOOLS/SIREN directory 
 (http://www.stack.nl/~dimitri/doxygen/index.html version 1.8.3.1 or upper)
 then
-   open ../doc/index.html 
+   open ./TOOLS/SIREN/doc/html/index.html in your web browser
 or 
-   run ../doc/latex/gmake and open refman.pdf 
-
-
-templates of namelists could be find in templates directory.
-read documentation for more information.
-
- 1- program to create coordinate file :
-
-   ./create_coord create_coord.nam
-
-
- Variables are extracted from the input coordinates coarse grid and
- interpolated to create fine coordinates files.
-
- 2- program to create bathymetry file:
-
- ./create_bathy create_bathy.nam
-
- Bathymetry could be extracted from fine grid Bathymetry file, or
- interpolated from coarse grid Bathymetry file.
-
- 3- program to merge bathymetry file at boundaries :
-
- ./merge_bathy merge_bathy.nam
-
- Coarse grid Bathymetry is interpolated on fine grid.
- Then fine Bathymetry and refined coarse bathymetry are merged at
- boundaries.
-
- 4- program to create restart file :
-
- ./create_restart create_restart.nam
-
- Variables are read from restart file, or standard output.
- Then theses variables are interpolated on fine grid.
- Finally table are split over new decomposition.
-
- 5- program to create boundary files (OBC) :
-
- ./create_boundary create_boundary.nam
-
- Variables are read from standard output.
- Then theses variables are interpolated on fine grid boundaries.
+   run ./TOOLS/SIREN/doc/latex/gmake and open ./TOOLS/SIREN/doc/latex/refman.pdf 
Index: anches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/Doxyfile
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 7024)
+++ 	(revision )
@@ -1,2331 +1,0 @@
-# Doxyfile 1.8.8
-
-# 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           = "SIREN"
-
-# 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         = "NEMO 3.6"
-
-# 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          = "System and Interface for oceanic RElocatable Nesting"
-
-# With the PROJECT_LOGO tag one can specify an logo or 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           = ./docsrc/Image/logoSirenNemo.png
-
-# 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       = ../doc
-
-# 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               = 3
-
-# 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   = NO
-
-# 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      = 
-
-# 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 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            = NO
-
-# 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         = NO
-
-# 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. When 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  = NO
-
-# 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       = YES
-
-# 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 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                  = . ./docsrc
-
-# 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          = 
-
-# 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              = NO
-
-# 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                =
-
-# 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             = ./docsrc/Image
-
-# 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         = NO
-
-# 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
-
-#---------------------------------------------------------------------------
-# 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     = NO
-
-# 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            = html
-
-# 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 therefor more robust against future updates.
-# Doxygen will copy the style sheet files to the output directory.
-# Note: The order of the extra stylesheet files is of importance (e.g. the last
-# stylesheet 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 stylesheet 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 stylesheets (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
-
-# When 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 prerendered 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         = YES
-
-# 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 empy string,
-# for the replacement values of the other commands the user is refered 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_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    =
-
-#---------------------------------------------------------------------------
-# 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 includes 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               = NO
-
-# 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               = YES
-
-# 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             = NO
-
-# 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           = NO
-
-# 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.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-PLANTUML_JAR_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 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
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/boundary.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 7025)
@@ -1529,5 +1529,8 @@
    !> @author J.Paul 
    !> @date November, 2013 - Initial Version 
-   ! 
+   !> @date June, 2016
+   !> - Bug fix: take into account that boundaries are compute on T point,
+   !>   but expressed on U,V point
+   !>
    !> @param[inout] td_bdy boundary structure 
    !> @param[in] td_var    variable structure 
@@ -1552,7 +1555,8 @@
       il_max(jp_west )=td_var%t_dim(2)%i_len
  
-      il_maxindex(jp_north)=td_var%t_dim(2)%i_len-ip_ghost
+      ! index expressed on U,V point, move on T point.
+      il_maxindex(jp_north)=td_var%t_dim(2)%i_len-ip_ghost+1
       il_maxindex(jp_south)=td_var%t_dim(2)%i_len-ip_ghost
-      il_maxindex(jp_east )=td_var%t_dim(1)%i_len-ip_ghost
+      il_maxindex(jp_east )=td_var%t_dim(1)%i_len-ip_ghost+1
       il_maxindex(jp_west )=td_var%t_dim(1)%i_len-ip_ghost
 
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 7025)
@@ -22,5 +22,6 @@
 !> <br/>    
 !> \image html  bathy_40.png 
-!> \image latex bathy_30.png
+!> <center>\image latex bathy_30.png
+!> </center>
 !>
 !> @note 
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 7025)
@@ -26,5 +26,6 @@
 !>  <br/> 
 !> \image html  boundary_NEATL36_70.png 
-!> \image latex boundary_NEATL36_70.png
+!> <center>\image latex boundary_NEATL36_70.png
+!> </center>
 !>
 !> @note 
@@ -65,5 +66,4 @@
 !>
 !>    * _vertical grid namelist (namzgr)_:<br/>
-!>       - dn_pp_to_be_computed  :
 !>       - dn_ppsur              :
 !>       - dn_ppa0               :
@@ -161,5 +161,6 @@
 !>             - cn_north='index1(width),first1:last1|index2,first2:last2'
 !>             \image html  boundary_50.png 
-!>             \image latex boundary_50.png
+!>             <center>\image latex boundary_50.png
+!>             </center>
 !>       - cn_south  : south boundary indices on fine grid
 !>       - cn_east   : east  boundary indices on fine grid
@@ -198,4 +199,7 @@
 !> @date January, 2016
 !> - same process use for variable extracted or interpolated from input file.
+!>
+!> @todo
+!> - rewitre using meshmask instead of bathymetry and coordinates files.
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -396,5 +400,4 @@
 
    !namzgr
-   REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
    REAL(dp)                                :: dn_ppsur   = -3958.951371276829_dp
    REAL(dp)                                :: dn_ppa0    =   103.953009600000_dp
@@ -457,5 +460,4 @@
  
    NAMELIST /namzgr/ &
-   &  dn_pp_to_be_computed, &
    &  dn_ppsur,     &
    &  dn_ppa0,      &
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_coord.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 7025)
@@ -76,4 +76,5 @@
 !>
 !>    * _nesting namelist (namnst)_:<br/>
+!>       you could define sub domain with coarse grid indices or with coordinates.
 !>       - in_imin0 : i-direction lower left  point indice 
 !> of coarse grid subdomain to be used
@@ -84,9 +85,14 @@
 !>       - in_jmax0 : j-direction upper right point indice
 !> of coarse grid subdomain to be used
+!>       - rn_lonmin0 : lower left  longitude of coarse grid subdomain to be used
+!>       - rn_lonmax0 : upper right longitude of coarse grid subdomain to be used
+!>       - rn_latmin0 : lower left  latitude  of coarse grid subdomain to be used
+!>       - rn_latmax0 : upper right latitude  of coarse grid subdomain to be used
 !>       - in_rhoi  : refinement factor in i-direction
 !>       - in_rhoj  : refinement factor in j-direction<br/>
 !>
 !>       \image html  grid_zoom_40.png 
-!>       \image latex grid_zoom_40.png
+!>       <center> \image latex grid_zoom_40.png 
+!>       </center>
 !>
 !>    * _output namelist (namout)_:
@@ -102,4 +108,6 @@
 !> @date September, 2015
 !> - manage useless (dummy) variable, attributes, and dimension
+!> @date September, 2016
+!> - allow to use coordinate to define subdomain
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -139,5 +147,11 @@
    INTEGER(i4)                                          :: il_nvar
    INTEGER(i4)                                          :: il_ew
+   INTEGER(i4)                                          :: il_imin0
+   INTEGER(i4)                                          :: il_imax0
+   INTEGER(i4)                                          :: il_jmin0
+   INTEGER(i4)                                          :: il_jmax0
+
    INTEGER(i4)      , DIMENSION(ip_maxdim)              :: il_rho
+   INTEGER(i4)      , DIMENSION(2)                      :: il_index
    INTEGER(i4)      , DIMENSION(2,2,ip_npoint)          :: il_offset
 
@@ -177,4 +191,8 @@
 
    !namnst
+   REAL(sp)          :: rn_lonmin0 = -360.
+   REAL(sp)          :: rn_lonmax0 = -360.
+   REAL(sp)          :: rn_latmin0 = -360.
+   REAL(sp)          :: rn_latmax0 = -360.
    INTEGER(i4)       :: in_imin0 = 0
    INTEGER(i4)       :: in_imax0 = 0
@@ -207,4 +225,8 @@
    
    NAMELIST /namnst/ &  !  nesting namelist
+   &  rn_lonmin0, &     !< lower left  coarse grid longitude
+   &  rn_lonmax0, &     !< upper right coarse grid longitude
+   &  rn_latmin0, &     !< lower left  coarse grid latitude
+   &  rn_latmax0, &     !< upper right coarse grid latitude
    &  in_imin0,   &     !< i-direction lower left  point indice 
    &  in_imax0,   &     !< i-direction upper right point indice
@@ -301,5 +323,39 @@
 
    ! check nesting parameters
-   IF( in_imin0 < 0 .OR. in_imax0 < 0 .OR. in_jmin0 < 0 .OR. in_jmax0 < 0)THEN
+   il_index(:)=0
+   IF( rn_lonmin0 >= -180. .AND. rn_lonmin0 <= 360 .AND. &
+     & rn_latmin0 >= -90.  .AND. rn_latmin0 <= 90. )THEN
+
+      il_index(:)=grid_get_closest(tl_coord0, &
+         &                         REAL(rn_lonmin0,dp), REAL(rn_latmin0,dp), &
+         &                         cd_pos='ll') 
+      il_imin0=il_index(1)
+      il_jmin0=il_index(2)
+   ELSE
+      il_imin0=in_imin0
+      il_jmin0=in_jmin0
+   ENDIF
+
+   il_index(:)=0
+   IF( rn_lonmax0 >= -180. .AND. rn_lonmax0 <= 360 .AND. &
+     & rn_latmax0 >= -90.  .AND. rn_latmax0 <= 90. )THEN
+      il_index(:)=grid_get_closest(tl_coord0, &
+         &                         REAL(rn_lonmax0,dp), REAL(rn_latmax0,dp), &
+         &                         cd_pos='ur') 
+      il_imax0=il_index(1)
+      il_jmax0=il_index(2)
+   ELSE
+      il_imax0=in_imax0
+      il_jmax0=in_jmax0
+   ENDIF
+
+   ! forced indices for east west cyclic domain
+   IF( rn_lonmin0 == rn_lonmax0 .AND. &
+     & rn_lonmin0 /= -360. )THEN
+      il_imin0=0
+      il_imax0=0
+   ENDIF
+
+   IF( il_imin0 < 0 .OR. il_imax0 < 0 .OR. il_jmin0 < 0 .OR. il_jmax0 < 0)THEN
       CALL logger_fatal("CREATE COORD: invalid points indices."//&
       &  " check namelist "//TRIM(cl_namelist))
@@ -318,10 +374,10 @@
 
    ! check domain validity
-   CALL grid_check_dom(tl_coord0, in_imin0, in_imax0, in_jmin0, in_jmax0 )
+   CALL grid_check_dom(tl_coord0, il_imin0, il_imax0, il_jmin0, il_jmax0 )
 
    ! compute domain
    tl_dom=dom_init( tl_coord0,         &
-   &                in_imin0, in_imax0,&
-   &                in_jmin0, in_jmax0 )
+   &                il_imin0, il_imax0,&
+   &                il_jmin0, il_jmax0 )
 
    ! add extra band (if need be) to compute interpolation
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_meshmask.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_meshmask.f90	(revision 7025)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_meshmask.f90	(revision 7025)
@@ -0,0 +1,1620 @@
+!----------------------------------------------------------------------
+! NEMO system team, System and Interface for oceanic RElocable Nesting
+!----------------------------------------------------------------------
+!
+! PROGRAM: create_meshmask
+!
+! DESCRIPTION:
+!> @file
+!> @brief 
+!>  This program creates the NetCDF file(s) which contain(s) all the
+!>  ocean domain informations (mesh and mask arrays).
+!>
+!> @details
+!> @section sec1 method
+!>  Bathymetry (and optionally ice shelf draft) is read on input file.<br/>
+!>  Horizontal grid-point position and scale factors, and the coriolis factor 
+!>  are read in coordinates file or computed.<br/> 
+!>  Vertical coordinate is defined, and the bathymetry recomputed to fit the
+!>  vertical grid.<br/>
+!>  Finally the masks from the bathymetry are computed.
+!>
+!>  All the arrays generated, are writen in one to three file(s) depending on
+!>  output option.
+!>  @note the file contain depends on
+!>  the vertical coordinate used (z-coord, partial steps, s-coord)
+!>
+!> @section sec2 how to
+!>    to create meshmask file:<br/>
+!> @code{.sh}
+!>    ./SIREN/bin/create_meshmask create_meshmask.nam
+!> @endcode
+!>
+!> @note 
+!>    you could find a template of the namelist in templates directory.
+!>
+!>    create_meshmask.nam contains 15 namelists:<br/>
+!>       - logger namelist (namlog)
+!>       - config namelist (namcfg)
+!>       - input files namelist (namin)
+!>       - horizontal grid namelist (namhgr)
+!>       - vertical grid namelist (namzgr)
+!>       - minimum depth namelist (namdmin)
+!>       - vertical coordinate namelist (namzco)
+!>       - partial step namelist (namzps)
+!>       - sigma or hybrid namelist (namsco)
+!>       - cross land advection namelist (namcla)
+!>       - lateral boundary condition namelist (namlbc)
+!>       - wetting and dryong namelist (namwd)
+!>       - grid namelist (namgrd)
+!>       - zoom namelist (namzoom)
+!>       - output namelist (namout)
+!>
+!>    * _logger namelist (namlog)_:<br/>
+!>       - cn_logfile   : log filename
+!>       - cn_verbosity : verbosity ('trace','debug','info',
+!> 'warning','error','fatal','none')
+!>       - in_maxerror  : maximum number of error allowed
+!>
+!>    * _config namelist (namcfg)_:<br/>
+!>       - cn_varcfg : variable configuration file
+!> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
+!>
+!>    * _input files namelist (namin)_:<br/>
+!>       - cn_bathy  : Bathymetry file
+!>       - cn_coord  : coordinate file (in_mshhgr=0)
+!>       - cn_isfdep : Iceshelf draft  (ln_isfcav=true)
+!>       - in_perio  : NEMO periodicity
+!>       - ln_closea :
+!>
+!>    * _horizontal grid namelist (namhgr)_:<br/>
+!>       - in_mshhgr   : type of horizontal mesh
+!>         - 0: curvilinear coordinate on the sphere read in coordinate.nc
+!>         - 1: geographical mesh on the sphere with regular grid-spacing
+!>         - 2: f-plane with regular grid-spacing
+!>         - 3: beta-plane with regular grid-spacing
+!>         - 4: Mercator grid with T/U point at the equator
+!>         - 5: beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+!>       - dn_ppglam0  : longitude of first raw and column T-point (in_mshhgr = 1 or 4)
+!>       - dn_ppgphi0  : latitude  of first raw and column T-point (in_mshhgr = 1 or 4)
+!>       - dn_ppe1_deg : zonal      grid-spacing (degrees)         (in_mshhgr = 1,2,3 or 4)
+!>       - dn_ppe2_deg : meridional grid-spacing (degrees)         (in_mshhgr = 1,2,3 or 4)
+!>
+!>    * _vertical grid namelist (namzgr)_:<br/>
+!>       - ln_zco    : z-coordinate - full steps
+!>       - ln_zps    : z-coordinate - partial steps
+!>       - ln_sco    : s- or hybrid z-s-coordinate
+!>       - ln_isfcav : ice shelf cavities
+!>       - ln_iscpl  : coupling with ice sheet
+!>       - ln_wd     : Wetting/drying activation
+!>       - in_nlevel : number of vertical level
+!>
+!>    * _depth namelist (namdmin)_:<br/>
+!>       - dn_hmin      : minimum ocean depth (>0) or minimum number of ocean levels (<0)
+!>       - dn_isfhmin   : threshold to discriminate grounded ice to floating ice
+!>
+!>    * _vertical coordinate namelist (namzco)_:<br/>
+!>       - dn_ppsur              : coefficient to compute vertical grid
+!>       - dn_ppa0               : coefficient to compute vertical grid
+!>       - dn_ppa1               : coefficient to compute vertical grid
+!>       - dn_ppkth              : coefficient to compute vertical grid
+!>       - dn_ppacr              : coefficient to compute vertical grid
+!>       - ln_dbletanh           : use double tanh function for vertical coordinates
+!>       - dn_ppa2               : double tanh function parameter
+!>       - dn_ppkth2             : double tanh function parameter
+!>       - dn_ppacr2             : double tanh function parameter
+!>       - dn_ppdzmin            : minimum vertical spacing
+!>       - dn_pphmax             : maximum depth
+!>
+!>     @note If *ppa1* and *ppa0* and *ppsur* are undefined
+!>           NEMO will compute them from *ppdzmin* , *pphmax*, *ppkth*, *ppacr*
+!>
+!>       this namelist is also needed to define partial steps, sigma or hybrid coordinate.
+!>
+!>    * _partial step namelist (namzps)_:<br/>
+!>       - dn_e3zps_min          : minimum thickness of partial step level (meters)
+!>       - dn_e3zps_rat          : minimum thickness ratio of partial step level
+!>
+!>    * _sigma or hybrid namelist (namsco)_:<br/>
+!>       - ln_s_sh94    : use hybrid s-sig Song and Haidvogel 1994 stretching function fssig1
+!>       - ln_s_sf12    : use hybrid s-z-sig Siddorn and Furner 2012 stretching function fgamma
+!>       - dn_sbot_min  : minimum depth of s-bottom surface (>0) (m)
+!>       - dn_sbot_max  : maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+!>       - dn_hc        : Critical depth for transition from sigma to stretched coordinates
+!>       Song and Haidvogel 1994 stretching additional parameters
+!>          - dn_rmax      : maximum cut-off r-value allowed (0<dn_rmax<1)
+!>          - dn_theta     : surface control parameter (0<=dn_theta<=20)
+!>          - dn_thetb     : bottom control parameter  (0<=dn_thetb<= 1)
+!>          - dn_bb        : stretching parameter ( dn_bb=0; top only, dn_bb =1; top and bottom)
+!>       Siddorn and Furner stretching additional parameters
+!>          - ln_sigcrit   : switching to sigma (T) or Z (F) at H<Hc
+!>          - dn_alpha     : stretchin parameter ( >1 surface; <1 bottom)
+!>          - dn_efold     : e-fold length scale for transition region
+!>          - dn_zs        : Surface cell depth (Zs) (m)
+!>          Bottom cell (Zb) (m) = H*rn_zb_a + rn_zb_b'
+!>          - dn_zb_a      : Bathymetry multiplier for Zb
+!>          - dn_zb_b      : Offset for Zb
+!>
+!>    * _cross land advection namelist (namcla)_:<br/>
+!>       - in_cla : =1 cross land advection for exchanges through some straits (only for ORCA2)
+!>
+!>    * _lateral boundary condition namelist (namlbc)_:<br/>
+!>       - rn_shlat : lateral boundary conditions at the coast (modify fmask)
+!>          -     shlat = 0 : free slip
+!>          - 0 < shlat < 2 : partial slip 
+!>          -     shlat = 2 : no slip
+!>          -     shlat > 2 : strong slip
+!>    for more information see Boundary Condition at the Coast 
+!>    in [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals)) 
+!>
+!>    * _wetting and drying namelist (namwd)_:<br/>
+!>       - dn_wdmin1    : minimum water depth on dried cells
+!>       - dn_wdmin2    : tolerrance of minimum water depth on dried cells
+!>       - dn_wdld      : land elevation below which wetting/drying
+!>    
+!>    * _grid namelist (namgrd)_:<br/>
+!>       - cn_cfg    : name of the configuration
+!>       - in_cfg    : resolution of the configuration
+!>       - in_bench  : benchmark parameter (in_mshhgr = 5 ).<br/>
+!>                     if /= 0 : forced the resolution to be about 100 km
+!>       - ln_zoom   : use zoom (namzoom)
+!>       - ln_c1d    : use configuration 1D
+!>
+!>    * _zoom namelist (namzoom)_:<br/>
+!>       - cn_cfz       : name of the zoom of configuration
+!>       - in_izoom     : left bottom i-indices of the zoom in data domain indices
+!>       - in_jzoom     : left bottom j-indices of the zoom in data domain indices
+!>       - ln_zoom_s    : South zoom type flag
+!>       - ln_zoom_e    : East  zoom type flag
+!>       - ln_zoom_w    : West  zoom type flag
+!>       - ln_zoom_n    : North zoom type flag
+!>
+!>    * _output namelist (namout)_:<br/>
+!>       - in_msh       : number of output file and contain (1-9)
+!>       - in_nproc     : number of processor to be used
+!>       - in_niproc    : i-direction number of processor
+!>       - in_njproc    : j-direction numebr of processor
+!>
+!>    @note
+!>        MOD(in_msh, 3) = 1  :   '<b>mesh_mask.nc</b>' file
+!>                       = 2  :   '<b>mesh.nc</b>' and '<b>mask.nc</b>' files
+!>                       = 0  :   '<b>mesh_hgr.nc</b>', '<b>mesh_zgr.nc</b>' and '<b>mask.nc</b>' files
+!>
+!>        For huge size domain, use option 2 or 3 depending on your vertical coordinate.
+!>
+!>        if     in_msh <= 3: write full 3D arrays for e3[tuvw] and gdep[tuvw]
+!>        if 3 < in_msh <= 6: write full 3D arrays for e3[tuvw] and 2D arrays 
+!>                            corresponding to the depth of the bottom t- and w-points
+!>        if 6 < in_msh <= 9: write 2D arrays corresponding to the depth and the
+!>                            thickness (e3[tw]_ps) of the bottom points
+!>
+!> @author
+!> J.Paul
+! REVISION HISTORY:
+!> @date September, 2015 - Initial Version (based on domhgr.F90, domzgr.F90, domwri.F90)
+!> @date October, 2016
+!> - update from trunk (revision 6961): add wetting and drying, ice sheet coupling..
+!>
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!----------------------------------------------------------------------
+PROGRAM create_meshmask
+
+   USE global                          ! global variable
+   USE kind                            ! F90 kind parameter
+   USE phycst                          ! physical constant
+   USE logger                          ! log file manager
+   USE date                            ! date manager
+   USE fct                             ! basic useful function
+   USE att                             ! attribute manager
+   USE dim                             ! dimension manager
+   USE var                             ! variable manager
+   USE mpp                             ! MPP manager
+   USE iom_mpp                         ! I/O MPP manager
+   USE lbc                             ! lateral boundary conditions
+   USE grid
+   USE grid_hgr
+   USE grid_zgr
+
+   IMPLICIT NONE
+
+   ! local variable
+   CHARACTER(LEN=lc)                              :: cl_namelist
+   CHARACTER(LEN=lc)                              :: cl_date
+
+   INTEGER(i4)                                    :: il_narg
+   INTEGER(i4)                                    :: il_status
+   INTEGER(i4)                                    :: il_fileid
+   INTEGER(i4)                                    :: il_attid
+   INTEGER(i4)                                    :: il_ew
+   INTEGER(i4)                                    :: jpi
+   INTEGER(i4)                                    :: jpj
+   INTEGER(i4)                                    :: jpk
+   INTEGER(i4), DIMENSION(:,:)      , ALLOCATABLE :: il_mask
+
+   LOGICAL                                        :: ll_exist
+
+   REAL(dp)   , DIMENSION(:,:)      , ALLOCATABLE :: dl_tmp2D
+   REAL(dp)   , DIMENSION(:,:,:)    , ALLOCATABLE :: dl_tmp3D
+
+   TYPE(TATT)                                     :: tl_att
+   TYPE(TATT) , DIMENSION(:)        , ALLOCATABLE :: tl_gatt
+   
+   TYPE(TVAR)                                     :: tl_bathy
+   TYPE(TVAR)                                     :: tl_risfdep
+   TYPE(TVAR)                                     :: tl_misf
+   TYPE(TVAR)                                     :: tl_gdepu
+   TYPE(TVAR)                                     :: tl_gdepv
+   TYPE(TVAR)                                     :: tl_hdept
+   TYPE(TVAR)                                     :: tl_hdepw
+
+   TYPE(TNAMH)                                    :: tl_namh
+   TYPE(TNAMZ)                                    :: tl_namz
+
+   TYPE(TMPP)                                     :: tl_mpp
+   TYPE(TMPP) , TARGET                            :: tl_mppout0
+   TYPE(TMPP) , TARGET                            :: tl_mppout1
+   TYPE(TMPP) , TARGET                            :: tl_mppout2
+   TYPE(TMPP) , POINTER                           :: tl_mppmsk
+   TYPE(TMPP) , POINTER                           :: tl_mpphgr
+   TYPE(TMPP) , POINTER                           :: tl_mppzgr
+
+   ! parameter
+   INTEGER(i4) , PARAMETER :: ip_maxatt = 40
+
+   ! loop indices
+   INTEGER(i4) :: ji
+   INTEGER(i4) :: jj
+   INTEGER(i4) :: jk
+
+   INTEGER(i4) :: ik
+
+   ! namelist variable
+   ! namlog
+   CHARACTER(LEN=lc) :: cn_logfile  = 'create_meshmask.log' 
+   CHARACTER(LEN=lc) :: cn_verbosity= 'warning' 
+   INTEGER(i4)       :: in_maxerror = 5
+
+   ! namcfg
+   CHARACTER(LEN=lc) :: cn_varcfg   = 'variable.cfg' 
+   CHARACTER(LEN=lc) :: cn_dumcfg   = 'dummy.cfg'
+
+   ! namin
+   CHARACTER(LEN=lc) :: cn_bathy    = ''
+   CHARACTER(LEN=lc) :: cn_coord    = ''
+   CHARACTER(LEN=lc) :: cn_isfdep   = ''
+   INTEGER(i4)       :: in_perio    = -1
+   LOGICAL           :: ln_closea   = .TRUE.
+
+   ! namzgr
+   LOGICAL           :: ln_zco      = .FALSE.
+   LOGICAL           :: ln_zps      = .FALSE.
+   LOGICAL           :: ln_sco      = .FALSE.
+   LOGICAL           :: ln_isfcav   = .FALSE.
+   LOGICAL           :: ln_iscpl    = .FALSE.
+   LOGICAL           :: ln_wd       = .FALSE.
+   INTEGER(i4)       :: in_nlevel   = 75
+
+   ! namlbc
+   REAL(sp)          :: rn_shlat    = 2.
+
+   ! namout
+   INTEGER(i4)       :: in_msh      = 1 
+   CHARACTER(LEN=lc) :: cn_type     = 'cdf'
+   INTEGER(i4)       :: in_nproc    = 0
+   INTEGER(i4)       :: in_niproc   = 0
+   INTEGER(i4)       :: in_njproc   = 0
+   !-------------------------------------------------------------------
+   NAMELIST /namlog/ &  !< logger namelist
+   &  cn_logfile,    &  !< log file
+   &  cn_verbosity,  &  !< log verbosity
+   &  in_maxerror
+
+   NAMELIST /namcfg/ &  !< configuration namelist
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
+
+   NAMELIST /namin/  &  !< input namelist
+   &  cn_bathy,      &  !< Bathymetry file
+   &  cn_coord,      &  !< Coordinate file (in_mshhgr=0)
+   &  cn_isfdep,     &  !< Iceshelf draft  (ln_isfcav=true)
+   &  in_perio,      &  !< NEMO periodicity
+   &  ln_closea
+
+   NAMELIST /namzgr/ &
+   &  ln_zco,        &  !< z-coordinate
+   &  ln_zps,        &  !< z-coordinate with partial steps
+   &  ln_sco,        &  !< s-coordinate
+   &  ln_isfcav,     &  !< presence of ISF
+   &  ln_iscpl,      &  !< coupling with ice sheet
+   &  ln_wd,         &  !< Wetting/drying activation
+   &  in_nlevel
+
+   NAMELIST /namlbc/  &
+   &  rn_shlat          !< lateral momentum boundary condition
+
+   NAMELIST /namout/ &  !< output namlist
+   &  in_msh,        &  !< number of output file (1,2,3)
+   &  in_nproc,      &  !< number of processor to be used
+   &  in_niproc,     &  !< i-direction number of processor
+   &  in_njproc         !< j-direction numebr of processor
+   !-------------------------------------------------------------------   
+
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   !1- namelist
+   !1-1 get namelist
+   il_narg=COMMAND_ARGUMENT_COUNT() !f03 intrinsec
+   IF( il_narg/=1 )THEN
+      PRINT *,"ERROR in create_mask: need a namelist"
+      STOP
+   ELSE
+      CALL GET_COMMAND_ARGUMENT(1,cl_namelist) !f03 intrinsec
+   ENDIF
+   !1-2 read namelist
+   INQUIRE(FILE=TRIM(cl_namelist), EXIST=ll_exist)
+   IF( ll_exist )THEN
+      
+      il_fileid=fct_getunit()
+
+      OPEN( il_fileid, FILE=TRIM(cl_namelist), &
+      &                FORM='FORMATTED',       &
+      &                ACCESS='SEQUENTIAL',    &
+      &                STATUS='OLD',           &
+      &                ACTION='READ',          &
+      &                IOSTAT=il_status)
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         PRINT *,"ERROR in create_mask: error opening "//TRIM(cl_namelist)
+         STOP
+      ENDIF
+
+      READ( il_fileid, NML = namlog )
+      !1-2-1 define log file
+      CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror)
+      CALL logger_header()
+
+      READ( il_fileid, NML = namcfg )
+      !1-2-2 get variable extra information
+      CALL var_def_extra(TRIM(cn_varcfg))
+
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
+      READ( il_fileid, NML = namin   )
+      READ( il_fileid, NML = namzgr  )
+      READ( il_fileid, NML = namlbc  )
+
+      READ( il_fileid, NML = namout  )
+
+      CLOSE( il_fileid, IOSTAT=il_status )
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         CALL logger_error("CREATE MASK: closing "//TRIM(cl_namelist))
+      ENDIF
+
+   ELSE
+
+      PRINT *,"ERROR in create_mask: can't find "//TRIM(cl_namelist)
+
+   ENDIF
+
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+   ! open file
+   IF( cn_bathy /= '' )THEN
+      tl_mpp=mpp_init( file_init(TRIM(cn_bathy)), id_perio=in_perio)
+      CALL grid_get_info(tl_mpp)
+   ELSE
+      CALL logger_fatal("CREATE MESH MASK: no input bathymetry file found. "//&
+      &     "check namelist")      
+   ENDIF
+
+   ! read bathymetry
+   WRITE(*,*) 'FILE TO BE USED:',TRIM(cn_bathy)
+   CALL iom_mpp_open(tl_mpp)
+
+   ! get dimension
+   jpi=tl_mpp%t_dim(jp_I)%i_len
+   jpj=tl_mpp%t_dim(jp_J)%i_len
+   jpk=in_nlevel
+
+   WRITE(*,*) 'DIMENSION TO BE USED :',jpi,jpj,jpk
+
+   IF( ln_zco )   THEN
+      WRITE(*,*) 'VARIABLE READ : Bathy_level'
+      tl_bathy=iom_mpp_read_var(tl_mpp, 'Bathy_level')
+   ELSEIF( ln_zps .OR. ln_sco )   THEN
+      IF ( ln_isfcav ) THEN
+         WRITE(*,*) 'VARIABLE READ : Bathymetry_isf'
+         tl_bathy=iom_mpp_read_var(tl_mpp, 'Bathymetry_isf' )
+      ELSE
+         WRITE(*,*) 'VARIABLE READ : Bathymetry'
+         tl_bathy=iom_mpp_read_var(tl_mpp, 'Bathymetry' )
+      END IF
+   ENDIF
+   CALL iom_mpp_close(tl_mpp)
+
+   WHERE( tl_bathy%d_value(:,:,1,1) == tl_bathy%d_fill .OR. &
+        & tl_bathy%d_value(:,:,1,1) < 0._dp )
+      tl_bathy%d_value(:,:,1,1) = 0._dp
+  END WHERE
+ 
+   IF ( ln_isfcav ) THEN
+      ! open Iceshelf draft
+      IF( cn_isfdep /= '' )THEN
+         tl_mpp=mpp_init( file_init(TRIM(cn_isfdep)), id_perio=in_perio)
+         CALL grid_get_info(tl_mpp)
+      ELSE
+         CALL logger_fatal("CREATE MESH MASK: no input Iceshelf draft '//&
+            &  'file found. check namelist")      
+      ENDIF
+
+      ! read Iceshelf draft
+      CALL iom_mpp_open(tl_mpp)
+      IF( ln_zps .OR. ln_sco )   THEN
+         tl_risfdep=iom_mpp_read_var(tl_mpp, 'isf_draft')
+      ENDIF
+      CALL iom_mpp_close(tl_mpp)
+   ELSE
+      ALLOCATE(dl_tmp2D(jpi,jpj))
+      dl_tmp2D(:,:)=0._dp
+
+      tl_risfdep=var_init('isf_draft',dl_tmp2D(:,:), id_type=NF90_FLOAT)
+
+      DEALLOCATE(dl_tmp2D)
+   ENDIF
+
+   ! fill closed sea
+   IF( ln_closea )THEN
+      WRITE(*,*) "CLOSED SEA"
+      ALLOCATE( il_mask(tl_bathy%t_dim(1)%i_len, &
+      &                 tl_bathy%t_dim(2)%i_len) )
+
+      ! split domain in N sea subdomain
+      il_mask(:,:)=grid_split_domain(tl_bathy)
+
+      !  fill smallest domain
+      CALL grid_fill_small_dom( tl_bathy, il_mask(:,:) )
+
+      DEALLOCATE( il_mask )
+   ENDIF
+
+   in_perio = tl_mpp%i_perio
+   il_ew    = tl_mpp%i_ew
+
+   ! clean
+   CALL mpp_clean(tl_mpp)
+
+   ! Horizontal mesh (dom_hgr) -------------------------------------------------
+   tl_namh=grid_hgr_nam( cn_coord, in_perio, cl_namelist )
+
+   ! init Horizontal grid global variable
+   CALL grid_hgr_init(jpi,jpj,jpk)
+
+   ! compute horizontal mesh
+   WRITE(*,*) "COMPUTE HORIZONTAL MESH"
+   CALL grid_hgr_fill(tl_namh,jpi,jpj)      
+
+   ! Vertyical  mesh (dom_zgr) -------------------------------------------------
+   tl_namz=grid_zgr_nam( cn_coord, in_perio, cl_namelist )
+
+   ! init Vertical grid global variable
+   CALL grid_zgr_init(jpi,jpj,jpk)
+   IF( ln_zps    ) CALL grid_zgr_zps_init(jpi,jpj)
+   IF( ln_sco    ) CALL grid_zgr_sco_init(jpi,jpj) 
+
+   ! compute vertical  mesh
+   WRITE(*,*) "COMPUTE VERTICAL MESH"
+   CALL grid_zgr_fill( tl_namz,jpi,jpj,jpk, tl_bathy, tl_risfdep )
+
+   ! compute masks
+   WRITE(*,*) "COMPUTE MASK"
+   CALL create__mask(tl_namh,jpi,jpj,jpk)
+
+   ! Maximum stiffness ratio/hydrostatic consistency
+   IF( ln_sco    ) CALL grid_zgr_sco_stiff(tl_namz,jpi,jpj,jpk)
+ 
+   ! clean
+   CALL var_clean(tl_bathy)
+
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   ! create ouptut structure 
+   IF( in_niproc == 0 .AND. &
+   &   in_njproc == 0 .AND. &
+   &   in_nproc  == 0 )THEN
+      in_niproc = 1
+      in_njproc = 1
+      in_nproc = 1
+   ENDIF
+
+   WRITE(*,*) "WRITE FILE(S)"
+   SELECT CASE ( MOD(in_msh, 3) )
+      !                                  ! ============================
+   CASE ( 1 )                            !  create 'mesh_mask.nc' file
+      !                                  ! ============================
+      tl_mppout0=mpp_init( 'mesh_mask', tg_tmask, &
+      &                    in_niproc, in_njproc, in_nproc, &
+      &                    cd_type=cn_type )
+
+      tl_mppmsk=>tl_mppout0
+      tl_mpphgr=>tl_mppout0
+      tl_mppzgr=>tl_mppout0
+      
+      !                                  ! ============================
+   CASE ( 2 )                            !  create 'mesh.nc' and 
+      !                                  !         'mask.nc' files
+      !                                  ! ============================
+      tl_mppout0=mpp_init( 'mask', tg_tmask, &
+      &                    in_niproc, in_njproc, in_nproc, &
+      &                    cd_type=cn_type )
+      tl_mppout1=mpp_init( 'mesh', tg_tmask, &
+      &                    in_niproc, in_njproc, in_nproc, &
+      &                    cd_type=cn_type )
+
+      tl_mppmsk=>tl_mppout0
+      tl_mpphgr=>tl_mppout1
+      tl_mppzgr=>tl_mppout1
+
+      !                                  ! ============================
+   CASE ( 0 )                            !  create 'mesh_hgr.nc'
+      !                                  !         'mesh_zgr.nc' and
+      !                                  !         'mask.nc'     files
+      !                                  ! ============================
+      tl_mppout0=mpp_init( 'mask', tg_tmask, &
+      &                    in_niproc, in_njproc, in_nproc, &
+      &                    cd_type=cn_type )
+      tl_mppout1=mpp_init( 'mesh_hgr', tg_tmask, &
+      &                    in_niproc, in_njproc, in_nproc, &
+      &                    cd_type=cn_type )
+      tl_mppout2=mpp_init( 'mesh_zgr', tg_tmask, &
+      &                    in_niproc, in_njproc, in_nproc, &
+      &                    cd_type=cn_type )
+      !
+
+      tl_mppmsk=>tl_mppout0
+      tl_mpphgr=>tl_mppout1
+      tl_mppzgr=>tl_mppout2
+
+   END SELECT
+
+   ! add variables
+   !!! mask (msk)
+   !!!----------------------
+
+   ! tmask
+   CALL mpp_add_var(tl_mppmsk, tg_tmask)
+   CALL var_clean(tg_tmask)
+   ! umask
+   CALL mpp_add_var(tl_mppmsk, tg_umask)
+   CALL var_clean(tg_umask)
+   ! vmask
+   CALL mpp_add_var(tl_mppmsk, tg_vmask)
+   CALL var_clean(tg_vmask)
+   ! fmask
+   CALL mpp_add_var(tl_mppmsk, tg_fmask)
+   CALL var_clean(tg_fmask)
+
+   !!! VOIR CAS TMASKUTIL ???
+   
+   !!! horizontal mesh (hgr)
+   !!!----------------------
+
+   ! latitude
+   ! glamt
+   CALL mpp_add_var(tl_mpphgr, tg_glamt)
+   CALL var_clean(tg_glamt)
+   ! glamu
+   CALL mpp_add_var(tl_mpphgr, tg_glamu)
+   CALL var_clean(tg_glamu)
+   ! glamV
+   CALL mpp_add_var(tl_mpphgr, tg_glamv)
+   CALL var_clean(tg_glamv)
+   ! glamf
+   CALL mpp_add_var(tl_mpphgr, tg_glamf)
+   CALL var_clean(tg_glamf)
+
+   ! longitude
+   ! gphit
+   CALL mpp_add_var(tl_mpphgr, tg_gphit)
+   CALL var_clean(tg_gphit)
+   ! gphiu
+   CALL mpp_add_var(tl_mpphgr, tg_gphiu)
+   CALL var_clean(tg_gphiu)
+   ! gphiv
+   CALL mpp_add_var(tl_mpphgr, tg_gphiv)
+   CALL var_clean(tg_gphiv)
+   ! gphif
+   CALL mpp_add_var(tl_mpphgr, tg_gphif)
+   CALL var_clean(tg_gphif)
+
+   ! e1 scale factors
+   ! e1t
+   CALL mpp_add_var(tl_mpphgr, tg_e1t)
+   CALL var_clean(tg_e1t)
+   ! e1u
+   CALL mpp_add_var(tl_mpphgr, tg_e1u)
+   CALL var_clean(tg_e1u)
+   ! e1v
+   CALL mpp_add_var(tl_mpphgr, tg_e1v)
+   CALL var_clean(tg_e1v)
+   ! e1f
+   CALL mpp_add_var(tl_mpphgr, tg_e1f)
+   CALL var_clean(tg_e1f)
+
+   ! e2 scale factors
+   ! e2t
+   CALL mpp_add_var(tl_mpphgr, tg_e2t)
+   CALL var_clean(tg_e2t)
+   ! e2u
+   CALL mpp_add_var(tl_mpphgr, tg_e2u)
+   CALL var_clean(tg_e2u)
+   ! e2v
+   CALL mpp_add_var(tl_mpphgr, tg_e2v)
+   CALL var_clean(tg_e2v)
+   ! e2f
+   CALL mpp_add_var(tl_mpphgr, tg_e2f)
+   CALL var_clean(tg_e2f)
+
+   ! coriolis factor
+   ! ff
+   CALL mpp_add_var(tl_mpphgr, tg_ff)
+   CALL var_clean(tg_ff)
+
+   ! angles
+   ! cost
+   CALL mpp_add_var(tl_mpphgr, tg_gcost)
+   CALL var_clean(tg_gcost)
+   ! cosu
+   CALL mpp_add_var(tl_mpphgr, tg_gcosu)
+   CALL var_clean(tg_gcosu)
+   ! cosv
+   CALL mpp_add_var(tl_mpphgr, tg_gcosv)
+   CALL var_clean(tg_gcosv)
+   ! cosf
+   CALL mpp_add_var(tl_mpphgr, tg_gcosf)
+   CALL var_clean(tg_gcosf)
+   
+   ! sint
+   CALL mpp_add_var(tl_mpphgr, tg_gsint)
+   CALL var_clean(tg_gsint)
+   ! sinu
+   CALL mpp_add_var(tl_mpphgr, tg_gsinu)
+   CALL var_clean(tg_gsinu)
+   ! sinv
+   CALL mpp_add_var(tl_mpphgr, tg_gsinv)
+   CALL var_clean(tg_gsinv)
+   ! sinf
+   CALL mpp_add_var(tl_mpphgr, tg_gsinf)
+   CALL var_clean(tg_gsinf)
+   
+   !!! vertical mesh (zgr)
+   !!!----------------------
+
+   ! note that mbkt is set to 1 over land ==> use surface tmask
+   ! 
+   ! mbathy
+   tg_mbathy%d_value(:,:,:,:) = tg_ssmask%d_value(:,:,:,:) * &
+      &                         tg_mbkt%d_value(:,:,:,:)
+   !
+   CALL mpp_add_var(tl_mppzgr, tg_mbathy)
+   CALL var_clean(tg_mbathy)
+
+   ! misf
+   ALLOCATE(dl_tmp2D(jpi,jpj))
+   dl_tmp2D(:,:)=dp_fill
+
+   tl_misf =var_init('misf    ',dl_tmp2D(:,:), id_type=NF90_INT)
+
+   DEALLOCATE(dl_tmp2D)
+   tl_misf%d_value(:,:,1,1) = tg_ssmask%d_value(:,:,1,1) * &
+      &                       tg_mikt%d_value(:,:,1,1)
+   !
+   CALL mpp_add_var(tl_mppzgr, tl_misf)
+   CALL var_clean(tl_misf)
+
+   ! isfdraft
+   tl_risfdep%d_value(:,:,:,:) = tl_risfdep%d_value(:,:,:,:) * &
+      &                          tg_mikt%d_value(:,:,:,:)
+   CALL mpp_add_var(tl_mppzgr, tl_risfdep)
+   CALL var_clean(tl_risfdep)
+
+   IF( ln_sco ) THEN ! s-coordinate
+
+      ! hbatt
+      CALL mpp_add_var(tl_mppzgr, tg_hbatt)
+      CALL var_clean(tg_hbatt)
+      ! hbatu
+      CALL mpp_add_var(tl_mppzgr, tg_hbatu)
+      CALL var_clean(tg_hbatu)
+      ! hbatv
+      CALL mpp_add_var(tl_mppzgr, tg_hbatv)
+      CALL var_clean(tg_hbatv)
+      ! hbatf
+      CALL mpp_add_var(tl_mppzgr, tg_hbatf)
+      CALL var_clean(tg_hbatf)
+
+      ! scaling coef.
+      IF( .NOT. (tl_namz%l_s_sh94 .OR. tl_namz%l_s_sf12) )THEN
+         ! gsigt
+         CALL mpp_add_var(tl_mppzgr, tg_gsigt)
+         CALL var_clean(tg_gsigt)
+         ! gsigw
+         CALL mpp_add_var(tl_mppzgr, tg_gsigw)
+         CALL var_clean(tg_gsigw)
+         ! gsi3w
+         CALL mpp_add_var(tl_mppzgr, tg_gsi3w)
+         CALL var_clean(tg_gsi3w)
+         ! esigt
+         CALL mpp_add_var(tl_mppzgr, tg_esigt)
+         CALL var_clean(tg_esigt)
+         ! esigw
+         CALL mpp_add_var(tl_mppzgr, tg_esigw)
+         CALL var_clean(tg_esigw)
+      ENDIF
+
+      ! scale factors
+      ! e3t_0
+      CALL mpp_add_var(tl_mppzgr, tg_e3t_0)
+      CALL var_clean(tg_e3t_0)
+      ! e3u_0
+      CALL mpp_add_var(tl_mppzgr, tg_e3u_0)
+      CALL var_clean(tg_e3u_0)
+      ! e3v_0
+      CALL mpp_add_var(tl_mppzgr, tg_e3v_0)
+      CALL var_clean(tg_e3v_0)
+      ! e3w_0
+      CALL mpp_add_var(tl_mppzgr, tg_e3w_0)
+      CALL var_clean(tg_e3w_0)
+
+      ! Max. grid stiffness ratio
+      ! rx1
+      CALL mpp_add_var(tl_mppzgr, tg_rx1)
+      CALL var_clean(tg_rx1)
+
+      ! stretched system
+      ! gdept_1d
+      CALL mpp_add_var(tl_mppzgr, tg_gdept_1d)
+      CALL var_clean(tg_gdept_1d)
+      ! gdepw_1d
+      CALL mpp_add_var(tl_mppzgr, tg_gdepw_1d)
+      CALL var_clean(tg_gdepw_1d)
+      
+      ! gdept_0
+      CALL mpp_add_var(tl_mppzgr, tg_gdept_0)      
+      CALL var_clean(tg_gdept_0)
+      ! gdepw_0
+      CALL mpp_add_var(tl_mppzgr, tg_gdepw_0)      
+      CALL var_clean(tg_gdepw_0)
+
+   ENDIF
+
+   IF( ln_zps ) THEN ! z-coordinate - partial steps
+
+      IF( in_msh <= 6 ) THEN ! 3D vertical scale factors
+
+         ! e3t_0
+         CALL mpp_add_var(tl_mppzgr, tg_e3t_0)
+         CALL var_clean(tg_e3t_0)
+         ! e3u_0
+         CALL mpp_add_var(tl_mppzgr, tg_e3u_0)
+         CALL var_clean(tg_e3u_0)
+         ! e3v_0
+         CALL mpp_add_var(tl_mppzgr, tg_e3v_0)
+         CALL var_clean(tg_e3v_0)
+         ! e3w_0
+         CALL mpp_add_var(tl_mppzgr, tg_e3w_0)
+         CALL var_clean(tg_e3w_0)
+
+      ELSE
+
+         DO jj = 1,jpj   
+            DO ji = 1,jpi
+               ik=tg_mbkt%d_value(ji,jj,1,1)
+               tg_e3tp%d_value(ji,jj,1,1) = tg_e3t_0%d_value(ji,jj,ik,1) * &
+                  &                         tg_ssmask%d_value(ji,jj,1,1)
+               tg_e3wp%d_value(ji,jj,1,1) = tg_e3w_0%d_value(ji,jj,ik,1) * &
+                  &                         tg_ssmask%d_value(ji,jj,1,1)
+            END DO
+         END DO         
+         ! e3t_ps
+         CALL mpp_add_var(tl_mppzgr, tg_e3tp)
+         CALL var_clean(tg_e3tp)
+         ! e3w_ps
+         CALL mpp_add_var(tl_mppzgr, tg_e3wp)
+         CALL var_clean(tg_e3wp)
+
+      ENDIF ! 3D vertical scale factors
+
+      IF( in_msh <= 3 ) THEN ! 3D depth
+         
+         ! gdept_0
+         CALL mpp_add_var(tl_mppzgr, tg_gdept_0)
+      
+         ! gdepu, gdepv
+         ALLOCATE(dl_tmp3D(jpi,jpj,jpk))
+         dl_tmp3D(:,:,:)=dp_fill
+
+         tl_gdepu=var_init('gdepu',dl_tmp3D(:,:,:), id_type=NF90_FLOAT)
+         tl_gdepv=var_init('gdepv',dl_tmp3D(:,:,:), id_type=NF90_FLOAT)
+
+         DEALLOCATE(dl_tmp3D)
+         DO jk = 1,jpk   
+            DO jj = 1, jpj-1   
+               DO ji = 1, jpi-1   ! vector opt.
+                  tl_gdepu%d_value(ji,jj,jk,1) = MIN( tg_gdept_0%d_value(ji  ,jj  ,jk,1) , &
+                     &                                tg_gdept_0%d_value(ji+1,jj  ,jk,1) )
+
+                  tl_gdepv%d_value(ji,jj,jk,1) = MIN( tg_gdept_0%d_value(ji  ,jj  ,jk,1) , &
+                     &                                tg_gdept_0%d_value(ji  ,jj+1,jk,1) )
+               END DO   
+            END DO   
+         END DO         
+         CALL lbc_lnk( tl_gdepu%d_value(:,:,:,1), 'U', in_perio, 1._dp )
+         CALL lbc_lnk( tl_gdepv%d_value(:,:,:,1), 'V', in_perio, 1._dp )
+
+         ! gdepu
+         CALL mpp_add_var(tl_mppzgr, tl_gdepu)
+         CALL var_clean(tl_gdepu)
+         ! gdepv
+         CALL mpp_add_var(tl_mppzgr, tl_gdepv)
+         CALL var_clean(tl_gdepv)
+
+         ! clean
+         CALL var_clean(tg_gdept_0)
+
+         ! gdepw_0
+         CALL mpp_add_var(tl_mppzgr, tg_gdepw_0)
+         CALL var_clean(tg_gdepw_0)
+
+      ELSE ! 2D bottom depth
+         ALLOCATE(dl_tmp2D(jpi,jpj))
+         dl_tmp2D(:,:)=dp_fill
+
+         tl_hdept=var_init('hdept',dl_tmp2D(:,:), id_type=NF90_INT)
+         tl_hdepw=var_init('hdepw',dl_tmp2D(:,:), id_type=NF90_INT)
+
+         DEALLOCATE(dl_tmp2D)
+         DO jj = 1,jpj   
+            DO ji = 1,jpi
+               ik=tg_mbkt%d_value(ji,jj,1,1)
+               tl_hdept%d_value(ji,jj,1,1) = tg_gdept_0%d_value(ji,jj,ik  ,1) * tg_ssmask%d_value(ji,jj,1,1)
+               tl_hdepw%d_value(ji,jj,1,1) = tg_gdepw_0%d_value(ji,jj,ik+1,1) * tg_ssmask%d_value(ji,jj,1,1)
+            END DO
+         END DO
+         ! hdept
+         CALL mpp_add_var(tl_mppzgr, tl_hdept)
+         CALL var_clean(tl_hdept)
+         ! hdepw
+         CALL mpp_add_var(tl_mppzgr, tl_hdepw)
+         CALL var_clean(tl_hdepw)
+
+         ! clean
+         CALL var_clean(tg_gdept_0)
+
+      ENDIF ! 3D depth
+
+   ENDIF
+
+   IF( ln_zps .OR. ln_zco )THEN ! z-coordinate 
+      ! depth
+      ! gdept_1d
+      CALL mpp_add_var(tl_mppzgr, tg_gdept_1d)
+      CALL var_clean(tg_gdept_1d)
+      ! gdepw_1d
+      CALL mpp_add_var(tl_mppzgr, tg_gdepw_1d)
+      CALL var_clean(tg_gdepw_1d)
+      ! scale factors
+      ! e3t_1d
+      CALL mpp_add_var(tl_mppzgr, tg_e3t_1d)
+      CALL var_clean(tg_e3t_1d)
+      ! e3w_1d
+      CALL mpp_add_var(tl_mppzgr, tg_e3w_1d)
+      CALL var_clean(tg_e3w_1d)
+   ENDIF
+
+   ! define global attributes
+   ALLOCATE(tl_gatt(ip_maxatt))
+
+   tl_gatt(:) = create__gloatt(cn_bathy,cn_coord,cn_isfdep,tl_namh,tl_namz)
+
+
+   SELECT CASE ( MOD(in_msh, 3) )
+      CASE ( 1 )
+         ! add some attribute
+         tl_att=att_init("Created_by","SIREN create_meshmask")
+         CALL mpp_add_att(tl_mppmsk, tl_att)
+         
+         cl_date=date_print(date_now())
+         tl_att=att_init("Creation_date",TRIM(cl_date))
+         CALL mpp_add_att(tl_mppmsk, tl_att)
+         
+         ! add attribute periodicity
+         il_attid=0
+         IF( ASSOCIATED(tl_mppmsk%t_proc(1)%t_att) )THEN
+            il_attid=att_get_id(tl_mppmsk%t_proc(1)%t_att(:),'periodicity')
+         ENDIF
+         IF( in_perio >= 0 .AND. il_attid == 0 )THEN
+            tl_att=att_init('periodicity',in_perio)
+            CALL mpp_add_att(tl_mppmsk,tl_att)
+         ENDIF
+         
+         il_attid=0
+         IF( ASSOCIATED(tl_mppmsk%t_proc(1)%t_att) )THEN
+            il_attid=att_get_id(tl_mppmsk%t_proc(1)%t_att(:),'ew_overlap')
+         ENDIF
+         IF( il_ew >= 0 .AND. il_attid == 0 )THEN
+            tl_att=att_init('ew_overlap',il_ew)
+            CALL mpp_add_att(tl_mppmsk,tl_att)
+         ENDIF
+         
+         ji=1
+         DO WHILE( tl_gatt(ji)%c_name /= '' )
+            CALL mpp_add_att(tl_mppmsk,tl_gatt(ji))
+            ji=ji+1
+         ENDDO
+         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+         ! create file
+         CALL iom_mpp_create(tl_mppmsk)
+         
+         ! write file
+         CALL iom_mpp_write_file(tl_mppmsk)
+         ! close file
+         CALL iom_mpp_close(tl_mppmsk)
+         
+         ! clean
+         CALL mpp_clean(tl_mppmsk)
+
+      CASE ( 2 )
+         ! add some attribute
+         tl_att=att_init("Created_by","SIREN create_meshmask")
+         CALL mpp_add_att(tl_mppmsk, tl_att)
+         CALL mpp_add_att(tl_mpphgr, tl_att)
+         
+         cl_date=date_print(date_now())
+         tl_att=att_init("Creation_date",TRIM(cl_date))
+         CALL mpp_add_att(tl_mppmsk, tl_att)
+         CALL mpp_add_att(tl_mpphgr, tl_att)
+         
+         ! add attribute periodicity
+         il_attid=0
+         IF( ASSOCIATED(tl_mppmsk%t_proc(1)%t_att) )THEN
+            il_attid=att_get_id(tl_mppmsk%t_proc(1)%t_att(:),'periodicity')
+         ENDIF
+         IF( in_perio >= 0 .AND. il_attid == 0 )THEN
+            tl_att=att_init('periodicity',in_perio)
+            CALL mpp_add_att(tl_mppmsk,tl_att)
+            CALL mpp_add_att(tl_mpphgr,tl_att)
+         ENDIF
+         
+         il_attid=0
+         IF( ASSOCIATED(tl_mppmsk%t_proc(1)%t_att) )THEN
+            il_attid=att_get_id(tl_mppmsk%t_proc(1)%t_att(:),'ew_overlap')
+         ENDIF
+         IF( il_ew >= 0 .AND. il_attid == 0 )THEN
+            tl_att=att_init('ew_overlap',il_ew)
+            CALL mpp_add_att(tl_mppmsk,tl_att)
+            CALL mpp_add_att(tl_mpphgr,tl_att)
+         ENDIF
+
+         ji=1
+         DO WHILE( tl_gatt(ji)%c_name /= '' )
+            CALL mpp_add_att(tl_mppmsk,tl_gatt(ji))
+            CALL mpp_add_att(tl_mpphgr,tl_gatt(ji))
+            ji=ji+1
+         ENDDO
+         
+         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+         ! create mask file
+         !-----------------
+         CALL iom_mpp_create(tl_mppmsk)
+         
+         ! write file
+         CALL iom_mpp_write_file(tl_mppmsk)
+         ! close file
+         CALL iom_mpp_close(tl_mppmsk)
+         
+         ! clean
+         CALL mpp_clean(tl_mppmsk)
+
+         ! create mesh file
+         !-----------------
+         CALL iom_mpp_create(tl_mpphgr)
+         
+         ! write file
+         CALL iom_mpp_write_file(tl_mpphgr)
+         ! close file
+         CALL iom_mpp_close(tl_mpphgr)
+         
+         ! clean
+         CALL mpp_clean(tl_mpphgr)
+
+      CASE(0)
+         ! add some attribute
+         tl_att=att_init("Created_by","SIREN create_meshmask")
+         CALL mpp_add_att(tl_mppmsk, tl_att)
+         CALL mpp_add_att(tl_mpphgr, tl_att)
+         CALL mpp_add_att(tl_mppzgr, tl_att)
+         
+         cl_date=date_print(date_now())
+         tl_att=att_init("Creation_date",TRIM(cl_date))
+         CALL mpp_add_att(tl_mppmsk, tl_att)
+         CALL mpp_add_att(tl_mpphgr, tl_att)
+         CALL mpp_add_att(tl_mppzgr, tl_att)
+         
+         ! add attribute periodicity
+         il_attid=0
+         IF( ASSOCIATED(tl_mppmsk%t_proc(1)%t_att) )THEN
+            il_attid=att_get_id(tl_mppmsk%t_proc(1)%t_att(:),'periodicity')
+         ENDIF
+         IF( in_perio >= 0 .AND. il_attid == 0 )THEN
+            tl_att=att_init('periodicity',in_perio)
+            CALL mpp_add_att(tl_mppmsk,tl_att)
+            CALL mpp_add_att(tl_mpphgr,tl_att)
+            CALL mpp_add_att(tl_mppzgr,tl_att)
+         ENDIF
+ 
+         il_attid=0
+         IF( ASSOCIATED(tl_mppmsk%t_proc(1)%t_att) )THEN
+            il_attid=att_get_id(tl_mppmsk%t_proc(1)%t_att(:),'ew_overlap')
+         ENDIF
+         IF( il_ew >= 0 .AND. il_attid == 0 )THEN
+            tl_att=att_init('ew_overlap',il_ew)
+            CALL mpp_add_att(tl_mppmsk,tl_att)
+            CALL mpp_add_att(tl_mpphgr,tl_att)
+            CALL mpp_add_att(tl_mppzgr,tl_att)
+         ENDIF
+
+         ji=1
+         DO WHILE( tl_gatt(ji)%c_name /= '' )
+            CALL mpp_add_att(tl_mppmsk,tl_gatt(ji))
+            CALL mpp_add_att(tl_mpphgr,tl_gatt(ji))
+            CALL mpp_add_att(tl_mppzgr,tl_gatt(ji))
+            ji=ji+1
+         ENDDO
+
+         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+         ! create mask file
+         !-----------------
+         CALL iom_mpp_create(tl_mppmsk)
+ 
+         ! write file
+         CALL iom_mpp_write_file(tl_mppmsk)
+         ! close file
+         CALL iom_mpp_close(tl_mppmsk)
+ 
+         ! clean
+         WRITE(*,*) "CLEAN MSK"
+         CALL mpp_clean(tl_mppmsk)
+
+         ! create mesh_hgr file
+         !-----------------
+         CALL iom_mpp_create(tl_mpphgr)
+ 
+         ! write file
+         CALL iom_mpp_write_file(tl_mpphgr)
+         ! close file
+         CALL iom_mpp_close(tl_mpphgr)
+ 
+         ! clean
+         WRITE(*,*) "CLEAN HGR"
+         CALL mpp_clean(tl_mpphgr)
+
+         ! create mesh_zgr file
+         !-----------------
+         WRITE(*,*) "CREATE ZGR"
+         CALL iom_mpp_create(tl_mppzgr)
+ 
+         ! write file
+         WRITE(*,*) "WRITE ZGR"
+         CALL iom_mpp_write_file(tl_mppzgr)
+         ! close file
+         WRITE(*,*) "CLOSE ZGR"
+         CALL iom_mpp_close(tl_mppzgr)
+ 
+         ! clean
+         WRITE(*,*) "CLEAN ZGR"
+         CALL mpp_clean(tl_mppzgr)
+
+      CASE DEFAULT
+         CALL logger_fatal("CREATE MESHMASK : something wrong with in_msh("//&
+            &  TRIM(fct_str(in_msh))//"), check your namelist.")
+    END SELECT
+
+   ! clean
+   WRITE(*,*) "CLEAN"
+   CALL att_clean(tl_att)
+   CALL att_clean(tl_gatt)
+
+   DEALLOCATE(tl_gatt)
+
+   CALL grid_hgr_clean()
+   CALL grid_zgr_clean()
+   IF( ln_zps    ) CALL grid_zgr_zps_clean()
+   IF( ln_sco    ) CALL grid_zgr_sco_clean()
+
+   ! close log file
+   CALL logger_footer()
+   CALL logger_close()
+CONTAINS
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute land/ocean mask arrays at tracer points, hori-
+   !>      zontal velocity points (u & v), vorticity points (f) and baro-
+   !>      tropic stream function  points (b). 
+   !>
+   !> @details
+   !>
+   !> ** Method  :   The ocean/land mask is computed from the basin bathy-
+   !>      metry in level (mbathy) which is defined or read in dommba.
+   !>      mbathy equals 0 over continental T-point 
+   !>      and the number of ocean level over the ocean.
+   !>
+   !>      At a given position (ji,jj,jk) the ocean/land mask is given by:
+   !>      t-point : 0. IF mbathy( ji ,jj) =< 0
+   !>                1. IF mbathy( ji ,jj) >= jk
+   !>      u-point : 0. IF mbathy( ji ,jj)  or mbathy(ji+1, jj ) =< 0
+   !>                1. IF mbathy( ji ,jj) and mbathy(ji+1, jj ) >= jk.
+   !>      v-point : 0. IF mbathy( ji ,jj)  or mbathy( ji ,jj+1) =< 0
+   !>                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1) >= jk.
+   !>      f-point : 0. IF mbathy( ji ,jj)  or mbathy( ji ,jj+1)
+   !>                   or mbathy(ji+1,jj)  or mbathy(ji+1,jj+1) =< 0
+   !>                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1)
+   !>                  and mbathy(ji+1,jj) and mbathy(ji+1,jj+1) >= jk.
+   !>      b-point : the same definition as for f-point of the first ocean
+   !>                level (surface level) but with 0 along coastlines.
+   !>      tmask_i : interior ocean mask at t-point, i.e. excluding duplicated
+   !>                rows/lines due to cyclic or North Fold boundaries as well
+   !>                as MPP halos.
+   !>
+   !>   @WARNING do not set the lateral friction through the value of fmask along
+   !>      the coast and topography. 
+   !>
+   !>      N.B. If nperio not equal to 0, the land/ocean mask arrays
+   !>      are defined with the proper value at lateral domain boundaries,
+   !>      but bmask. indeed, bmask defined the domain over which the
+   !>      barotropic stream function is computed. this domain cannot
+   !>      contain identical columns because the matrix associated with
+   !>      the barotropic stream function equation is then no more inverti-
+   !>      ble. therefore bmask is set to 0 along lateral domain boundaries
+   !>      even IF nperio is not zero.
+   !>
+   !>      In case of open boundaries (lk_bdy=T):
+   !>        - tmask is set to 1 on the points to be computed bay the open
+   !>          boundaries routines.
+   !>        - bmask is  set to 0 on the open boundaries.
+   !>
+   !> ** Action :   tmask    : land/ocean mask at t-point (=0. or 1.)
+   !>               umask    : land/ocean mask at u-point (=0. or 1.)
+   !>               vmask    : land/ocean mask at v-point (=0. or 1.)
+   !>               fmask    : land/ocean mask at f-point (=0. or 1.)
+   !>               bmask    : land/ocean mask at barotropic stream
+   !>                          function point (=0. or 1.) and set to 0 along lateral boundaries
+   !>               tmask_i  : interior ocean mask
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from dom_msk
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !-------------------------------------------------------------------
+   SUBROUTINE create__mask(td_nam,jpi,jpj,jpk) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+
+      ! local variable
+      INTEGER(i4)  ::   ii0, ii1  ! local integers
+      INTEGER(i4)  ::   ij0, ij1
+      INTEGER(i4)  ::   isrow
+
+!      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE ::  imsk
+      REAL(dp)   , DIMENSION(:,:), ALLOCATABLE ::  zwf
+
+!      REAL(dp)   , DIMENSION(:)  , ALLOCATABLE :: dl_tpol
+!      REAL(dp)   , DIMENSION(:)  , ALLOCATABLE :: dl_fpol
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+!      ALLOCATE( imsk(jpi,jpj) )
+      ALLOCATE( zwf(jpi,jpj) )
+
+!      ALLOCATE( dl_tpol(jpi) )
+!      ALLOCATE( dl_fpol(jpi) )
+
+      CALL logger_info('dommsk : ocean mask ')
+      CALL logger_info('~~~~~~')
+      IF    (      rn_shlat == 0.               )THEN ; CALL logger_info('   ocean lateral  free-slip ')
+      ELSEIF(      rn_shlat == 2.               )THEN ; CALL logger_info('   ocean lateral  no-slip ')
+      ELSEIF( 0. < rn_shlat .AND. rn_shlat < 2. )THEN ; CALL logger_info('   ocean lateral  partial-slip ')
+      ELSEIF( 2. < rn_shlat                     )THEN ; CALL logger_info('   ocean lateral  strong-slip ')
+      ELSE ; CALL logger_info(' rn_shlat is negative = '//TRIM(fct_str(rn_shlat)))
+      ENDIF
+
+      ! 1. Ocean/land mask at t-point (computed from mbathy)
+      ! -----------------------------
+      ! N.B. tmask has already the right boundary conditions since mbathy is ok
+      !
+      tg_tmask%d_value(:,:,:,1) = 0._dp
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tg_mbathy%d_value(ji,jj,1,1) - REAL(jk,dp) + 0.1_dp >= 0._dp )THEN
+                  tg_tmask%d_value(ji,jj,jk,1) = 1._dp
+               ENDIF
+            ENDDO  
+         ENDDO  
+      ENDDO  
+      
+      ! (ISF) define barotropic mask and mask the ice shelf point
+      tg_ssmask%d_value(:,:,1,1)=tg_tmask%d_value(:,:,1,1) ! at this stage ice shelf is not masked
+      
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tg_misfdep%d_value(ji,jj,1,1) - REAL(jk,dp) - 0.1_dp >= 0._dp )   THEN
+                  tg_tmask%d_value(ji,jj,jk,1) = 0._dp
+               END IF
+            ENDDO  
+         ENDDO  
+      ENDDO
+
+!      ! Interior domain mask (used for global sum)
+!      ! --------------------
+!      tg_tmask_i%d_value(:,:,1,1) = tg_ssmask%d_value(:,:,1,1)  ! (ISH) tmask_i = 1 even on the ice shelf
+!
+!      tg_tmask_h%d_value(:,:,1,1) = 1._dp          ! 0 on the halo and 1 elsewhere
+!
+!      tg_tmask_h%d_value( 1 , : ,1,1) = 0._dp      ! first columns
+!      tg_tmask_h%d_value(jpi, : ,1,1) = 0._dp      ! last  columns
+!      tg_tmask_h%d_value( : , 1 ,1,1) = 0._dp      ! first rows
+!      tg_tmask_h%d_value( : ,jpj,1,1) = 0._dp      ! last  rows
+!
+!      ! north fold mask
+!      ! ---------------
+!      dl_tpol(1:jpi) = 1._dp 
+!      dl_fpol(1:jpi) = 1._dp
+!      IF( td_nam%i_perio == 3 .OR. td_nam%i_perio == 4 )THEN      ! T-point pivot
+!         dl_tpol(jpi/2+1:jpi) = 0._dp
+!         dl_fpol(   1   :jpi) = 0._dp
+!         IF( mjg(nlej) == jpj ) THEN                  ! only half of the nlcj-1 row
+!            DO ji = iif+1, iil-1
+!               tg_tmask_h%d_value(ji,nlej-1,1,1) = tg_tmask_h%d_value(ji,nlej-1,1,1) * dl_tpol(mig(ji))
+!            END DO
+!         ENDIF
+!      ENDIF
+!
+!      tg_tmask_i%d_value(:,:,1,1) = tg_tmask_i%d_value(:,:,1,1) * tg_tmask_h%d_value(:,:,1,1)
+!
+!      IF( td_nam%i_perio == 5 .OR. td_nam%i_perio == 6 )THEN      ! F-point pivot
+!         dl_tpol(   1   :jpi) = 0._dp
+!         dl_fpol(jpi/2+1:jpi) = 0._dp
+!      ENDIF
+
+      ! 2. Ocean/land mask at u-,  v-, and z-points (computed from tmask)
+      ! -------------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1  ! vector loop
+               tg_umask%d_value(ji,jj,jk,1) = tg_tmask%d_value(ji  ,jj  ,jk,1) * &
+                                            & tg_tmask%d_value(ji+1,jj  ,jk,1)
+
+               tg_vmask%d_value(ji,jj,jk,1) = tg_tmask%d_value(ji  ,jj  ,jk,1) * &
+                                            & tg_tmask%d_value(ji  ,jj+1,jk,1)
+            !END DO
+            !DO ji = 1, jpi-1  ! NO vector opt.
+               tg_fmask%d_value(ji,jj,jk,1) = tg_tmask%d_value(ji  ,jj  ,jk,1) * &
+                                            & tg_tmask%d_value(ji+1,jj  ,jk,1) * &
+                                            & tg_tmask%d_value(ji  ,jj+1,jk,1) * &
+                                            & tg_tmask%d_value(ji+1,jj+1,jk,1)
+            ENDDO
+         ENDDO
+      ENDDO      
+
+!      ! (ISF) MIN(1,SUM(umask)) is here to check if you have effectively at least 1 wet cell at u point
+!      DO jj = 1, jpjm1
+!         DO ji = 1, fs_jpim1   ! vector loop
+!            tg_ssumask%d_value(ji,jj,1,1)  = tg_ssmask%d_value(ji  ,jj  ,1,1) * &
+!                                           & tg_ssmask%d_value(ji+1,jj  ,1,1) * &
+!                                           & MIN( 1._wp, SUM(tg_umask%d_value(ji,jj,:,1)) )
+!            tg_ssvmask%d_value(ji,jj,1,1)  = tg_ssmask%d_value(ji  ,jj  ,1,1) * &
+!                                           & tg_ssmask%d_value(ji  ,jj+1,1,1) * &
+!                                           & MIN( 1._wp, SUM(tg_vmask%d_value(ji,jj,:,1)) )
+!         END DO
+!         DO ji = 1, jpim1      ! NO vector opt.
+!            tg_ssfmask%d_value(ji,jj,1,1) =  tg_ssmask%d_value(ji  ,jj  ,1,1) * &
+!                                          &  tg_ssmask%d_value(ji+1,jj  ,1,1) * &
+!                                          &  tg_ssmask%d_value(ji  ,jj+1,1,1) * &
+!                                          &  tg_ssmask%d_value(ji+1,jj+1,1,1) * &
+!                                          &  MIN( 1._wp, SUM(tg_fmask%d_value(ji,jj,:,1)) )
+!         END DO
+!      END DO
+      CALL lbc_lnk( tg_umask%d_value  (:,:,:,1), 'U', td_nam%i_perio, 1._dp )      ! Lateral boundary conditions
+      CALL lbc_lnk( tg_vmask%d_value  (:,:,:,1), 'V', td_nam%i_perio, 1._dp )
+      CALL lbc_lnk( tg_fmask%d_value  (:,:,:,1), 'F', td_nam%i_perio, 1._dp )
+!      CALL lbc_lnk( tg_ssumask%d_value(:,:,:,1), 'U', td_nam%i_perio, 1._dp )      ! Lateral boundary conditions
+!      CALL lbc_lnk( tg_ssvmask%d_value(:,:,:,1), 'V', td_nam%i_perio, 1._dp )
+!      CALL lbc_lnk( tg_ssfmask%d_value(:,:,:,1), 'F', td_nam%i_perio, 1._dp )
+
+      ! 3. Ocean/land mask at wu-, wv- and w points 
+      !----------------------------------------------
+!      tg_wmask%d_value (:,:,1,1) = tg_tmask%d_value(:,:,1,1) ! surface
+!      tg_wumask%d_value(:,:,1,1) = tg_umask%d_value(:,:,1,1)
+!      tg_wvmask%d_value(:,:,1,1) = tg_vmask%d_value(:,:,1,1)
+!
+!      DO jk=2,jpk                                            ! interior values
+!         tg_wmask%d_value (:,:,jk,1) = tg_tmask%d_value(:,:,jk  ,1) * &
+!                                     & tg_tmask%d_value(:,:,jk-1,1)
+!         tg_wumask%d_value(:,:,jk,1) = tg_umask%d_value(:,:,jk  ,1) * &
+!                                     & tg_umask%d_value(:,:,jk-1,1)   
+!         tg_wvmask%d_value(:,:,jk,1) = tg_vmask%d_value(:,:,jk  ,1) * &
+!                                     & tg_vmask%d_value(:,:,jk-1,1)
+!      ENDDO
+
+      ! Lateral boundary conditions on velocity (modify fmask)
+      ! ---------------------------------------     
+      DO jk = 1, jpk
+         zwf(:,:) = tg_fmask%d_value(:,:,jk,1)         
+         DO jj = 2, jpj-1
+            DO ji = 2, jpi-1   ! vector opt.
+               IF( tg_fmask%d_value(ji,jj,jk,1) == 0._dp )THEN
+                  tg_fmask%d_value(ji,jj,jk,1) = rn_shlat * &
+                                               & MIN(1._dp , MAX(zwf(ji+1,jj), zwf(ji,jj+1), &
+                                               &                 zwf(ji-1,jj), zwf(ji,jj-1)) )
+               ENDIF
+            END DO
+         END DO
+         DO jj = 2, jpj-1
+            IF( tg_fmask%d_value(1,jj,jk,1) == 0._dp )THEN
+               tg_fmask%d_value(1  ,jj,jk,1) = rn_shlat * &
+                                             & MIN(1._dp, MAX(zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1)))
+            ENDIF
+            IF( tg_fmask%d_value(jpi,jj,jk,1) == 0._dp )THEN
+               tg_fmask%d_value(jpi,jj,jk,1) = rn_shlat * &
+                                             & MIN(1._wp, MAX(zwf(jpi,jj+1), zwf(jpi-1,jj), zwf(jpi,jj-1)))
+            ENDIF
+         END DO         
+         DO ji = 2, jpi-1
+            IF( tg_fmask%d_value(ji,1,jk,1) == 0._dp )THEN
+               tg_fmask%d_value(ji, 1 ,jk,1) = rn_shlat * &
+                                             & MIN(1._dp, MAX(zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1)))
+            ENDIF
+            IF( tg_fmask%d_value(ji,jpj,jk,1) == 0._dp )THEN
+               tg_fmask%d_value(ji,jpj,jk,1) = rn_shlat * &
+                                             & MIN(1._dp, MAX(zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpj-1)))
+            ENDIF
+         END DO
+      END DO
+
+      IF( td_nam%c_cfg == "orca" .AND. td_nam%i_cfg == 2 )THEN   ! ORCA_R2 configuration
+         !                                                 ! Increased lateral friction near of some straits
+         IF( td_nam%i_cla == 0 ) THEN
+            ! Gibraltar strait  : partial slip (fmask=0.5)
+            ij0 = 101   ;   ij1 = 101
+            ii0 = 139   ;   ii1 = 140   
+            tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1) =  0.5_dp
+
+            ij0 = 102   ;   ij1 = 102
+            ii0 = 139   ;   ii1 = 140
+            tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1) =  0.5_dp
+            !
+            !Bab el Mandeb : partial slip (fmask=1)
+            ij0 =  87   ;   ij1 =  88
+            ii0 = 160   ;   ii1 = 160
+            tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1) =  1._dp
+
+            ij0 =  88   ;   ij1 =  88
+            ii0 = 159   ;   ii1 = 159
+            tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1) =  1._dp
+            !
+         ENDIF
+      ENDIF
+      !
+      IF( td_nam%c_cfg == "orca" .AND. td_nam%i_cfg == 1 )THEN   ! ORCA R1 configuration
+         ! Increased lateral friction near of some straits
+         ! This dirty section will be suppressed by simplification process:
+         ! all this will come back in input files
+         ! Currently these hard-wired indices relate to configuration with
+         ! extend grid (jpjglo=332)
+         !
+         isrow = 332 - jpj
+         ! Gibraltar Strait
+         ii0 = 282           ;   ii1 = 283 
+         ij0 = 201 + isrow   ;   ij1 = 241 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1) = 2._dp  
+
+         ! Bhosporus Strait
+         ii0 = 314           ;   ii1 = 315
+         ij0 = 208 + isrow   ;   ij1 = 248 - isrow 
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 2._dp  
+
+         ! Makassar Strait (Top) 
+         ii0 =  48           ;   ii1 =  48
+         ij0 = 149 + isrow   ;   ij1 = 190 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 3._dp  
+
+         ! Lombok Strait
+         ii0 =  44           ;   ii1 =  44
+         ij0 = 124 + isrow   ;   ij1 = 165 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 2._dp  
+
+         ! Ombai Strait
+         ii0 =  53           ;   ii1 =  53
+         ij0 = 124 + isrow   ;   ij1 = 165 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 2._dp  
+
+         ! Timor Passage
+         ii0 =  56           ;   ii1 =  56
+         ij0 = 124 + isrow   ;   ij1 = 165 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 2._dp  
+
+         ! West Halmahera Strait
+         ii0 =  58           ;   ii1 =  58
+         ij0 = 141 + isrow   ;   ij1 = 182 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 3._dp  
+
+         ! East Halmahera Strait
+         ii0 =  55           ;   ii1 =  55
+         ij0 = 141 + isrow   ;   ij1 = 182 - isrow
+         tg_fmask%d_value(ii0:ii1,ij0:ij1,1:jpk,1 ) = 3._dp  
+         !
+      ENDIF
+      !
+      CALL lbc_lnk( tg_fmask%d_value(:,:,:,1), 'F', td_nam%i_perio, 1._dp )      ! Lateral boundary conditions on fmask
+
+!      DEALLOCATE( imsk )
+      DEALLOCATE( zwf )
+
+!      DEALLOCATE( dl_tpol )
+!      DEALLOCATE( dl_fpol )
+      
+   END SUBROUTINE create__mask
+   !-------------------------------------------------------------------
+   !> @brief 
+   !> this function create array of global attributes.
+   !>
+   !> @author J.Paul
+   !> @date October, 2016 - initial release
+   !>
+   !> @param[in] cd_bathy
+   !> @param[in] cd_coord
+   !> @param[in] cd_isfdep
+   !> @param[in] td_namh
+   !> @param[in] td_namz
+   !-------------------------------------------------------------------
+   FUNCTION create__gloatt(cd_bathy,cd_coord,cd_isfdep,td_namh,td_namz) RESULT(td_att)
+      IMPLICIT NONE
+      ! Argument      
+      CHARACTER(LEN=*), INTENT(IN   ) :: cd_bathy 
+      CHARACTER(LEN=*), INTENT(IN   ) :: cd_coord 
+      CHARACTER(LEN=*), INTENT(IN   ) :: cd_isfdep 
+      TYPE(TNAMH)     , INTENT(IN   ) :: td_namh 
+      TYPE(TNAMZ)     , INTENT(IN   ) :: td_namz 
+
+      ! function
+      TYPE(TATT), DIMENSION(ip_maxatt) :: td_att
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      ji=1    ; td_att(ji)=att_init("src_bathy",TRIM(cd_bathy))
+      ! horizontal grid
+      ji=ji+1 ; td_att(ji)=att_init("in_mshhgr",td_namh%i_mshhgr)
+      SELECT CASE(td_namh%i_mshhgr)
+         CASE(0)
+            ji=ji+1 ; td_att(ji)=att_init("src_coord",TRIM(cd_coord))
+         CASE(1,4)
+            ji=ji+1 ; td_att(ji)=att_init("ppglam0",td_namh%d_ppglam0)
+            ji=ji+1 ; td_att(ji)=att_init("ppgphi0",td_namh%d_ppgphi0)
+         CASE(2,3)
+            ji=ji+1 ; td_att(ji)=att_init("ppglam0",td_namh%d_ppglam0)
+            ji=ji+1 ; td_att(ji)=att_init("ppgphi0",td_namh%d_ppgphi0)
+            ji=ji+1 ; td_att(ji)=att_init("ppe1_deg",td_namh%d_ppe1_deg)
+            ji=ji+1 ; td_att(ji)=att_init("ppe2_deg",td_namh%d_ppe2_deg)
+      END SELECT
+
+      IF( td_namz%l_isfcav )THEN
+         ji=ji+1 ; td_att(ji)=att_init("ice_shelf_cavities","activated")
+         ji=ji+1 ; td_att(ji)=att_init("src_isfdep",TRIM(cd_isfdep))
+      ENDIF
+      IF( td_namz%l_iscpl )THEN
+         ji=ji+1 ; td_att(ji)=att_init("ice_sheet_coupling","activated")
+      ENDIF
+
+      ! vertical grid
+      IF( td_namz%l_zco )THEN
+         ji=ji+1 ; td_att(ji)=att_init("z_coord","full steps")
+      ENDIF
+      IF( td_namz%l_zps )THEN
+         ji=ji+1 ; td_att(ji)=att_init("z_coord","partial steps")
+      ENDIF
+      IF( td_namz%l_sco )THEN
+         IF( td_namz%l_s_sh94 )THEN
+            ji=ji+1 ; td_att(ji)=att_init("z_coord","hybrid Song and Haidvogel 1994")
+         ELSEIF( td_namz%l_s_sf12 )THEN
+            ji=ji+1 ; td_att(ji)=att_init("z_coord","hybrid Siddorn and Furner 2012")
+         ELSE
+            ji=ji+1 ; td_att(ji)=att_init("z_coord","sigma")
+         ENDIF
+      ENDIF
+      ji=ji+1 ; td_att(ji)=att_init("hmin",td_namz%d_hmin)
+      IF( td_namz%l_isfcav ) ji=ji+1 ; td_att(ji)=att_init("isfhmin",td_namz%d_isfhmin)
+
+      ! zco
+      IF( td_namz%d_ppsur /= NF90_FILL_DOUBLE )THEN
+         ji=ji+1 ; td_att(ji)=att_init("ppsur",td_namz%d_ppsur)
+      ELSE
+         ji=ji+1 ; td_att(ji)=att_init("ppsur","to_be_computed")
+      ENDIF
+      IF( td_namz%d_ppa0 /= NF90_FILL_DOUBLE )THEN
+         ji=ji+1 ; td_att(ji)=att_init("ppa0",td_namz%d_ppa0)
+      ELSE
+         ji=ji+1 ; td_att(ji)=att_init("ppa0","to_be_computed")
+      ENDIF
+      IF( td_namz%d_ppa1 /= NF90_FILL_DOUBLE )THEN
+         ji=ji+1 ; td_att(ji)=att_init("ppa1",td_namz%d_ppa1)
+      ELSE
+         ji=ji+1 ; td_att(ji)=att_init("ppa1","to_be_computed")
+      ENDIF
+
+      ji=ji+1 ; td_att(ji)=att_init("ppkth",td_namz%d_ppkth)
+      ji=ji+1 ; td_att(ji)=att_init("ppacr",td_namz%d_ppacr)
+      ji=ji+1 ; td_att(ji)=att_init("ppdzmin",td_namz%d_ppdzmin)
+      ji=ji+1 ; td_att(ji)=att_init("pphmax",td_namz%d_pphmax)
+
+      IF( td_namz%l_dbletanh )THEN
+         ji=ji+1 ; td_att(ji)=att_init("ppa2",td_namz%d_ppa2)
+         ji=ji+1 ; td_att(ji)=att_init("ppkth2",td_namz%d_ppkth2)
+         ji=ji+1 ; td_att(ji)=att_init("ppacr2",td_namz%d_ppacr2)
+      ENDIF
+
+      IF( td_namz%l_zps )THEN
+         ji=ji+1 ; td_att(ji)=att_init("e3zps_min",td_namz%d_e3zps_min)
+         ji=ji+1 ; td_att(ji)=att_init("e3zps_rat",td_namz%d_e3zps_rat)
+      ENDIF
+
+      IF( td_namz%l_sco )THEN
+         ji=ji+1 ; td_att(ji)=att_init("sbot_min",td_namz%d_sbot_min)
+         ji=ji+1 ; td_att(ji)=att_init("sbot_max",td_namz%d_sbot_max)
+         ji=ji+1 ; td_att(ji)=att_init("hc",td_namz%d_hc)
+         IF( td_namz%l_s_sh94 )THEN
+            ji=ji+1 ; td_att(ji)=att_init("rmax",td_namz%d_rmax)
+            ji=ji+1 ; td_att(ji)=att_init("theta",td_namz%d_theta)
+            ji=ji+1 ; td_att(ji)=att_init("thetb",td_namz%d_thetb)
+            ji=ji+1 ; td_att(ji)=att_init("bb",td_namz%d_bb)
+         ELSEIF( td_namz%l_s_sf12 )THEN
+            IF( td_namz%l_sigcrit ) ji=ji+1 ; td_att(ji)=att_init("sigma below critical depth","activated")
+            ji=ji+1 ; td_att(ji)=att_init("alpha",td_namz%d_alpha)
+            ji=ji+1 ; td_att(ji)=att_init("efold",td_namz%d_efold)
+            ji=ji+1 ; td_att(ji)=att_init("zs",td_namz%d_zs)
+            ji=ji+1 ; td_att(ji)=att_init("zb_a",td_namz%d_zb_a)
+            ji=ji+1 ; td_att(ji)=att_init("zb_b",td_namz%d_zb_b)
+         ENDIF
+      ENDIF
+
+      IF( td_namz%l_wd )THEN
+         ji=ji+1 ; td_att(ji)=att_init("wetting_drying","activated")
+      ENDIF
+
+      IF( td_namz%l_wd )THEN
+         ji=ji+1 ; td_att(ji)=att_init("wdmin1",td_namz%d_wdmin1)
+         ji=ji+1 ; td_att(ji)=att_init("wdmin2",td_namz%d_wdmin2)
+         ji=ji+1 ; td_att(ji)=att_init("wdld",td_namz%d_wdld)
+      ENDIF
+      
+   END FUNCTION create__gloatt
+
+END PROGRAM
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_restart.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 7025)
@@ -62,20 +62,22 @@
 !>
 !>    * _vertical grid namelist (namzgr)_:<br/>
-!>       - dn_pp_to_be_computed  :
-!>       - dn_ppsur              :
-!>       - dn_ppa0               :
-!>       - dn_ppa1               :
-!>       - dn_ppa2               : 
-!>       - dn_ppkth              :
-!>       - dn_ppkth2             :
-!>       - dn_ppacr              :
-!>       - dn_ppacr2             :
-!>       - dn_ppdzmin            :
-!>       - dn_pphmax             :
+!>       - dn_ppsur              : coefficient to compute vertical grid
+!>       - dn_ppa0               : coefficient to compute vertical grid
+!>       - dn_ppa1               : coefficient to compute vertical grid
+!>       - dn_ppa2               : double tanh function parameter
+!>       - dn_ppkth              : coefficient to compute vertical grid
+!>       - dn_ppkth2             : double tanh function parameter
+!>       - dn_ppacr              : coefficient to compute vertical grid
+!>       - dn_ppacr2             : double tanh function parameter
+!>       - dn_ppdzmin            : minimum vertical spacing
+!>       - dn_pphmax             : maximum depth
 !>       - in_nlevel             : number of vertical level
 !>
+!>     @note If ppa1 and ppa0 and ppsur are undefined
+!>           NEMO will compute them from ppdzmin , pphmax, ppkth, ppacr
+!>
 !>    * _partial step namelist (namzps)_:<br/>
-!>       - dn_e3zps_min          :
-!>       - dn_e3zps_rat          : 
+!>       - dn_e3zps_min          : minimum thickness of partial step level (meters)
+!>       - dn_e3zps_rat          : minimum thickness ratio of partial step level
 !>
 !>    * _variable namelist (namvar)_:<br/>
@@ -158,4 +160,7 @@
 !> @date September, 2015
 !> - manage useless (dummy) variable, attributes, and dimension
+!>
+!> @todo
+!> - rewrite using meshmask instead of bathymetry and coordinates files
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -262,5 +267,4 @@
 
    !namzgr
-   REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
    REAL(dp)                                :: dn_ppsur   = -3958.951371276829_dp
    REAL(dp)                                :: dn_ppa0    =   103.953009600000_dp
@@ -316,5 +320,4 @@
  
    NAMELIST /namzgr/ &
-   &  dn_pp_to_be_computed, &
    &  dn_ppsur,     &
    &  dn_ppa0,      &
@@ -402,5 +405,5 @@
       ! match variable with file
       tl_multi=multi_init(cn_varfile)
-      
+ 
       READ( il_fileid, NML = namnst )
       READ( il_fileid, NML = namout )
@@ -592,4 +595,5 @@
                !- check grid coincidence
                IF( ll_sameGrid )THEN
+                  il_rho(:)=1
                   CALL grid_check_coincidence( tl_mpp, tl_coord1, &
                   &                            il_imin1, il_imax1, &
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 7025)
@@ -20,8 +20,8 @@
   <b>
   - @ref index
-  - @ref md_docsrc_2_quickstart
-  - @ref md_docsrc_3_support_bug
-  - @ref md_docsrc_4_codingRules
-  - @ref md_docsrc_5_changeLog
+  - @ref md_src_docsrc_2_quickstart
+  - @ref md_src_docsrc_3_support_bug
+  - @ref md_src_docsrc_4_codingRules
+  - @ref md_src_docsrc_5_changeLog
   - @ref todo
   </b>
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 7025)
@@ -7,5 +7,5 @@
 Actually SIREN creates all the input files you need to run a NEMO regional configuration.<br/>
  
-SIREN is composed of a set of 5 Fortran programs :
+SIREN is composed of a set of 6 Fortran programs :
 <ul>
  <li>create_coord.f90 to create regional grid coordinates.</li>
@@ -16,4 +16,5 @@
  This break may cause inconsistency between forcing fields  at boundary and regional fields.
  </li>
+ <li>create_meshmask.f90 to create meshmask file(s) which contain(s) all the ocean domain informations.</li>
  <li>create_restart.f90 to create initial state file from coarse grid restart
  or standard outputs.
@@ -35,8 +36,6 @@
 Here after we briefly describe how to use each programs,
 and so how to create your own regional configuration.
-@note A set of GLORYS files (global reanalysis on *ORCA025*
-grid), as well as examples of namelists are available in dods repository.<br/>
-You could create and forced a first release of your own regional configuration,
-with those files. 
+@note As demonstrator for a first start a set of GLORYS files (global reanalysis on *ORCA025* grid), as well as examples of namelists are available [here](https://cloud.mercator-ocean.fr/public.php?service=files&t=877fb1b6e4f589340fc0df1ea6a53228).
+
 <!-- ######################################################################  -->
 # Create coordinates file # {#coord}
@@ -121,5 +120,5 @@
 example: ORCA05</dd>
 </dl>
-@sa For more information see @ref md_docsrc_6_perio
+@sa For more information see @ref md_src_docsrc_6_perio
 </dd>
 </dl>
@@ -150,5 +149,6 @@
 ~~~~~~~~~~~
 @image html grid_zoom_60.png
-@image latex grid_zoom_40.png
+<center>@image latex grid_zoom_40.png
+</center>
 <!-- @note ghost cells all around the grid are not shown here. -->
 
@@ -167,5 +167,6 @@
 ~~~~~~~~~~~
 @image html grid_glob_over_30.png
-@image latex grid_glob_over_20.png
+<center>@image latex grid_glob_over_20.png
+</center>
 <!-- @note in blue, the east-west overlap band of ORCA grid. -->
 
@@ -184,5 +185,6 @@
 ~~~~~~~~~~~
 @image html grid_glob_band_30.png
-@image latex grid_glob_band_20.png
+<center>@image latex grid_glob_band_20.png
+</center>
 
 </ul>
@@ -361,4 +363,133 @@
 
 <!-- ######################################################################  -->
+# Create meshmask (ocean domain informations) # {#meshmask}
+
+
+Depending on the vertical grid you choose to use, NEMO may not see the bathymetry as you defined it just before. To get the ocean domain informations as seen by NEMO, SIREN allows you to create the meshmask file(s) which contain(s) all those informations.
+
+To create this new meshmask file(s), you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_meshmask.exe create_meshmask.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_meshmask.exe*.<br/>
+In this example, you create one meshmask file named *mesh_mask.nc*.<br/>
+It uses coordinates file *coord_fine.nc* to define horizontal grid.
+and defines z-coordinate with partial steps.
+The minimum depth of the final Bathymetry is 10m. 
+~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namin
+   cn_bathy = "PATH/bathy_merged.nc"
+   cn_coord = "PATH/coord_fine.nc"
+   in_perio = 4
+/
+
+&namhgr
+   in_mshhgr = 0
+/
+
+&namzgr
+   ln_zps   = .TRUE.
+   in_nlevel= 75
+/
+
+&namdmin
+   dn_hmin=10.
+/
+
+&namzco
+   dn_ppsur   = -3958.951371276829
+   dn_ppa0    =   103.953009600000
+   dn_ppa1    =     2.415951269000
+   dn_ppkth   =    15.351013700000
+   dn_ppacr   =     7.000000000000
+   dn_ppdzmin = 6.
+   dn_pphmax  = 5750.
+   ln_dbletanh= .TRUE.
+   dn_ppa2    =   100.760928500000
+   dn_ppkth2  =    48.029893720000
+   dn_ppacr2  =    13.000000000000
+/
+
+&namzps
+   dn_e3zps_min = 25.
+   dn_e3zps_rat = 0.2
+/
+
+&namsco
+/
+
+&namcla
+/
+
+&namlbc
+/
+
+&namwd
+/
+
+&namgrd
+/
+
+&namzoom
+/
+
+&namout
+   in_msh = 1
+/
+~~~~~~~~~~~
+
+Let's get describe this namelist more accurately.<br/>
+
+As previously, we have the **namlog** and **namcfg** describe above.<br/>
+
+The **namin** sub-namelist defines the Bathymetry to be used.
+Mainly SIREN need Bathymetry to create meshmask.
+Here we also read coordinates directly on a file. 
+@note here again you could add the *in_perio* parameter if need be i.e. if your
+Bathymetry was not created by SIREN.<br/>
+@note By default SIREN suppress closed sea/lake from the ORCA domain.
+
+The **namhgr** sub-namelist defines the horizontal grid.
+the type of horizontal mesh is choose between :<ul>
+<li> in_mshhgr=0 : curvilinear coordinate on the sphere read in coordinate.nc</li>
+<li> in_mshhgr=1 : geographical mesh on the sphere with regular grid-spacing</li>
+<li> in_mshhgr=2 : f-plane with regular grid-spacing</li>
+<li> in_mshhgr=3 : beta-plane with regular grid-spacing</li>
+<li> in_mshhgr=4 : Mercator grid with T/U point at the equator</li>
+<li> in_mshhgr=5 : beta-plane with regular grid-spacing and rotated domain (GYRE configuration)</li>
+</ul>
+
+The **namzgr** sub-namelist allows to choose the type of vertical grid (z-coordinate full steps, partial steps, sigma or hybrid coordinates) and the number of level.
+
+The **namdmin** sub-namelist dfines the minimum ocean depth. It could be defines in meter (>0) or in number of level (<0).
+
+The **namzco** sub-namelist defines respectively parameters to compute z-coordinate vertical grid (**needed for all type of vertical grid**)
+<!-- By default, those parameters are defined the same way than in GLORYS (i.e. 75 vertical levels).<br/> -->
+
+The **namzps** sub-namelist defines extra parameters needed to define z-coordinates partial steps.
+
+The **namsco** sub-namelist defines extra parameters needed to define sigma or hybrid coordinates (not needed here).
+
+The **namcla** sub-namelist defines cross land advection for exchanges through some straits only used for ORCA2 (see namgrd).
+
+The **namlbc** sub-namelist defines lateral boundary conditions at the coast. It is needed to modify the fmask.
+
+The **namwd** sub-namelist defines the wetting and drying parameters if activated (see namzgr sub-namelist)
+
+The **namgrd** and **namzoom** sub-namelists define grid configuration. Those namelist only activated local correction.
+
+Finally, this **namout** sub-namelist defines the number output file(s).<br/>
+
+@sa For more information about how to create meshmask, see create_meshmask.f90
+
+<!-- ######################################################################  -->
 # Create initial state # {#restart}
 
@@ -442,7 +573,7 @@
 Finally, this **namout** sub-namelist defines the output files.<br/>
 Here we ask for output on 81 processors, with *restart_out.nc* as file "basename".<br/>
-So SIREN computes the optimal layout for 81 porcessors
+So SIREN computes the optimal layout for 81 processors
 available,<br/>
-and split restart on output files named *restart_out_num.nc*, where *num* is the porc number.
+and split restart on output files named *restart_out_num.nc*, where *num* is the proc number.
 
 @note SIREN could also create the other fields you may need for
@@ -592,9 +723,9 @@
    <b>
    - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_2_quickstart
-   - @ref md_docsrc_3_support_bug
-   - @ref md_docsrc_4_codingRules
-   - @ref md_docsrc_5_changeLog
+   - @ref md_src_docsrc_1_install
+   - @ref md_src_docsrc_2_quickstart
+   - @ref md_src_docsrc_3_support_bug
+   - @ref md_src_docsrc_4_codingRules
+   - @ref md_src_docsrc_5_changeLog
    - @ref todo
    </b>
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 7025)
@@ -20,9 +20,9 @@
    <b>
    - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_2_quickstart
-   - @ref md_docsrc_3_support_bug
-   - @ref md_docsrc_4_codingRules
-   - @ref md_docsrc_5_changeLog
+   - @ref md_src_docsrc_1_install
+   - @ref md_src_docsrc_2_quickstart
+   - @ref md_src_docsrc_3_support_bug
+   - @ref md_src_docsrc_4_codingRules
+   - @ref md_src_docsrc_5_changeLog
    - @ref todo
    </b>
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 7025)
@@ -15,5 +15,5 @@
 _GET_COMMAND_ARGUMENT_.<br/>
 There exist no equivalent for those Fortran 03 intrinsec functions in Fortran
-95.<br/> At least none convenient for compilers tested (see @ref md_docsrc_1_install). 
+95.<br/> At least none convenient for compilers tested (see @ref md_src_docsrc_1_install). 
 
 #  Free Form Source {#free}
@@ -93,8 +93,8 @@
    <b>
    - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_2_quickstart
-   - @ref md_docsrc_3_support_bug
-   - @ref md_docsrc_5_changeLog
+   - @ref md_src_docsrc_1_install
+   - @ref md_src_docsrc_2_quickstart
+   - @ref md_src_docsrc_3_support_bug
+   - @ref md_src_docsrc_5_changeLog
    - @ref todo
    </b>
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 7025)
@@ -3,18 +3,24 @@
 @tableofcontents
 
-# Release $Revision$
-Initial release (2016-03-17)
+# Release $Date::             $ ($Revision$)
 
+## New Features
+- create_meshmask.F90 program to create meshmask from coordinates and bathymetry files.
 ## Changes
-## New Features
+- create_coord.F90: allow to define sub domain with coarse grid indices or coordinates.
+- grid.F90:grid__get_closest_str: add function to get closest grid point using coarse grid coordinates strucutre.
+- iom.F90:iom_open: open cdf4 file as cdf
 ## Bug fixes
+- boundary.F90:boundary_check: take into account that boundaries are compute on T point, but expressed on U,V point
+
+# Initial Release 2016-03-17
 
  <HR>
    <b>
    - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_2_quickstart
-   - @ref md_docsrc_3_support_bug
-   - @ref md_docsrc_4_codingRules
+   - @ref md_src_docsrc_1_install
+   - @ref md_src_docsrc_2_quickstart
+   - @ref md_src_docsrc_3_support_bug
+   - @ref md_src_docsrc_4_codingRules
    - @ref todo
    </b>
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 7025)
@@ -6,29 +6,36 @@
 <dd>ghost cells (solid walls) are imposed at all model boundaries.</dd> 
 @image html perio0_20.png 
-@image latex perio0_20.png
+<center>@image latex perio0_20.png 
+</center>
 <dt>cyclic east-west boundary (in_perio=1)</dt>
 <dd>first and last rows are closed, whilst the first column is set to the value of the last-but-one column and the last column to the value of the second one.</dd>  
 @image html perio1_20.png 
-@image latex perio1_20.png
+<center>@image latex perio1_20.png 
+</center>
 <dt>symmetric boundary condition across the equator. (in_perio=2)</dt>
 <dd>last row, and first and last columns are closed. </dd> 
 @image html perio2_20.png 
-@image latex perio2_20.png
+<center>@image latex perio2_20.png 
+</center>
 <dt>North fold boundary with a T -point pivot (in_perio=3)</dt>
 <dd>first row, and first and last columns are closed. </dd> 
 @image html perio3_20.png 
-@image latex perio3_20.png
+<center>@image latex perio3_20.png 
+</center>
 <dt>North fold boundary with a T -point pivot and cyclic east-west boundary (in_perio=4)</dt>
 <dd>first row is closed. The first column is set to the value of the last-but-one column and the last column to the value of the second one. </dd> 
 @image html perio4_20.png 
-@image latex perio4_20.png
+<center>@image latex perio4_20.png 
+</center>
 <dt>North fold boundary with a F -point pivot (in_perio=5)</dt>
 <dd>first row, and first and last columns are closed. </dd> 
 @image html perio5_20.png 
-@image latex perio5_20.png
+<center>@image latex perio5_20.png 
+</center>
 <dt>North fold boundary with a F -point pivot and cyclic east-west boundary (in_perio=6)</dt>
 <dd>first row is closed. The first column is set to the value of the last-but-one column and the last column to the value of the second one.</dd> 
 @image html perio6_20.png 
-@image latex perio6_20.png
+<center>@image latex perio6_20.png 
+</center>
 </dl>
 @sa For more information about NEMO periodicity, see _Model Boundary Condition_ chapter in [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 7025)
@@ -2,21 +2,17 @@
  @mainpage About 
 
- SIREN is a software to create regional configuration with [NEMO](http://www.nemo-ocean.eu).<br/> 
- Actually SIREN create input files needed for a basic NEMO configuration.<br/>
+ SIREN is a software to set up regional configuration with [NEMO](http://www.nemo-ocean.eu).<br/> 
+ Actually SIREN creates the input files you need to run a NEMO regional configuration.<br/>
+ 
+ SIREN allows you to create your own regional configuration embedded in a wider one.<br/>
 
- SIREN allows you to create your own regional configuration embedded in a wider one.<br/>
- In order to help you, a set of GLORYS files (global reanalysis on ORCA025 grid), as well as examples
- of namelists are available in dods repository.
+ To know how to install SIREN see @ref md_src_docsrc_1_install.
 
- @note This software was created, and is maintain by the Configuration Manager Working Group, composed
- of NEMO system team members.
- 
- To know how to install SIREN see @ref md_docsrc_1_install.
-
- You could find a tutorial for a quick start with SIREN in @ref md_docsrc_2_quickstart.<br/>
+ You could find a tutorial for a quick start with SIREN in @ref md_src_docsrc_2_quickstart.<br/>
  For more information about how to use each component of SIREN
  - see create_coord.f90 to create fine grid coordinate file
  - see create_bathy.f90 to create fine grid bathymetry
  - see merge_bathy.f90 to merge fine grid bathymetry
+ - see create_meshmask.f90 to create mesh mask grid
  - see create_restart.f90 to create initial state file, or other fields.
  - see create_boundary.F90 to create boundary condition
@@ -24,9 +20,9 @@
 <HR>
    <b>
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_2_quickstart
-   - @ref md_docsrc_3_support_bug
-   - @ref md_docsrc_4_codingRules
-   - @ref md_docsrc_5_changeLog
+   - @ref md_src_docsrc_1_install
+   - @ref md_src_docsrc_2_quickstart
+   - @ref md_src_docsrc_3_support_bug
+   - @ref md_src_docsrc_4_codingRules
+   - @ref md_src_docsrc_5_changeLog
    - @ref todo
    </b>
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/global.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 7025)
@@ -101,5 +101,5 @@
    REAL(dp)                                , PARAMETER :: dp_fill_i4=NF90_FILL_INT    !< INT fill value
    REAL(dp)                                , PARAMETER :: dp_fill_sp=NF90_FILL_FLOAT  !< real fill value
-   REAL(dp)                                , PARAMETER :: dp_fill=NF90_FILL_DOUBLE !< double fill value
+   REAL(dp)                                , PARAMETER :: dp_fill=NF90_FILL_DOUBLE    !< double fill value
 
    INTEGER(i4)                             , PARAMETER :: ip_npoint=4
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 7025)
@@ -218,7 +218,9 @@
 !> @date February, 2015
 !> - add function grid_fill_small_msk to fill small domain inside bigger one
-!> @February, 2016
+!> @date February, 2016
 !> - improve way to check coincidence (bug fix)
 !> - manage grid cases for T,U,V or F point, with even or odd refinment (bug fix)
+!> @date April, 2016
+!> - add function to get closest grid point using coarse grid coordinates strucutre 
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -271,4 +273,8 @@
    PRIVATE :: grid__get_coarse_index_cc ! - using coarse and fine grid array of lon,lat
 
+                                     ! return closest coarse grid point from another point
+   PRIVATE :: grid__get_closest_str    ! - using coarse grid coordinates strucutre
+   PRIVATE :: grid__get_closest_arr    ! - using coarse grid array of lon,lat
+
                                      ! get offset between fine and coarse grid
    PRIVATE :: grid__get_fine_offset_ff ! - using coarse and fine grid coordinates files
@@ -333,4 +339,9 @@
       MODULE PROCEDURE grid__get_ghost_mpp
    END INTERFACE  grid_get_ghost
+
+   INTERFACE  grid_get_closest
+      MODULE PROCEDURE grid__get_closest_str
+      MODULE PROCEDURE grid__get_closest_arr
+   END INTERFACE  grid_get_closest
 
    INTERFACE  grid_get_coarse_index
@@ -1365,4 +1376,5 @@
             END SELECT
          ELSE
+            il_perio=-1
             ! check periodicity
             IF(ANY(td_var%d_value(   1     ,:,1,1)/=td_var%d_fill).OR.&
@@ -3020,4 +3032,119 @@
    !>
    !> @author J.Paul
+   !> @date April, 2016 - Initial Version
+   !
+   !> @param[in] td_coord0 coarse grid coordinate mpp structure
+   !> @param[in] dd_lon1   fine   grid longitude
+   !> @param[in] dd_lat1   fine   grid latitude
+   !> @param[in] cd_pos    relative position of grid point from point 
+   !> @param[in] dd_fill   fill value
+   !> @return coarse grid indices of closest point of fine grid point
+   !-------------------------------------------------------------------
+   FUNCTION grid__get_closest_str( td_coord0, dd_lon1, dd_lat1, cd_pos, dd_fill ) &
+   &  RESULT(id_res)
+
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP )     , INTENT(IN) :: td_coord0
+      REAL(dp),         INTENT(IN) :: dd_lon1
+      REAL(dp),         INTENT(IN) :: dd_lat1
+      CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_pos
+      REAL(dp),         INTENT(IN), OPTIONAL :: dd_fill
+
+      ! function
+      INTEGER(i4), DIMENSION(2) :: id_res
+
+      ! local variable
+      CHARACTER(LEN=lc)                        :: cl_point
+      CHARACTER(LEN=lc)                        :: cl_name
+
+      INTEGER(i4)                              :: il_ind
+
+      REAL(dp)   , DIMENSION(:,:), ALLOCATABLE :: dl_lon0
+      REAL(dp)   , DIMENSION(:,:), ALLOCATABLE :: dl_lat0
+
+      TYPE(TVAR)                               :: tl_lon0
+      TYPE(TVAR)                               :: tl_lat0
+      TYPE(TMPP)                               :: tl_coord0
+      !----------------------------------------------------------------
+
+      id_res(:)=-1
+      cl_point='T'
+
+      ! copy structure
+      tl_coord0=mpp_copy(td_coord0)
+
+      IF( .NOT. ASSOCIATED(tl_coord0%t_proc) )THEN
+
+         CALL logger_error("GRID GET CLOSEST: decompsition of mpp "//&
+         &  "file "//TRIM(tl_coord0%c_name)//" not defined." )
+
+      ELSE
+
+         ! open mpp files
+         CALL iom_mpp_open(tl_coord0)
+ 
+         ! read coarse longitue and latitude
+         WRITE(cl_name,*) 'longitude_'//TRIM(cl_point)
+         il_ind=var_get_id(tl_coord0%t_proc(1)%t_var(:), cl_name)
+         IF( il_ind == 0 )THEN
+            CALL logger_warn("GRID GET CLOSEST: no variable "//&
+            &  TRIM(cl_name)//"in file "//TRIM(tl_coord0%c_name)//". &
+            &  try to use longitude.")
+            WRITE(cl_name,*) 'longitude'
+         ENDIF
+         tl_lon0=iom_mpp_read_var(tl_coord0, TRIM(cl_name))
+ 
+         WRITE(cl_name,*) 'latitude_'//TRIM(cl_point)
+         il_ind=var_get_id(tl_coord0%t_proc(1)%t_var(:), cl_name)
+         IF( il_ind == 0 )THEN
+            CALL logger_warn("GRID GET CLOSEST: no variable "//&
+            &  TRIM(cl_name)//"in file "//TRIM(tl_coord0%c_name)//". &
+            &  try to use latitude.")
+            WRITE(cl_name,*) 'latitude'
+         ENDIF
+         tl_lat0=iom_mpp_read_var(tl_coord0, TRIM(cl_name))
+
+         ! close mpp files
+         CALL iom_mpp_close(tl_coord0)
+
+         ALLOCATE(dl_lon0(tl_coord0%t_dim(jp_I)%i_len-tl_coord0%i_ew, &
+            &             tl_coord0%t_dim(jp_J)%i_len) )             
+         ALLOCATE(dl_lat0(tl_coord0%t_dim(jp_I)%i_len-tl_coord0%i_ew, &
+            &             tl_coord0%t_dim(jp_J)%i_len) )
+
+         dl_lon0(:,:)=tl_lon0%d_value(tl_coord0%i_ew+1:,:,1,1)
+         dl_lat0(:,:)=tl_lat0%d_value(tl_coord0%i_ew+1:,:,1,1)
+
+         id_res(:)=grid_get_closest( dl_lon0, dl_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill )
+
+         DEALLOCATE(dl_lon0, dl_lat0)
+         CALL var_clean(tl_lon0)
+         CALL var_clean(tl_lat0)
+         CALL mpp_clean(tl_coord0)
+
+      ENDIF
+
+   END FUNCTION  grid__get_closest_str
+   !-------------------------------------------------------------------
+   !> @brief This function return grid indices of the closest point
+   !> from point (lon1,lat1) 
+   !> 
+   !> @details
+   !>
+   !> @note overlap band should have been already removed from coarse grid array 
+   !> of longitude and latitude, before running this function
+   !>
+   !> if you add cd_pos argument, you could choice to return closest point at
+   !> - lower left  (ll) of the point
+   !> - lower right (lr) of the point
+   !> - upper left  (ul) of the point
+   !> - upper right (ur) of the point
+   !> - lower       (lo) of the point
+   !> - upper       (up) of the point
+   !> -       left  (le) of the point
+   !> -       right (ri) of the point
+   !>
+   !> @author J.Paul
    !> @date November, 2013 - Initial Version
    !> @date February, 2015
@@ -3034,5 +3161,5 @@
    !> @return coarse grid indices of closest point of fine grid point
    !-------------------------------------------------------------------
-   FUNCTION grid_get_closest( dd_lon0, dd_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill )
+   FUNCTION grid__get_closest_arr( dd_lon0, dd_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill )
       IMPLICIT NONE
       ! Argument
@@ -3045,5 +3172,5 @@
 
       ! function
-      INTEGER(i4), DIMENSION(2) :: grid_get_closest
+      INTEGER(i4), DIMENSION(2) :: grid__get_closest_arr
 
       ! local variable
@@ -3261,13 +3388,13 @@
          END SELECT
       ENDIF
-      grid_get_closest(:)=MINLOC(dl_dist(:,:),dl_dist(:,:)/=NF90_FILL_DOUBLE)
-
-      grid_get_closest(1)=grid_get_closest(1)+il_iinf-1
-      grid_get_closest(2)=grid_get_closest(2)+il_jinf-1
+      grid__get_closest_arr(:)=MINLOC(dl_dist(:,:),dl_dist(:,:)/=NF90_FILL_DOUBLE)
+
+      grid__get_closest_arr(1)=grid__get_closest_arr(1)+il_iinf-1
+      grid__get_closest_arr(2)=grid__get_closest_arr(2)+il_jinf-1
 
       DEALLOCATE( dl_dist )
       DEALLOCATE( dl_lon0 )
 
-   END FUNCTION grid_get_closest
+   END FUNCTION grid__get_closest_arr
    !-------------------------------------------------------------------
    !> @brief This function compute the distance between a point A and grid points.  
@@ -4647,4 +4774,5 @@
 
       IF( ll_even )THEN
+
          ! look for variable value on domain for F point
          il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'longitude_F')
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid_hgr.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid_hgr.f90	(revision 7025)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid_hgr.f90	(revision 7025)
@@ -0,0 +1,1387 @@
+!----------------------------------------------------------------------
+! NEMO system team, System and Interface for oceanic RElocable Nesting
+!----------------------------------------------------------------------
+!
+! MODULE: grid_hgr
+!
+! DESCRIPTION:
+!> @brief This module manage Horizontal grid.
+!>
+!> @details
+!> ** Purpose :   Compute the geographical position (in degre) of the 
+!>      model grid-points,  the horizontal scale factors (in meters) and 
+!>      the Coriolis factor (in s-1).
+!>
+!> ** Method  :   The geographical position of the model grid-points is
+!>      defined from analytical functions, fslam and fsphi, the deriva-
+!>      tives of which gives the horizontal scale factors e1,e2.
+!>      Defining two function fslam and fsphi and their derivatives in 
+!>      the two horizontal directions (fse1 and fse2), the model grid-
+!>      point position and scale factors are given by:
+!>         t-point:<br/>
+!>      glamt(i,j) = fslam(i    ,j    )   e1t(i,j) = fse1(i    ,j    )<br/>
+!>      gphit(i,j) = fsphi(i    ,j    )   e2t(i,j) = fse2(i    ,j    )<br/>
+!>         u-point:<br/>
+!>      glamu(i,j) = fslam(i+1/2,j    )   e1u(i,j) = fse1(i+1/2,j    )<br/>
+!>      gphiu(i,j) = fsphi(i+1/2,j    )   e2u(i,j) = fse2(i+1/2,j    )<br/>
+!>         v-point:<br/>
+!>      glamv(i,j) = fslam(i    ,j+1/2)   e1v(i,j) = fse1(i    ,j+1/2)<br/>
+!>      gphiv(i,j) = fsphi(i    ,j+1/2)   e2v(i,j) = fse2(i    ,j+1/2)<br/>
+!>            f-point:<br/>
+!>      glamf(i,j) = fslam(i+1/2,j+1/2)   e1f(i,j) = fse1(i+1/2,j+1/2)<br/>
+!>      gphif(i,j) = fsphi(i+1/2,j+1/2)   e2f(i,j) = fse2(i+1/2,j+1/2)<br/>
+!>      Where fse1 and fse2 are defined by:<br/>
+!>         fse1(i,j) = ra * rad * SQRT( (cos(phi) di(fslam))**2
+!>                                     +          di(fsphi) **2 )(i,j)<br/>
+!>         fse2(i,j) = ra * rad * SQRT( (cos(phi) dj(fslam))**2
+!>                                     +          dj(fsphi) **2 )(i,j)<br/>
+!>
+!>        The coriolis factor is given at z-point by:<br/>
+!>                     ff = 2.*omega*sin(gphif)      (in s-1)<br/>
+!>
+!>        This routine is given as an example, it must be modified
+!>      following the user s desiderata. nevertheless, the output as
+!>      well as the way to compute the model grid-point position and
+!>      horizontal scale factors must be respected in order to insure
+!>      second order accuracy schemes.
+!>
+!> N.B. If the domain is periodic, verify that scale factors are also
+!>      periodic, and the coriolis term again.
+!>
+!> ** Action  : - define  glamt, glamu, glamv, glamf: longitude of t-, 
+!>                u-, v- and f-points (in degre)
+!>              - define  gphit, gphiu, gphiv, gphit: latitude  of t-,
+!>               u-, v-  and f-points (in degre)
+!>        define e1t, e2t, e1u, e2u, e1v, e2v, e1f, e2f: horizontal
+!>      scale factors (in meters) at t-, u-, v-, and f-points.
+!>        define ff: coriolis factor at f-point
+!>
+!> References :   Marti, Madec and Delecluse, 1992, JGR
+!>                Madec, Imbard, 1996, Clim. Dyn.
+!>
+!> @author
+!> G, Madec
+! REVISION HISTORY:
+!> @date March, 1988 - Original code
+!> @date January, 1996 
+!> - terrain following coordinates
+!> @date February, 1997 
+!> - print mesh informations
+!> @date November, 1999
+!> - M. Imbard : NetCDF format with IO-IPSL
+!> @date Augustr, 2000
+!> - D. Ludicone : Reduced section at Bab el Mandeb
+!> @date September, 2001
+!> - M. Levy : eel config: grid in km, beta-plane
+!> @date August, 2002
+!> - G. Madec :  F90: Free form and module, namelist
+!> @date January, 2004
+!> - A.M. Treguier, J.M. Molines : Case 4 (Mercator mesh)
+!> use of parameters in par_CONFIG-Rxx.h90, not in namelist
+!> @date May, 2004
+!> - A. Koch-Larrouy : Add Gyre configuration 
+!> @date February, 2011
+!> - G. Madec : add cell surface (e1e2t)
+!> @date September, 2015 
+!> - J, Paul : rewrite to SIREN format from $Id: domhgr.F90 5506 2015-06-29 15:19:38Z clevy $
+!> @date October, 2015
+!> - J, Paul : update from trunk (revision 6961): add wetting and drying, ice sheet coupling..
+!>
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!----------------------------------------------------------------------
+MODULE grid_hgr
+   USE netcdf                          ! nf90 library
+   USE kind                            ! F90 kind parameter
+   USE fct                             ! basic usefull function
+   USE global                          ! global parameter
+   USE phycst                          ! physical constant
+   USE logger                          ! log file manager
+   USE file                            ! file manager
+   USE var                             ! variable manager
+   USE dim                             ! dimension manager
+   USE dom                             ! domain manager
+   USE grid                            ! grid manager
+   USE iom                             ! I/O manager
+   USE mpp                             ! MPP manager
+   USE iom_mpp                         ! I/O MPP manager
+   USE lbc                             ! lateral boundary conditions
+   IMPLICIT NONE
+   ! NOTE_avoid_public_variables_if_possible
+
+   ! type and variable
+   PUBLIC :: TNAMH
+
+   PUBLIC :: tg_tmask
+   PUBLIC :: tg_umask
+   PUBLIC :: tg_vmask
+   PUBLIC :: tg_fmask
+
+!   PUBLIC :: tg_wmask
+!   PUBLIC :: tg_wumask
+!   PUBLIC :: tg_wvmask
+
+   PUBLIC :: tg_ssmask
+!   PUBLIC :: tg_ssumask
+!   PUBLIC :: tg_ssvmask
+!   PUBLIC :: tg_ssfmask
+
+   PUBLIC :: tg_glamt
+   PUBLIC :: tg_glamu
+   PUBLIC :: tg_glamv
+   PUBLIC :: tg_glamf
+
+   PUBLIC :: tg_gphit
+   PUBLIC :: tg_gphiu
+   PUBLIC :: tg_gphiv
+   PUBLIC :: tg_gphif
+   
+   PUBLIC :: tg_e1t
+   PUBLIC :: tg_e1u
+   PUBLIC :: tg_e1v
+   PUBLIC :: tg_e1f
+   
+   PUBLIC :: tg_e2t
+   PUBLIC :: tg_e2u
+   PUBLIC :: tg_e2v
+   PUBLIC :: tg_e2f
+   
+   PUBLIC :: tg_ff
+
+   PUBLIC :: tg_gcost
+   PUBLIC :: tg_gcosu
+   PUBLIC :: tg_gcosv
+   PUBLIC :: tg_gcosf
+
+   PUBLIC :: tg_gsint
+   PUBLIC :: tg_gsinu
+   PUBLIC :: tg_gsinv
+   PUBLIC :: tg_gsinf
+
+   ! function and subroutine
+   PUBLIC :: grid_hgr_init 
+   PUBLIC :: grid_hgr_fill
+   PUBLIC :: grid_hgr_clean
+   PUBLIC :: grid_hgr_nam 
+
+   PRIVATE :: grid_hgr__fill_curv
+   PRIVATE :: grid_hgr__fill_reg
+   PRIVATE :: grid_hgr__fill_plan
+   PRIVATE :: grid_hgr__fill_merc
+   PRIVATE :: grid_hgr__fill_gyre
+   PRIVATE :: grid_hgr__fill_coriolis
+   PRIVATE :: grid_hgr__angle
+
+   TYPE TNAMH
+
+      CHARACTER(LEN=lc) :: c_coord   
+      INTEGER(i4)       :: i_perio   
+                
+      INTEGER(i4)       :: i_mshhgr  
+      REAL(dp)          :: d_ppglam0 
+      REAL(dp)          :: d_ppgphi0 
+                
+      REAL(dp)          :: d_ppe1_deg
+      REAL(dp)          :: d_ppe2_deg
+!      REAL(dp)          :: d_ppe1_m  
+!      REAL(dp)          :: d_ppe2_m     
+
+      INTEGER(i4)       :: i_cla     
+                
+      CHARACTER(LEN=lc) :: c_cfg     
+      INTEGER(i4)       :: i_cfg     
+      INTEGER(i4)       :: i_bench   
+                
+   END TYPE
+
+   TYPE(TVAR), SAVE :: tg_tmask   
+   TYPE(TVAR), SAVE :: tg_umask
+   TYPE(TVAR), SAVE :: tg_vmask
+   TYPE(TVAR), SAVE :: tg_fmask
+!   TYPE(TVAR), SAVE :: tg_wmask
+!   TYPE(TVAR), SAVE :: tg_wumask
+!   TYPE(TVAR), SAVE :: tg_wvmask
+
+   TYPE(TVAR), SAVE :: tg_ssmask 
+!   TYPE(TVAR), SAVE :: tg_ssumask
+!   TYPE(TVAR), SAVE :: tg_ssvmask
+!   TYPE(TVAR), SAVE :: tg_ssfmask
+
+   TYPE(TVAR), SAVE :: tg_glamt
+   TYPE(TVAR), SAVE :: tg_glamu
+   TYPE(TVAR), SAVE :: tg_glamv
+   TYPE(TVAR), SAVE :: tg_glamf
+
+   TYPE(TVAR), SAVE :: tg_gphit
+   TYPE(TVAR), SAVE :: tg_gphiu
+   TYPE(TVAR), SAVE :: tg_gphiv
+   TYPE(TVAR), SAVE :: tg_gphif
+
+   TYPE(TVAR), SAVE :: tg_e1t
+   TYPE(TVAR), SAVE :: tg_e1u
+   TYPE(TVAR), SAVE :: tg_e1v
+   TYPE(TVAR), SAVE :: tg_e1f
+
+   TYPE(TVAR), SAVE :: tg_e2t
+   TYPE(TVAR), SAVE :: tg_e2u
+   TYPE(TVAR), SAVE :: tg_e2v
+   TYPE(TVAR), SAVE :: tg_e2f
+
+   TYPE(TVAR), SAVE :: tg_ff
+
+   TYPE(TVAR), SAVE :: tg_gcost
+   TYPE(TVAR), SAVE :: tg_gcosu
+   TYPE(TVAR), SAVE :: tg_gcosv
+   TYPE(TVAR), SAVE :: tg_gcosf
+
+   TYPE(TVAR), SAVE :: tg_gsint
+   TYPE(TVAR), SAVE :: tg_gsinu
+   TYPE(TVAR), SAVE :: tg_gsinv
+   TYPE(TVAR), SAVE :: tg_gsinf
+
+CONTAINS
+   !-------------------------------------------------------------------
+   !> @brief This function initialise hgr structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr_init(jpi,jpj,jpk) 
+      IMPLICIT NONE
+      ! Argument      
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+      INTEGER(i4), INTENT(IN) :: jpk
+
+      REAL(dp), DIMENSION(jpi,jpj)     :: dl_tmp2D
+      REAL(dp), DIMENSION(jpi,jpj,jpk) :: dl_tmp3D
+      ! loop indices
+      !----------------------------------------------------------------
+      ! variable 2D
+      dl_tmp2D(:,:)  =dp_fill_i1
+
+      tg_ssmask   = var_init('ssmask' ,dl_tmp2D(:,:)  , dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+!      tg_ssumask  = var_init('ssumask',dl_tmp2D(:,:)  , dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+!      tg_ssvmask  = var_init('ssvmask',dl_tmp2D(:,:)  , dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+!      tg_ssfmask  = var_init('ssfmask',dl_tmp2D(:,:)  , dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+
+      dl_tmp2D(:,:)=dp_fill_sp
+
+      tg_glamt    = var_init('glamt',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_glamu    = var_init('glamu',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_glamv    = var_init('glamv',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_glamf    = var_init('glamf',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+
+      tg_gphit    = var_init('gphit',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_gphiu    = var_init('gphiu',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_gphiv    = var_init('gphiv',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_gphif    = var_init('gphif',dl_tmp2D(:,:)   , dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+
+      dl_tmp2D(:,:)=dp_fill
+
+      tg_e1t      = var_init('e1t'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e1u      = var_init('e1u'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e1v      = var_init('e1v'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e1f      = var_init('e1f'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      tg_e2t      = var_init('e2t'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e2u      = var_init('e2u'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e2v      = var_init('e2v'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e2f      = var_init('e2f'  ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      tg_ff       = var_init('ff'   ,dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      tg_gcost     =var_init('gcost',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gcosu     =var_init('gcosu',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gcosv     =var_init('gcosv',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gcosf     =var_init('gcosf',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      tg_gsint     =var_init('gsint',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gsinu     =var_init('gsinu',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gsinv     =var_init('gsinv',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gsinf     =var_init('gsinf',dl_tmp2D(:,:)   , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      ! variable 3D
+      dl_tmp3D(:,:,:)=dp_fill_i1
+
+      tg_tmask   = var_init('tmask'  ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+      tg_umask   = var_init('umask'  ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+      tg_vmask   = var_init('vmask'  ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+      tg_fmask   = var_init('fmask'  ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+      
+!      tg_wmask   = var_init('wmask'  ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+!      tg_wumask  = var_init('wumask' ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+!      tg_wvmask  = var_init('wvmask' ,dl_tmp3D(:,:,:), dd_fill=dp_fill_i1, id_type=NF90_BYTE)
+
+   END SUBROUTINE grid_hgr_init
+   !-------------------------------------------------------------------
+   !> @brief This function clean hgr structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr_clean() 
+      IMPLICIT NONE
+      ! Argument      
+
+      ! local variable
+      ! loop indices
+      !----------------------------------------------------------------
+      CALL var_clean(tg_ssmask  )
+      CALL var_clean(tg_tmask   )
+      CALL var_clean(tg_umask   )
+      CALL var_clean(tg_vmask   )
+      CALL var_clean(tg_fmask   )
+
+      CALL var_clean(tg_glamt)
+      CALL var_clean(tg_glamu)
+      CALL var_clean(tg_glamv)
+      CALL var_clean(tg_glamf)
+
+      CALL var_clean(tg_gphit)
+      CALL var_clean(tg_gphiu)
+      CALL var_clean(tg_gphiv)
+      CALL var_clean(tg_gphif)
+
+      CALL var_clean(tg_e1t  )
+      CALL var_clean(tg_e1u  )
+      CALL var_clean(tg_e1v  )
+      CALL var_clean(tg_e1f  )
+
+      CALL var_clean(tg_e2t  )
+      CALL var_clean(tg_e2u  )
+      CALL var_clean(tg_e2v  )
+      CALL var_clean(tg_e2f  )
+
+      CALL var_clean(tg_ff   )
+
+      CALL var_clean(tg_gcost )
+      CALL var_clean(tg_gcosu )
+      CALL var_clean(tg_gcosv )
+      CALL var_clean(tg_gcosf )
+
+      CALL var_clean(tg_gsint )
+      CALL var_clean(tg_gsinu )
+      CALL var_clean(tg_gsinv )
+      CALL var_clean(tg_gsinf )
+
+   END SUBROUTINE grid_hgr_clean
+   !-------------------------------------------------------------------
+   !> @brief This function initialise hgr namelist structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] cd_coord   
+   !> @param[in] id_perio  
+   !> @param[in] cd_namelist
+   !> @return hgr namelist structure
+   !-------------------------------------------------------------------
+   FUNCTION grid_hgr_nam( cd_coord,id_perio,cd_namelist )
+      IMPLICIT NONE
+      ! Argument      
+      CHARACTER(LEN=*), INTENT(IN) :: cd_coord
+      INTEGER(i4)     , INTENT(IN) :: id_perio   
+      CHARACTER(LEN=*), INTENT(IN) :: cd_namelist
+      
+      ! function
+      TYPE(TNAMH) :: grid_hgr_nam
+
+      ! local variable
+      INTEGER(i4)        :: il_status
+      INTEGER(i4)        :: il_fileid
+
+      LOGICAL            :: ll_exist
+
+      ! loop indices
+      ! namelist
+
+      ! namhgr
+      INTEGER(i4)       :: in_mshhgr   = 0 
+      REAL(dp)          :: dn_ppglam0  = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppgphi0  = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppe1_deg = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppe2_deg = NF90_FILL_DOUBLE
+!      REAL(dp)          :: dn_ppe1_m   = NF90_FILL_DOUBLE
+!      REAL(dp)          :: dn_ppe2_m   = NF90_FILL_DOUBLE
+
+      ! namcla
+      INTEGER(i4)       :: in_cla      = 0
+
+      ! namgrd
+      CHARACTER(LEN=lc) :: cn_cfg      = ''
+      INTEGER(i4)       :: in_cfg      = 0
+      INTEGER(i4)       :: in_bench    = 0
+
+      !----------------------------------------------------------------
+      NAMELIST /namhgr/ &  
+      &  in_mshhgr,     &  !< type of horizontal mesh 
+                           !< 0: curvilinear coordinate on the sphere read in coordinate.nc
+                           !< 1: geographical mesh on the sphere with regular grid-spacing
+                           !< 2: f-plane with regular grid-spacing
+                           !< 3: beta-plane with regular grid-spacing
+                           !< 4: Mercator grid with T/U point at the equator
+                           !< 5: beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+      &  dn_ppglam0,    &  !< longitude of first raw and column T-point (in_mshhgr = 1 or 4)
+      &  dn_ppgphi0,    &  !< latitude  of first raw and column T-point (in_mshhgr = 1 or 4)
+      &  dn_ppe1_deg,   &  !< zonal      grid-spacing (degrees)         (in_mshhgr = 1,2,3 or 4)
+      &  dn_ppe2_deg       !< meridional grid-spacing (degrees)         (in_mshhgr = 1,2,3 or 4)
+!      &  dn_ppe1_m,     &  !< zonal      grid-spacing (degrees)
+!      &  dn_ppe2_m         !< meridional grid-spacing (degrees)
+
+      NAMELIST /namcla/ &
+      &  in_cla            !< =1 cross land advection for exchanges through some straits (ORCA2)
+
+      NAMELIST/namgrd/  &  !< orca grid namelist
+      &  cn_cfg,        &  !< name of the configuration (orca)
+      &  in_cfg,        &  !< resolution of the configuration (2,1,025..)
+      &  in_bench          !< benchmark parameter (in_mshhgr = 5 ). 
+
+      !----------------------------------------------------------------
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_namelist), EXIST=ll_exist)
+      IF( ll_exist )THEN
+         
+         il_fileid=fct_getunit()
+
+         OPEN( il_fileid, FILE=TRIM(cd_namelist), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("GRID HGR NAM: error opening "//&
+               &  TRIM(cd_namelist))
+         ENDIF
+
+         READ( il_fileid, NML = namhgr  )
+         READ( il_fileid, NML = namcla  )
+         READ( il_fileid, NML = namgrd  )
+
+         CLOSE( il_fileid, IOSTAT=il_status )
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_error("GRID HGR NAM: closing "//TRIM(cd_namelist))
+         ENDIF
+        
+         grid_hgr_nam%c_coord   = TRIM(cd_coord)
+         grid_hgr_nam%i_perio   = id_perio
+
+         grid_hgr_nam%i_mshhgr  = in_mshhgr
+         grid_hgr_nam%d_ppglam0 = dn_ppglam0
+         grid_hgr_nam%d_ppgphi0 = dn_ppgphi0
+
+         grid_hgr_nam%d_ppe1_deg= dn_ppe1_deg
+         grid_hgr_nam%d_ppe2_deg= dn_ppe2_deg
+!         grid_hgr_nam%d_ppe1_m  = dn_ppe1_m
+!         grid_hgr_nam%d_ppe2_m  = dn_ppe2_m
+
+         grid_hgr_nam%i_cla     = in_cla
+
+         grid_hgr_nam%c_cfg     = TRIM(cn_cfg)
+         grid_hgr_nam%i_cfg     = in_cfg
+         grid_hgr_nam%i_bench   = in_bench
+
+      ELSE
+
+         CALL logger_fatal(" GRID HGR NAM: can't find "//TRIM(cd_namelist))
+
+      ENDIF
+
+   END FUNCTION grid_hgr_nam
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill horizontal mesh (hgr structure)
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr_fill(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp)    :: znorme
+      ! loop indices
+      !----------------------------------------------------------------
+      CALL logger_info('GRIG HGR FILL : define the horizontal mesh from ithe'//&
+      &  ' type of horizontal mesh mshhgr = '//TRIM(fct_str(td_nam%i_mshhgr)))
+      IF( td_nam%i_mshhgr == 1 )THEN
+         CALL logger_info('   position of the first row and     ppglam0  = '//&
+            &  TRIM(fct_str(td_nam%d_ppglam0  )) )
+         CALL logger_info('   column grid-point (degrees)       ppgphi0  = '//&
+            &  TRIM(fct_str(td_nam%d_ppgphi0  )) )
+      ELSEIF( td_nam%i_mshhgr == 2 .OR. td_nam%i_mshhgr == 3  )THEN
+         CALL logger_info('   zonal      grid-spacing (degrees) ppe1_deg = '//&
+            &  TRIM(fct_str(td_nam%d_ppe1_deg )) )
+         CALL logger_info('   meridional grid-spacing (degrees) ppe2_deg = '//&
+            &  TRIM(fct_str(td_nam%d_ppe2_deg )) )
+!         CALL logger_info('   zonal      grid-spacing (meters)  ppe1_m   = '//&
+!            &  TRIM(fct_str(td_nam%d_ppe1_m   )) ) 
+!         CALL logger_info('   meridional grid-spacing (meters)  ppe2_m   = '//&
+!            &  TRIM(fct_str(td_nam%d_ppe2_m   )) ) 
+      ENDIF
+
+      SELECT CASE( td_nam%i_mshhgr ) ! type of horizontal mesh
+
+         CASE(0)   !  curvilinear coordinate on the sphere read in coordinate.nc file
+
+            CALL grid_hgr__fill_curv(td_nam,jpi,jpj)
+
+         CASE(1)   ! geographical mesh on the sphere with regular grid-spacing
+
+            CALL grid_hgr__fill_reg(td_nam,jpi,jpj)
+
+         CASE(2:3) ! f- or beta-plane with regular grid-spacing
+
+            CALL grid_hgr__fill_plan(td_nam,jpi,jpj)
+
+         CASE(4)   ! geographical mesh on the sphere, isotropic MERCATOR type
+
+            CALL grid_hgr__fill_merc(td_nam,jpi,jpj)
+
+         CASE(5)   ! beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+
+            CALL grid_hgr__fill_gyre(td_nam,jpi,jpj)
+
+         CASE DEFAULT
+
+            CALL logger_fatal('GRIG HGR FILL : bad flag value for mshhgr = '//&
+               &  TRIM(fct_str(td_nam%i_mshhgr)))
+
+      END SELECT
+
+      ! No Useful associated horizontal metrics
+      ! ---------------------------------------
+
+      ! create coriolis factor
+      CALL grid_hgr__fill_coriolis(td_nam,jpi,jpj)
+     
+      ! Control of domain for symetrical condition
+      ! ------------------------------------------
+      ! The equator line must be the latitude coordinate axe
+
+      IF( td_nam%i_perio == 2 ) THEN
+         znorme = SQRT( SUM(tg_gphiu%d_value(:,2,1,1)*tg_gphiu%d_value(:,2,1,1)) ) / FLOAT( jpi )
+         IF( znorme > 1.e-13 )THEN
+            CALL logger_fatal( ' ===>>>> : symmetrical condition: rerun with good equator line' )
+         ENDIF
+      ENDIF
+
+      ! compute angles between model grid lines and the North direction
+      ! ---------------------------------------------------------------
+      CALL grid_hgr__angle(td_nam,jpi,jpj) 
+
+   END SUBROUTINE grid_hgr_fill
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill horizontal mesh (hgr structure)
+   !> for case of curvilinear coordinate on the sphere read in coordinate.nc file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj   
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr__fill_curv( td_nam,jpi,jpj ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      INTEGER(i4) :: ii0, ii1, ij0, ij1   ! temporary integers
+      INTEGER(i4) :: isrow                ! index for ORCA1 starting row
+
+      TYPE(TMPP)  :: tl_coord
+
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! read coordinates
+      ! open file
+      IF( td_nam%c_coord /= '' )THEN
+         tl_coord=mpp_init( file_init(TRIM(td_nam%c_coord)), id_perio=td_nam%i_perio)
+         CALL grid_get_info(tl_coord)
+      ELSE
+         CALL logger_fatal("GRID HGR FILL: no input coordinates file found. "//&
+         &     "check namelist")      
+      ENDIF
+
+      CALL iom_mpp_open( tl_coord )
+
+      ! read variable in coordinates
+      tg_glamt=iom_mpp_read_var(tl_coord, 'glamt')
+      tg_glamu=iom_mpp_read_var(tl_coord, 'glamu')
+      tg_glamv=iom_mpp_read_var(tl_coord, 'glamv')
+      tg_glamf=iom_mpp_read_var(tl_coord, 'glamf')
+
+      tg_gphit=iom_mpp_read_var(tl_coord, 'gphit')
+      tg_gphiu=iom_mpp_read_var(tl_coord, 'gphiu')
+      tg_gphiv=iom_mpp_read_var(tl_coord, 'gphiv')
+      tg_gphif=iom_mpp_read_var(tl_coord, 'gphif')
+
+      ! force output type
+      tg_glamt%i_type=NF90_FLOAT
+      tg_glamu%i_type=NF90_FLOAT
+      tg_glamv%i_type=NF90_FLOAT
+      tg_glamf%i_type=NF90_FLOAT
+
+      tg_gphit%i_type=NF90_FLOAT
+      tg_gphiu%i_type=NF90_FLOAT
+      tg_gphiv%i_type=NF90_FLOAT
+      tg_gphif%i_type=NF90_FLOAT
+
+      tg_e1t  =iom_mpp_read_var(tl_coord, 'e1t')
+      tg_e1u  =iom_mpp_read_var(tl_coord, 'e1u')
+      tg_e1v  =iom_mpp_read_var(tl_coord, 'e1v')
+      tg_e1f  =iom_mpp_read_var(tl_coord, 'e1f')
+
+      tg_e2t  =iom_mpp_read_var(tl_coord, 'e2t')
+      tg_e2u  =iom_mpp_read_var(tl_coord, 'e2u')
+      tg_e2v  =iom_mpp_read_var(tl_coord, 'e2v')
+      tg_e2f  =iom_mpp_read_var(tl_coord, 'e2f')
+
+      CALL iom_mpp_close( tl_coord )
+      ! clean
+      CALL mpp_clean(tl_coord)
+
+      !! WARNING extended grid have to be correctly fill
+
+      !! special case for ORCA grid
+      ! ORCA R2 configuration
+      IF( TRIM(td_nam%c_cfg) == "orca" .AND. td_nam%i_cfg == 2 ) THEN
+            IF( td_nam%i_cla == 0 ) THEN
+               !
+               ! Gibraltar Strait (e2u = 20 km)
+               ii0 = 139   ;   ii1 = 140
+               ij0 = 102   ;   ij1 = 102   
+               ! e2u = 20 km
+               tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  20.e3
+               CALL logger_info('orca_r2: Gibraltar    : e2u reduced to 20 km')
+               !
+               ! Bab el Mandeb (e2u = 18 km)
+               ii0 = 160   ;   ii1 = 160 
+               ij0 =  88   ;   ij1 =  88   
+               ! e1v = 18 km
+               tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) =  18.e3
+               ! e2u = 30 km
+               tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  30.e3
+
+               CALL logger_info('orca_r2: Bab el Mandeb: e2u reduced to 30 km')
+               CALL logger_info('e1v reduced to 18 km')
+            ENDIF
+            ! Danish Straits
+            ii0 = 145   ;   ii1 = 146
+            ij0 = 116   ;   ij1 = 116   
+            ! e2u = 10 km
+            tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  10.e3
+            CALL logger_info('orca_r2: Danish Straits : e2u reduced to 10 km')
+      ENDIF
+
+      ! ORCA R1 configuration
+      IF( TRIM(td_nam%c_cfg) == "orca" .AND. td_nam%i_cfg == 1 ) THEN
+         ! This dirty section will be suppressed by simplification process: all this will come back in input files
+         ! Currently these hard-wired indices relate to configuration with
+         ! extend grid (jpjglo=332)
+         ! which had a grid-size of 362x292.
+
+         isrow = 332 - jpj
+
+         ! Gibraltar Strait (e2u = 20 km)
+         ii0 = 282           ;   ii1 = 283
+         ij0 = 201 + isrow   ;   ij1 = 241 - isrow 
+         ! e2u = 20 km
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  20.e3
+         CALL logger_info('orca_r1: Gibraltar : e2u reduced to 20 km')
+
+         ! Bhosporus Strait (e2u = 10 km)
+         ii0 = 314           ;   ii1 = 315        ! Bhosporus Strait (e2u = 10 km)
+         ij0 = 208 + isrow   ;   ij1 = 248 - isrow
+         ! Bhosporus Strait (e2u = 10 km)
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  10.e3
+         CALL logger_info('orca_r1: Bhosporus : e2u reduced to 10 km')
+
+         ! Lombok Strait (e1v = 13 km)
+         ii0 =  44           ;   ii1 =  44        ! Lombok Strait (e1v = 13 km)
+         ij0 = 124 + isrow   ;   ij1 = 165 - isrow
+         ! Lombok Strait (e1v = 13 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) =  13.e3
+         CALL logger_info('orca_r1: Lombok : e1v reduced to 10 km')
+
+         ! Sumba Strait (e1v = 8 km) [closed from bathy_11 on]
+         ii0 =  48           ;   ii1 =  48        ! Sumba Strait (e1v = 8 km) [closed from bathy_11 on]
+         ij0 = 124 + isrow   ;   ij1 = 165 - isrow
+         ! Sumba Strait (e1v = 8 km) [closed from bathy_11 on]
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) =  8.e3
+         CALL logger_info('orca_r1: Sumba : e1v reduced to 8 km')
+
+         ! Ombai Strait (e1v = 13 km)
+         ii0 =  53           ;   ii1 =  53        ! Ombai Strait (e1v = 13 km)
+         ij0 = 124 + isrow   ;   ij1 = 165 - isrow
+         ! Ombai Strait (e1v = 13 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) = 13.e3
+         CALL logger_info('orca_r1: Ombai : e1v reduced to 13 km')
+
+         ! Timor Passage (e1v = 20 km)
+         ii0 =  56           ;   ii1 =  56        ! Timor Passage (e1v = 20 km)
+         ij0 = 124 + isrow   ;   ij1 = 145 - isrow
+         ! Timor Passage (e1v = 20 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) = 20.e3
+         CALL logger_info('orca_r1: Timor Passage : e1v reduced to 20 km')
+
+          ! West Halmahera Strait (e1v = 30 km)
+         ii0 =  55           ;   ii1 =  55        ! West Halmahera Strait (e1v = 30 km)
+         ij0 = 141 + isrow   ;   ij1 = 182 - isrow
+         ! West Halmahera Strait (e1v = 30 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) = 30.e3
+         CALL logger_info('orca_r1: W Halmahera : e1v reduced to 30 km')
+
+         ! East Halmahera Strait (e1v = 50 km)
+         ii0 =  58           ;   ii1 =  58        ! East Halmahera Strait (e1v = 50 km)
+         ij0 = 141 + isrow   ;   ij1 = 182 - isrow
+         ! East Halmahera Strait (e1v = 50 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) = 50.e3
+         CALL logger_info('orca_r1: E Halmahera : e1v reduced to 50 km')
+
+      ENDIF
+
+      ! ORCA R05 configuration
+      IF( TRIM(td_nam%c_cfg) == "orca" .AND. td_nam%i_cfg == 05 ) THEN
+
+         ! Gibraltar Strait (e2u = 20 km)
+         ii0 = 563   ;   ii1 = 564        ! Gibraltar Strait (e2u = 20 km)
+         ij0 = 327   ;   ij1 = 327
+         ! Gibraltar Strait (e2u = 20 km)
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  20.e3
+         CALL logger_info('orca_r05: Reduced e2u at the Gibraltar Strait')
+         !
+         ! Bosphore Strait (e2u = 10 km)
+         ii0 = 627   ;   ii1 = 628        ! Bosphore Strait (e2u = 10 km)
+         ij0 = 343   ;   ij1 = 343
+         ! Bosphore Strait (e2u = 10 km)
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  10.e3
+         CALL logger_info('orca_r05: Reduced e2u at the Bosphore Strait')
+         !
+         ! Sumba Strait (e2u = 40 km)
+         ii0 =  93   ;   ii1 =  94        ! Sumba Strait (e2u = 40 km)
+         ij0 = 232   ;   ij1 = 232
+         ! Sumba Strait (e2u = 40 km)
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  40.e3
+         CALL logger_info('orca_r05: Reduced e2u at the Sumba Strait')
+         !
+         ! Ombai Strait (e2u = 15 km)
+         ii0 = 103   ;   ii1 = 103        ! Ombai Strait (e2u = 15 km)
+         ij0 = 232   ;   ij1 = 232
+         ! Ombai Strait (e2u = 15 km)
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  15.e3
+         CALL logger_info('orca_r05: Reduced e2u at the Ombai Strait')
+         !
+         ! Palk Strait (e2u = 10 km)
+         ii0 =  15   ;   ii1 =  15        ! Palk Strait (e2u = 10 km)
+         ij0 = 270   ;   ij1 = 270
+         ! Palk Strait (e2u = 10 km)
+         tg_e2u%d_value(ii0:ii1,ij0:ij1,1,1) =  10.e3
+         CALL logger_info('orca_r05: Reduced e2u at the Palk Strait')
+         !
+         ! Lombok Strait (e1v = 10 km)
+         ii0 =  87   ;   ii1 =  87        ! Lombok Strait (e1v = 10 km)
+         ij0 = 232   ;   ij1 = 233
+         ! Lombok Strait (e1v = 10 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) =  10.e3
+         CALL logger_info('orca_r05: Reduced e1v at the Lombok Strait')
+         !
+         !
+         ! Bab el Mandeb (e1v = 25 km)
+         ii0 = 662   ;   ii1 = 662        ! Bab el Mandeb (e1v = 25 km)
+         ij0 = 276   ;   ij1 = 276
+         ! Bab el Mandeb (e1v = 25 km)
+         tg_e1v%d_value(ii0:ii1,ij0:ij1,1,1) =  25.e3
+         CALL logger_info('orca_r05: Reduced e1v at the Bab el Mandeb')
+
+      ENDIF
+
+   END SUBROUTINE grid_hgr__fill_curv
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill horizontal mesh (hgr structure)
+   !> for case of geographical mesh on the sphere with regular grid-spacing
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj   
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr__fill_reg(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp)   ::   zti, zui, zvi, zfi   ! local scalars
+      REAL(dp)   ::   ztj, zuj, zvj, zfj   !
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID HGR FILL : geographical mesh on the sphere with'//&
+         &  ' regular grid-spacing given by ppe1_deg and ppe2_deg')
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zti = FLOAT( ji - 1 )         ;   ztj = FLOAT( jj - 1 )
+            zui = FLOAT( ji - 1 ) + 0.5   ;   zuj = FLOAT( jj - 1 )
+            zvi = FLOAT( ji - 1 )         ;   zvj = FLOAT( jj - 1 ) + 0.5
+            zfi = FLOAT( ji - 1 ) + 0.5   ;   zfj = FLOAT( jj - 1 ) + 0.5
+      ! Longitude
+            tg_glamt%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zti
+            tg_glamu%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zui
+            tg_glamv%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zvi
+            tg_glamf%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zfi
+      ! Latitude
+            tg_gphit%d_value(ji,jj,1,1) = td_nam%d_ppgphi0 + td_nam%d_ppe2_deg * ztj
+            tg_gphiu%d_value(ji,jj,1,1) = td_nam%d_ppgphi0 + td_nam%d_ppe2_deg * zuj
+            tg_gphiv%d_value(ji,jj,1,1) = td_nam%d_ppgphi0 + td_nam%d_ppe2_deg * zvj
+            tg_gphif%d_value(ji,jj,1,1) = td_nam%d_ppgphi0 + td_nam%d_ppe2_deg * zfj
+      ! e1
+            tg_e1t%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphit%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e1u%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphiu%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e1v%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphiv%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e1f%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphif%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+      ! e2
+            tg_e2t%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * td_nam%d_ppe2_deg
+            tg_e2u%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * td_nam%d_ppe2_deg
+            tg_e2v%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * td_nam%d_ppe2_deg
+            tg_e2f%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * td_nam%d_ppe2_deg
+         END DO
+      END DO
+
+   END SUBROUTINE grid_hgr__fill_reg
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill horizontal mesh (hgr structure)
+   !> for case of f- or beta-plane with regular grid-spacing
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj   
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr__fill_plan(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp)    :: dl_glam0
+      REAL(dp)    :: dl_gphi0
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID HGR FILL : f- or beta-plane with regular'//&
+         &  ' grid-spacing given by ppe1_deg and ppe2_deg')
+!         &  ' grid-spacing given by ppe1_m and ppe2_m')
+
+      ! Position coordinates (in kilometers)
+      !                          ==========
+      dl_glam0 = 0.e0
+      dl_gphi0 = - td_nam%d_ppe2_deg * 1.e-3
+!      dl_gphi0 = - td_nam%d_ppe2_m * 1.e-3
+
+         !
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+!            tg_glamt%d_value(ji,jj,1,1) = dl_glam0 + td_nam%d_ppe1_m * 1.e-3 * ( FLOAT( ji - 1 )       )
+!            tg_glamu%d_value(ji,jj,1,1) = dl_glam0 + td_nam%d_ppe1_m * 1.e-3 * ( FLOAT( ji - 1 ) + 0.5 )
+            tg_glamt%d_value(ji,jj,1,1) = dl_glam0 + td_nam%d_ppe1_deg * 1.e-3 * ( FLOAT( ji - 1 )       )
+            tg_glamu%d_value(ji,jj,1,1) = dl_glam0 + td_nam%d_ppe1_deg * 1.e-3 * ( FLOAT( ji - 1 ) + 0.5 )
+            tg_glamv%d_value(ji,jj,1,1) = tg_glamt%d_value(ji,jj,1,1)
+            tg_glamf%d_value(ji,jj,1,1) = tg_glamu%d_value(ji,jj,1,1)
+   
+            !tg_gphit%d_value(ji,jj,1,1) = dl_gphi0 + td_nam%d_ppe2_m * 1.e-3 * ( FLOAT( jj - 1 )       )
+            tg_gphit%d_value(ji,jj,1,1) = dl_gphi0 + td_nam%d_ppe2_deg * 1.e-3 * ( FLOAT( jj - 1 )       )
+            tg_gphiu%d_value(ji,jj,1,1) = tg_gphit%d_value(ji,jj,1,1)
+            !tg_gphiv%d_value(ji,jj,1,1) = dl_gphi0 + td_nam%d_ppe2_m * 1.e-3 * ( FLOAT( jj - 1 ) + 0.5 )
+            tg_gphiv%d_value(ji,jj,1,1) = dl_gphi0 + td_nam%d_ppe2_deg * 1.e-3 * ( FLOAT( jj - 1 ) + 0.5 )
+            tg_gphif%d_value(ji,jj,1,1) = tg_gphiv%d_value(ji,jj,1,1)
+         END DO
+      END DO
+
+      ! Horizontal scale factors (in meters)
+      !                              ======
+!      tg_e1t%d_value(:,:,1,1) = td_nam%d_ppe1_m      
+!      tg_e1u%d_value(:,:,1,1) = td_nam%d_ppe1_m      
+!      tg_e1v%d_value(:,:,1,1) = td_nam%d_ppe1_m      
+!      tg_e1f%d_value(:,:,1,1) = td_nam%d_ppe1_m      
+      tg_e1t%d_value(:,:,1,1) = td_nam%d_ppe1_deg      
+      tg_e1u%d_value(:,:,1,1) = td_nam%d_ppe1_deg      
+      tg_e1v%d_value(:,:,1,1) = td_nam%d_ppe1_deg      
+      tg_e1f%d_value(:,:,1,1) = td_nam%d_ppe1_deg      
+
+!      tg_e2t%d_value(:,:,1,1) = td_nam%d_ppe2_m
+!      tg_e2u%d_value(:,:,1,1) = td_nam%d_ppe2_m
+!      tg_e2v%d_value(:,:,1,1) = td_nam%d_ppe2_m
+!      tg_e2f%d_value(:,:,1,1) = td_nam%d_ppe2_m
+      tg_e2t%d_value(:,:,1,1) = td_nam%d_ppe2_deg
+      tg_e2u%d_value(:,:,1,1) = td_nam%d_ppe2_deg
+      tg_e2v%d_value(:,:,1,1) = td_nam%d_ppe2_deg
+      tg_e2f%d_value(:,:,1,1) = td_nam%d_ppe2_deg
+
+   END SUBROUTINE grid_hgr__fill_plan
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill horizontal mesh (hgr structure)
+   !> for case of geographical mesh on the sphere, isotropic MERCATOR type
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj   
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr__fill_merc(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      INTEGER  ::   ijeq                 ! index of equator T point (used in case 4)
+
+      REAL(dp) ::   zti, zui, zvi, zfi   ! local scalars
+      REAL(dp) ::   ztj, zuj, zvj, zfj   !
+      REAL(dp) ::   zarg
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID HGR FILL : geographical mesh on the sphere, '//&
+        &  'MERCATOR type longitudinal/latitudinal spacing given by ppe1_deg')
+
+      IF( td_nam%d_ppgphi0 == -90 )THEN
+         CALL logger_fatal(' Mercator grid cannot start at south pole !!!! ' )
+      ENDIF
+
+      !  Find index corresponding to the equator, given the grid spacing e1_deg
+      !  and the (approximate) southern latitude ppgphi0.
+      !  This way we ensure that the equator is at a "T / U" point, when in the domain.
+      !  The formula should work even if the equator is outside the domain.
+      zarg = dp_pi / 4. - dp_pi / 180. * td_nam%d_ppgphi0 / 2.
+      ijeq = ABS( 180./dp_pi * LOG( COS( zarg ) / SIN( zarg ) ) / td_nam%d_ppe1_deg )
+      IF( td_nam%d_ppgphi0 > 0 )  ijeq = -ijeq
+
+      CALL logger_info('Index of the equator on the MERCATOR grid: '//TRIM(fct_str(ijeq)))
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zti = FLOAT( ji - 1 )         ;   ztj = FLOAT( jj - ijeq )
+            zui = FLOAT( ji - 1 ) + 0.5   ;   zuj = FLOAT( jj - ijeq )
+            zvi = FLOAT( ji - 1 )         ;   zvj = FLOAT( jj - ijeq ) + 0.5
+            zfi = FLOAT( ji - 1 ) + 0.5   ;   zfj = FLOAT( jj - ijeq ) + 0.5
+         ! Longitude
+            tg_glamt%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zti
+            tg_glamu%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zui
+            tg_glamv%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zvi
+            tg_glamf%d_value(ji,jj,1,1) = td_nam%d_ppglam0 + td_nam%d_ppe1_deg * zfi
+         ! Latitude
+            tg_gphit%d_value(ji,jj,1,1) = 1./dp_deg2rad * ASIN ( TANH( td_nam%d_ppe1_deg *dp_deg2rad* ztj ) )
+            tg_gphiu%d_value(ji,jj,1,1) = 1./dp_deg2rad * ASIN ( TANH( td_nam%d_ppe1_deg *dp_deg2rad* zuj ) )
+            tg_gphiv%d_value(ji,jj,1,1) = 1./dp_deg2rad * ASIN ( TANH( td_nam%d_ppe1_deg *dp_deg2rad* zvj ) )
+            tg_gphif%d_value(ji,jj,1,1) = 1./dp_deg2rad * ASIN ( TANH( td_nam%d_ppe1_deg *dp_deg2rad* zfj ) )
+         ! e1
+            tg_e1t%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphit%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e1u%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphiu%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e1v%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphiv%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e1f%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphif%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+         ! e2
+            tg_e2t%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphit%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e2u%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphiu%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e2v%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphiv%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+            tg_e2f%d_value(ji,jj,1,1) = dp_rearth * dp_deg2rad * COS( dp_deg2rad * tg_gphif%d_value(ji,jj,1,1) ) * td_nam%d_ppe1_deg
+         END DO
+      END DO
+
+   END SUBROUTINE grid_hgr__fill_merc
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill horizontal mesh (hgr structure)
+   !> for case of beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr__fill_gyre(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp) ::   zlam1, zcos_alpha, zim1 , zjm1 , ze1, ze1deg
+      REAL(dp) ::   zphi1, zsin_alpha, zim05, zjm05
+
+      REAL(dp) ::   dl_glam0
+      REAL(dp) ::   dl_gphi0
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID HGR FILL : beta-plane with regular grid-spacing '//&
+         &  'and rotated domain (GYRE configuration)')
+
+      ! Position coordinates (in kilometers)
+      !
+      ! angle 45deg and ze1=106.e+3 / jp_cfg forced -> zlam1 = -85deg, zphi1 = 29degN
+      zlam1 = -85
+      zphi1 = 29
+      ! resolution in meters
+      ze1 = 106000. / FLOAT(td_nam%i_cfg)            
+      ! benchmark: forced the resolution to be about 100 km
+      IF( td_nam%i_bench /= 0 )   ze1 = 106000.e0     
+      zsin_alpha = - SQRT( 2. ) / 2.
+      zcos_alpha =   SQRT( 2. ) / 2.
+      ze1deg = ze1 / (dp_rearth * dp_deg2rad)
+      ! benchmark: keep the lat/+lon at the right in_cfg resolution
+      IF( td_nam%i_bench /= 0 )   ze1deg = ze1deg / FLOAT(td_nam%i_cfg)
+      dl_glam0 = zlam1 + zcos_alpha * ze1deg * FLOAT( jpj-2 )
+      dl_gphi0 = zphi1 + zsin_alpha * ze1deg * FLOAT( jpj-2 )
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zim1 = FLOAT( ji - 1 )   ;   zim05 = FLOAT( ji ) - 1.5
+            zjm1 = FLOAT( jj - 1 )   ;   zjm05 = FLOAT( jj ) - 1.5
+
+            tg_glamf%d_value(ji,jj,1,1) = dl_glam0 &
+                                        &  + zim1  * ze1deg * zcos_alpha &
+                                        &  + zjm1  * ze1deg * zsin_alpha
+            tg_gphif%d_value(ji,jj,1,1) = dl_gphi0 &
+                                        & - zim1  * ze1deg * zsin_alpha &
+                                        & + zjm1  * ze1deg * zcos_alpha
+
+            tg_glamt%d_value(ji,jj,1,1) = dl_glam0 &
+                                        & + zim05 * ze1deg * zcos_alpha &
+                                        & + zjm05 * ze1deg * zsin_alpha
+            tg_gphit%d_value(ji,jj,1,1) = dl_gphi0 &
+                                        & - zim05 * ze1deg * zsin_alpha &
+                                        & + zjm05 * ze1deg * zcos_alpha
+
+            tg_glamu%d_value(ji,jj,1,1) = dl_glam0 &
+                                        & + zim1  * ze1deg * zcos_alpha &
+                                        & + zjm05 * ze1deg * zsin_alpha
+            tg_gphiu%d_value(ji,jj,1,1) = dl_gphi0 & 
+                                        & - zim1  * ze1deg * zsin_alpha &
+                                        & + zjm05 * ze1deg * zcos_alpha
+
+            tg_glamv%d_value(ji,jj,1,1) = dl_glam0 &
+                                        & + zim05 * ze1deg * zcos_alpha &
+                                        & + zjm1  * ze1deg * zsin_alpha
+            tg_gphiv%d_value(ji,jj,1,1) = dl_gphi0 &
+                                        & - zim05 * ze1deg * zsin_alpha &
+                                        & + zjm1  * ze1deg * zcos_alpha
+
+         END DO
+      END DO
+
+      ! Horizontal scale factors (in meters)
+      !                              ======
+      tg_e1t%d_value(:,:,1,1) = ze1      
+      tg_e1u%d_value(:,:,1,1) = ze1      
+      tg_e1v%d_value(:,:,1,1) = ze1      
+      tg_e1f%d_value(:,:,1,1) = ze1      
+
+      tg_e2t%d_value(:,:,1,1) = ze1
+      tg_e2u%d_value(:,:,1,1) = ze1
+      tg_e2v%d_value(:,:,1,1) = ze1
+      tg_e2f%d_value(:,:,1,1) = ze1
+
+   END SUBROUTINE grid_hgr__fill_gyre
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill coriolis factor
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_hgr__fill_coriolis(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp) :: zbeta
+      REAL(dp) :: zphi0  
+      REAL(dp) :: zf0
+
+      ! loop indices
+      !----------------------------------------------------------------
+
+      !  Coriolis factor
+      SELECT CASE( td_nam%i_mshhgr )   ! type of horizontal mesh
+
+         CASE ( 0, 1, 4 ) ! mesh on the sphere
+
+            tg_ff%d_value(:,:,1,1) = 2. * dp_omega * SIN(dp_deg2rad * tg_gphif%d_value(:,:,1,1))
+
+         CASE ( 2 )  ! f-plane at ppgphi0 
+
+            tg_ff%d_value(:,:,1,1) = 2. * dp_omega * SIN( dp_deg2rad * td_nam%d_ppgphi0 )
+            CALL logger_info('f-plane: Coriolis parameter = constant = '//&
+               &  TRIM(fct_str(tg_ff%d_value(1,1,1,1))) )
+
+         CASE ( 3 )  ! beta-plane
+
+            ! beta at latitude ppgphi0
+            zbeta = 2. * dp_omega * COS( dp_deg2rad * td_nam%d_ppgphi0 ) / dp_rearth
+            ! latitude of the first row F-points
+!            zphi0 = td_nam%d_ppgphi0 - FLOAT( jpi/2 ) * td_nam%d_ppe2_m / ( dp_rearth * dp_deg2rad )
+            zphi0 = td_nam%d_ppgphi0 - FLOAT( jpi/2 ) * td_nam%d_ppe2_deg / ( dp_rearth * dp_deg2rad )
+
+            ! compute f0 1st point south
+            zf0 = 2. * dp_omega * SIN( dp_deg2rad * zphi0 )
+            ! f = f0 +beta* y ( y=0 at south)
+            tg_ff%d_value(:,:,1,1) = zf0 + zbeta * tg_gphif%d_value(:,:,1,1) * 1.e3
+
+         CASE ( 5 )  ! beta-plane and rotated domain (gyre configuration)
+
+            ! beta at latitude ppgphi0
+            zbeta = 2. * dp_omega * COS( dp_deg2rad * td_nam%d_ppgphi0 ) / dp_rearth
+            ! latitude of the first row F-points
+            zphi0 = 15.e0
+            ! compute f0 1st point south
+            zf0   = 2. * dp_omega * SIN( dp_deg2rad * zphi0 )
+
+            ! f = f0 +beta* y ( y=0 at south)
+            tg_ff%d_value(:,:,1,1) = ( zf0 + zbeta * ABS( tg_gphif%d_value(:,:,1,1) - zphi0 ) * dp_deg2rad * dp_rearth )
+
+      END SELECT
+
+   END SUBROUTINE grid_hgr__fill_coriolis
+   !!----------------------------------------------------------------------
+   !! @brief This subroutine compute angles between model grid lines and the North direction
+   !>
+   !> @details
+   !> ** Method  :
+   !>
+   !> ** Action  :   Compute (gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf) arrays:
+   !>      sinus and cosinus of the angle between the north-south axe and the 
+   !>      j-direction at t, u, v and f-points
+   !>
+   !> History :
+   !>   7.0  !  96-07  (O. Marti )  Original code
+   !>   8.0  !  98-06  (G. Madec )
+   !>   8.5  !  98-06  (G. Madec )  Free form, F90 + opt.
+   !>   9.2  !  07-04  (S. Masson)  Add T, F points and bugfix in cos lateral boundary
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from geo2ocean
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !!----------------------------------------------------------------------
+   SUBROUTINE grid_hgr__angle(td_nam, jpi,jpj)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TNAMH), INTENT(IN) :: td_nam
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp) :: zlam, zphi          
+      REAL(dp) :: zlan, zphh          
+      REAL(dp) :: zxnpt, zynpt, znnpt ! x,y components and norm of the vector: T point to North Pole
+      REAL(dp) :: zxnpu, zynpu, znnpu ! x,y components and norm of the vector: U point to North Pole
+      REAL(dp) :: zxnpv, zynpv, znnpv ! x,y components and norm of the vector: V point to North Pole
+      REAL(dp) :: zxnpf, zynpf, znnpf ! x,y components and norm of the vector: F point to North Pole
+      REAL(dp) :: zxvvt, zyvvt, znvvt ! x,y components and norm of the vector: between V points below and above a T point
+      REAL(dp) :: zxffu, zyffu, znffu ! x,y components and norm of the vector: between F points below and above a U point
+      REAL(dp) :: zxffv, zyffv, znffv ! x,y components and norm of the vector: between F points left  and right a V point
+      REAL(dp) :: zxuuf, zyuuf, znuuf ! x,y components and norm of the vector: between U points below and above a F point
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !!----------------------------------------------------------------------
+
+      ! ============================= !
+      ! Compute the cosinus and sinus !
+      ! ============================= !
+      ! (computation done on the north stereographic polar plane)
+
+      DO jj = 2, jpj-1
+!CDIR NOVERRCHK
+         DO ji = 2, jpi   ! vector opt.
+
+            ! north pole direction & modulous (at t-point)
+            zlam = tg_glamt%d_value(ji,jj,1,1)
+            zphi = tg_gphit%d_value(ji,jj,1,1)
+            zxnpt = 0._dp - 2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            zynpt = 0._dp - 2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            znnpt = zxnpt*zxnpt + zynpt*zynpt
+
+            ! north pole direction & modulous (at u-point)
+            zlam = tg_glamu%d_value(ji,jj,1,1)
+            zphi = tg_gphiu%d_value(ji,jj,1,1)
+            zxnpu = 0._dp - 2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            zynpu = 0._dp - 2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            znnpu = zxnpu*zxnpu + zynpu*zynpu
+
+            ! north pole direction & modulous (at v-point)
+            zlam = tg_glamv%d_value(ji,jj,1,1)
+            zphi = tg_gphiv%d_value(ji,jj,1,1)
+            zxnpv = 0._dp - 2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            zynpv = 0._dp - 2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            znnpv = zxnpv*zxnpv + zynpv*zynpv
+
+            ! north pole direction & modulous (at f-point)
+            zlam = tg_glamf%d_value(ji,jj,1,1)
+            zphi = tg_gphif%d_value(ji,jj,1,1)
+            zxnpf = 0._dp - 2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            zynpf = 0._dp - 2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )
+            znnpf = zxnpf*zxnpf + zynpf*zynpf
+
+            ! j-direction: v-point segment direction (around t-point)
+            zlam = tg_glamv%d_value(ji,jj  ,1,1)
+            zphi = tg_gphiv%d_value(ji,jj  ,1,1)
+            zlan = tg_glamv%d_value(ji,jj-1,1,1)
+            zphh = tg_gphiv%d_value(ji,jj-1,1,1)
+            zxvvt =  2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * COS( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            zyvvt =  2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * SIN( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            znvvt = SQRT( znnpt * ( zxvvt*zxvvt + zyvvt*zyvvt )  )
+            znvvt = MAX( znvvt, dp_eps )
+
+            ! j-direction: f-point segment direction (around u-point)
+            zlam = tg_glamf%d_value(ji,jj  ,1,1)
+            zphi = tg_gphif%d_value(ji,jj  ,1,1)
+            zlan = tg_glamf%d_value(ji,jj-1,1,1)
+            zphh = tg_gphif%d_value(ji,jj-1,1,1)
+            zxffu =  2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * COS( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            zyffu =  2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * SIN( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            znffu = SQRT( znnpu * ( zxffu*zxffu + zyffu*zyffu )  )
+            znffu = MAX( znffu, dp_eps )
+
+            ! i-direction: f-point segment direction (around v-point)
+            zlam = tg_glamf%d_value(ji  ,jj,1,1)
+            zphi = tg_gphif%d_value(ji  ,jj,1,1)
+            zlan = tg_glamf%d_value(ji-1,jj,1,1)
+            zphh = tg_gphif%d_value(ji-1,jj,1,1)
+            zxffv =  2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * COS( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            zyffv =  2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * SIN( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            znffv = SQRT( znnpv * ( zxffv*zxffv + zyffv*zyffv )  )
+            znffv = MAX( znffv, dp_eps )
+
+            ! j-direction: u-point segment direction (around f-point)
+            zlam = tg_glamu%d_value(ji,jj+1,1,1)
+            zphi = tg_gphiu%d_value(ji,jj+1,1,1)
+            zlan = tg_glamu%d_value(ji,jj  ,1,1)
+            zphh = tg_gphiu%d_value(ji,jj  ,1,1)
+            zxuuf =  2._dp * COS( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * COS( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            zyuuf =  2._dp * SIN( dp_deg2rad*zlam ) * TAN( dp_pi/4._dp - dp_deg2rad*zphi/2._dp )   &
+               &  -  2._dp * SIN( dp_deg2rad*zlan ) * TAN( dp_pi/4._dp - dp_deg2rad*zphh/2._dp )
+            znuuf = SQRT( znnpf * ( zxuuf*zxuuf + zyuuf*zyuuf )  )
+            znuuf = MAX( znuuf, dp_eps )
+
+            ! cosinus and sinus using scalar and vectorial products
+            tg_gsint%d_value(ji,jj,1,1) = ( zxnpt*zyvvt - zynpt*zxvvt ) / znvvt
+            tg_gcost%d_value(ji,jj,1,1) = ( zxnpt*zxvvt + zynpt*zyvvt ) / znvvt
+
+            tg_gsinu%d_value(ji,jj,1,1) = ( zxnpu*zyffu - zynpu*zxffu ) / znffu
+            tg_gcosu%d_value(ji,jj,1,1) = ( zxnpu*zxffu + zynpu*zyffu ) / znffu
+
+            tg_gsinf%d_value(ji,jj,1,1) = ( zxnpf*zyuuf - zynpf*zxuuf ) / znuuf
+            tg_gcosf%d_value(ji,jj,1,1) = ( zxnpf*zxuuf + zynpf*zyuuf ) / znuuf
+
+            ! (caution, rotation of 90 degres)
+            tg_gsinv%d_value(ji,jj,1,1) = ( zxnpv*zxffv + zynpv*zyffv ) / znffv
+            tg_gcosv%d_value(ji,jj,1,1) =-( zxnpv*zyffv - zynpv*zxffv ) / znffv
+
+         END DO
+      END DO
+
+      ! =============== !
+      ! Geographic mesh !
+      ! =============== !
+
+      DO jj = 2, jpj-1
+         DO ji = 2, jpi   ! vector opt.
+            IF( MOD( ABS( tg_glamv%d_value(ji,jj,1,1) - tg_glamv%d_value(ji,jj-1,1,1) ), 360._dp ) < 1.e-8 ) THEN
+               tg_gsint%d_value(ji,jj,1,1) = 0._dp
+               tg_gcost%d_value(ji,jj,1,1) = 1._dp
+            ENDIF
+            IF( MOD( ABS( tg_glamf%d_value(ji,jj,1,1) - tg_glamf%d_value(ji,jj-1,1,1) ), 360._dp ) < 1.e-8 ) THEN
+               tg_gsinu%d_value(ji,jj,1,1) = 0._dp
+               tg_gcosu%d_value(ji,jj,1,1) = 1._dp
+            ENDIF
+            IF(      ABS( tg_gphif%d_value(ji,jj,1,1) - tg_gphif%d_value(ji-1,jj,1,1) )            < 1.e-8 ) THEN
+               tg_gsinv%d_value(ji,jj,1,1) = 0._dp
+               tg_gcosv%d_value(ji,jj,1,1) = 1._dp
+            ENDIF
+            IF( MOD( ABS( tg_glamu%d_value(ji,jj,1,1) - tg_glamu%d_value(ji,jj+1,1,1) ), 360._dp ) < 1.e-8 ) THEN
+               tg_gsinf%d_value(ji,jj,1,1) = 0._dp
+               tg_gcosf%d_value(ji,jj,1,1) = 1._dp
+            ENDIF
+         END DO
+      END DO
+
+      ! =========================== !
+      ! Lateral boundary conditions !
+      ! =========================== !
+
+      ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
+      CALL lbc_lnk( tg_gcost%d_value(:,:,1,1), 'T', td_nam%i_perio, -1._dp )   
+      CALL lbc_lnk( tg_gcosu%d_value(:,:,1,1), 'U', td_nam%i_perio, -1._dp )   
+      CALL lbc_lnk( tg_gcosv%d_value(:,:,1,1), 'V', td_nam%i_perio, -1._dp )   
+      CALL lbc_lnk( tg_gcosf%d_value(:,:,1,1), 'F', td_nam%i_perio, -1._dp )   
+
+      CALL lbc_lnk( tg_gsint%d_value(:,:,1,1), 'T', td_nam%i_perio, -1._dp )
+      CALL lbc_lnk( tg_gsinu%d_value(:,:,1,1), 'U', td_nam%i_perio, -1._dp )
+      CALL lbc_lnk( tg_gsinv%d_value(:,:,1,1), 'V', td_nam%i_perio, -1._dp )
+      CALL lbc_lnk( tg_gsinf%d_value(:,:,1,1), 'F', td_nam%i_perio, -1._dp )
+
+   END SUBROUTINE grid_hgr__angle
+END MODULE grid_hgr
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid_zgr.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid_zgr.f90	(revision 7025)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid_zgr.f90	(revision 7025)
@@ -0,0 +1,4362 @@
+!----------------------------------------------------------------------
+! NEMO system team, System and Interface for oceanic RElocable Nesting
+!----------------------------------------------------------------------
+!
+! MODULE: grid_zgr
+!
+! DESCRIPTION:
+!> @brief This module manage Vertical grid.
+!>
+!> @details
+!> ** Purpose :   set the depth of model levels and the resulting 
+!>              vertical scale factors.
+!>
+!> ** Method  : - reference 1D vertical coordinate (gdep._1d, e3._1d)
+!>              - read/set ocean depth and ocean levels (bathy, mbathy)
+!>              - vertical coordinate (gdep., e3.) depending on the 
+!>                coordinate chosen :
+!>                   ln_zco=T   z-coordinate   
+!>                   ln_zps=T   z-coordinate with partial steps
+!>                   ln_zco=T   s-coordinate 
+!>
+!> ** Action  :   define gdep., e3., mbathy and bathy
+!>
+!> @author
+!> G, Madec
+! REVISION HISTORY:
+!> @date December, 1995 - Original code : s vertical coordinate
+!> @date July, 1997
+!> - lbc_lnk call
+!> @date September, 2002
+!> - A. Bozec, G. Madec : F90: Free form and module
+!> @date September, 2002
+!> - A. de Miranda : rigid-lid + islands
+!> @date August, 2003
+!> - G. Madec : Free form and module
+!> @date October, 2005
+!> - A. Beckmann : modifications for hybrid s-ccordinates & new stretching function
+!> @date April, 2006
+!> - R. Benshila, G. Madec : add zgr_zco
+!> @date June, 2008
+!> - G. Madec : insertion of domzgr_zps.h90 & conding style
+!> @date July, 2009
+!> - R. Benshila : Suppression of rigid-lid option
+!> @date November, 2011
+!> - G. Madec : add mbk. arrays associated to the deepest ocean level
+!> @date August, 2012
+!> - J. Siddorn : added Siddorn and Furner stretching function
+!> @date December, 2012
+!> - R. Bourdalle-Badie and G. Reffray : modify C1D case
+!> @date November, 2014
+!> - P. Mathiot and C. Harris : add ice shelf capabilitye
+!> @date November, 2015
+!> - H. Liu : Modifications for Wetting/Drying
+!> @date October, 2016
+!> - update from trunk (revision 6961): add wetting and drying, ice sheet coupling..
+!>
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!----------------------------------------------------------------------
+MODULE grid_zgr
+   USE netcdf                          ! nf90 library
+   USE kind                            ! F90 kind parameter
+   USE fct                             ! basic usefull function
+   USE global                          ! global parameter
+   USE phycst                          ! physical constant
+   USE logger                          ! log file manager
+   USE file                            ! file manager
+   USE var                             ! variable manager
+   USE dim                             ! dimension manager
+   USE dom                             ! domain manager
+   USE grid                            ! grid manager
+   USE iom                             ! I/O manager
+   USE mpp                             ! MPP manager
+   USE iom_mpp                         ! I/O MPP manager
+   USE lbc                             ! lateral boundary conditions
+   USE grid_hgr                        ! Horizontal mesh
+   IMPLICIT NONE
+   ! NOTE_avoid_public_variables_if_possible
+   ! type and variable
+   PUBLIC :: TNAMZ
+
+   PUBLIC :: tg_gdepw_1d
+   PUBLIC :: tg_gdept_1d
+   PUBLIC :: tg_e3w_1d
+   PUBLIC :: tg_e3t_1d
+   PUBLIC :: tg_e3tp 
+   PUBLIC :: tg_e3wp 
+
+   PUBLIC :: tg_rx1 
+   
+   PUBLIC :: tg_mbathy
+   PUBLIC :: tg_misfdep
+
+   PUBLIC :: tg_gdept_0 
+   PUBLIC :: tg_gdepw_0
+!   PUBLIC :: tg_gdep3w_0  !useless to create meshmask
+   PUBLIC :: tg_e3t_0
+   PUBLIC :: tg_e3u_0
+   PUBLIC :: tg_e3v_0
+   PUBLIC :: tg_e3w_0
+!   PUBLIC :: tg_e3f_0     !useless to create meshmask
+!   PUBLIC :: tg_e3uw_0    !useless to create meshmask
+!   PUBLIC :: tg_e3vw_0    !useless to create meshmask
+   
+   PUBLIC :: tg_mbkt
+!   PUBLIC :: tg_mbku      !useless to create meshmask
+!   PUBLIC :: tg_mbkv      !useless to create meshmask
+   PUBLIC :: tg_mikt
+!   PUBLIC :: tg_miku      !useless to create meshmask
+!   PUBLIC :: tg_mikv      !useless to create meshmask
+!   PUBLIC :: tg_mikf      !useless to create meshmask
+
+   PUBLIC :: tg_hbatt     !            sco
+   PUBLIC :: tg_hbatu     !            sco
+   PUBLIC :: tg_hbatv     !            sco
+   PUBLIC :: tg_hbatf     !            sco
+
+   PUBLIC :: tg_gsigt     !            sco(tanh)
+   PUBLIC :: tg_gsigw     !            sco(tanh)
+   PUBLIC :: tg_gsi3w     !            sco(tanh)
+   PUBLIC :: tg_esigt     !            sco(tanh)
+   PUBLIC :: tg_esigw     !            sco(tanh)
+
+   ! function and subroutine
+   PUBLIC :: grid_zgr_init 
+   PUBLIC :: grid_zgr_nam
+   PUBLIC :: grid_zgr_fill
+   PUBLIC :: grid_zgr_clean
+
+   PUBLIC :: grid_zgr_zps_init 
+   PUBLIC :: grid_zgr_zps_clean
+   PUBLIC :: grid_zgr_sco_init
+   PUBLIC :: grid_zgr_sco_clean
+   PUBLIC :: grid_zgr_sco_stiff 
+
+   PRIVATE :: grid_zgr__z
+   PRIVATE :: grid_zgr__bat 
+   PRIVATE :: grid_zgr__zco 
+   PRIVATE :: grid_zgr__bat_zoom
+   PRIVATE :: grid_zgr__bat_ctl
+   PRIVATE :: grid_zgr__bot_level
+   PRIVATE :: grid_zgr__top_level
+   PRIVATE :: grid_zgr__zps_fill
+   PRIVATE :: grid_zgr__isf_fill
+!   PRIVATE :: grid_zgr__isf_fill_e3x
+!   PRIVATE :: grid_zgr__isf_fill_e3uw
+!   PRIVATE :: grid_zgr__isf_fill_gdep3w_0
+   PRIVATE :: grid_zgr__sco_fill
+   PRIVATE :: grid_zgr__sco_s_sh94 
+   PRIVATE :: grid_zgr__sco_s_sf12
+   PRIVATE :: grid_zgr__sco_s_tanh
+   PRIVATE :: grid_zgr__sco_fssig      !: tanh stretch function
+   PRIVATE :: grid_zgr__sco_fssig1     !: Song and Haidvogel 1994 stretch function
+   PRIVATE :: grid_zgr__sco_fgamma     !: Siddorn and Furner 2012 stretching function 
+
+   TYPE TNAMZ
+      CHARACTER(LEN=lc) :: c_coord   
+      INTEGER(i4)       :: i_perio   
+                
+      LOGICAL           :: l_zco               
+      LOGICAL           :: l_zps      
+      LOGICAL           :: l_sco      
+      LOGICAL           :: l_isfcav   
+      LOGICAL           :: l_iscpl   
+      LOGICAL           :: l_wd   
+      INTEGER(i4)       :: i_nlevel   
+                  
+      REAL(dp)          :: d_ppsur    
+      REAL(dp)          :: d_ppa0     
+      REAL(dp)          :: d_ppa1     
+      REAL(dp)          :: d_ppkth    
+      REAL(dp)          :: d_ppacr    
+      REAL(dp)          :: d_ppdzmin  
+      REAL(dp)          :: d_pphmax   
+      LOGICAL           :: l_dbletanh 
+      REAL(dp)          :: d_ppa2     
+      REAL(dp)          :: d_ppkth2   
+      REAL(dp)          :: d_ppacr2   
+                  
+      REAL(dp)          :: d_hmin     
+      REAL(dp)          :: d_isfhmin
+
+      REAL(dp)          :: d_e3zps_min
+      REAL(dp)          :: d_e3zps_rat
+!      INTEGER(i4)       :: i_msh      
+                  
+      LOGICAL           :: l_s_sh94   
+      LOGICAL           :: l_s_sf12   
+      REAL(dp)          :: d_sbot_min 
+      REAL(dp)          :: d_sbot_max 
+      ! Song and Haidvogel 1994 stretching additional parameters
+      REAL(dp)          :: d_rmax     
+      REAL(dp)          :: d_hc       
+      REAL(dp)          :: d_theta    
+      REAL(dp)          :: d_thetb    
+      REAL(dp)          :: d_bb       
+      ! Siddorn and Furner stretching additional parameters 
+      LOGICAL           :: l_sigcrit  
+      REAL(dp)          :: d_alpha    
+      REAL(dp)          :: d_efold    
+      REAL(dp)          :: d_zs       
+      REAL(dp)          :: d_zb_a     
+      REAL(dp)          :: d_zb_b     
+                  
+      INTEGER(i4)       :: i_cla     
+
+      REAL(dp)          :: d_wdmin1 
+      REAL(dp)          :: d_wdmin2 
+      REAL(dp)          :: d_wdld 
+
+      CHARACTER(LEN=lc) :: c_cfg     
+      INTEGER(i4)       :: i_cfg     
+      INTEGER(i4)       :: i_bench   
+      LOGICAL           :: l_zoom
+      LOGICAL           :: l_c1d
+                
+      CHARACTER(LEN=lc) :: c_cfz      
+      INTEGER(i4)       :: i_izoom    
+      INTEGER(i4)       :: i_jzoom    
+      LOGICAL           :: l_zoom_s   
+      LOGICAL           :: l_zoom_e   
+      LOGICAL           :: l_zoom_w   
+      LOGICAL           :: l_zoom_n
+
+   END TYPE
+
+   TYPE(TVAR), SAVE :: tg_gdepw_1d  !zco & zps & sco
+   TYPE(TVAR), SAVE :: tg_gdept_1d  !zco & zps & sco
+   TYPE(TVAR), SAVE :: tg_e3w_1d    !zco & zps
+   TYPE(TVAR), SAVE :: tg_e3t_1d    !zco & zps
+   TYPE(TVAR), SAVE :: tg_e3tp      !      zps
+   TYPE(TVAR), SAVE :: tg_e3wp      !      zps
+   
+   TYPE(TVAR), SAVE :: tg_rx1       !            sco
+   
+   TYPE(TVAR), SAVE :: tg_mbathy    !zco & zps & sco
+   TYPE(TVAR), SAVE :: tg_misfdep
+
+   TYPE(TVAR), SAVE :: tg_gdept_0   !      zps & sco
+   TYPE(TVAR), SAVE :: tg_gdepw_0   !      zps & sco
+   !TYPE(TVAR), SAVE :: tg_gdep3w_0
+   TYPE(TVAR), SAVE :: tg_e3t_0     !      zps & sco
+   TYPE(TVAR), SAVE :: tg_e3u_0     !      zps & sco
+   TYPE(TVAR), SAVE :: tg_e3v_0     !      zps & sco
+   TYPE(TVAR), SAVE :: tg_e3w_0     !      zps & sco
+   !TYPE(TVAR), SAVE :: tg_e3f_0
+   !TYPE(TVAR), SAVE :: tg_e3uw_0
+   !TYPE(TVAR), SAVE :: tg_e3vw_0
+   
+   TYPE(TVAR), SAVE :: tg_mbkt      !zco & zps & sco
+   !TYPE(TVAR), SAVE :: tg_mbku
+   !TYPE(TVAR), SAVE :: tg_mbkv
+   TYPE(TVAR), SAVE :: tg_mikt      !zco & zps & sco
+   !TYPE(TVAR), SAVE :: tg_miku
+   !TYPE(TVAR), SAVE :: tg_mikv
+   !TYPE(TVAR), SAVE :: tg_mikf
+
+   TYPE(TVAR), SAVE :: tg_hbatt     !            sco
+   TYPE(TVAR), SAVE :: tg_hbatu     !            sco
+   TYPE(TVAR), SAVE :: tg_hbatv     !            sco
+   TYPE(TVAR), SAVE :: tg_hbatf     !            sco
+
+   TYPE(TVAR), SAVE :: tg_gsigt     !            sco(tanh)
+   TYPE(TVAR), SAVE :: tg_gsigw     !            sco(tanh)
+   TYPE(TVAR), SAVE :: tg_gsi3w     !            sco(tanh)
+   TYPE(TVAR), SAVE :: tg_esigt     !            sco(tanh)
+   TYPE(TVAR), SAVE :: tg_esigw     !            sco(tanh)
+
+CONTAINS
+   !-------------------------------------------------------------------
+   !> @brief This function initialise global variable needed to compute vertical
+   !>        mesh
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_init( jpi,jpj,jpk ) 
+      IMPLICIT NONE
+      ! Argument      
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+      INTEGER(i4), INTENT(IN) :: jpk
+
+      ! local variable
+      REAL(dp), DIMENSION(jpk)         :: dl_tmp1D
+      REAL(dp), DIMENSION(jpi,jpj)     :: dl_tmp2D
+      REAL(dp), DIMENSION(jpi,jpj,jpk) :: dl_tmp3D
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! variable 1D
+      dl_tmp1D(:)    =dp_fill
+
+      tg_gdepw_1d=var_init('gdepw_1d',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gdept_1d=var_init('gdept_1d',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e3w_1d  =var_init('e3w_1d  ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e3t_1d  =var_init('e3t_1d  ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      tg_gsigt   =var_init('gsigt   ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gsigw   =var_init('gsigw   ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_gsi3w   =var_init('gsi3w   ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_esigt   =var_init('esigt   ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_esigw   =var_init('esigw   ',dl_tmp1D(:)    , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      ! variable 2D
+      dl_tmp2D(:,:)  =dp_fill_i2
+
+      tg_mbathy  =var_init('mbathy  ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      tg_misfdep =var_init('misfdep ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+
+      tg_mbkt    =var_init('mbkt    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      !tg_mbku    =var_init('mbku    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      !tg_mbkv    =var_init('mbkv    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      tg_mikt    =var_init('mikt    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      !tg_miku    =var_init('miku    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      !tg_mikv    =var_init('mikv    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+      !tg_mikf    =var_init('mikf    ',dl_tmp2D(:,:)  , dd_fill=dp_fill_i2, id_type=NF90_SHORT)
+
+      dl_tmp2D(:,:)  =dp_fill
+
+      tg_hbatt   =var_init('hbatt   ',dl_tmp2D(:,:)  , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_hbatu   =var_init('hbatu   ',dl_tmp2D(:,:)  , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_hbatv   =var_init('hbatv   ',dl_tmp2D(:,:)  , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_hbatf   =var_init('hbatf   ',dl_tmp2D(:,:)  , dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+      ! variable 3D
+      dl_tmp3D(:,:,:)=dp_fill_sp
+
+      tg_gdept_0 =var_init('gdept_0 ',dl_tmp3D(:,:,:), dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      tg_gdepw_0 =var_init('gdepw_0 ',dl_tmp3D(:,:,:), dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+      !tg_gdep3w_0=var_init('gdep3w_0',dl_tmp3D(:,:,:), dd_fill=dp_fill_sp, id_type=NF90_FLOAT)
+
+      dl_tmp3D(:,:,:)=dp_fill
+      
+      tg_e3t_0   =var_init('e3t_0   ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e3u_0   =var_init('e3u_0   ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e3v_0   =var_init('e3v_0   ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e3w_0   =var_init('e3w_0   ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      !tg_e3f_0   =var_init('e3f_0   ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      !tg_e3uw_0  =var_init('e3uw_0  ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      !tg_e3vw_0  =var_init('e3vw_0  ',dl_tmp3D(:,:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+   END SUBROUTINE grid_zgr_init
+   !-------------------------------------------------------------------
+   !> @brief This function clean hgr structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_clean() 
+      IMPLICIT NONE
+      ! Argument      
+
+      ! local variable
+      ! loop indices
+      !----------------------------------------------------------------
+
+      CALL var_clean(tg_gdepw_1d)
+      CALL var_clean(tg_gdept_1d)
+      CALL var_clean(tg_e3w_1d  )
+      CALL var_clean(tg_e3t_1d  )
+
+      CALL var_clean(tg_gsigt   )
+      CALL var_clean(tg_gsigw   )
+      CALL var_clean(tg_gsi3w   )
+      CALL var_clean(tg_esigt   )
+      CALL var_clean(tg_esigw   )
+      
+      CALL var_clean(tg_mbathy  )
+      CALL var_clean(tg_misfdep )
+
+      CALL var_clean(tg_mbkt    )
+      !CALL var_clean(tg_mbku    )
+      !CALL var_clean(tg_mbkv    )
+      CALL var_clean(tg_mikt    )
+      !CALL var_clean(tg_miku    )
+      !CALL var_clean(tg_mikv    )
+      !CALL var_clean(tg_mikf    )
+
+      CALL var_clean(tg_hbatt   )
+      CALL var_clean(tg_hbatu   )
+      CALL var_clean(tg_hbatv   )
+      CALL var_clean(tg_hbatf   )
+
+      CALL var_clean(tg_gdept_0 )
+      CALL var_clean(tg_gdepw_0 )
+      !CALL var_clean(tg_gdep3w_0)
+
+      CALL var_clean(tg_e3t_0   )
+      CALL var_clean(tg_e3u_0   )
+      CALL var_clean(tg_e3v_0   )
+      !CALL var_clean(tg_e3f_0   )
+      !CALL var_clean(tg_e3uw_0  )
+      !CALL var_clean(tg_e3vw_0  )
+      
+   END SUBROUTINE grid_zgr_clean
+   !-------------------------------------------------------------------
+   !> @brief This function initialise zgr namelist structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] cd_coord   
+   !> @param[in] id_perio  
+   !> @param[in] cd_namelist
+   !> @return hgr namelist structure
+   !-------------------------------------------------------------------
+   FUNCTION grid_zgr_nam( cd_coord,id_perio,cd_namelist )
+      IMPLICIT NONE
+      ! Argument      
+      CHARACTER(LEN=*), INTENT(IN) :: cd_coord
+      INTEGER(i4)     , INTENT(IN) :: id_perio   
+
+      CHARACTER(LEN=*), INTENT(IN) :: cd_namelist
+      
+      ! function
+      TYPE(TNAMZ) :: grid_zgr_nam
+
+      ! local variable
+      INTEGER(i4)        :: il_status
+      INTEGER(i4)        :: il_fileid
+
+      LOGICAL            :: ll_exist
+
+      ! namelist
+      ! namzgr
+      LOGICAL           :: ln_zco      = .FALSE.
+      LOGICAL           :: ln_zps      = .FALSE.
+      LOGICAL           :: ln_sco      = .FALSE.
+      LOGICAL           :: ln_isfcav   = .FALSE.
+      LOGICAL           :: ln_iscpl    = .FALSE.
+      LOGICAL           :: ln_wd       = .FALSE.
+      INTEGER(i4)       :: in_nlevel   = 75
+
+      ! namdmin
+      REAL(dp)          :: dn_hmin     = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_isfhmin  = NF90_FILL_DOUBLE
+
+      ! namzco
+      REAL(dp)          :: dn_ppsur    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppa0     = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppa1     = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppkth    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppacr    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppdzmin  = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_pphmax   = NF90_FILL_DOUBLE
+      LOGICAL           :: ln_dbletanh = .FALSE.
+      REAL(dp)          :: dn_ppa2     = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppkth2   = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_ppacr2   = NF90_FILL_DOUBLE
+
+      ! namzps
+      REAL(dp)          :: dn_e3zps_min= NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_e3zps_rat= NF90_FILL_DOUBLE
+!      INTEGER(i4)       :: in_msh      = NF90_FILL_INT
+
+      ! namsco
+      LOGICAL           :: ln_s_sh94   = .FALSE.
+      LOGICAL           :: ln_s_sf12   = .FALSE.
+      REAL(dp)          :: dn_sbot_min = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_sbot_max = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_rmax     = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_hc       = NF90_FILL_DOUBLE
+      !
+      REAL(dp)          :: dn_theta    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_thetb    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_bb       = NF90_FILL_DOUBLE
+      !                               
+      LOGICAL           :: ln_sigcrit  = .FALSE.
+      REAL(dp)          :: dn_alpha    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_efold    = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_zs       = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_zb_a     = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_zb_b     = NF90_FILL_DOUBLE
+
+      ! namcla
+      INTEGER(i4)       :: in_cla      = 0
+
+      ! namwd
+      REAL(dp)          :: dn_wdmin1   = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_wdmin2   = NF90_FILL_DOUBLE
+      REAL(dp)          :: dn_wdld     = NF90_FILL_DOUBLE
+
+      ! namgrd
+      CHARACTER(LEN=lc) :: cn_cfg      = ''
+      INTEGER(i4)       :: in_cfg      = 0
+      INTEGER(i4)       :: in_bench    = 0
+      LOGICAL           :: ln_zoom     = .FALSE.
+      LOGICAL           :: ln_c1d      = .FALSE.
+
+      ! namzoom
+      CHARACTER(LEN=lc) :: cn_cfz      =''
+      INTEGER(i4)       :: in_izoom    = NF90_FILL_INT
+      INTEGER(i4)       :: in_jzoom    = NF90_FILL_INT
+      LOGICAL           :: ln_zoom_s   = .FALSE.
+      LOGICAL           :: ln_zoom_e   = .FALSE.
+      LOGICAL           :: ln_zoom_w   = .FALSE.
+      LOGICAL           :: ln_zoom_n   = .FALSE.
+      !----------------------------------------------------------------
+      NAMELIST /namzgr/ &
+      &  ln_zco,        &  !< z-coordinate
+      &  ln_zps,        &  !< z-coordinate with partial steps
+      &  ln_sco,        &  !< s-coordinate
+      &  ln_isfcav,     &  !< presence of ISF 
+      &  ln_iscpl,      &  !< coupling with ice sheet
+      &  ln_wd,         &  !< Wetting/drying activation      
+      &  in_nlevel         !< number of vertical level
+
+      NAMELIST /namdmin/ &
+      &  dn_hmin,       &  !< minimum ocean depth (>0) or minimum number of ocean levels (<0)
+      &  dn_isfhmin        !< threshold to discriminate grounded ice to floating ice
+
+      NAMELIST /namzco/ &
+      &  dn_ppsur,      &
+      &  dn_ppa0,       &
+      &  dn_ppa1,       &
+      &  dn_ppkth,      &
+      &  dn_ppacr,      &
+      &  dn_ppdzmin,    &
+      &  dn_pphmax,     &
+      &  ln_dbletanh,   &
+      &  dn_ppa2,       &
+      &  dn_ppkth2,     &
+      &  dn_ppacr2
+
+      NAMELIST /namzps/ &
+      &  dn_e3zps_min,  &
+      &  dn_e3zps_rat!,  &
+!      &  in_msh          
+
+      NAMELIST /namsco/ &
+      &   ln_s_sh94,    & !< use hybrid s-sig Song and Haidvogel 1994 stretching function fssig1
+      &   ln_s_sf12,    & !< use hybrid s-z-sig Siddorn and Furner 2012 stretching function fgamma
+      &   dn_sbot_min,  & !< minimum depth of s-bottom surface (>0) (m)
+      &   dn_sbot_max,  & !< maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+      &   dn_hc,        & !< Critical depth for transition from sigma to stretched coordinates
+      ! Song and Haidvogel 1994 stretching parameters
+      &   dn_rmax,      & !< maximum cut-off r-value allowed (0<dn_rmax<1)
+      &   dn_theta,     & !< surface control parameter (0<=dn_theta<=20)
+      &   dn_thetb,     & !< bottom control parameter  (0<=dn_thetb<= 1)
+      &   dn_bb,        & !< stretching parameter ( dn_bb=0; top only, dn_bb =1; top and bottom)
+      ! Siddorn and Furner stretching parameters
+      &   ln_sigcrit,   & !< use sigma coordinates below critical depth (T) or Z coordinates (F) for Siddorn & Furner stretch
+      &   dn_alpha,     & !< control parameter ( > 1 stretch towards surface, < 1 towards seabed)
+      &   dn_efold,     & !<  efold length scale for transition to stretched coord
+      &   dn_zs,        & !<  depth of surface grid box
+                          !<  bottom cell depth (Zb) is a linear function of water depth Zb = H*rn_zb_a + rn_zb_b'
+      &   dn_zb_a,      & !<  bathymetry scaling factor for calculating Zb
+      &   dn_zb_b         !<  offset for calculating Zb
+
+      NAMELIST /namcla/ &
+      &  in_cla            !< =1 cross land advection for exchanges through some straits (ORCA2)
+
+      NAMELIST /namwd/ &  !< wetting and drying
+      &  dn_wdmin1, &     !< minimum water depth on dried cells
+      &  dn_wdmin2, &     !< tolerrance of minimum water depth on dried cells
+      &  dn_wdld          !< land elevation below which wetting/drying
+
+      NAMELIST/namgrd/  &  !< orca grid namelist
+      &  cn_cfg,        &  !< name of the configuration (orca)
+      &  in_cfg,        &  !< resolution of the configuration (2,1,025..)
+      &  in_bench,      &  !< benchmark parameter (in_mshhgr = 5 )
+      &  ln_zoom,       &  !< use zoom
+      &  ln_c1d            !< use configuration 1D
+
+      NAMELIST /namzoom/&
+      &  cn_cfz,        &  !< name of the zoom of configuration
+      &  in_izoom,      &  !< left bottom i-indices of the zoom in data domain indices
+      &  in_jzoom,      &  !< left bottom j-indices of the zoom in data domain indices
+      &  ln_zoom_s,     &  !< South zoom type flag
+      &  ln_zoom_e,     &  !< East  zoom type flag
+      &  ln_zoom_w,     &  !< West  zoom type flag
+      &  ln_zoom_n         !< North zoom type flag
+      !----------------------------------------------------------------
+   !1-2 read namelist
+   INQUIRE(FILE=TRIM(cd_namelist), EXIST=ll_exist)
+   IF( ll_exist )THEN
+      
+      il_fileid=fct_getunit()
+
+      OPEN( il_fileid, FILE=TRIM(cd_namelist), &
+      &                FORM='FORMATTED',       &
+      &                ACCESS='SEQUENTIAL',    &
+      &                STATUS='OLD',           &
+      &                ACTION='READ',          &
+      &                IOSTAT=il_status)
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         CALL logger_fatal("GRID ZGR NAM: error opening "//&
+            &  TRIM(cd_namelist))
+      ENDIF
+
+      READ( il_fileid, NML = namzgr  )
+      READ( il_fileid, NML = namdmin )
+      READ( il_fileid, NML = namzco  )
+
+      IF( ln_zps    ) READ( il_fileid, NML = namzps  )
+      IF( ln_sco    ) READ( il_fileid, NML = namsco  )
+      READ( il_fileid, NML = namcla  )
+      READ( il_fileid, NML = namwd   )
+      READ( il_fileid, NML = namgrd  )
+      IF( ln_zoom   ) READ( il_fileid, NML = namzoom )
+
+      CLOSE( il_fileid, IOSTAT=il_status )
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         CALL logger_error("GRID ZGR NAM: closing "//TRIM(cd_namelist))
+      ENDIF
+     
+      grid_zgr_nam%c_coord    = TRIM(cd_coord)
+      grid_zgr_nam%i_perio    = id_perio
+
+      grid_zgr_nam%l_zco      = ln_zco    
+      grid_zgr_nam%l_zps      = ln_zps    
+      grid_zgr_nam%l_sco      = ln_sco    
+      grid_zgr_nam%l_isfcav   = ln_isfcav 
+      grid_zgr_nam%l_iscpl    = ln_iscpl 
+      grid_zgr_nam%l_wd       = ln_wd 
+      grid_zgr_nam%i_nlevel   = in_nlevel
+
+      grid_zgr_nam%d_hmin     = dn_hmin  
+      grid_zgr_nam%d_isfhmin  = dn_isfhmin  
+
+      grid_zgr_nam%d_ppsur    = dn_ppsur  
+      grid_zgr_nam%d_ppa0     = dn_ppa0   
+      grid_zgr_nam%d_ppa1     = dn_ppa1   
+      grid_zgr_nam%d_ppkth    = dn_ppkth  
+      grid_zgr_nam%d_ppacr    = dn_ppacr  
+      grid_zgr_nam%d_ppdzmin  = dn_ppdzmin
+      grid_zgr_nam%d_pphmax   = dn_pphmax 
+                             
+      grid_zgr_nam%l_dbletanh = ln_dbletanh
+      grid_zgr_nam%d_ppa2     = dn_ppa2    
+      grid_zgr_nam%d_ppkth2   = dn_ppkth2  
+      grid_zgr_nam%d_ppacr2   = dn_ppacr2  
+
+      grid_zgr_nam%d_e3zps_min= dn_e3zps_min
+      grid_zgr_nam%d_e3zps_rat= dn_e3zps_rat
+!      grid_zgr_nam%i_msh      = in_msh      
+
+      grid_zgr_nam%l_s_sh94   = ln_s_sh94  
+      grid_zgr_nam%l_s_sf12   = ln_s_sf12  
+      grid_zgr_nam%d_sbot_min = dn_sbot_min
+      grid_zgr_nam%d_sbot_max = dn_sbot_max
+      grid_zgr_nam%d_rmax     = dn_rmax    
+      grid_zgr_nam%d_hc       = dn_hc      
+      !
+      grid_zgr_nam%d_theta    = dn_theta   
+      grid_zgr_nam%d_thetb    = dn_thetb   
+      grid_zgr_nam%d_bb       = dn_bb      
+      !
+      grid_zgr_nam%l_sigcrit  = ln_sigcrit
+      grid_zgr_nam%d_alpha    = dn_alpha  
+      grid_zgr_nam%d_efold    = dn_efold  
+      grid_zgr_nam%d_zs       = dn_zs     
+      grid_zgr_nam%d_zb_a     = dn_zb_a
+      grid_zgr_nam%d_zb_b     = dn_zb_b
+
+      grid_zgr_nam%i_cla      = in_cla
+
+      grid_zgr_nam%d_wdmin1   = dn_wdmin1  
+      grid_zgr_nam%d_wdmin2   = dn_wdmin2  
+      grid_zgr_nam%d_wdld     = dn_wdld  
+
+      grid_zgr_nam%c_cfg      = TRIM(cn_cfg)
+      grid_zgr_nam%i_cfg      = in_cfg
+      grid_zgr_nam%i_bench    = in_bench
+      grid_zgr_nam%l_zoom     = ln_zoom
+      grid_zgr_nam%l_c1d      = ln_c1d
+
+      grid_zgr_nam%c_cfz      = cn_cfz   
+      grid_zgr_nam%i_izoom    = in_izoom 
+      grid_zgr_nam%i_jzoom    = in_jzoom 
+      grid_zgr_nam%l_zoom_s   = ln_zoom_s
+      grid_zgr_nam%l_zoom_e   = ln_zoom_e
+      grid_zgr_nam%l_zoom_w   = ln_zoom_w
+      grid_zgr_nam%l_zoom_n   = ln_zoom_n
+
+   ELSE
+
+      CALL logger_fatal(" GRID ZGR NAM: can't find "//TRIM(cd_namelist))
+
+   ENDIF
+
+   END FUNCTION grid_zgr_nam
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill vertical mesh
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !> @date October, 2016
+   !> - ice shelf cavity
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !> @param[in] td_bathy
+   !> @param[in] td_risfdep
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_fill( td_nam,jpi,jpj,jpk,td_bathy,td_risfdep ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      TYPE(TVAR) , INTENT(INOUT) :: td_bathy
+      TYPE(TVAR) , INTENT(INOUT) :: td_risfdep
+
+      ! local variable
+      INTEGER(i4) :: il_count
+
+      REAL(dp)    :: dl_bat
+
+      ! loop indices
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID ZGR : vertical coordinate')
+      CALL logger_info('~~~~~~~')
+      CALL logger_info(' Namelist namzgr : set vertical coordinate')
+      CALL logger_info(' z-coordinate - full steps      ln_zco    = '//TRIM(fct_str(td_nam%l_zco)))
+      CALL logger_info(' z-coordinate - partial steps   ln_zps    = '//TRIM(fct_str(td_nam%l_zps)))
+      CALL logger_info(' s- or hybrid z-s-coordinate    ln_sco    = '//TRIM(fct_str(td_nam%l_sco)))
+      CALL logger_info(' ice shelf cavities             ln_isfcav = '//TRIM(fct_str(td_nam%l_isfcav)))
+
+      il_count=0
+      IF( td_nam%l_zco      )   il_count = il_count + 1
+      IF( td_nam%l_zps      )   il_count = il_count + 1
+      IF( td_nam%l_sco      )   il_count = il_count + 1
+      IF( il_count /= 1 )THEN
+         CALL logger_fatal(' GRID ZGR : none or several vertical coordinate options used' )
+      ENDIF
+      !
+      il_count=0
+      IF ( td_nam%l_zco .AND. td_nam%l_isfcav ) il_count = il_count + 1
+      IF ( td_nam%l_sco .AND. td_nam%l_isfcav ) il_count = il_count + 1
+      IF( il_count > 0 )THEN
+         CALL logger_fatal(' GRID ZGR : Cavity not tested/compatible with full step (zco) and sigma (ln_sco)' )
+      ENDIF
+
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+
+      ! Reference z-coordinate system (always called)
+      CALL grid_zgr__z( td_nam,jpk )
+
+      ! Bathymetry fields (levels and meters)
+      CALL grid_zgr__bat( td_nam,jpi,jpj,td_bathy,td_risfdep )
+
+      ! 1D config.: same bathy value over the 3x3 domain
+      IF( td_nam%l_c1d ) CALL lbc_lnk( td_bathy%d_value(:,:,1,1),'T',td_nam%i_perio,1._dp )
+
+      ! z-coordinate
+      IF( td_nam%l_zco ) CALL grid_zgr__zco(jpk)
+      
+      ! Partial step z-coordinate
+      IF( td_nam%l_zps ) CALL grid_zgr__zps_fill( td_nam,jpi,jpj,jpk,td_bathy,td_risfdep )
+      
+      ! s-coordinate or hybrid z-s coordinate
+      IF( td_nam%l_sco ) CALL grid_zgr__sco_fill( td_nam,jpi,jpj,jpk,td_bathy )
+
+      ! final adjustment of mbathy & check 
+      ! ----------------------------------
+
+      ! correct mbathy in case of zoom subdomain
+      IF( td_nam%l_zoom )   CALL grid_zgr__bat_zoom( td_nam,jpi,jpj )
+
+      ! check bathymetry (mbathy) and suppress isolated ocean points
+      IF( .NOT. td_nam%l_c1d )   CALL grid_zgr__bat_ctl( td_nam,jpi,jpj,jpk )
+
+      ! deepest ocean level for t-, u- and v-points
+      CALL grid_zgr__bot_level( td_nam,jpi,jpj )
+
+      ! shallowest ocean level for T-, U-, V- points
+      CALL grid_zgr__top_level( td_nam,jpi,jpj )
+
+      ! 1D config.: same mbathy value over the 3x3 domain
+      IF( td_nam%l_c1d ) THEN
+         dl_bat = tg_mbathy%d_value(2,2,1,1)
+         tg_mbathy%d_value(:,:,1,1) = dl_bat
+      END IF      
+
+      CALL logger_info(' MIN val mbathy '//TRIM(fct_str(MINVAL( tg_mbathy%d_value(:,:,1,1) )))//&
+         &   ' MAX '//TRIM(fct_str(MAXVAL( tg_mbathy%d_value(:,:,1,1) ))) )
+      CALL logger_info(' MIN val depth  t '//TRIM(fct_str(MINVAL( tg_gdept_0%d_value(:,:,:,1) )))//&
+         &   ' w '//TRIM(fct_str(MINVAL( tg_gdepw_0%d_value(:,:,:,1) )))//&
+         !&   ' 3w '//TRIM(fct_str(MINVAL( tg_gdep3w_0%d_value(:,:,:,1) )))//&
+         &   '  t '//TRIM(fct_str(MINVAL( tg_e3t_0%d_value(:,:,:,1) )))//&
+         !&   '  f '//TRIM(fct_str(MINVAL( tg_e3f_0%d_value(:,:,:,1) )))//&
+         &   '  u '//TRIM(fct_str(MINVAL( tg_e3u_0%d_value(:,:,:,1) )))//&
+         &   '  v '//TRIM(fct_str(MINVAL( tg_e3v_0%d_value(:,:,:,1) )))//&
+         !&   ' uw '//TRIM(fct_str(MINVAL( tg_e3uw_0%d_value(:,:,:,1) )))//&
+         !&   ' vw '//TRIM(fct_str(MINVAL( tg_e3vw_0%d_value(:,:,:,1) )))//&
+         &   '  w '//TRIM(fct_str(MINVAL( tg_e3w_0%d_value(:,:,:,1) ))) )
+      CALL logger_info(' MAX val depth t '//TRIM(fct_str(MAXVAL( tg_gdept_0%d_value(:,:,:,1) )))//&
+         &   ' w '//TRIM(fct_str(MAXVAL( tg_gdepw_0%d_value(:,:,:,1) ))) )!//&
+         !&   ' 3w '//TRIM(fct_str(MAXVAL( tg_gdep3w_0%d_value(:,:,:,1) ))) )
+      CALL logger_info(' MAX val e3    t '//TRIM(fct_str(MAXVAL( tg_e3t_0%d_value(:,:,:,1) )))//&
+         !&   ' f '//TRIM(fct_str(MAXVAL( tg_e3f_0%d_value(:,:,:,1) )))//&
+         &   ' u '//TRIM(fct_str(MAXVAL( tg_e3u_0%d_value(:,:,:,1) )))//&
+         &   ' v '//TRIM(fct_str(MAXVAL( tg_e3v_0%d_value(:,:,:,1) )))//&
+         !&   ' uw '//TRIM(fct_str(MAXVAL( tg_e3uw_0%d_value(:,:,:,1) )))//&
+         !&   ' vw '//TRIM(fct_str(MAXVAL( tg_e3vw_0%d_value(:,:,:,1) )))//&
+         &   ' w '//TRIM(fct_str(MAXVAL( tg_e3w_0%d_value(:,:,:,1) ))) )
+
+   END SUBROUTINE grid_zgr_fill
+   !-------------------------------------------------------------------
+   !> @brief This subroutine set the depth of model levels and the resulting 
+   !>        vertical scale factors.
+   !>
+   !> @details
+   !>
+   !> ** Method  :   z-coordinate system (use in all type of coordinate)
+   !>        The depth of model levels is defined from an analytical
+   !>      function the derivative of which gives the scale factors.
+   !>        both depth and scale factors only depend on k (1d arrays).<br/>
+   !>              w-level: 
+   !>                       - gdepw_1d  = gdep(k)<br/>
+   !>                       - e3w_1d(k) = dk(gdep)(k)     = e3(k)<br/>
+   !>              t-level: 
+   !>                       - gdept_1d  = gdep(k+0.5)<br/>
+   !>                       - e3t_1d(k) = dk(gdep)(k+0.5) = e3(k+0.5)<br/>
+   !>
+   !>
+   !> ** Action  : - gdept_1d, gdepw_1d : depth of T- and W-point (m)
+   !>              - e3t_1d  , e3w_1d   : scale factors at T- and W-levels (m)
+   !>
+   !> !! Reference : Marti, Madec & Delecluse, 1992, JGR, 97, No8, 12,763-12,766.
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_z
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpk
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__z(td_nam,jpk) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpk
+
+      ! local variable
+      CHARACTER(LEN=lc)          :: cl_tmp
+
+      REAL(dp)                   :: zsur, za0, za1, zkth   ! Values set from parameters in
+      REAL(dp)                   :: zacr, zdzmin, zhmax    ! par_CONFIG_Rxx.h90
+!      REAL(dp)                   :: zrefdep                ! depth of the reference level (~10m)
+      REAL(dp)                   :: za2, zkth2, zacr2      ! Values for optional double tanh function set from parameters
+      REAL(dp)                   :: zt, zw                 ! temporary scalars
+      REAL(dp), PARAMETER        :: dp_pp_to_be_computed = NF90_FILL_DOUBLE
+
+      ! loop indices
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      ! Set variables from parameters
+      ! ------------------------------
+      zkth   = td_nam%d_ppkth       
+      zacr   = td_nam%d_ppacr
+      zdzmin = td_nam%d_ppdzmin   
+      zhmax  = td_nam%d_pphmax
+      zkth2  = td_nam%d_ppkth2     
+      zacr2  = td_nam%d_ppacr2
+
+      ! If ppa1 and ppa0 and ppsur are set to pp_to_be_computed
+      !  za0, za1, zsur are computed from ppdzmin , pphmax, ppkth, ppacr
+      IF(   td_nam%d_ppa1  == dp_pp_to_be_computed  .AND.  &
+         &  td_nam%d_ppa0  == dp_pp_to_be_computed  .AND.  &
+         &  td_nam%d_ppsur == dp_pp_to_be_computed           ) THEN
+         !
+         za1  = (  zdzmin - zhmax / FLOAT(jpk-1)  )                                                 &
+            & / ( TANH((1-zkth)/zacr) - zacr/FLOAT(jpk-1) * (  LOG( COSH( (jpk - zkth) / zacr) )    &
+            &                                                - LOG( COSH( ( 1  - zkth) / zacr) )  )  )
+         za0  = zdzmin  - za1 *             TANH( (1-zkth) / zacr )
+         zsur =   - za0 - za1 * zacr * LOG( COSH( (1-zkth) / zacr )  )
+         ! za2 ???
+      ELSE
+         za1  = td_nam%d_ppa1 
+         za0  = td_nam%d_ppa0
+         zsur = td_nam%d_ppsur
+         za2  = td_nam%d_ppa2                            ! optional (ldbletanh=T) double tanh parameter
+      ENDIF      
+
+      CALL logger_info(' GRID ZGR Z : Reference vertical z-coordinates')
+      CALL logger_info('~~~~~~~~~~~')
+      IF( zkth == 0._wp ) THEN 
+         CALL logger_info('Uniform grid with '//TRIM(fct_str(jpk-1))//' layers')
+         CALL logger_info('Total depth    :'//TRIM(fct_str(zhmax)))
+         CALL logger_info('Layer thickness:'//TRIM(fct_str(zhmax/(jpk-1))))         
+      ELSE
+         IF( za1 == 0._wp .AND. za0 == 0._wp .AND. zsur == 0._wp ) THEN
+            CALL logger_info('zsur, za0, za1 computed from ')
+            CALL logger_info('        zdzmin = '//TRIM(fct_str(zdzmin)))
+            CALL logger_info('        zhmax  = '//TRIM(fct_str(zhmax)))            
+         ENDIF
+            CALL logger_info('Value of coefficients for vertical mesh:')
+            CALL logger_info('      zsur = '//TRIM(fct_str(zsur)))
+            CALL logger_info('      za0  = '//TRIM(fct_str(za0)))
+            CALL logger_info('      za1  = '//TRIM(fct_str(za1)))
+            CALL logger_info('      zkth = '//TRIM(fct_str(zkth)))
+            CALL logger_info('      zacr = '//TRIM(fct_str(zacr)))
+         IF( td_nam%l_dbletanh ) THEN
+            CALL logger_info(' (Double tanh    za2  = '//TRIM(fct_str(za2)))
+            CALL logger_info('  parameters)    zkth2= '//TRIM(fct_str(zkth2)))
+            CALL logger_info('                 zacr2= '//TRIM(fct_str(zacr2)))
+         ENDIF
+      ENDIF
+
+      ! Reference z-coordinate (depth - scale factor at T- and W-points)
+      ! ======================
+      ! init
+      IF( zkth == 0._dp ) THEN            !  uniform vertical grid       
+         za1 = zhmax / FLOAT(jpk-1) 
+         DO jk = 1, jpk
+            zw = FLOAT( jk )
+            zt = FLOAT( jk ) + 0.5_dp
+            tg_gdepw_1d%d_value(1,1,jk,1) = ( zw - 1 ) * za1
+            tg_gdept_1d%d_value(1,1,jk,1) = ( zt - 1 ) * za1
+            tg_e3w_1d%d_value  (1,1,jk,1) =  za1
+            tg_e3t_1d%d_value  (1,1,jk,1) =  za1
+         END DO
+      ELSE                                ! Madec & Imbard 1996 function
+         IF( .NOT. td_nam%l_dbletanh ) THEN
+            DO jk = 1, jpk
+               zw = REAL( jk , wp )
+               zt = REAL( jk , wp ) + 0.5_dp
+               tg_gdepw_1d%d_value(1,1,jk,1) = ( zsur + za0 * zw + za1 * zacr * LOG ( COSH( (zw-zkth) / zacr ) )  )
+               tg_gdept_1d%d_value(1,1,jk,1) = ( zsur + za0 * zt + za1 * zacr * LOG ( COSH( (zt-zkth) / zacr ) )  )
+               tg_e3w_1d%d_value  (1,1,jk,1) =          za0      + za1        * TANH(       (zw-zkth) / zacr   )
+               tg_e3t_1d%d_value  (1,1,jk,1) =          za0      + za1        * TANH(       (zt-zkth) / zacr   )
+            END DO
+         ELSE
+            DO jk = 1, jpk
+               zw = FLOAT( jk )
+               zt = FLOAT( jk ) + 0.5_dp
+               ! Double tanh function
+               tg_gdepw_1d%d_value(1,1,jk,1) = ( zsur + za0 * zw + za1 * zacr * LOG ( COSH( (zw-zkth ) / zacr  ) )    &
+                           &                                     + za2 * zacr2* LOG ( COSH( (zw-zkth2) / zacr2 ) )  )
+               tg_gdept_1d%d_value(1,1,jk,1) = ( zsur + za0 * zt + za1 * zacr * LOG ( COSH( (zt-zkth ) / zacr  ) )    &
+                           &                                     + za2 * zacr2* LOG ( COSH( (zt-zkth2) / zacr2 ) )  )
+               tg_e3w_1d  %d_value(1,1,jk,1) =          za0      + za1        * TANH(       (zw-zkth ) / zacr  )      &
+                           &                                     + za2        * TANH(       (zw-zkth2) / zacr2 )
+               tg_e3t_1d  %d_value(1,1,jk,1) =          za0      + za1        * TANH(       (zt-zkth ) / zacr  )      &
+                  &                                              + za2        * TANH(       (zt-zkth2) / zacr2 )
+            END DO
+         ENDIF
+         tg_gdepw_1d%d_value(1,1,1,1) = 0._dp                    ! force first w-level to be exactly at zero
+      ENDIF      
+
+      IF ( td_nam%l_isfcav ) THEN
+         ! need to be like this to compute the pressure gradient with ISF. 
+         ! If not, level beneath the ISF are not aligned (sum(e3t) /= depth)
+         ! define e3t_0 and e3w_0 as the differences between gdept and gdepw respectively
+         DO jk = 1, jpk-1
+            tg_e3t_1d%d_value(1,1,jk,1) = tg_gdepw_1d%d_value(1,1,jk+1,1)-tg_gdepw_1d%d_value(1,1,jk,1) 
+         END DO
+         ! we don't care because this level is masked in NEMO
+         tg_e3t_1d%d_value(1,1,jpk,1) = tg_e3t_1d%d_value(1,1,jpk-1,1)
+
+         DO jk = 2, jpk
+            tg_e3w_1d%d_value(1,1,jk,1) = tg_gdept_1d%d_value(1,1,jk,1) - tg_gdept_1d%d_value(1,1,jk-1,1) 
+         END DO
+         tg_e3w_1d%d_value(1,1,1,1) = 2._dp * (tg_gdept_1d%d_value(1,1,1,1) - tg_gdepw_1d%d_value(1,1,1,1)) 
+      END IF 
+
+! unused ?
+!!!!gm BUG in s-coordinate this does not work!
+!      ! deepest/shallowest W level Above/Below ~10m
+!      
+!      ! ref. depth with tolerance (10% of minimum layer thickness)
+!      zrefdep = 10._wp - 0.1_wp * MINVAL( tg_e3w_1d%d_value(1,1,:,1) )
+!      
+!      ! shallowest W level Below ~10m
+!      nlb10 = MINLOC( tg_gdepw_1d%d_value(1,1,:,1), mask = tg_gdepw_1d%d_value(1,1,:,1) > zrefdep, dim = 1 )
+!      
+!      ! deepest    W level Above ~10m
+!      nla10 = nlb10 - 1
+!!!!gm end bug
+
+      ! control print
+      CALL logger_info(' GRID ZGR Z : Reference z-coordinate depth and scale factors:')
+      CALL logger_info('~~~~~~~~~~~')
+      WRITE(cl_tmp, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
+      CALL logger_info(cl_tmp)
+      DO jk=1,jpk
+         WRITE(cl_tmp, "(10x, i4, 4f9.2)" ) jk, tg_gdept_1d%d_value(1,1,jk,1), tg_gdepw_1d%d_value(1,1,jk,1), &
+            &                                   tg_e3t_1d%d_value  (1,1,jk,1), tg_e3w_1d%d_value  (1,1,jk,1)
+         CALL logger_info(cl_tmp)
+      ENDDO
+
+      ! control positivity
+      DO jk = 1, jpk                      
+         IF( tg_e3w_1d%d_value  (1,1,jk,1) <= 0._dp .OR. tg_e3t_1d%d_value  (1,1,jk,1) <= 0._dp )THEN
+            CALL logger_fatal( 'GRID ZGR Z: e3w_1d or e3t_1d =< 0 '    )
+         ENDIF
+         IF( tg_gdepw_1d%d_value(1,1,jk,1) <  0._dp .OR. tg_gdept_1d%d_value(1,1,jk,1) <  0._dp )THEN
+            CALL logger_fatal( 'GRID ZGR Z: gdepw_1d or gdept_1d < 0 ' )
+         ENDIF
+      END DO
+
+   END SUBROUTINE grid_zgr__z
+   !-------------------------------------------------------------------
+   !> @brief This subroutine set bathymetry both in levels and meters
+   !>
+   !> @details
+   !>
+   !> ** Method  :   read or define mbathy and bathy arrays
+   !>       * level bathymetry:
+   !>      The ocean basin geometry is given by a two-dimensional array,
+   !>      mbathy, which is defined as follow :
+   !>            mbathy(ji,jj) = 1, ..., jpk-1, the number of ocean level
+   !>                              at t-point (ji,jj).
+   !>                          = 0  over the continental t-point.
+   !>      The array mbathy is checked to verified its consistency with
+   !>      model option. in particular:
+   !>            mbathy must have at least 1 land grid-points (mbathy<=0)
+   !>                  along closed boundary.
+   !>            mbathy must be cyclic IF jperio=1.
+   !>            mbathy must be lower or equal to jpk-1.
+   !>            isolated ocean grid points are suppressed from mbathy
+   !>                  since they are only connected to remaining
+   !>                  ocean through vertical diffusion.
+   !>      ntopo=-1 :   rectangular channel or bassin with a bump 
+   !>      ntopo= 0 :   flat rectangular channel or basin 
+   !>      ntopo= 1 :   mbathy is read in 'bathy_level.nc' NetCDF file
+   !>                   bathy  is read in 'bathy_meter.nc' NetCDF file
+   !>
+   !> ** Action  : - mbathy: level bathymetry (in level index)
+   !>              - bathy : meter bathymetry (in meters)   
+   !>
+   !> @warning do not manage case ntopo=-1 or 0
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_bat
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] td_bathy
+   !> @param[in] td_risfdep
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__bat( td_nam,jpi,jpj,td_bathy,td_risfdep ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      TYPE(TVAR) , INTENT(INOUT) :: td_bathy
+      TYPE(TVAR) , INTENT(INOUT) :: td_risfdep
+
+      ! local variable
+      INTEGER(i4) :: ii0, ii1
+      INTEGER(i4) :: ij0, ij1
+
+      REAL(dp)                                  :: zhmin
+
+      ! loop indices
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      CALL logger_info(' GRID ZGR BAT : defines level and meter bathymetry')
+      CALL logger_info(' ~~~~~~~~~~~~~')
+      CALL logger_info(' GRID ZGR BAT : bathymetry read in file')
+
+      IF( td_nam%l_zco )THEN
+         ! zco : read level bathymetry
+
+         ! read variable in bathymetry file
+         tg_mbathy%d_value(:,:,1,1) = INT(td_bathy%d_value(:,:,1,1),i4)
+         tg_misfdep%d_value(:,:,1,1)=1
+         !                                                ! =====================
+         IF( TRIM(td_nam%c_cfg) == "orca" .AND. td_nam%i_cfg == 2 ) THEN    ! ORCA R2 configuration
+            !                                             ! =====================
+            IF( td_nam%i_cla == 0 ) THEN
+               ii0 = 140   ;   ii1 = 140                  ! Gibraltar Strait open 
+               ij0 = 102   ;   ij1 = 102                  ! (Thomson, Ocean Modelling, 1995)
+               tg_mbathy%d_value(ii0:ii1,ij0:ij1,1,1) = 15
+               CALL logger_info('orca_r2: Gibraltar strait open at i='//&
+                  &  TRIM(fct_str(ii0))//' j='//TRIM(fct_str(ij0)) )
+               !
+               ii0 = 160   ;   ii1 = 160                  ! Bab el mandeb Strait open
+               ij0 = 88    ;   ij1 = 88                   ! (Thomson, Ocean Modelling, 1995)
+               tg_mbathy%d_value(ii0:ii1,ij0:ij1,1,1) = 12
+               CALL logger_info('orca_r2: Bab el Mandeb strait open at i='//&
+                  &  TRIM(fct_str(ii0))//' j='//TRIM(fct_str(ij0)) )
+            ENDIF
+            !
+         ENDIF
+
+      ENDIF
+
+      IF( td_nam%l_zps .OR. td_nam%l_sco )THEN
+         ! zps or sco : read meter bathymetry
+
+         tg_misfdep%d_value(:,:,:,:)=1
+
+         IF ( td_nam%l_isfcav ) THEN
+            WHERE( td_bathy%d_value(:,:,1,1) <= 0._dp )
+               td_risfdep%d_value(:,:,1,1) = 0._dp
+            END WHERE
+
+            ! set grounded point to 0
+            ! (a treshold could be set here if needed, or set it offline based on the grounded fraction)
+            WHERE ( td_bathy%d_value(:,:,1,1) <= td_risfdep%d_value(:,:,1,1) + td_nam%d_isfhmin )
+               tg_misfdep%d_value(:,:,1,1) = 0
+               td_risfdep%d_value(:,:,1,1) = 0._wp
+               tg_mbathy%d_value (:,:,1,1) = 0
+               td_bathy%d_value  (:,:,1,1) = 0._wp
+            END WHERE
+         END IF
+         !       
+         IF( TRIM(td_nam%c_cfg) == "orca" .AND. td_nam%i_cfg == 2 ) THEN    ! ORCA R2 configuration
+            !
+           IF( td_nam%i_cla == 0 ) THEN
+              ii0 = 140   ;   ii1 = 140                   ! Gibraltar Strait open 
+              ij0 = 102   ;   ij1 = 102                   ! (Thomson, Ocean Modelling, 1995)
+              td_bathy%d_value(ii0:ii1,ij0:ij1,1,1) = 284._dp 
+              CALL logger_info('orca_r2: Gibraltar strait open at i='//&
+                 &   TRIM(fct_str(ii0))//' j='//TRIM(fct_str(ij0)) )
+              !
+              ii0 = 160   ;   ii1 = 160                   ! Bab el mandeb Strait open
+              ij0 = 88    ;   ij1 = 88                    ! (Thomson, Ocean Modelling, 1995)
+              td_bathy%d_value(ii0:ii1,ij0:ij1,1,1) = 137._dp
+              CALL logger_info('orca_r2: Bab el Mandeb strait open at i='//&
+                 &   TRIM(fct_str(ii0))//' j='//TRIM(fct_str(ij0)) )
+           ENDIF
+           !
+        ENDIF
+         !
+      ENDIF      
+
+      !==  NO closed seas or lakes  ==!
+      ! already done
+
+      IF ( .NOT. td_nam%l_sco ) THEN
+         !==  set a minimum depth  ==!
+         
+         IF( td_nam%d_hmin < 0._dp ) THEN
+            ! from a nb of level
+            jk = - INT(td_nam%d_hmin, i4)
+         ELSE
+            ! from a depth
+            jk = MINLOC( tg_gdepw_1d%d_value(1,1,:,1), &
+               &  MASK = tg_gdepw_1d%d_value(1,1,:,1) > td_nam%d_hmin, &
+               &  DIM  = 1)
+         ENDIF
+
+         ! minimum depth = ik+1 w-levels
+         zhmin = tg_gdepw_1d%d_value(1,1,jk+1,1)
+         WHERE( td_bathy%d_value(:,:,1,1) <= 0._dp )
+            ! min=0     over the lands
+            td_bathy%d_value(:,:,1,1) = 0._dp
+         ELSE WHERE
+            ! min=zhmin over the oceans
+            td_bathy%d_value(:,:,1,1) = MAX(zhmin, td_bathy%d_value(:,:,1,1))
+         END WHERE
+         CALL logger_info('GRID ZGR BAT: Minimum ocean depth: '//&
+            &   TRIM(fct_str(zhmin))//' minimum number of ocean'//&
+            &   ' levels : '//TRIM(fct_str(jk)))
+      ENDIF
+
+   END SUBROUTINE grid_zgr__bat
+   !-------------------------------------------------------------------
+   !> @brief This subroutine define the z-coordinate system
+   !>
+   !> @details
+   !> set 3D coord. arrays to reference 1D array
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_zco
+   !>
+   !> @param[in] jpk
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__zco(jpk) 
+      IMPLICIT NONE
+      ! Argument      
+      INTEGER(i4), INTENT(IN   ) :: jpk
+
+      ! local variable
+      ! loop indices
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      DO jk = 1, jpk
+         tg_gdept_0%d_value (:,:,jk,1) = tg_gdept_1d%d_value(1,1,jk,1)
+         tg_gdepw_0%d_value (:,:,jk,1) = tg_gdepw_1d%d_value(1,1,jk,1)
+         !tg_gdep3w_0%d_value(:,:,jk,1) = tg_gdepw_1d%d_value(1,1,jk,1)
+         tg_e3t_0%d_value   (:,:,jk,1) = tg_e3t_1d%d_value  (1,1,jk,1)
+         tg_e3u_0%d_value   (:,:,jk,1) = tg_e3t_1d%d_value  (1,1,jk,1)
+         tg_e3v_0%d_value   (:,:,jk,1) = tg_e3t_1d%d_value  (1,1,jk,1)
+         !tg_e3f_0%d_value   (:,:,jk,1) = tg_e3t_1d%d_value  (1,1,jk,1)
+         tg_e3w_0%d_value   (:,:,jk,1) = tg_e3w_1d%d_value  (1,1,jk,1)
+         !tg_e3uw_0%d_value  (:,:,jk,1) = tg_e3w_1d%d_value  (1,1,jk,1)
+         !tg_e3vw_0%d_value  (:,:,jk,1) = tg_e3w_1d%d_value  (1,1,jk,1)
+      END DO
+
+   END SUBROUTINE grid_zgr__zco
+   !-------------------------------------------------------------------
+   !> @brief This subroutine : 
+   !> - close zoom domain boundary if necessary
+   !> - suppress Med Sea from ORCA R2 and R05 arctic zoom
+   !> 
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__bat_zoom(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+
+      ! local variable
+      INTEGER(i4) :: jpizoom
+      INTEGER(i4) :: jpjzoom
+
+      INTEGER(i4) :: ii0, ii1
+      INTEGER(i4) :: ij0, ij1
+      ! loop indices
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID ZGR BAT ZOOM : modify the level bathymetry for zoom domain')
+      CALL logger_info('~~~~~~~~~~~~')
+
+      jpizoom=td_nam%i_izoom
+      jpjzoom=td_nam%i_jzoom
+
+      ! Forced closed boundary if required
+      IF( td_nam%l_zoom_s ) tg_mbathy%d_value(    :         ,    jpjzoom  ,1,1) = 0
+      IF( td_nam%l_zoom_w ) tg_mbathy%d_value(     jpizoom  ,   :         ,1,1) = 0
+      IF( td_nam%l_zoom_e ) tg_mbathy%d_value( jpi+jpizoom-1,   :         ,1,1) = 0
+      IF( td_nam%l_zoom_n ) tg_mbathy%d_value(    :         ,jpj+jpjzoom-1,1,1) = 0
+
+      ! Configuration specific domain modifications
+      ! (here, ORCA arctic configuration: suppress Med Sea)
+      IF( TRIM(td_nam%c_cfg) == "orca" .AND. &
+        & TRIM(td_nam%c_cfz) == "arctic" ) THEN
+         SELECT CASE ( td_nam%i_cfg )
+         !                                        ! =======================
+         CASE ( 2 )                               !  ORCA_R2 configuration
+            !                                     ! =======================
+            CALL logger_info('ORCA R2 arctic zoom: suppress the Med Sea')
+            ii0 = 141   ;   ii1 = 162      ! Sea box i,j indices
+            ij0 =  98   ;   ij1 = 110
+            !                                     ! =======================
+         CASE ( 05 )                              !  ORCA_R05 configuration
+            !                                     ! =======================
+            CALL logger_info('ORCA R05 arctic zoom: suppress the Med Sea')
+            ii0 = 563   ;   ii1 = 642      ! zero over the Med Sea boxe
+            ij0 = 314   ;   ij1 = 370 
+         END SELECT
+         !
+         tg_mbathy%d_value( ii0:ii1, ij0:ij1, 1, 1) = 0   ! zero over the Med Sea boxe
+         !
+      ENDIF
+
+   END SUBROUTINE grid_zgr__bat_zoom
+   !-------------------------------------------------------------------
+   !> @brief This subroutine check the bathymetry in levels
+   !>
+   !> @details
+   !>
+   !> 
+   !> ** Method  :   The array mbathy is checked to verified its consistency
+   !>      with the model options. in particular:
+   !>            mbathy must have at least 1 land grid-points (mbathy<=0)
+   !>                  along closed boundary.
+   !>            mbathy must be cyclic IF jperio=1.
+   !>            mbathy must be lower or equal to jpk-1.
+   !>            isolated ocean grid points are suppressed from mbathy
+   !>                  since they are only connected to remaining
+   !>                  ocean through vertical diffusion.
+   !>      C A U T I O N : mbathy will be modified during the initializa-
+   !>      tion phase to become the number of non-zero w-levels of a water
+   !>      column, with a minimum value of 1.
+   !>
+   !> ** Action  : - update mbathy: level bathymetry (in level index)
+   !>              - update bathy : meter bathymetry (in meters)
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__bat_ctl(td_nam,jpi,jpj,jpk) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+
+      ! local variable
+      INTEGER(i4) :: icompt, ibtest, ikmax         ! temporary integers
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jl
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID ZGR BAT CTL: check the bathymetry')
+      CALL logger_info('~~~~~~~~~~~~~~~')
+      CALL logger_info('                   suppress isolated ocean grid points')
+      CALL logger_info('                   -----------------------------------')
+
+      icompt = 0
+      DO jl = 1, 2
+         IF( td_nam%i_perio == 1 .OR. &
+           & td_nam%i_perio == 4 .OR. &
+           & td_nam%i_perio == 6 ) THEN
+            tg_mbathy%d_value( 1 ,:,1,1) = tg_mbathy%d_value(jpi-1,:,1,1)           ! local domain is cyclic east-west
+            tg_mbathy%d_value(jpi,:,1,1) = tg_mbathy%d_value(  2  ,:,1,1)
+         ENDIF
+         DO jj = 2, jpj-1
+            DO ji = 2, jpi-1
+               ibtest = MAX(  tg_mbathy%d_value(ji-1,jj  ,1,1), &
+                  &           tg_mbathy%d_value(ji+1,jj  ,1,1), &
+                  &           tg_mbathy%d_value(ji  ,jj-1,1,1), &
+                  &           tg_mbathy%d_value(ji  ,jj+1,1,1)  )
+               IF( ibtest < tg_mbathy%d_value(ji,jj,1,1) ) THEN
+                  CALL logger_info(' the number of ocean level at '//&
+                     &             'grid-point (i,j) =  ('//TRIM(fct_str(ji))//&
+                     &             ','//TRIM(fct_str(jj))//') is changed from '//&
+                     &             TRIM(fct_str(tg_mbathy%d_value(ji,jj,1,1)))//' to '//&
+                     &             TRIM(fct_str(ibtest)) )
+                  tg_mbathy%d_value(ji,jj,1,1) = ibtest
+                  icompt = icompt + 1
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      !! lk_mpp not used
+
+      IF( icompt == 0 ) THEN
+         CALL logger_info('     no isolated ocean grid points')
+      ELSE
+         CALL logger_info(TRIM(fct_str(icompt))//' ocean grid points suppressed')
+      ENDIF
+
+      !! lk_mpp not used
+
+      !                                          ! East-west cyclic boundary conditions
+      IF( td_nam%i_perio == 0 ) THEN
+         CALL logger_info(' mbathy set to 0 along east and west boundary:'//&
+            &  ' nperio = '//TRIM(fct_str(td_nam%i_perio)) )
+         !! lk_mpp not used
+         IF( td_nam%l_zco .OR. td_nam%l_zps ) THEN
+            tg_mbathy%d_value( 1 ,:,1,1) = 0
+            tg_mbathy%d_value(jpi,:,1,1) = 0
+         ELSE
+            tg_mbathy%d_value( 1 ,:,1,1) = jpk-1
+            tg_mbathy%d_value(jpi,:,1,1) = jpk-1
+         ENDIF
+      ELSEIF( td_nam%i_perio == 1 .OR. &
+            & td_nam%i_perio == 4 .OR. &
+            & td_nam%i_perio == 6 ) THEN
+         CALL logger_info(' east-west cyclic boundary conditions on mbathy:'//&
+            &  ' nperio = '//TRIM(fct_str(td_nam%i_perio)) )
+         tg_mbathy%d_value( 1 ,:,1,1) = tg_mbathy%d_value(jpi-1,:,1,1)
+         tg_mbathy%d_value(jpi,:,1,1) = tg_mbathy%d_value(  2  ,:,1,1)
+      ELSEIF( td_nam%i_perio == 2 ) THEN
+         CALL logger_info('   equatorial boundary conditions on mbathy:'//&
+            ' nperio = '//TRIM(fct_str(td_nam%i_perio)) )
+      ELSE
+         CALL logger_info('    e r r o r')
+         CALL logger_info('    parameter , nperio = '//TRIM(fct_str(td_nam%i_perio)) )
+         !         STOP 'dom_mba'
+      ENDIF
+
+      !  Boundary condition on mbathy
+!!gm  !!bug ???  think about it !
+      !   ... mono- or macro-tasking: T-point, >0, 2D array, no slab
+      CALL lbc_lnk( tg_mbathy%d_value(:,:,1,1), 'T', td_nam%i_perio, 1._dp )
+
+
+      ! Number of ocean level inferior or equal to jpkm1
+      ikmax = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikmax = MAX( ikmax, INT(tg_mbathy%d_value(ji,jj,1,1),i4) )
+         END DO
+      END DO      
+!!gm  !!! test to do:   ikmax = MAX( mbathy(:,:) )   ???
+      IF( ikmax > jpk-1 ) THEN
+         CALL logger_info(' maximum number of ocean level = '//TRIM(fct_str(ikmax))//' >  jpk-1')
+         CALL logger_info(' change jpk to '//TRIM(fct_str(ikmax+1))//' to use the exact ead bathymetry')
+      ELSE IF( ikmax < jpk-1 ) THEN
+         CALL logger_info(' maximum number of ocean level = '//TRIM(fct_str(ikmax))//' < jpk-1')
+         CALL logger_info(' you can decrease jpk to '//TRIM(fct_str(ikmax+1)))
+      ENDIF      
+
+   END SUBROUTINE grid_zgr__bat_ctl
+   !-------------------------------------------------------------------
+   !> @brief This subroutine defines the vertical index of ocean bottom (mbk. arrays)
+   !>
+   !> @details
+   !>
+   !> ** Method  :   computes from mbathy with a minimum value of 1 over land
+   !>
+   !> ** Action  :   mbkt, mbku, mbkv :   vertical indices of the deeptest 
+   !>                                     ocean level at t-, u- & v-points
+   !>                                     (min value = 1 over land)
+   !> 
+   !> 
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_bot_level
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__bot_level(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+
+      ! local variable
+
+      ! loop indices
+!      INTEGER(i4) :: ji
+!      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID ZGR BOT LEVEL: ocean bottom k-index of T-, U-, V- and W-levels ')
+      CALL logger_info('    ~~~~~~~~~~~~~')
+
+      ! bottom k-index of T-level (=1 over land)
+      tg_mbkt%d_value(:,:,1,1) = MAX( tg_mbathy%d_value(:,:,1,1) , 1._dp )
+
+!      ! bottom k-index of W-level = mbkt+1
+!      ! bottom k-index of u- (v-) level
+!      DO jj = 1, jpj-1                      ! bottom k-index of u- (v-) level
+!         DO ji = 1, jpi-1
+!            tg_mbku%d_value(ji,jj,1,1) = MIN(  tg_mbkt%d_value(ji+1,jj  ,1,1) , &
+!               &                               tg_mbkt%d_value(ji  ,jj  ,1,1)  )
+!
+!            tg_mbkv%d_value(ji,jj,1,1) = MIN(  tg_mbkt%d_value(ji  ,jj+1,1,1) , &
+!               &                               tg_mbkt%d_value(ji  ,jj  ,1,1)  )
+!         END DO
+!      END DO
+!
+!      CALL lbc_lnk(tg_mbku%d_value(:,:,1,1),'U', td_nam%i_perio, 1._dp)
+!      CALL lbc_lnk(tg_mbkv%d_value(:,:,1,1),'U', td_nam%i_perio, 1._dp)
+
+   END SUBROUTINE grid_zgr__bot_level
+   !-------------------------------------------------------------------
+   !> @brief This subroutine defines the vertical index of ocean top (mik. arrays)
+   !>
+   !> @details
+   !>
+   !> ** Method  :   computes from misfdep with a minimum value of 1
+   !>
+   !> ** Action  :   mikt, miku, mikv :   vertical indices of the shallowest 
+   !>                                     ocean level at t-, u- & v-points
+   !>                                     (min value = 1)
+   !> 
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_top_level
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__top_level(td_nam,jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      ! local variable
+
+      ! loop indices
+!      INTEGER(i4) :: ji
+!      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      CALL logger_info('    GRID ZGR TOP LEVEL : ocean top k-index of T-, U-, V- and W-levels ')
+      CALL logger_info('    ~~~~~~~~~~~~~')
+
+      ! top k-index of T-level (=1)
+      tg_mikt%d_value(:,:,1,1) = MAX( tg_misfdep%d_value(:,:,1,1) , 1._dp )
+
+!      ! top k-index of W-level (=mikt)
+!      ! top k-index of U- (U-) level
+!      DO jj = 1, jpj-1                       ! top k-index of U- (U-) level
+!         DO ji = 1, jpi-1
+!            tg_miku%d_value(ji,jj,1,1) = MAX(  tg_mikt%d_value(ji+1,jj  ,1,1), &
+!               &                               tg_mikt%d_value(ji  ,jj  ,1,1)  )
+!
+!            tg_mikv%d_value(ji,jj,1,1) = MAX(  tg_mikt%d_value(ji  ,jj+1,1,1), &
+!               &                               tg_mikt%d_value(ji  ,jj  ,1,1)  )
+!
+!            tg_mikf%d_value(ji,jj,1,1) = MAX(  tg_mikt%d_value(ji  ,jj+1,1,1), &
+!               &                               tg_mikt%d_value(ji  ,jj  ,1,1), &
+!               &                               tg_mikt%d_value(ji+1,jj  ,1,1), &
+!               &                               tg_mikt%d_value(ji+1,jj+1,1,1)  )
+!         END DO
+!      END DO
+!
+!      CALL lbc_lnk(tg_miku%d_value(:,:,1,1),'U',td_nam%i_perio,1._dp)
+!      CALL lbc_lnk(tg_mikv%d_value(:,:,1,1),'V',td_nam%i_perio,1._dp)
+!      CALL lbc_lnk(tg_mikf%d_value(:,:,1,1),'F',td_nam%i_perio,1._dp)
+
+   END SUBROUTINE grid_zgr__top_level
+   !-------------------------------------------------------------------
+   !> @brief This function initialise global variable needed to compute vertical
+   !>        mesh
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_zps_init(jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp), DIMENSION(jpi,jpj) :: dl_tmp
+
+      ! loop indices
+      !----------------------------------------------------------------
+
+      dl_tmp(:,:)=dp_fill
+
+      tg_e3tp    =var_init('e3t_ps   ',dl_tmp(:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+      tg_e3wp    =var_init('e3w_ps   ',dl_tmp(:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+   END SUBROUTINE grid_zgr_zps_init
+   !-------------------------------------------------------------------
+   !> @brief This function clean hgr structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_zps_clean() 
+      IMPLICIT NONE
+      ! Argument      
+
+      ! local variable
+      ! loop indices
+      !----------------------------------------------------------------
+
+      CALL var_clean(tg_e3tp     )
+      CALL var_clean(tg_e3wp     )
+      
+   END SUBROUTINE grid_zgr_zps_clean
+   !-------------------------------------------------------------------
+   !> @brief This subroutine define the depth and vertical scale factor in partial step
+   !>      z-coordinate case
+   !>
+   !> @details
+   !> ** Method  :   Partial steps : computes the 3D vertical scale factors
+   !>      of T-, U-, V-, W-, UW-, VW and F-points that are associated with
+   !>      a partial step representation of bottom topography.
+   !>
+   !>        The reference depth of model levels is defined from an analytical
+   !>      function the derivative of which gives the reference vertical
+   !>      scale factors.
+   !>        From  depth and scale factors reference, we compute there new value
+   !>      with partial steps  on 3d arrays ( i, j, k ).
+   !>
+   !>              w-level: gdepw_0(i,j,k)  = gdep(k)
+   !>                       e3w_0(i,j,k) = dk(gdep)(k)     = e3(i,j,k)
+   !>              t-level: gdept_0(i,j,k)  = gdep(k+0.5)
+   !>                       e3t_0(i,j,k) = dk(gdep)(k+0.5) = e3(i,j,k+0.5)
+   !>
+   !>        With the help of the bathymetric file ( bathymetry_depth_ORCA_R2.nc),
+   !>      we find the mbathy index of the depth at each grid point.
+   !>      This leads us to three cases:
+   !>
+   !>              - bathy = 0 => mbathy = 0
+   !>              - 1 < mbathy < jpkm1    
+   !>              - bathy > gdepw_0(jpk) => mbathy = jpkm1  
+   !>
+   !>        Then, for each case, we find the new depth at t- and w- levels
+   !>      and the new vertical scale factors at t-, u-, v-, w-, uw-, vw- 
+   !>      and f-points.
+   !> 
+   !>        This routine is given as an example, it must be modified
+   !>      following the user s desiderata. nevertheless, the output as
+   !>      well as the way to compute the model levels and scale factors
+   !>      must be respected in order to insure second order accuracy
+   !>      schemes.
+   !>
+   !>  @warrning gdept_1d, gdepw_1d and e3._1d are positives
+   !>            gdept_0, gdepw_0 and e3. are positives
+   !>      
+   !>  Reference :   Pacanowsky & Gnanadesikan 1997, Mon. Wea. Rev., 126, 3248-3270.
+   !> set 3D coord. arrays to reference 1D array
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_zps
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !> @param[inout] td_bathy
+   !> @param[inout] td_risfdep
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__zps_fill( td_nam, jpi,jpj,jpk,td_bathy, td_risfdep ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      TYPE(TVAR) , INTENT(INOUT) :: td_bathy
+      TYPE(TVAR) , INTENT(INOUT) :: td_risfdep
+
+      ! local variable
+      REAL(dp)    :: zmax             ! Maximum depth
+      REAL(dp)    :: zdepwp, zdepth   ! Ajusted ocean depth to avoid too small e3t
+      REAL(dp)    :: ze3tp , ze3wp    ! Last ocean level thickness at T- and W-points
+      REAL(dp)    :: zdiff            ! temporary scalar
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+
+      INTEGER(i4) :: ik
+      INTEGER(i4) :: it
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID ZGR ZPS : z-coordinate with partial steps')
+      CALL logger_info('mbathy is recomputed : bathy_level file is NOT used')
+
+      ! bathymetry in level (from bathy_meter)
+
+      ! maximum depth (i.e. the last ocean level thickness <= 2*e3t_1d(jpkm1) )
+      zmax = tg_gdepw_1d%d_value(1,1,jpk,1) + tg_e3t_1d%d_value(1,1,jpk,1)
+
+      ! bounded value of bathy (min already set at the end of zgr_bat)
+      td_bathy%d_value(:,:,1,1) = MIN(zmax, td_bathy%d_value(:,:,1,1))
+
+      WHERE( td_bathy%d_value(:,:,1,1) == 0._dp )
+         ! land  : set mbathy to 0
+         tg_mbathy%d_value(:,:,1,1) = 0
+      ELSE WHERE
+         ! ocean : initialize mbathy to the max ocean level
+         tg_mbathy%d_value(:,:,1,1) = jpk-1
+      END WHERE
+
+      ! Compute mbathy for ocean points (i.e. the number of ocean levels)
+      ! find the number of ocean levels such that the last level thickness
+      ! is larger than the minimum of e3zps_min and e3zps_rat * e3t_1d (where
+      ! e3t_1d is the reference level thickness
+      DO jk = jpk-1, 1, -1
+         zdepth = tg_gdepw_1d%d_value(1,1,jk,1) +  MIN( td_nam%d_e3zps_min, &
+            &                                           td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,jk,1))
+
+         WHERE( 0._dp < td_bathy%d_value(:,:,1,1) .AND. &
+            &           td_bathy%d_value(:,:,1,1) <= zdepth )
+            tg_mbathy%d_value(:,:,1,1) = jk-1
+         END WHERE
+      END DO
+
+      ! Scale factors and depth at T- and W-points
+      DO jk = 1, jpk                        
+         ! intitialization to the reference z-coordinate
+         tg_gdept_0%d_value(:,:,jk,1) = tg_gdept_1d%d_value(1,1,jk,1)
+         tg_gdepw_0%d_value(:,:,jk,1) = tg_gdepw_1d%d_value(1,1,jk,1)
+         tg_e3t_0%d_value  (:,:,jk,1) = tg_e3t_1d%d_value  (1,1,jk,1)
+         tg_e3w_0%d_value  (:,:,jk,1) = tg_e3w_1d%d_value  (1,1,jk,1)
+      END DO
+
+      IF ( td_nam%l_isfcav )THEN
+         ! Bathy, iceshelf draft, scale factor and depth at T- and W- points in case of isf
+         CALL grid_zgr__isf_fill( td_nam, jpi,jpj,jpk, td_bathy, td_risfdep )
+
+      ELSE ! .NOT. td_nam%l_isfcav
+         !
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ik = tg_mbathy%d_value(ji,jj,1,1)
+               IF( ik > 0 ) THEN               
+                  ! ocean point only
+                  IF( ik == jpk-1 ) THEN
+                     ! max ocean level case
+                     zdepwp = td_bathy%d_value(ji,jj,1,1)
+                     ze3tp  = td_bathy%d_value(ji,jj,1,1) - tg_gdepw_1d%d_value(1,1,ik,1)
+                     ze3wp  = 0.5_dp * tg_e3w_1d%d_value(1,1,ik,1) &
+                        &            * ( 1._dp + ( ze3tp/tg_e3t_1d%d_value(1,1,ik,1) ) )
+                     tg_e3t_0%d_value  (ji,jj,ik  ,1) = ze3tp
+                     tg_e3t_0%d_value  (ji,jj,ik+1,1) = ze3tp
+                     tg_e3w_0%d_value  (ji,jj,ik  ,1) = ze3wp
+                     tg_e3w_0%d_value  (ji,jj,ik+1,1) = ze3tp
+
+                     tg_gdepw_0%d_value(ji,jj,ik+1,1) = zdepwp
+                     tg_gdept_0%d_value(ji,jj,ik  ,1) = tg_gdept_1d%d_value( 1, 1,ik-1,1) + ze3wp
+                     tg_gdept_0%d_value(ji,jj,ik+1,1) = tg_gdept_0%d_value (ji,jj,ik  ,1) + ze3tp
+                     !
+                  ELSE
+                     ! standard case
+                     IF( td_bathy%d_value(ji,jj,1,1) <= tg_gdepw_1d%d_value(1,1,ik+1,1) ) THEN
+                        tg_gdepw_0%d_value(ji,jj,ik+1,1) = td_bathy%d_value(ji,jj,1,1)
+                     ELSE
+                        tg_gdepw_0%d_value(ji,jj,ik+1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1)
+                     ENDIF
+                     !gm Bug?  check the gdepw_1d
+                     !       ... on ik
+                     tg_gdept_0%d_value(ji,jj,ik,1) = tg_gdepw_1d%d_value( 1, 1,ik  ,1) + &
+                     &        ( tg_gdepw_0%d_value(ji,jj,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) )  &
+                     &    * ( (tg_gdept_1d%d_value( 1, 1,ik  ,1) - tg_gdepw_1d%d_value(1,1,ik,1) )  &
+                     &      / (tg_gdepw_1d%d_value( 1, 1,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) )
+
+                     tg_e3t_0%d_value  (ji,jj,ik,1) = tg_e3t_1d%d_value  ( 1, 1,ik  ,1)            &
+                     &     * ( tg_gdepw_0%d_value (ji,jj,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) &
+                     &     / ( tg_gdepw_1d%d_value( 1, 1,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) 
+
+                     tg_e3w_0%d_value  (ji,jj,ik,1) = 0.5_dp   &
+                     &                               * ( tg_gdepw_0%d_value(ji,jj,ik+1,1) &
+                     &                                 + tg_gdepw_1d%d_value(1,1 ,ik+1,1) &
+                     &                                 - tg_gdepw_1d%d_value(1,1 ,ik  ,1) * 2._dp ) &
+                     &                               * ( tg_e3w_1d%d_value (1 ,1 ,ik  ,1) &
+                     &                                 / (tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1)) )
+
+                     !       ... on ik+1
+                     tg_e3w_0%d_value  (ji,jj,ik+1,1) = tg_e3t_0%d_value  (ji,jj,ik,1)
+                     tg_e3t_0%d_value  (ji,jj,ik+1,1) = tg_e3t_0%d_value  (ji,jj,ik,1)
+                     tg_gdept_0%d_value(ji,jj,ik+1,1) = tg_gdept_0%d_value(ji,jj,ik,1) + tg_e3t_0%d_value(ji,jj,ik,1)
+                  ENDIF
+                  !gm Bug?  check the gdepw_1d
+                  !       ... on ik
+                  tg_gdept_0%d_value(ji,jj,ik,1) = tg_gdepw_1d%d_value ( 1, 1,ik  ,1)   &
+                                                &    + ( tg_gdepw_0%d_value  (ji,jj,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) )&
+                                                &    * ( (tg_gdept_1d%d_value( 1, 1,ik  ,1) - tg_gdepw_1d%d_value(1,1,ik,1)) &
+                                                &      / (tg_gdepw_1d%d_value( 1, 1,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1)) )
+
+                  tg_e3t_0%d_value  (ji,jj,ik,1) = tg_e3t_1d%d_value  ( 1, 1,ik  ,1)   &
+                                                &    * ( tg_gdepw_0%d_value (ji,jj,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) &
+                                                &    / ( tg_gdepw_1d%d_value( 1, 1,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) 
+
+                  tg_e3w_0%d_value  (ji,jj,ik,1) = 0.5_dp   &
+                                                &     *  ( tg_gdepw_0%d_value (ji,jj,ik+1,1)   &
+                                                &        + tg_gdepw_1d%d_value( 1, 1,ik+1,1)   &
+                                                &        - tg_gdepw_1d%d_value( 1, 1,ik  ,1)*2._dp) &
+                                                &     *  ( tg_e3w_1d%d_value  ( 1, 1,ik  ,1)   &
+                                                &        / ( tg_gdepw_1d%d_value( 1, 1,ik+1,1)   &
+                                                &          - tg_gdepw_1d%d_value( 1, 1,ik  ,1) ) )
+
+                  !       ... on ik+1
+                  tg_e3w_0%d_value  (ji,jj,ik+1,1) = tg_e3t_0%d_value  (ji,jj,ik,1)
+                  tg_e3t_0%d_value  (ji,jj,ik+1,1) = tg_e3t_0%d_value  (ji,jj,ik,1)
+                  tg_gdept_0%d_value(ji,jj,ik+1,1) = tg_gdept_0%d_value(ji,jj,ik,1) + tg_e3t_0%d_value(ji,jj,ik,1)
+               ENDIF
+            END DO
+         END DO
+         !
+         it = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ik = tg_mbathy%d_value(ji,jj,1,1)
+               IF( ik > 0 ) THEN               ! ocean point only
+                  tg_e3tp%d_value (ji,jj,1,1) = tg_e3t_0%d_value(ji,jj,ik,1)
+                  tg_e3wp%d_value (ji,jj,1,1) = tg_e3w_0%d_value(ji,jj,ik,1)
+                  ! test
+                  zdiff= tg_gdepw_0%d_value(ji,jj,ik+1,1) - tg_gdept_0%d_value(ji,jj,ik,1)
+                  IF( zdiff <= 0._dp ) THEN 
+                     it = it + 1
+                     CALL logger_info(' it      = '//TRIM(fct_str(it))//&
+                        &             ' ik      = '//TRIM(fct_str(ik))//&
+                        &             ' (i,j)   = ('//TRIM(fct_str(ji))//','//TRIM(fct_str(jj))//')')
+                     CALL logger_info(' bathy = '//TRIM(fct_str(td_bathy%d_value(ji,jj,1,1))))
+                     CALL logger_info(' gdept_0 = '//TRIM(fct_str( tg_gdept_0%d_value(ji,jj,ik  ,1) ))//&
+                        &             ' gdepw_0 = '//TRIM(fct_str( tg_gdepw_0%d_value(ji,jj,ik+1,1) ))//&
+                        &             ' zdiff = '//TRIM(fct_str(zdiff)) )
+                     CALL logger_info(' e3tp    = '//TRIM(fct_str(tg_e3t_0%d_value(ji,jj,ik,1)))//&
+                        &             ' e3wp    = '//TRIM(fct_str(tg_e3w_0%d_value(ji,jj,ik,1)))  )
+                  ENDIF
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+      !
+!      IF ( td_nam%l_isfcav ) THEN
+!      ! (ISF) Definition of e3t, u, v, w for ISF case
+!         CALL grid_zgr__isf_fill_e3x( jpi,jpj, &
+!            &                        td_risfdep )
+!      END IF
+
+      ! Scale factors and depth at U-, V-, UW and VW-points
+      DO jk = 1, jpk
+         ! initialisation to z-scale factors
+         tg_e3u_0%d_value (:,:,jk,1) = tg_e3t_1d%d_value(1,1,jk,1)
+         tg_e3v_0%d_value (:,:,jk,1) = tg_e3t_1d%d_value(1,1,jk,1)
+         !tg_e3uw_0%d_value(:,:,jk,1) = tg_e3w_1d%d_value(1,1,jk,1)
+         !tg_e3vw_0%d_value(:,:,jk,1) = tg_e3w_1d%d_value(1,1,jk,1)
+      END DO
+
+      ! Computed as the minimum of neighbooring scale factors
+      DO jk = 1,jpk
+         DO jj = 1, jpj - 1
+            DO ji = 1, jpi - 1 
+               tg_e3u_0%d_value (ji,jj,jk,1) = MIN( tg_e3t_0%d_value(ji,jj,jk,1), tg_e3t_0%d_value(ji+1,jj  ,jk,1) )
+               tg_e3v_0%d_value (ji,jj,jk,1) = MIN( tg_e3t_0%d_value(ji,jj,jk,1), tg_e3t_0%d_value(ji  ,jj+1,jk,1) )
+               !tg_e3uw_0%d_value(ji,jj,jk,1) = MIN( tg_e3w_0%d_value(ji,jj,jk,1), tg_e3w_0%d_value(ji+1,jj  ,jk,1) )
+               !tg_e3vw_0%d_value(ji,jj,jk,1) = MIN( tg_e3w_0%d_value(ji,jj,jk,1), tg_e3w_0%d_value(ji  ,jj+1,jk,1) )
+            END DO
+         END DO
+      END DO
+
+      !IF ( td_nam%l_isfcav ) THEN
+      !   ! (ISF) define e3uw (adapted for 2 cells in the water column)
+      !   CALL grid_zgr__isf_fill_e3uw(jpi,jpj)
+      !END IF
+
+      ! lateral boundary conditions
+      CALL lbc_lnk( tg_e3u_0%d_value (:,:,:,1), 'U', td_nam%i_perio, 1._dp )
+      CALL lbc_lnk( tg_e3v_0%d_value (:,:,:,1), 'V', td_nam%i_perio, 1._dp )
+      !CALL lbc_lnk( tg_e3uw_0%d_value(:,:,:,1), 'U', td_nam%i_perio, 1._dp )
+      !CALL lbc_lnk( tg_e3vw_0%d_value(:,:,:,1), 'V', td_nam%i_perio, 1._dp )
+
+      ! set to z-scale factor if zero (i.e. along closed boundaries)
+      DO jk = 1, jpk
+         WHERE( tg_e3u_0%d_value (:,:,jk,1) == 0._dp )   tg_e3u_0%d_value (:,:,jk,1) = tg_e3t_1d%d_value(1,1,jk,1)
+         WHERE( tg_e3v_0%d_value (:,:,jk,1) == 0._dp )   tg_e3v_0%d_value (:,:,jk,1) = tg_e3t_1d%d_value(1,1,jk,1)
+         !WHERE( tg_e3uw_0%d_value(:,:,jk,1) == 0._dp )   tg_e3uw_0%d_value(:,:,jk,1) = tg_e3w_1d%d_value(1,1,jk,1)
+         !WHERE( tg_e3vw_0%d_value(:,:,jk,1) == 0._dp )   tg_e3vw_0%d_value(:,:,jk,1) = tg_e3w_1d%d_value(1,1,jk,1)
+      END DO
+
+      !! Scale factor at F-point
+      !DO jk = 1, jpk                        
+      !   ! initialisation to z-scale factors
+      !   tg_e3f_0%d_value(:,:,jk,1) = tg_e3t_1d%d_value(1,1,jk,1)
+      !END DO
+      !
+      !! Computed as the minimum of neighbooring V-scale factors
+      !DO jk = 1, jpk
+      !   DO jj = 1, jpj - 1
+      !      DO ji = 1, jpi - 1
+      !         tg_e3f_0%d_value(ji,jj,jk,1) = MIN( tg_e3v_0%d_value(ji,jj,jk,1), tg_e3v_0%d_value(ji+1,jj,jk,1) )
+      !      END DO
+      !   END DO
+      !END DO
+      !! Lateral boundary conditions
+      !CALL lbc_lnk( tg_e3f_0%d_value(:,:,:,1), 'F', td_nam%i_perio, 1._dp )
+      !
+      !! set to z-scale factor if zero (i.e. along closed boundaries)
+      !DO jk = 1, jpk
+      !   WHERE( tg_e3f_0%d_value(:,:,jk,1) == 0._dp )   tg_e3f_0%d_value(:,:,jk,1) = tg_e3t_1d%d_value(1,1,jk,1)
+      !END DO
+
+!!gm  bug ? :  must be a do loop with mj0,mj1
+
+      ! we duplicate factor scales for jj = 1 and jj = 2
+      tg_e3t_0%d_value(:,1,:,1) = tg_e3t_0%d_value(:,2,:,1)
+      tg_e3w_0%d_value(:,1,:,1) = tg_e3w_0%d_value(:,2,:,1) 
+      tg_e3u_0%d_value(:,1,:,1) = tg_e3u_0%d_value(:,2,:,1) 
+      tg_e3v_0%d_value(:,1,:,1) = tg_e3v_0%d_value(:,2,:,1) 
+      !tg_e3f_0%d_value(:,1,:,1) = tg_e3f_0%d_value(:,2,:,1)
+
+      ! Control of the sign
+      IF( MINVAL( tg_e3t_0%d_value  (:,:,:,:) ) <= 0._dp )   CALL logger_fatal( ' GRID ZGR ZPS:   e r r o r   e3t_0 <= 0' )
+      IF( MINVAL( tg_e3w_0%d_value  (:,:,:,:) ) <= 0._dp )   CALL logger_fatal( ' GRID ZGR ZPS:   e r r o r   e3w_0 <= 0' )
+      IF( MINVAL( tg_gdept_0%d_value(:,:,:,:) ) <  0._dp )   CALL logger_fatal( ' GRID ZGR ZPS:   e r r o r   gdept_0 <  0' )
+      IF( MINVAL( tg_gdepw_0%d_value(:,:,:,:) ) <  0._dp )   CALL logger_fatal( ' GRID ZGR ZPS:   e r r o r   gdepw_0 <  0' )
+
+      !! Compute gdep3w_0 (vertical sum of e3w)
+      !IF ( td_nam%l_isfcav ) THEN 
+      !   ! if cavity
+      !   CALL grid_zgr__isf_fill_gdep3w_0(jpi, jpj, jpk, td_risfdep)
+      !ELSE 
+      !   ! no cavity
+      !   tg_gdep3w_0%d_value(:,:,1,1) = 0.5_dp * tg_e3w_0%d_value(:,:,1,1)
+      !   DO jk = 2, jpk
+      !      tg_gdep3w_0%d_value(:,:,jk,1) = tg_gdep3w_0%d_value(:,:,jk-1,1) + tg_e3w_0%d_value(:,:,jk,1)
+      !   END DO
+      !END IF
+
+   END SUBROUTINE grid_zgr__zps_fill
+   !-------------------------------------------------------------------
+   !> @brief This subroutine check the bathymetry in levels
+   !>
+   !> @details
+   !> ** Method  :   THe water column have to contained at least 2 cells
+   !>                Bathymetry and isfdraft are modified (dig/close) to respect
+   !>                this criterion.
+   !>                 
+   !>   
+   !> ** Action  : - test compatibility between isfdraft and bathy 
+   !>              - bathy and isfdraft are modified   
+   !> 
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_isf
+   !> @date October, 2016
+   !> - add ice sheet coupling case
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !> @param[in] td_bathy
+   !> @param[in] td_risfdep
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__isf_fill( td_nam, jpi,jpj,jpk, td_bathy, td_risfdep) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      TYPE(TVAR) , INTENT(INOUT) :: td_bathy
+      TYPE(TVAR) , INTENT(INOUT) :: td_risfdep
+
+      ! local variable
+      INTEGER(i4) :: ik, it
+      INTEGER(i4) :: ibtest, ibtestim1, ibtestip1, ibtestjm1, ibtestjp1   ! (ISF)
+
+      INTEGER(i4), ALLOCATABLE, DIMENSION(:,:) :: zmbathy, zmisfdep     ! 2D workspace (ISH)
+
+      REAL(dp)    :: zdepth           ! Ajusted ocean depth to avoid too small e3t
+      REAL(dp)    :: zmax             ! Maximum and minimum depth
+      REAL(dp)    :: zbathydiff, zrisfdepdiff  ! isf temporary scalar
+      REAL(dp)    :: zdepwp           ! Ajusted ocean depth to avoid too small e3t
+      REAL(dp)    :: ze3tp , ze3wp    ! Last ocean level thickness at T- and W-points
+      REAL(dp)    :: zdiff            ! temporary scalar
+
+      REAL(dp), ALLOCATABLE, DIMENSION(:,:) :: zrisfdep, zmask   ! 2D workspace (ISH)
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      INTEGER(i4) :: jl
+      
+      !----------------------------------------------------------------
+
+      ! (ISF) compute misfdep
+      WHERE( td_risfdep%d_value(:,:,1,1) == 0._dp .AND. &
+           & td_bathy%d_value  (:,:,1,1) /= 0 )
+        ! open water : set misfdep to 1
+        tg_misfdep%d_value(:,:,1,1) = 1
+      ELSEWHERE
+         ! iceshelf : initialize misfdep to second level
+         tg_misfdep%d_value(:,:,1,1) = 2
+      END WHERE
+
+      ALLOCATE(zmask   (jpi,jpj))
+      ALLOCATE(zrisfdep(jpi,jpj))
+      ALLOCATE(zmisfdep(jpi,jpj))
+
+      ! Compute misfdep for ocean points (i.e. first wet level) 
+      ! find the first ocean level such that the first level thickness 
+      ! is larger than the bot_level of e3zps_min and e3zps_rat * e3t_0 (where 
+      ! e3t_0 is the reference level thickness
+      DO jk = 2, jpk-1 
+         zdepth = tg_gdepw_1d%d_value(1,1,jk+1,1) - MIN( td_nam%d_e3zps_min, &
+            &                                            td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,jk,1) ) 
+         WHERE( 0._dp < td_risfdep%d_value(:,:,1,1) .AND. &
+         &              td_risfdep%d_value(:,:,1,1) >= zdepth )
+            tg_misfdep%d_value(:,:,1,1) = jk+1 
+         END WHERE
+      END DO 
+
+      WHERE( 0._dp < td_risfdep%d_value(:,:,1,1) .AND. &
+           &         td_risfdep%d_value(:,:,1,1) <= tg_e3t_1d%d_value(1,1,1,1) )
+         td_risfdep%d_value(:,:,1,1) = 0.
+         tg_misfdep%d_value(:,:,1,1) = 1
+      END WHERE
+
+      ! remove very shallow ice shelf (less than ~ 10m if 75L)
+      WHERE( td_risfdep%d_value(:,:,1,1) <= 10._wp .AND. &
+           & tg_misfdep%d_value(:,:,1,1) > 1 )
+         tg_misfdep%d_value(:,:,1,1) = 0
+         td_risfdep%d_value(:,:,1,1) = 0.0_wp
+         tg_mbathy%d_value (:,:,1,1) = 0
+         td_bathy%d_value  (:,:,1,1) = 0.0_wp
+      END WHERE
+      WHERE( td_bathy%d_value(:,:,1,1) <= 30.0_wp .AND. &
+           & tg_gphit%d_value(:,:,1,1) < -60._wp )
+         tg_misfdep%d_value(:,:,1,1) = 0
+         td_risfdep%d_value(:,:,1,1) = 0.0_wp
+         tg_mbathy%d_value (:,:,1,1) = 0
+         td_bathy%d_value  (:,:,1,1) = 0.0_wp
+      END WHERE
+
+      ! basic check for the compatibility of bathy and risfdep. 
+      ! I think it should be offline because it is not perfect and cannot solved all the situation
+      ! run the bathy check 10 times to be sure all the modif in the bathy or iceshelf draft are compatible together
+      DO jl = 1, 10
+
+         WHERE( td_bathy%d_value(:,:,1,1) <= td_risfdep%d_value(:,:,1,1) + td_nam%d_isfhmin )
+            tg_misfdep%d_value(:,:,1,1) = 0
+            td_risfdep%d_value(:,:,1,1) = 0._dp
+            tg_mbathy%d_value (:,:,1,1) = 0
+            td_bathy%d_value  (:,:,1,1) = 0._dp
+         END WHERE
+
+         WHERE( tg_mbathy%d_value(:,:,1,1) <= 0 )
+            tg_misfdep%d_value(:,:,1,1) = 0 
+            td_risfdep%d_value(:,:,1,1) = 0._dp
+            tg_mbathy%d_value (:,:,1,1) = 0
+            td_bathy%d_value  (:,:,1,1) = 0._dp
+         ENDWHERE
+
+         !! lk_mpp not added
+
+         IF( td_nam%i_perio == 1 .OR. &
+           & td_nam%i_perio == 4 .OR. &
+           & td_nam%i_perio == 6 )THEN 
+            ! local domain is cyclic east-west
+            tg_misfdep%d_value( 1 ,:,1,1) = tg_misfdep%d_value(jpi-1,:,1,1)
+            tg_misfdep%d_value(jpi,:,1,1) = tg_misfdep%d_value(  2  ,:,1,1) 
+
+            tg_mbathy%d_value( 1 ,:,1,1) = tg_mbathy%d_value(jpi-1,:,1,1)
+            tg_mbathy%d_value(jpi,:,1,1) = tg_mbathy%d_value(  2  ,:,1,1)
+         ENDIF
+
+         ! split last cell if possible (only where water column is 2 cell or less)
+         ! if coupled to ice sheet, we do not modify the bathymetry (can be discuss).
+         IF( .NOT. td_nam%l_iscpl )THEN
+            DO jk = jpk-1, 1, -1
+               zmax = tg_gdepw_1d%d_value(1,1,jk,1) + &
+                  &   MIN( td_nam%d_e3zps_min, &
+                  &        td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,jk,1) )
+
+               WHERE( td_bathy%d_value(:,:,1,1)       >  tg_gdepw_1d%d_value(1,1,jk,1).AND. &
+                   &  td_bathy%d_value(:,:,1,1)       <= zmax                         .AND. &
+                   &  tg_misfdep%d_value(:,:,1,1) + 1 >= tg_mbathy%d_value(:,:,1,1) )
+
+                  tg_mbathy%d_value(:,:,1,1) = jk
+                  td_bathy%d_value (:,:,1,1) = zmax
+
+               END WHERE
+            END DO
+         ENDIF
+
+         ! split top cell if possible (only where water column is 2 cell or less)
+         DO jk = 2, jpk-1
+            zmax = tg_gdepw_1d%d_value(1,1,jk+1,1) - &
+               &   MIN( td_nam%d_e3zps_min, &
+               &        td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,jk,1) )
+
+            WHERE( td_risfdep%d_value(:,:,1,1)     <  tg_gdepw_1d%d_value(1,1,jk+1,1) .AND. &
+                &  td_risfdep%d_value(:,:,1,1)     >= zmax                            .AND. &
+                &  tg_misfdep%d_value(:,:,1,1) + 1 >= tg_mbathy%d_value(:,:,1,1) )
+
+               tg_misfdep%d_value(:,:,1,1) = jk
+               td_risfdep%d_value(:,:,1,1) = zmax
+
+            END WHERE
+         END DO
+
+         ! Case where bathy and risfdep compatible but not the level 
+         ! variable mbathy/misfdep because of partial cell condition
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ! find the minimum change option:
+               ! test bathy
+               IF( td_risfdep%d_value(ji,jj,1,1) > 1 )THEN
+                  IF( .NOT. td_nam%l_iscpl )THEN
+
+                     ik=tg_mbathy%d_value(ji,jj,1,1)
+                     zbathydiff = ABS( td_bathy%d_value(ji,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                        &              + MIN(td_nam%d_e3zps_min,                                       &
+                        &                    td_nam%d_e3zps_rat * tg_e3t_1d%d_value(1,1,ik+1,1)) ))
+
+                     ik=tg_misfdep%d_value(ji,jj,1,1)
+                     zrisfdepdiff = ABS( td_risfdep%d_value(ji,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik,1) &
+                        &                - MIN( td_nam%d_e3zps_min,                                      &
+                        &                       td_nam%d_e3zps_rat * tg_e3t_1d%d_value(1,1,ik-1,1)) ))
+ 
+                     IF( td_bathy%d_value (ji,jj,1,1) > td_risfdep%d_value (ji,jj,1,1) .AND. &
+                      &  tg_mbathy%d_value(ji,jj,1,1) < tg_misfdep%d_value(ji,jj,1,1) )THEN
+
+                        IF( zbathydiff <= zrisfdepdiff )THEN
+
+                           tg_mbathy%d_value(ji,jj,1,1) = tg_mbathy%d_value(ji,jj,1,1) + 1
+
+                           ik=tg_mbathy%d_value(ji,jj,1,1)
+                           td_bathy%d_value (ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                              &                           MIN( td_nam%d_e3zps_min, &
+                              &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1) )
+                        ELSE
+
+                           tg_misfdep%d_value(ji,jj,1,1) = tg_misfdep%d_value(ji,jj,1,1) - 1
+
+                           ik=tg_misfdep%d_value(ji,jj,1,1)
+                           td_risfdep%d_value(ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) - &
+                              &                            MIN( td_nam%d_e3zps_min, &
+                              &                                 td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1) )
+                        ENDIF
+
+                     ENDIF
+
+                  ELSE
+
+                     IF( td_bathy%d_value (ji,jj,1,1) > td_risfdep%d_value (ji,jj,1,1) .AND. &
+                       & tg_mbathy%d_value(ji,jj,1,1) < tg_misfdep%d_value(ji,jj,1,1) )THEN
+
+                        tg_misfdep%d_value(ji,jj,1,1) = tg_misfdep%d_value(ji,jj,1,1) - 1
+                    
+                        ik=tg_misfdep%d_value(ji,jj,1,1)
+                        td_risfdep%d_value(ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) - &
+                           &                            MIN( td_nam%d_e3zps_min, &
+                           &                                 td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1) )
+                     ENDIF
+
+                  ENDIF
+
+               ENDIF
+            ENDDO
+         ENDDO
+
+          ! At least 2 levels for water thickness at T, U, and V point.
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ! find the minimum change option:
+               ! test bathy
+               IF( tg_misfdep%d_value(ji,jj,1,1) == tg_mbathy%d_value(ji,jj,1,1) .AND. &
+                 & tg_mbathy%d_value (ji,jj,1,1) > 1) THEN
+
+                  IF ( .NOT. td_nam%l_iscpl ) THEN
+
+                     ik=tg_mbathy%d_value(ji,jj,1,1)
+                     zbathydiff  = ABS( td_bathy%d_value(ji,jj,1,1)  - ( tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                        &               + MIN( td_nam%d_e3zps_min, &
+                        &                      td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1)) ))
+
+                     ik=tg_misfdep%d_value(ji,jj,1,1)
+                     zrisfdepdiff = ABS( td_risfdep%d_value(ji,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik,1) &
+                        &                - MIN( td_nam%d_e3zps_min, &
+                        &                       td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1)) ))
+
+                     IF( zbathydiff <= zrisfdepdiff )THEN
+
+                        tg_mbathy%d_value(ji,jj,1,1) = tg_mbathy%d_value(ji,jj,1,1) + 1
+
+                        ik=tg_mbathy%d_value(ji,jj,1,1)
+                        td_bathy%d_value(ji,jj,1,1)  = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                           &                           MIN( td_nam%d_e3zps_min, &
+                           &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1) )
+                     ELSE
+
+                        tg_misfdep%d_value(ji,jj,1,1) = tg_misfdep%d_value(ji,jj,1,1) - 1
+
+                        ik=tg_misfdep%d_value(ji,jj,1,1)
+                        td_risfdep%d_value(ji,jj,1,1)  = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                           &                            MIN( td_nam%d_e3zps_min, &
+                           &                                 td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                     ENDIF
+
+                  ELSE
+
+                     tg_misfdep%d_value(ji,jj,1,1) = tg_misfdep%d_value(ji,jj,1,1) - 1
+
+                     ik=tg_misfdep%d_value(ji,jj,1,1)
+                     td_risfdep%d_value(ji,jj,1,1)  = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                        &                            MIN( td_nam%d_e3zps_min, &
+                        &                                 td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+
+                  ENDIF
+               ENDIF
+
+            ENDDO
+         ENDDO
+
+         ! point V mbathy(ji,jj  ) == misfdep(ji,jj+1) 
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+
+               IF( tg_mbathy%d_value(ji,jj  ,1,1) == tg_misfdep%d_value(ji,jj+1,1,1) .AND. &
+                &  tg_mbathy%d_value(ji,jj  ,1,1) >  1 )THEN
+                  IF ( .NOT. td_nam%l_iscpl ) THEN
+
+                     ik=tg_mbathy%d_value(ji,jj  ,1,1)
+                     zbathydiff = ABS( td_bathy%d_value(ji,jj  ,1,1) - ( tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                        &              + MIN( td_nam%d_e3zps_min,                                        &
+                        &                     td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1)) ))
+
+                     ik=tg_misfdep%d_value(ji,jj+1,1,1)
+                     zrisfdepdiff = ABS( td_risfdep%d_value(ji,jj+1,1,1) - ( tg_gdepw_1d%d_value(1,1,ik,1) &
+                        &                - MIN( td_nam%d_e3zps_min,                                        &
+                        &                       td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1)) ))
+
+                     IF( zbathydiff <= zrisfdepdiff )THEN
+
+                        tg_mbathy%d_value(ji,jj  ,1,1) = tg_mbathy%d_value(ji,jj  ,1,1) + 1
+
+                        ik=tg_mbathy%d_value(ji,jj  ,1,1)
+                        td_bathy%d_value (ji,jj  ,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                           &                           MIN( td_nam%d_e3zps_min, &
+                           &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1) )
+                     ELSE
+
+                        tg_misfdep%d_value(ji,jj+1,1,1) = tg_misfdep%d_value(ji,jj+1,1,1) - 1
+
+                        ik=tg_misfdep%d_value(ji,jj+1,1,1)
+                        td_risfdep%d_value(ji,jj+1,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                           &                             MIN( td_nam%d_e3zps_min, &
+                           &                                  td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                     ENDIF
+
+                  ELSE
+                     tg_misfdep%d_value(ji,jj+1,1,1) = tg_misfdep%d_value(ji,jj+1,1,1) - 1
+
+                     ik=tg_misfdep%d_value(ji,jj+1,1,1)
+                     td_risfdep%d_value(ji,jj+1,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                        &                             MIN( td_nam%d_e3zps_min, &
+                        &                                  td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                  ENDIF
+
+               ENDIF
+
+            ENDDO
+         ENDDO
+
+         !! lk_mpp not added
+
+         ! point V mbathy(ji,jj+1) == misfdep(ji,jj  ) 
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+
+               IF( tg_mbathy%d_value(ji,jj+1,1,1) == tg_misfdep%d_value(ji,jj  ,1,1) .AND. &
+                &  tg_mbathy%d_value(ji,jj  ,1,1) > 1) THEN
+                  IF ( .NOT. td_nam%l_iscpl ) THEN
+
+                     ik=tg_mbathy%d_value(ji,jj+1,1,1)
+                     zbathydiff = ABS( td_bathy%d_value(ji,jj+1,1,1) - ( tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                        &              + MIN( td_nam%d_e3zps_min,                                        &
+                        &                     td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1)) ))
+
+                     ik=tg_misfdep%d_value(ji,jj  ,1,1)
+                     zrisfdepdiff = ABS( td_risfdep%d_value(ji,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik,1) &
+                        &                - MIN( td_nam%d_e3zps_min,                                      &
+                        &                       td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1)) ))
+
+                     IF( zbathydiff <= zrisfdepdiff )THEN
+
+                        tg_mbathy%d_value (ji,jj+1,1,1) = tg_mbathy%d_value(ji,jj+1,1,1) + 1
+
+                        ik=tg_mbathy%d_value(ji,jj+1,1,1)
+                        td_bathy%d_value  (ji,jj+1,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                           &                            MIN( td_nam%d_e3zps_min,          &
+                           &                                 td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1) )
+                     ELSE
+
+                        tg_misfdep%d_value(ji,jj  ,1,1) = tg_misfdep%d_value(ji,jj  ,1,1) - 1
+
+                        ik=tg_misfdep%d_value(ji,jj  ,1,1)
+                        td_risfdep%d_value(ji,jj  ,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                           &                           MIN( td_nam%d_e3zps_min,              &
+                           &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                     END IF
+
+                  ELSE
+
+                     tg_misfdep%d_value(ji,jj  ,1,1) = tg_misfdep%d_value(ji,jj  ,1,1) - 1
+
+                     ik=tg_misfdep%d_value(ji,jj  ,1,1)
+                     td_risfdep%d_value(ji,jj  ,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                        &                           MIN( td_nam%d_e3zps_min,           &
+                        &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+
+                  ENDIF
+               
+               ENDIF
+
+            ENDDO
+         ENDDO         
+
+         !! lk_mpp not added
+
+         ! point U mbathy(ji  ,jj) EQ misfdep(ji+1,jj)
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+
+               IF( tg_mbathy%d_value(ji  ,jj,1,1) == tg_misfdep%d_value(ji+1,jj,1,1) .AND. &
+                &  tg_mbathy%d_value(ji  ,jj,1,1) > 1 )THEN
+                  IF ( .NOT. td_nam%l_iscpl ) THEN
+
+                     ik=tg_mbathy%d_value(ji  ,jj,1,1)
+                     zbathydiff = ABS(     td_bathy%d_value(ji  ,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                        &              + MIN( td_nam%d_e3zps_min,                                     &
+                        &                     td_nam%d_e3zps_rat* tg_e3t_1d%d_value(1,1,ik+1,1)) ))
+
+                     ik=tg_misfdep%d_value(ji+1,jj,1,1)
+                     zrisfdepdiff = ABS( td_risfdep%d_value(ji+1,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik,1) &
+                        &                - MIN( td_nam%d_e3zps_min,                                       &
+                        &                       td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1)) ))
+
+                     IF( zbathydiff <= zrisfdepdiff )THEN
+
+                        tg_mbathy%d_value (ji  ,jj,1,1) = tg_mbathy%d_value(ji  ,jj,1,1) + 1
+
+                        ik=tg_mbathy%d_value(ji  ,jj,1,1)
+                        td_bathy%d_value  (ji  ,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                           &                           MIN( td_nam%d_e3zps_min, &
+                           &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1) )
+                     ELSE
+                        tg_misfdep%d_value(ji+1,jj,1,1) = tg_misfdep%d_value(ji+1,jj,1,1) - 1
+
+                        ik=tg_misfdep%d_value(ji+1,jj,1,1)
+                        td_risfdep%d_value(ji+1,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                           &                             MIN( td_nam%d_e3zps_min, &
+                           &                                  td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                     END IF
+
+                  ELSE
+                     tg_misfdep%d_value(ji+1,jj,1,1)= tg_misfdep%d_value(ji+1,jj,1,1) - 1
+
+                     ik=tg_misfdep%d_value(ji+1,jj,1,1)
+                     td_risfdep%d_value(ji+1,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                        &                             MIN( td_nam%d_e3zps_min, &
+                        &                                  td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                  ENDIF
+               ENDIF
+
+            ENDDO
+         ENDDO
+
+         !! lk_mpp not added
+
+         ! point U mbathy(ji+1,jj) == misfdep(ji  ,jj) 
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+
+               IF( tg_mbathy%d_value(ji+1,jj,1,1) == tg_misfdep%d_value(ji  ,jj,1,1) .AND. &
+                &  tg_mbathy%d_value(ji  ,jj,1,1) > 1 )THEN
+                  IF ( .NOT. td_nam%l_iscpl ) THEN
+
+                     ik=tg_mbathy%d_value(ji+1,jj,1,1)
+                     zbathydiff = ABS(     td_bathy%d_value(ji+1,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                        &              + MIN( td_nam%d_e3zps_min,                                        &
+                        &                     td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1)) ))
+
+                     ik=tg_misfdep%d_value(ji ,jj,1,1)
+                     zrisfdepdiff = ABS( td_risfdep%d_value(ji  ,jj,1,1) - ( tg_gdepw_1d%d_value(1,1,ik,1) &
+                        &                - MIN( td_nam%d_e3zps_min,                                      &
+                        &                       td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik-1,1)) ))
+
+                     IF( zbathydiff <= zrisfdepdiff )THEN
+
+                        tg_mbathy%d_value (ji+1,jj,1,1) = tg_mbathy%d_value(ji+1,jj,1,1) + 1
+
+                        ik=tg_mbathy%d_value(ji+1,jj,1,1)
+                        td_bathy%d_value  (ji+1,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                           &                            MIN( td_nam%d_e3zps_min, &
+                           &                                 td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik+1,1) )
+                     ELSE
+                        tg_misfdep%d_value(ji  ,jj,1,1) = tg_misfdep%d_value(ji  ,jj,1,1) - 1
+
+                        ik=tg_misfdep%d_value(ji  ,jj,1,1)
+                        td_risfdep%d_value(ji  ,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                           &                           MIN( td_nam%d_e3zps_min, &
+                           &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+                     END IF
+
+                  ELSE
+
+                     tg_misfdep%d_value(ji ,jj,1,1) = tg_misfdep%d_value(ji ,jj,1,1) - 1
+
+                     ik=tg_misfdep%d_value(ji  ,jj,1,1)
+                     td_risfdep%d_value(ji  ,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - &
+                        &                           MIN( td_nam%d_e3zps_min, &
+                        &                                td_nam%d_e3zps_rat*tg_e3t_1d%d_value(1,1,ik,1) )
+
+                  ENDIF
+
+               ENDIF
+
+            ENDDO
+         ENDDO
+
+      END DO ! jl 
+      ! end dig bathy/ice shelf to be compatible
+
+      ! now fill single point in "coastline" of ice shelf, bathy, hole, and test again one cell tickness
+      DO jl = 1,20
+
+         ! remove single point "bay" on isf coast line in the ice shelf draft'
+         DO jk = 2, jpk
+            WHERE( tg_misfdep%d_value(:,:,1,1) == 0 )
+               tg_misfdep%d_value(:,:,1,1)=jpk
+            END WHERE
+
+            zmask(:,:)=0
+            WHERE( tg_misfdep%d_value(:,:,1,1) <= jk ) zmask(:,:)=1
+            
+            DO jj = 2, jpj-1
+               DO ji = 2, jpi-1
+                  IF( tg_misfdep%d_value(ji,jj,1,1) == jk )THEN
+
+                     ibtest =   zmask(ji-1,jj  ) &
+                        &     + zmask(ji+1,jj  ) &
+                        &     + zmask(ji  ,jj-1) &
+                        &     + zmask(ji  ,jj+1)
+                     IF( ibtest <= 1 )THEN
+                        td_risfdep%d_value(ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,jk+1,1)
+                        tg_misfdep%d_value(ji,jj,1,1) = jk+1
+                        IF( tg_misfdep%d_value(ji,jj,1,1) > tg_mbathy%d_value(ji,jj,1,1) )THEN
+                           tg_misfdep%d_value(ji,jj,1,1) = jpk
+                        ENDIF
+                     ENDIF
+
+                  ENDIF
+               ENDDO
+            ENDDO
+         ENDDO
+
+         WHERE( tg_misfdep%d_value(:,:,1,1) == jpk )
+             tg_misfdep%d_value(:,:,1,1)=0
+             td_risfdep%d_value(:,:,1,1)=0.
+             tg_mbathy%d_value (:,:,1,1)=0
+             td_bathy%d_value  (:,:,1,1)=0.
+         END WHERE
+
+         !! lk_mpp not added
+
+         ! remove single point "bay" on bathy coast line beneath an ice shelf'
+         DO jk = jpk,1,-1
+
+            zmask(:,:)=0
+            WHERE( tg_mbathy%d_value(:,:,1,1) >= jk ) zmask(:,:)=1
+
+            DO jj = 2, jpj-1
+               DO ji = 2, jpi-1
+                  IF( tg_mbathy%d_value (ji,jj,1,1) == jk .AND. &
+                    & tg_misfdep%d_value(ji,jj,1,1) >= 2 )THEN
+
+                     ibtest =   zmask(ji-1,jj  ) &
+                        &     + zmask(ji+1,jj  ) &
+                        &     + zmask(ji  ,jj-1) &
+                        &     + zmask(ji  ,jj+1)
+                     IF( ibtest <= 1 )THEN
+                        td_bathy%d_value (ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,jk,1)
+                        tg_mbathy%d_value(ji,jj,1,1) = jk-1
+                        IF( tg_misfdep%d_value(ji,jj,1,1) > tg_mbathy%d_value(ji,jj,1,1) )THEN
+                           tg_mbathy%d_value(ji,jj,1,1) = 0
+                        ENDIF
+                     ENDIF
+
+                  ENDIF
+               ENDDO
+            ENDDO
+         ENDDO
+
+         WHERE( tg_mbathy%d_value(:,:,1,1) == 0 )
+             tg_misfdep%d_value(:,:,1,1)=0
+             td_risfdep%d_value(:,:,1,1)=0.
+             tg_mbathy%d_value (:,:,1,1)=0
+             td_bathy%d_value  (:,:,1,1)=0.
+         END WHERE
+
+         !! lk_mpp not added
+
+         ! fill hole in ice shelf
+         zmisfdep(:,:) = tg_misfdep%d_value(:,:,1,1)
+         zrisfdep(:,:) = td_risfdep%d_value(:,:,1,1)
+         WHERE( zmisfdep(:,:) <= 1 ) zmisfdep(:,:)=jpk
+
+         DO jj = 2, jpj-1
+            DO ji = 2, jpi-1
+
+               ibtestim1 = zmisfdep(ji-1,jj  )
+               ibtestip1 = zmisfdep(ji+1,jj  )
+               
+               ibtestjm1 = zmisfdep(ji  ,jj-1)
+               ibtestjp1 = zmisfdep(ji  ,jj+1)
+
+               IF( zmisfdep(ji,jj) >= tg_mbathy%d_value(ji-1,jj  ,1,1) ) ibtestim1 = jpk
+               IF( zmisfdep(ji,jj) >= tg_mbathy%d_value(ji+1,jj  ,1,1) ) ibtestip1 = jpk
+               IF( zmisfdep(ji,jj) >= tg_mbathy%d_value(ji  ,jj-1,1,1) ) ibtestjm1 = jpk
+               IF( zmisfdep(ji,jj) >= tg_mbathy%d_value(ji  ,jj+1,1,1) ) ibtestjp1 = jpk
+
+               ibtest=MIN(ibtestim1, ibtestip1, ibtestjm1, ibtestjp1)
+               IF( ibtest == jpk .AND. &
+                 & tg_misfdep%d_value(ji,jj,1,1) >= 2 )THEN
+                  tg_mbathy%d_value (ji,jj,1,1) = 0
+                  td_bathy%d_value  (ji,jj,1,1) = 0.0_dp
+                  tg_misfdep%d_value(ji,jj,1,1) = 0
+                  td_risfdep%d_value(ji,jj,1,1) = 0.0_dp
+               END IF
+
+               IF( zmisfdep(ji,jj) < ibtest .AND. &
+                 & tg_misfdep%d_value(ji,jj,1,1) >= 2 )THEN
+                  tg_misfdep%d_value(ji,jj,1,1) = ibtest
+                  td_risfdep%d_value(ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ibtest,1)
+               ENDIF
+
+            ENDDO
+         ENDDO         
+
+         !! lk_mpp not added
+
+         !! fill hole in bathymetry
+         zmbathy(:,:) = tg_mbathy%d_value(:,:,1,1)
+         DO jj = 2, jpj-1
+            DO ji = 2, jpi-1
+
+               ibtestim1 = zmbathy(ji-1,jj  )
+               ibtestip1 = zmbathy(ji+1,jj  )
+
+               ibtestjm1 = zmbathy(ji  ,jj-1)
+               ibtestjp1 = zmbathy(ji  ,jj+1)
+
+               IF( zmbathy(ji,jj) < tg_misfdep%d_value(ji-1,jj  ,1,1) ) ibtestim1 = 0
+               IF( zmbathy(ji,jj) < tg_misfdep%d_value(ji+1,jj  ,1,1) ) ibtestip1 = 0
+               IF( zmbathy(ji,jj) < tg_misfdep%d_value(ji  ,jj-1,1,1) ) ibtestjm1 = 0
+               IF( zmbathy(ji,jj) < tg_misfdep%d_value(ji  ,jj+1,1,1) ) ibtestjp1 = 0
+
+               ibtest=MAX(ibtestim1, ibtestip1, ibtestjm1, ibtestjp1)
+               IF( ibtest == 0 .AND. tg_misfdep%d_value(ji,jj,1,1) >= 2) THEN
+                  tg_mbathy%d_value (ji,jj,1,1) = 0
+                  td_bathy%d_value  (ji,jj,1,1) = 0.0_dp
+                  tg_misfdep%d_value(ji,jj,1,1) = 0
+                  td_risfdep%d_value(ji,jj,1,1) = 0.0_dp
+               END IF
+
+               IF( ibtest < zmbathy(ji,jj) .AND. &
+               &   tg_misfdep%d_value(ji,jj,1,1) >= 2) THEN
+                  tg_mbathy%d_value(ji,jj,1,1) = ibtest
+                  td_bathy%d_value (ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ibtest+1,1) 
+               ENDIF
+
+            ENDDO
+         ENDDO
+
+         !! lk_mpp not added
+
+         ! if not compatible after all check (ie U point water column less than 2 cells), mask U
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+               IF( tg_mbathy%d_value(ji  ,jj,1,1) == tg_misfdep%d_value(ji+1,jj,1,1) .AND. &
+                 & tg_mbathy%d_value(ji  ,jj,1,1) >= 1   .AND. &
+                 & tg_mbathy%d_value(ji+1,jj,1,1) >= 1   )THEN
+
+                  tg_mbathy%d_value(ji,jj,1,1)  = tg_mbathy%d_value(ji,jj,1,1) - 1 
+
+                  ik=tg_mbathy%d_value(ji,jj,1,1)
+                  td_bathy%d_value (ji,jj,1,1)  = tg_gdepw_1d%d_value(1,1,ik+1,1)
+               ENDIF
+            ENDDO
+         ENDDO
+
+         !! lk_mpp not added
+
+         ! if not compatible after all check (ie U point water column less than 2 cells), mask U
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+               IF( tg_misfdep%d_value(ji  ,jj,1,1) == tg_mbathy%d_value(ji+1,jj,1,1) .AND. &
+                 & tg_mbathy%d_value (ji  ,jj,1,1) >= 1 .AND.&
+                 & tg_mbathy%d_value (ji+1,jj,1,1) >= 1 )THEN
+
+                  tg_mbathy%d_value(ji+1,jj,1,1)  = tg_mbathy%d_value(ji+1,jj,1,1) - 1
+
+                  ik=tg_mbathy%d_value(ji+1,jj,1,1)
+                  td_bathy%d_value(ji+1,jj,1,1)   = tg_gdepw_1d%d_value(1,1,ik+1,1)
+               ENDIF
+            ENDDO
+         ENDDO         
+
+         !! lk_mpp not added
+
+         ! if not compatible after all check (ie V point water column less than 2 cells), mask V
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi
+               IF( tg_mbathy%d_value(ji,jj  ,1,1) == tg_misfdep%d_value(ji,jj+1,1,1) .AND. &
+                 & tg_mbathy%d_value(ji,jj  ,1,1) >= 1 .AND. &
+                 & tg_mbathy%d_value(ji,jj+1,1,1) >= 1 )THEN
+
+                  tg_mbathy%d_value(ji,jj,1,1) = tg_mbathy%d_value(ji,jj,1,1) - 1
+
+                  ik=tg_mbathy%d_value(ji,jj,1,1)
+                  td_bathy%d_value (ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1)
+
+               ENDIF
+            ENDDO
+         ENDDO
+
+         !! lk_mpp not added
+
+         ! if not compatible after all check (ie V point water column less than 2 cells), mask V
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi
+               IF( tg_misfdep%d_value(ji,jj  ,1,1) == tg_mbathy%d_value(ji,jj+1,1,1) .AND.&
+                 & tg_mbathy%d_value (ji,jj  ,1,1) >= 1 .AND.&
+                 & tg_mbathy%d_value (ji,jj+1,1,1) >= 1 )THEN
+
+                  tg_mbathy%d_value(ji,jj+1,1,1) = tg_mbathy%d_value(ji,jj+1,1,1) - 1
+
+                  ik=tg_mbathy%d_value(ji,jj+1,1,1)
+                  td_bathy%d_value (ji,jj+1,1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1)
+               ENDIF
+            ENDDO
+         ENDDO
+
+         !! lk_mpp not added
+
+         ! if not compatible after all check, mask T
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tg_mbathy%d_value(ji,jj,1,1) <= tg_misfdep%d_value(ji,jj,1,1) )THEN
+                  tg_misfdep%d_value(ji,jj,1,1) = 0
+                  td_risfdep%d_value(ji,jj,1,1) = 0._dp
+                  tg_mbathy%d_value (ji,jj,1,1) = 0
+                  td_bathy%d_value  (ji,jj,1,1) = 0._dp
+               ENDIF
+            ENDDO
+         ENDDO
+ 
+         WHERE( tg_mbathy%d_value(:,:,1,1) == 1 )
+            tg_mbathy%d_value (:,:,1,1) = 0
+            td_bathy%d_value  (:,:,1,1) = 0.0_dp
+            tg_misfdep%d_value(:,:,1,1) = 0
+            td_risfdep%d_value(:,:,1,1) = 0.0_dp
+         END WHERE
+      ENDDO
+      ! end check compatibility ice shelf/bathy
+
+      ! remove very shallow ice shelf (less than ~ 10m if 75L)
+      WHERE( td_risfdep%d_value(:,:,1,1) <= 10._dp )
+         tg_misfdep%d_value(:,:,1,1) = 1
+         td_risfdep%d_value(:,:,1,1) = 0.0_dp;
+      END WHERE
+
+      DEALLOCATE(zmask   )
+      DEALLOCATE(zrisfdep)
+      DEALLOCATE(zmisfdep)
+
+      ! compute scale factor and depth at T- and W- points
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = tg_mbathy%d_value(ji,jj,1,1)
+            IF( ik > 0 ) THEN               ! ocean point only      
+               ! max ocean level case
+               IF( ik == jpk-1 ) THEN
+
+                  zdepwp = td_bathy%d_value(ji,jj,1,1)
+                  ze3tp  = td_bathy%d_value(ji,jj,1,1) - tg_gdepw_1d%d_value(1,1,ik,1)
+                  ze3wp  = 0.5_wp * tg_e3w_1d%d_value(1,1,ik,1) &
+                     &            * ( 1._wp + ( ze3tp/tg_e3t_1d%d_value(1,1,ik,1) ) )
+                  tg_e3t_0%d_value  (ji,jj,ik  ,1) = ze3tp
+                  tg_e3t_0%d_value  (ji,jj,ik+1,1) = ze3tp
+                  tg_e3w_0%d_value  (ji,jj,ik  ,1) = ze3wp
+                  tg_e3w_0%d_value  (ji,jj,ik+1,1) = ze3wp
+
+                  tg_gdepw_0%d_value(ji,jj,ik+1,1) = zdepwp
+                  tg_gdept_0%d_value(ji,jj,ik  ,1) = tg_gdept_1d%d_value(1 ,1 ,ik-1,1) + ze3wp
+                  tg_gdept_0%d_value(ji,jj,ik+1,1) = tg_gdept_0%d_value (ji,jj,ik  ,1) + ze3tp
+                  !
+               ELSE    ! standard case
+
+                  IF( td_bathy%d_value(ji,jj,1,1) <= tg_gdepw_1d%d_value(1,1,ik+1,1) ) THEN
+                     tg_gdepw_0%d_value(ji,jj,ik+1,1) = td_bathy%d_value(ji,jj,1,1)
+                  ELSE
+                     tg_gdepw_0%d_value(ji,jj,ik+1,1) = tg_gdepw_1d%d_value(1,1,ik+1,1)
+                  ENDIF      
+                  !
+                  !gm Bug?  check the gdepw_1d
+                  ! ... on ik
+                  tg_gdept_0%d_value(ji,jj,ik,1) = tg_gdepw_1d%d_value(1,1,ik,1) + &
+                     &     ( tg_gdepw_0%d_value(ji,jj,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) &
+                     & * ( ( tg_gdept_1d%d_value(1,1, ik  ,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) &
+                     &   / ( tg_gdepw_1d%d_value(1,1, ik+1,1) - tg_gdepw_1d%d_value(1,1,ik,1) ) )
+
+                  tg_e3t_0%d_value(ji,jj,ik  ,1) = tg_gdepw_0%d_value(ji,jj,ik+1,1) - tg_gdepw_1d%d_value(1,1,ik  ,1)
+                  tg_e3w_0%d_value(ji,jj,ik  ,1) = tg_gdept_0%d_value(ji,jj,ik  ,1) - tg_gdept_1d%d_value(1,1,ik-1,1)
+                  ! ... on ik+1
+                  tg_e3w_0%d_value(ji,jj,ik+1,1) = tg_e3t_0%d_value(ji,jj,ik,1)
+                  tg_e3t_0%d_value(ji,jj,ik+1,1) = tg_e3t_0%d_value(ji,jj,ik,1)
+                  !
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      !
+      it = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = tg_mbathy%d_value(ji,jj,1,1)
+            IF( ik > 0 ) THEN               ! ocean point only
+               tg_e3tp%d_value(ji,jj,1,1) = tg_e3t_0%d_value(ji,jj,ik,1)
+               tg_e3wp%d_value(ji,jj,1,1) = tg_e3w_0%d_value(ji,jj,ik,1)
+               ! test
+               zdiff= tg_gdepw_0%d_value(ji,jj,ik+1,1) - tg_gdept_0%d_value(ji,jj,ik,1)
+               IF( zdiff <= 0._dp ) THEN 
+                  it = it + 1
+                  CALL logger_info(' it    = '//TRIM(fct_str(it))//&
+                     &             ' ik    = '//TRIM(fct_str(ik))//&
+                     &             ' (i,j) = '//trim(fct_str(ji))//' '//TRIM(fct_str(jj)))
+                  CALL logger_info(' bathy = '//TRIM(fct_str(td_bathy%d_value(ji,jj,1,1))))
+                  CALL logger_info(' gdept_0 = '//TRIM(fct_str(tg_gdept_0%d_value(ji,jj,ik,1)))//&
+                     &             ' gdepw_0 = '//TRIM(fct_str(tg_gdepw_0%d_value(ji,jj,ik+1,1)))//&
+                     &             ' zdiff   = '//TRIM(fct_str(zdiff)))
+                  CALL logger_info(' e3tp    = '//TRIM(fct_str(tg_e3t_0%d_value(ji,jj,ik,1)))//&
+                     &             ' e3wp    = '//TRIM(fct_str(tg_e3w_0%d_value(ji,jj,ik,1))))
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      !
+      ! (ISF) Definition of e3t, u, v, w for ISF case
+      DO jj = 1, jpj 
+         DO ji = 1, jpi 
+            ik = tg_misfdep%d_value(ji,jj,1,1) 
+            IF( ik > 1 ) THEN               ! ice shelf point only 
+
+               IF( td_risfdep%d_value(ji,jj,1,1) < tg_gdepw_1d%d_value(1,1,ik,1) )THEN
+                   td_risfdep%d_value(ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) 
+               ENDIF
+               tg_gdepw_0%d_value(ji,jj,ik,1) = td_risfdep%d_value(ji,jj,1,1) 
+!gm Bug?  check the gdepw_0 
+            !       ... on ik 
+               tg_gdept_0%d_value(ji,jj,ik,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) &
+                  &        - ( tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdepw_0%d_value(ji,jj,ik,1) )   & 
+                  &        * ( tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdept_1d%d_value(1,1, ik,1) )   & 
+                  &        / ( tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdepw_1d%d_value(1,1, ik,1) ) 
+
+               tg_e3t_0%d_value(ji,jj,ik  ,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdepw_0%d_value(ji,jj,ik,1) 
+               tg_e3w_0%d_value(ji,jj,ik+1,1) = tg_gdept_1d%d_value(1,1,ik+1,1) - tg_gdept_0%d_value(ji,jj,ik,1)
+
+               IF( ik + 1 == tg_mbathy%d_value(ji,jj,1,1) )THEN    ! ice shelf point only (2 cell water column) 
+                  tg_e3w_0%d_value(ji,jj,ik+1,1) = tg_gdept_0%d_value(ji,jj,ik+1,1) - tg_gdept_0%d_value(ji,jj,ik,1) 
+               ENDIF 
+            !       ... on ik / ik-1 
+               tg_e3w_0%d_value  (ji,jj,ik  ,1) = tg_e3t_0%d_value  (ji,jj,ik,1) 
+               tg_e3t_0%d_value  (ji,jj,ik-1,1) = tg_gdepw_0%d_value(ji,jj,ik,1) - tg_gdepw_1d%d_value(1,1,ik-1,1)
+! The next line isn't required and doesn't affect results - included for consistency with bathymetry code 
+               tg_gdept_0%d_value(ji,jj,ik-1,1) = tg_gdept_1d%d_value(1,1,ik-1,1)
+
+            ENDIF 
+         END DO 
+      END DO
+
+      it = 0 
+      DO jj = 1, jpj 
+         DO ji = 1, jpi 
+            ik = tg_misfdep%d_value(ji,jj,1,1) 
+            IF( ik > 1 ) THEN               ! ice shelf point only 
+               tg_e3tp%d_value(ji,jj,1,1) = tg_e3t_0%d_value(ji,jj,ik  ,1) 
+               tg_e3wp%d_value(ji,jj,1,1) = tg_e3w_0%d_value(ji,jj,ik+1,1) 
+            ! test 
+               zdiff= tg_gdept_0%d_value(ji,jj,ik,1) - tg_gdepw_0%d_value(ji,jj,ik,1) 
+               IF( zdiff <= 0. ) THEN  
+                  it = it + 1 
+                  CALL logger_info(' it    = '//TRIM(fct_str(it))//&
+                  &                ' ik    = '//TRIM(fct_str(ik))//&
+                  &                ' (i,j) = '//trim(fct_str(ji))//' '//TRIM(fct_str(jj)))
+
+                  CALL logger_info(' risfdep = '//TRIM(fct_str(td_risfdep%d_value(ji,jj,1,1)))) 
+                  CALL logger_info(' gdept = '//TRIM(fct_str(tg_gdept_0%d_value(ji,jj,ik,1)))//&
+                  &                ' gdepw = '//TRIM(fct_str(tg_gdepw_0%d_value(ji,jj,ik+1,1)))//&
+                  &                ' zdiff = '//TRIM(fct_str(zdiff)))
+                  CALL logger_info(' e3tp  = '//TRIM(fct_str(tg_e3t_0%d_value(ji,jj,ik  ,1)))//&
+                  &                ' e3wp  = '//TRIM(fct_str(tg_e3w_0%d_value(ji,jj,ik+1,1))))
+               ENDIF 
+            ENDIF 
+         END DO 
+      END DO
+
+   END SUBROUTINE grid_zgr__isf_fill
+!   !-------------------------------------------------------------------
+!   !> @brief This subroutine define e3t, u, v, w for ISF case 
+!   !>
+!   !> @details
+!   !>
+!   !> @author J.Paul
+!   !> @date September, 2015 - rewrite from zgr_zps
+!   !>
+!   !> @param[in] jpi
+!   !> @param[in] jpj
+!   !> @param[in] td_risfdep
+!   !-------------------------------------------------------------------
+!   SUBROUTINE grid_zgr__isf_fill_e3x( jpi,jpj, &
+!         &                            td_risfdep) 
+!      IMPLICIT NONE
+!      ! Argument      
+!      INTEGER(i4), INTENT(IN   ) :: jpi
+!      INTEGER(i4), INTENT(IN   ) :: jpj
+!      TYPE(TVAR) , INTENT(INOUT) :: td_risfdep
+!
+!      ! local variable
+!      REAL(dp)    :: zdiff            ! temporary scalar
+!
+!      ! loop indices
+!      INTEGER(i4) :: ji
+!      INTEGER(i4) :: jj
+!      INTEGER(i4) :: it
+!      INTEGER(i4) :: ik
+!      !----------------------------------------------------------------
+!
+!      ! (ISF) Definition of e3t, u, v, w for ISF case
+!      DO jj = 1, jpj 
+!         DO ji = 1, jpi 
+!            ik = tg_misfdep%d_value(ji,jj,1,1) 
+!
+!            IF( ik > 1 ) THEN
+!               ! ice shelf point only
+!               IF( td_risfdep%d_value(ji,jj,1,1) < tg_gdepw_1d%d_value(1,1,ik,1) )THEN
+!                   td_risfdep%d_value(ji,jj,1,1) = tg_gdepw_1d%d_value(1,1,ik,1) 
+!               ENDIF
+!               tg_gdepw_0%d_value(ji,jj,ik,1) = td_risfdep%d_value(ji,jj,1,1) 
+!            !gm Bug?  check the gdepw_0 
+!            !       ... on ik 
+!               tg_gdept_0%d_value(ji,jj,ik  ,1) = tg_gdepw_1d%d_value(1,1,ik+1,1) - & 
+!                  &                               (tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdepw_0%d_value (ji,jj,ik,1)) * &
+!                  &                               (tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdept_1d%d_value( 1, 1,ik,1)) / & 
+!                  &                               (tg_gdepw_1d%d_value(1,1,ik+1,1) - tg_gdepw_1d%d_value( 1, 1,ik,1)) 
+!
+!               tg_e3t_0%d_value  (ji,jj,ik  ,1) = tg_gdepw_1d%d_value( 1, 1,ik+1,1) - &
+!                  &                               tg_gdepw_0%d_value (ji,jj,ik  ,1) 
+!
+!               tg_e3w_0%d_value  (ji,jj,ik+1,1) = tg_gdept_1d%d_value( 1, 1,ik+1,1) - &
+!                  &                               tg_gdept_0%d_value (ji,jj,ik  ,1)
+!
+!               IF( ik + 1 == tg_mbathy%d_value(ji,jj,1,1) ) THEN
+!
+!                  ! ice shelf point only (2 cell water column)
+!                  tg_e3w_0%d_value(ji,jj,ik+1,1) = tg_gdept_0%d_value(ji,jj,ik+1,1) - &
+!                     &                             tg_gdept_0%d_value(ji,jj,ik  ,1) 
+!
+!               ENDIF 
+!            !       ... on ik / ik-1 
+!               tg_e3w_0%d_value  (ji,jj,ik  ,1) = 2._dp * (tg_gdept_0%d_value(ji,jj,ik,1) - &
+!                  &                                        tg_gdepw_0%d_value(ji,jj,ik,1)) 
+!
+!               tg_e3t_0%d_value  (ji,jj,ik-1,1) = tg_gdepw_0%d_value (ji,jj,ik  ,1) - &
+!                  &                               tg_gdepw_1d%d_value( 1, 1,ik-1,1)
+!
+!               ! The next line isn't required and doesn't affect results - included for consistency with bathymetry code 
+!               tg_gdept_0%d_value(ji,jj,ik-1,1) = tg_gdept_1d%d_value(1,1,ik-1,1)
+!            ENDIF 
+!
+!         END DO 
+!      END DO 
+!      
+!      it = 0 
+!      DO jj = 1, jpj 
+!         DO ji = 1, jpi 
+!            ik = tg_misfdep%d_value(ji,jj,1,1) 
+!            IF( ik > 1 ) THEN               ! ice shelf point only 
+!               tg_e3tp%d_value(ji,jj,1,1) = tg_e3t_0%d_value(ji,jj,ik  ,1) 
+!               tg_e3wp%d_value(ji,jj,1,1) = tg_e3w_0%d_value(ji,jj,ik+1,1) 
+!            ! test 
+!               zdiff= tg_gdept_0%d_value(ji,jj,ik,1) - &
+!                  &   tg_gdepw_0%d_value(ji,jj,ik,1) 
+!
+!               IF( zdiff <= 0. ) THEN  
+!                  it = it + 1 
+!                  CALL logger_info(' it      = '//TRIM(fct_str(it))//&
+!                     &             ' ik      = '//TRIM(fct_str(ik))//&
+!                     &             ' (i,j)   =('//TRIM(fct_str(ji))//','//TRIM(fct_str(jj))//')')  
+!                  CALL logger_info(' risfdep = '//TRIM(fct_str(td_risfdep%d_value(ji,jj,1,1))) )
+!                  CALL logger_info(' gdept = '//TRIM(fct_str(tg_gdept_0%d_value(ji,jj,ik  ,1)))//&
+!                     &             ' gdepw = '//TRIM(fct_str(tg_gdepw_0%d_value(ji,jj,ik+1,1)))//&
+!                     &             ' zdiff = '//TRIM(fct_str(zdiff)) ) 
+!                  CALL logger_info(' e3tp  = '//TRIM(fct_str( tg_e3tp%d_value(ji,jj,1,1)))//&
+!                     &             ' e3wp  = '//TRIM(fct_str( tg_e3wp%d_value(ji,jj,1,1))) ) 
+!               ENDIF 
+!            ENDIF 
+!         END DO 
+!      END DO 
+!      ! END (ISF)
+!
+!   END SUBROUTINE grid_zgr__isf_fill_e3x
+!   !-------------------------------------------------------------------
+!   !> @brief This subroutine define e3uw 
+!   !>    (adapted for 2 cells in the water column) for ISF case 
+!   !>
+!   !> @details
+!   !>
+!   !> @author J.Paul
+!   !> @date September, 2015 - rewrite from zgr_zps
+!   !>
+!   !> @param[in] jpi
+!   !> @param[in] jpj
+!   !-------------------------------------------------------------------
+!   SUBROUTINE grid_zgr__isf_fill_e3uw(jpi,jpj) 
+!      IMPLICIT NONE
+!      ! Argument      
+!      INTEGER(i4)   , INTENT(IN   ) :: jpi
+!      INTEGER(i4)   , INTENT(IN   ) :: jpj
+!
+!      ! local variable
+!      INTEGER(i4) :: ikb, ikt
+!
+!      ! loop indices
+!      INTEGER(i4) :: ji
+!      INTEGER(i4) :: jj
+!      !----------------------------------------------------------------
+!
+!      DO jj = 2, jpj - 1 
+!         DO ji = 2, jpi - 1 
+!
+!            ikb = MAX(tg_mbathy%d_value (ji,jj,1,1), tg_mbathy%d_value (ji+1,jj,1,1))
+!            ikt = MAX(tg_misfdep%d_value(ji,jj,1,1), tg_misfdep%d_value(ji+1,jj,1,1))
+!            IF( ikb == ikt+1 )THEN
+!               tg_e3uw_0%d_value(ji,jj,ikb,1) = MIN( tg_gdept_0%d_value(ji,jj,ikb  ,1), tg_gdept_0%d_value(ji+1,jj  ,ikb  ,1) ) - &
+!               &                                MAX( tg_gdept_0%d_value(ji,jj,ikb-1,1), tg_gdept_0%d_value(ji+1,jj  ,ikb-1,1) )
+!            ENDIF
+!            
+!            ikb = MAX( tg_mbathy%d_value (ji,jj,1,1), tg_mbathy%d_value (ji,jj+1,1,1))
+!            ikt = MAX( tg_misfdep%d_value(ji,jj,1,1), tg_misfdep%d_value(ji,jj+1,1,1))
+!            IF( ikb == ikt+1 )THEN
+!               tg_e3vw_0%d_value(ji,jj,ikb,1) = MIN( tg_gdept_0%d_value(ji,jj,ikb  ,1), tg_gdept_0%d_value(ji  ,jj+1,ikb  ,1) ) - &
+!               &                                MAX( tg_gdept_0%d_value(ji,jj,ikb-1,1), tg_gdept_0%d_value(ji  ,jj+1,ikb-1,1) )
+!            ENDIF
+!         END DO
+!      END DO
+!
+!   END SUBROUTINE grid_zgr__isf_fill_e3uw
+!   !-------------------------------------------------------------------
+!   !> @brief This subroutine compute gdep3w_0 (vertical sum of e3w) 
+!   !>
+!   !> @details
+!   !>
+!   !> @author J.Paul
+!   !> @date September, 2015 - rewrite from zgr_zps
+!   !>
+!   !> @param[in] jpi
+!   !> @param[in] jpj
+!   !> @param[in] jpk
+!   !> @param[in] td_risfdep
+!   !-------------------------------------------------------------------
+!   SUBROUTINE grid_zgr__isf_fill_gdep3w_0( jpi,jpj,jpk,td_risfdep )
+!      IMPLICIT NONE
+!      ! Argument      
+!      INTEGER(i4), INTENT(IN   ) :: jpi
+!      INTEGER(i4), INTENT(IN   ) :: jpj
+!      INTEGER(i4), INTENT(IN   ) :: jpk
+!      TYPE(TVAR) , INTENT(INOUT) :: td_risfdep
+!
+!      ! local variable
+!      INTEGER(i4) :: ik
+!
+!      ! loop indices
+!      INTEGER(i4) :: ji
+!      INTEGER(i4) :: jj
+!      INTEGER(i4) :: jk
+!      !----------------------------------------------------------------
+!
+!      WHERE( tg_misfdep%d_value(:,:,:,:) == 0 ) tg_misfdep%d_value(:,:,:,:) = 1
+!      
+!      DO jj = 1,jpj
+!         DO ji = 1,jpi
+!
+!            tg_gdep3w_0%d_value(ji,jj,1,1) = 0.5_dp * tg_e3w_0%d_value(ji,jj,1,1)
+!            DO jk = 2, INT(tg_misfdep%d_value(ji,jj,1,1),i4)
+!               tg_gdep3w_0%d_value(ji,jj,jk,1) = tg_gdep3w_0%d_value(ji,jj,jk-1,1) + &
+!                  &                              tg_e3w_0%d_value   (ji,jj,jk  ,1) 
+!            END DO
+!
+!            ik=tg_misfdep%d_value(ji,jj,1,1)
+!            IF( ik >= 2 )THEN
+!               tg_gdep3w_0%d_value(ji,jj,ik,1) = td_risfdep%d_value(ji,jj, 1,1) + &
+!                  &                       0.5_dp * tg_e3w_0%d_value(ji,jj,ik,1)
+!            ENDIF
+!
+!            DO jk = ik + 1, jpk
+!               tg_gdep3w_0%d_value(ji,jj,jk,1) = tg_gdep3w_0%d_value(ji,jj,jk-1,1) + &
+!                  &                              tg_e3w_0%d_value   (ji,jj,jk  ,1) 
+!            END DO
+!
+!         END DO
+!      END DO
+!
+!   END SUBROUTINE grid_zgr__isf_fill_gdep3w_0
+   !-------------------------------------------------------------------
+   !> @brief This function initialise global variable needed to compute vertical
+   !>        mesh
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_sco_init(jpi,jpj) 
+      IMPLICIT NONE
+      ! Argument      
+      INTEGER(i4), INTENT(IN) :: jpi
+      INTEGER(i4), INTENT(IN) :: jpj
+
+      ! local variable
+      REAL(dp), DIMENSION(jpi,jpj) :: dl_tmp
+
+      ! loop indices
+      !----------------------------------------------------------------
+
+      dl_tmp(:,:)=dp_fill
+
+      tg_rx1     =var_init('rx1      ',dl_tmp(:,:), dd_fill=dp_fill, id_type=NF90_DOUBLE)
+
+   END SUBROUTINE grid_zgr_sco_init
+   !-------------------------------------------------------------------
+   !> @brief This function clean structure
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial version
+   !>
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_sco_clean() 
+      IMPLICIT NONE
+      ! Argument      
+
+      ! local variable
+      ! loop indices
+      !----------------------------------------------------------------
+
+      CALL var_clean(tg_rx1      )
+      
+   END SUBROUTINE grid_zgr_sco_clean
+   !-------------------------------------------------------------------
+   !> @brief This subroutine define the s-coordinate system
+   !>
+   !> @details
+   !>
+   !> ** Method  :   s-coordinate
+   !>         The depth of model levels is defined as the product of an
+   !>      analytical function by the local bathymetry, while the vertical
+   !>      scale factors are defined as the product of the first derivative
+   !>      of the analytical function by the bathymetry.
+   !>      (this solution save memory as depth and scale factors are not
+   !>      3d fields)
+   !>          - Read bathymetry (in meters) at t-point and compute the
+   !>         bathymetry at u-, v-, and f-points.
+   !>            - hbatu = mi( hbatt )
+   !>            - hbatv = mj( hbatt )
+   !>            - hbatf = mi( mj( hbatt ) )
+   !>          - Compute z_gsigt, z_gsigw, z_esigt, z_esigw from an analytical
+   !>         function and its derivative given as function.
+   !>            - z_gsigt(k) = fssig (k    )
+   !>            - z_gsigw(k) = fssig (k-0.5)
+   !>            - z_esigt(k) = fsdsig(k    )
+   !>            - z_esigw(k) = fsdsig(k-0.5)
+   !>      Three options for stretching are give, and they can be modified
+   !>      following the users requirements. Nevertheless, the output as
+   !>      well as the way to compute the model levels and scale factors
+   !>      must be respected in order to insure second order accuracy
+   !>      schemes.
+   !>
+   !>      The three methods for stretching available are:
+   !> 
+   !>           s_sh94 (Song and Haidvogel 1994)
+   !>                a sinh/tanh function that allows sigma and stretched sigma
+   !>
+   !>           s_sf12 (Siddorn and Furner 2012?)
+   !>                allows the maintenance of fixed surface and or
+   !>                bottom cell resolutions (cf. geopotential coordinates) 
+   !>                within an analytically derived stretched S-coordinate framework.
+   !> 
+   !>          s_tanh  (Madec et al 1996)
+   !>                a cosh/tanh function that gives stretched coordinates
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from zgr_sco
+   !> @date October, 2016
+   !> - add wetting and drying boolean
+   !>
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__sco_fill( td_nam,jpi,jpj,jpk,td_bathy ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      TYPE(TVAR) , INTENT(INOUT) :: td_bathy
+
+      ! local variable
+      INTEGER  ::   iip1, ijp1, iim1, ijm1   ! temporary integers
+
+      REAL(dp) :: zrmax, zrfact
+      REAL(dp) :: ztaper
+
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hifv  !< interface depth between stretching at v--f
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hiff
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hift  !< and quasi-uniform spacing t--u points (m)
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hifu
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_scosrf !< ocean surface topography
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_scobot !< ocean bottom topography
+
+!      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hbatt
+!      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hbatu
+!      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hbatv
+!      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: dl_hbatf
+
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: zenv
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: zri
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: zrj
+      REAL(dp), DIMENSION(:,:), ALLOCATABLE :: zhbat
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztmpi1
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztmpi2
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztmpj1
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztmpj2
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      INTEGER(i4) :: jl
+      !----------------------------------------------------------------
+
+      CALL logger_info('GRID ZGR SCO: s-coordinate or hybrid z-s-coordinate')
+      CALL logger_info('~~~~~~~~~~~')
+      CALL logger_info('   Namelist namzgr_sco')
+      CALL logger_info('     stretching coeffs ')
+      CALL logger_info('        maximum depth of s-bottom surface (>0)       dn_sbot_max   = '//TRIM(fct_str(td_nam%d_sbot_max)))
+      CALL logger_info('        minimum depth of s-bottom surface (>0)       dn_sbot_min   = '//TRIM(fct_str(td_nam%d_sbot_min)))
+      CALL logger_info('        Critical depth                               dn_hc         = '//TRIM(fct_str(td_nam%d_hc)))
+      CALL logger_info('        maximum cut-off r-value allowed              dn_rmax       = '//TRIM(fct_str(td_nam%d_rmax)))
+      CALL logger_info('     Song and Haidvogel 1994 stretching              ln_s_sh94     = '//TRIM(fct_str(td_nam%l_s_sh94)))
+      CALL logger_info('        Song and Haidvogel 1994 stretching coefficients')
+      CALL logger_info('        surface control parameter (0<=rn_theta<=20)  dn_theta      = '//TRIM(fct_str(td_nam%d_theta)))
+      CALL logger_info('        bottom  control parameter (0<=rn_thetb<= 1)  dn_thetb      = '//TRIM(fct_str(td_nam%d_thetb)))
+      CALL logger_info('        stretching parameter (song and haidvogel)    dn_bb         = '//TRIM(fct_str(td_nam%d_bb)))
+      CALL logger_info('     Siddorn and Furner 2012 stretching              ln_s_sf12     = '//TRIM(fct_str(td_nam%l_s_sf12)))
+      CALL logger_info('        switching to sigma (T) or Z (F) at H<Hc      ln_sigcrit    = '//TRIM(fct_str(td_nam%l_sigcrit)))
+      CALL logger_info('        Siddorn and Furner 2012 stretching coefficients')
+      CALL logger_info('        stretchin parameter ( >1 surface; <1 bottom) dn_alpha      = '//TRIM(fct_str(td_nam%d_alpha)))
+      CALL logger_info('        e-fold length scale for transition region    dn_efold      = '//TRIM(fct_str(td_nam%d_efold)))
+      CALL logger_info('        Surface cell depth (Zs) (m)                  dn_zs         = '//TRIM(fct_str(td_nam%d_zs)))
+      CALL logger_info('        Bathymetry multiplier for Zb                 dn_zb_a       = '//TRIM(fct_str(td_nam%d_zb_a)))
+      CALL logger_info('        Offset for Zb                                dn_zb_b       = '//TRIM(fct_str(td_nam%d_zb_b)))
+      CALL logger_info('        Bottom cell (Zb) (m) = H*rn_zb_a + rn_zb_b')
+
+      ALLOCATE(dl_hifv(jpi,jpj))
+      ALLOCATE(dl_hiff(jpi,jpj))
+      ALLOCATE(dl_hift(jpi,jpj))
+      ALLOCATE(dl_hifu(jpi,jpj))
+
+      ! set the minimum depth for the s-coordinate
+      dl_hift(:,:) = td_nam%d_sbot_min
+      dl_hifu(:,:) = td_nam%d_sbot_min
+      dl_hifv(:,:) = td_nam%d_sbot_min
+      dl_hiff(:,:) = td_nam%d_sbot_min
+
+      ! set maximum ocean depth
+      td_bathy%d_value(:,:,1,1) = MIN( td_nam%d_sbot_max, td_bathy%d_value(:,:,1,1) )
+      IF( .NOT.td_nam%l_wd ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+              IF( td_bathy%d_value(ji,jj,1,1) > 0._dp )THEN
+                 td_bathy%d_value(ji,jj,1,1) = MAX(td_nam%d_sbot_min, td_bathy%d_value(ji,jj,1,1))
+              ENDIF
+            END DO
+         END DO
+      ENDIF
+
+      ! =============================
+      ! Define the envelop bathymetry   (hbatt)
+      ! =============================
+      ! use r-value to create hybrid coordinates
+      ALLOCATE(zenv(jpi,jpj))
+      zenv(:,:) = td_bathy%d_value(:,:,1,1)
+
+      IF( .NOT. td_nam%l_wd ) THEN
+      ! set first land point adjacent to a wet cell to sbot_min as this needs to be included in smoothing
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+              IF( td_bathy%d_value(ji,jj,1,1) == 0._dp ) THEN
+                iip1 = MIN( ji+1, jpi )
+                ijp1 = MIN( jj+1, jpj )
+                iim1 = MAX( ji-1,  1  )
+                ijm1 = MAX( jj-1,  1  )
+                IF( ( td_bathy%d_value(iim1,ijm1,1,1) + &
+                   &  td_bathy%d_value(ji  ,ijp1,1,1) + &
+                   &  td_bathy%d_value(iip1,ijp1,1,1) + &
+                   &  td_bathy%d_value(iim1,jj  ,1,1) + &
+                   &  td_bathy%d_value(iip1,jj  ,1,1) + &
+                   &  td_bathy%d_value(iim1,ijm1,1,1) + &
+                   &  td_bathy%d_value(ji  ,ijm1,1,1) + &
+                   &  td_bathy%d_value(iip1,ijp1,1,1) ) > 0._dp ) THEN
+                  zenv(ji,jj) = td_nam%d_sbot_min
+                ENDIF
+              ENDIF
+            END DO
+         END DO
+      ENDIF
+
+      ! apply lateral boundary condition   CAUTION: keep the value when the lbc field is zero
+      CALL lbc_lnk( zenv(:,:), 'T', td_nam%i_perio, 1._dp) ! ?? , 'no0' )
+
+      ! smooth the bathymetry (if required)
+      ALLOCATE(dl_scosrf(jpi,jpj))
+      ALLOCATE(dl_scobot(jpi,jpj))
+      dl_scosrf(:,:) = 0._dp                      ! ocean surface depth (here zero: no under ice-shelf sea)
+      dl_scobot(:,:) = td_bathy%d_value(:,:,1,1)  ! ocean bottom  depth
+
+      jl    = 0
+      zrmax = 1._dp
+
+      ! set scaling factor used in reducing vertical gradients
+      zrfact = ( 1._dp - td_nam%d_rmax ) / ( 1._dp + td_nam%d_rmax )      
+
+      ! initialise temporary evelope depth arrays
+      ALLOCATE(ztmpi1(jpi,jpj))
+      ALLOCATE(ztmpi2(jpi,jpj))
+      ALLOCATE(ztmpj1(jpi,jpj))
+      ALLOCATE(ztmpj2(jpi,jpj))
+
+      ztmpi1(:,:) = zenv(:,:)
+      ztmpi2(:,:) = zenv(:,:)
+      ztmpj1(:,:) = zenv(:,:)
+      ztmpj2(:,:) = zenv(:,:)
+      
+      ! initialise temporary r-value arrays
+      ALLOCATE(zri(jpi,jpj))
+      ALLOCATE(zrj(jpi,jpj))
+      zri(:,:) = 1._dp
+      zrj(:,:) = 1._dp
+
+      !  Iterative loop  !
+      ! ================ !
+      DO WHILE( jl <= 10000 .AND. ( zrmax - td_nam%d_rmax ) > 1.e-8_dp )
+
+         jl = jl + 1
+         zrmax = 0._dp
+         ! we set zrmax from previous r-values (zri and zrj) first
+         ! if set after current r-value calculation (as previously)
+         ! we could exit DO WHILE prematurely before checking r-value
+         ! of current zenv
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zrmax = MAX( zrmax, ABS(zri(ji,jj)), ABS(zrj(ji,jj)) )
+            END DO
+         END DO
+         zri(:,:) = 0._dp
+         zrj(:,:) = 0._dp
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               iip1 = MIN( ji+1, jpi )      ! force zri = 0 on last line (ji=ncli+1 to jpi)
+               ijp1 = MIN( jj+1, jpj )      ! force zrj = 0 on last raw  (jj=nclj+1 to jpj)
+               IF( (zenv(ji  ,jj) > 0._dp) .AND. &
+                 & (zenv(iip1,jj) > 0._dp) )THEN
+                  zri(ji,jj) = ( zenv(iip1,jj) - zenv(ji,jj) ) / ( zenv(iip1,jj) + zenv(ji,jj) )
+               END IF
+               IF( (zenv(ji,jj  ) > 0._dp) .AND. &
+                 & (zenv(ji,ijp1) > 0._dp) )THEN
+                  zrj(ji,jj) = ( zenv(ji,ijp1) - zenv(ji,jj) ) / ( zenv(ji,ijp1) + zenv(ji,jj) )
+               END IF
+               IF( zri(ji,jj) >  td_nam%d_rmax ) ztmpi1(ji  ,jj  ) = zenv(iip1,jj  ) * zrfact
+               IF( zri(ji,jj) < -td_nam%d_rmax ) ztmpi2(iip1,jj  ) = zenv(ji  ,jj  ) * zrfact
+               IF( zrj(ji,jj) >  td_nam%d_rmax ) ztmpj1(ji  ,jj  ) = zenv(ji  ,ijp1) * zrfact
+               IF( zrj(ji,jj) < -td_nam%d_rmax ) ztmpj2(ji  ,ijp1) = zenv(ji  ,jj  ) * zrfact
+            END DO
+         END DO
+         !! 
+         !
+         CALL logger_info('zgr_sco :   iter= '//TRIM(fct_str(jl))//&
+            &             ' rmax= '//TRIM(fct_str(zrmax)) )
+         !
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zenv(ji,jj) = MAX( zenv  (ji,jj), &
+                                & ztmpi1(ji,jj), &
+                                & ztmpi2(ji,jj), &
+                                & ztmpj1(ji,jj), &
+                                & ztmpj2(ji,jj) )
+            END DO
+         END DO
+         ! apply lateral boundary condition   CAUTION: keep the value when the lbc field is zero
+         CALL lbc_lnk( zenv, 'T', td_nam%i_perio, 1._dp) ! ?? , 'no0' )
+      ENDDO
+      !     End loop     !
+      ! ================ !
+
+      DEALLOCATE(zri)
+      DEALLOCATE(zrj)
+
+      DEALLOCATE(ztmpi1)
+      DEALLOCATE(ztmpi2)
+      DEALLOCATE(ztmpj1)
+      DEALLOCATE(ztmpj2)
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! set all points to avoid undefined scale value warnings
+            zenv(ji,jj) = MAX( zenv(ji,jj), td_nam%d_sbot_min )
+         ENDDO
+      ENDDO
+      !
+      ! Envelope bathymetry saved in hbatt
+      !
+!      ALLOCATE(dl_hbatt(jpi,jpj))
+!      ALLOCATE(dl_hbatu(jpi,jpj))
+!      ALLOCATE(dl_hbatv(jpi,jpj))
+!      ALLOCATE(dl_hbatf(jpi,jpj))
+
+      tg_hbatt%d_value(:,:,1,1) = zenv(:,:) 
+      IF( MINVAL( tg_gphit%d_value(:,:,1,1) ) * &
+        & MAXVAL( tg_gphit%d_value(:,:,1,1) ) <= 0._dp ) THEN
+         CALL logger_warn( ' s-coordinates are tapered in vicinity of the Equator' )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztaper = EXP( -(tg_gphit%d_value(ji,jj,1,1)/8._dp)**2._dp )
+               tg_hbatt%d_value(ji,jj,1,1) =   td_nam%d_sbot_max           * ztaper           &
+               &                             + tg_hbatt%d_value(ji,jj,1,1) * (1._dp - ztaper)
+            END DO
+         END DO
+      ENDIF
+
+      DEALLOCATE(zenv)
+
+      CALL logger_info(' bathy  MAX '//TRIM(fct_str(MAXVAL( td_bathy%d_value(:,:,1,1) )))//&
+         &                    ' MIN '//TRIM(fct_str(MINVAL( td_bathy%d_value(:,:,1,1) ))) )
+      CALL logger_info(' hbatt  MAX '//TRIM(fct_str(MAXVAL( tg_hbatt%d_value(:,:,1,1) )))//&
+         &                    ' MIN '//TRIM(fct_str(MINVAL( tg_hbatt%d_value(:,:,1,1) ))) )
+      !
+      !   hbatu, hbatv, hbatf fields
+      !
+      tg_hbatu%d_value(:,:,1,1) = td_nam%d_sbot_min
+      tg_hbatv%d_value(:,:,1,1) = td_nam%d_sbot_min
+      tg_hbatf%d_value(:,:,1,1) = td_nam%d_sbot_min
+      
+      DO jj = 1, jpj-1
+        DO ji = 1, jpi-1   ! NO vector opt.
+           tg_hbatu%d_value(ji,jj,1,1) = 0.50_dp * ( tg_hbatt%d_value(ji  ,jj  ,1,1) + &
+              &                                      tg_hbatt%d_value(ji+1,jj  ,1,1) )
+           tg_hbatv%d_value(ji,jj,1,1) = 0.50_dp * ( tg_hbatt%d_value(ji  ,jj  ,1,1) + &
+              &                                      tg_hbatt%d_value(ji  ,jj+1,1,1) )
+           tg_hbatf%d_value(ji,jj,1,1) = 0.25_dp * ( tg_hbatt%d_value(ji  ,jj  ,1,1) + &
+              &                                      tg_hbatt%d_value(ji  ,jj+1,1,1) + &
+              &                                      tg_hbatt%d_value(ji+1,jj  ,1,1) + &
+              &                                      tg_hbatt%d_value(ji+1,jj+1,1,1) )
+        ENDDO
+      ENDDO
+
+      IF( td_nam%l_wd ) THEN               !avoid the zero depth on T- (U-,V-,F-) points
+        DO jj = 1, jpj
+          DO ji = 1, jpi
+            IF( ABS(tg_hbatt%d_value(ji,jj,1,1)) < td_nam%d_wdmin1 )THEN
+               tg_hbatt%d_value(ji,jj,1,1) = SIGN(1._wp, tg_hbatt%d_value(ji,jj,1,1)) * td_nam%d_wdmin1
+            ENDIF
+            IF( ABS(tg_hbatu%d_value(ji,jj,1,1)) < td_nam%d_wdmin1 )THEN
+               tg_hbatu%d_value(ji,jj,1,1) = SIGN(1._wp, tg_hbatu%d_value(ji,jj,1,1)) * td_nam%d_wdmin1
+            ENDIF
+            IF( ABS(tg_hbatv%d_value(ji,jj,1,1)) < td_nam%d_wdmin1 )THEN
+               tg_hbatv%d_value(ji,jj,1,1) = SIGN(1._wp, tg_hbatv%d_value(ji,jj,1,1)) * td_nam%d_wdmin1
+            ENDIF
+            IF( ABS(tg_hbatf%d_value(ji,jj,1,1)) < td_nam%d_wdmin1 )THEN
+               tg_hbatf%d_value(ji,jj,1,1) = SIGN(1._wp, tg_hbatf%d_value(ji,jj,1,1)) * td_nam%d_wdmin1
+            ENDIF
+          END DO
+        END DO
+      ENDIF
+
+      ! Apply lateral boundary condition
+      ALLOCATE(zhbat(jpi,jpj))
+
+!!gm  ! CAUTION: retain non zero value in the initial file this should be OK for orca cfg, not for EEL
+      zhbat(:,:) = tg_hbatu%d_value(:,:,1,1)
+      CALL lbc_lnk( tg_hbatu%d_value(:,:,1,1), 'U', td_nam%i_perio, 1._dp )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tg_hbatu%d_value(ji,jj,1,1) == 0._dp ) THEN
+               !No worries about the following line when l_wd == .true.
+               IF( zhbat(ji,jj) == 0._dp ) tg_hbatu%d_value(ji,jj,1,1) = td_nam%d_sbot_min
+               IF( zhbat(ji,jj) /= 0._dp ) tg_hbatu%d_value(ji,jj,1,1) = zhbat(ji,jj)
+            ENDIF
+         ENDDO
+      ENDDO
+
+      zhbat(:,:) = tg_hbatv%d_value(:,:,1,1)
+      CALL lbc_lnk( tg_hbatv%d_value(:,:,1,1), 'V', td_nam%i_perio, 1._dp )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tg_hbatv%d_value(ji,jj,1,1) == 0._dp ) THEN
+               IF( zhbat(ji,jj) == 0._dp ) tg_hbatv%d_value(ji,jj,1,1) = td_nam%d_sbot_min
+               IF( zhbat(ji,jj) /= 0._dp ) tg_hbatv%d_value(ji,jj,1,1) = zhbat(ji,jj)
+            ENDIF
+         ENDDO
+      ENDDO
+
+      zhbat(:,:) = tg_hbatf%d_value(:,:,1,1)
+      CALL lbc_lnk( tg_hbatf%d_value(:,:,1,1), 'F', td_nam%i_perio, 1._dp )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tg_hbatf%d_value(ji,jj,1,1) == 0._dp ) THEN
+               IF( zhbat(ji,jj) == 0._dp ) tg_hbatf%d_value(ji,jj,1,1) = td_nam%d_sbot_min
+               IF( zhbat(ji,jj) /= 0._dp ) tg_hbatf%d_value(ji,jj,1,1) = zhbat(ji,jj)
+            ENDIF
+         ENDDO
+      ENDDO
+
+      DEALLOCATE(zhbat)
+
+!!bug:  key_helsinki a verifer
+      IF( .NOT.td_nam%l_wd ) THEN
+         dl_hift(:,:) = MIN( dl_hift(:,:), tg_hbatt%d_value(:,:,1,1) )
+         dl_hifu(:,:) = MIN( dl_hifu(:,:), tg_hbatu%d_value(:,:,1,1) )
+         dl_hifv(:,:) = MIN( dl_hifv(:,:), tg_hbatv%d_value(:,:,1,1) )
+         dl_hiff(:,:) = MIN( dl_hiff(:,:), tg_hbatf%d_value(:,:,1,1) )
+      ENDIf
+
+      CALL logger_info(' MAX val hif   t '//TRIM(fct_str(MAXVAL( dl_hift(:,:) )))//&
+         &                           ' f '//TRIM(fct_str(MAXVAL( dl_hiff(:,:) )))//&
+         &                           ' u '//TRIM(fct_str(MAXVAL( dl_hifu(:,:) )))//&
+         &                           ' v '//TRIM(fct_str(MAXVAL( dl_hifv(:,:) ))) )
+      CALL logger_info(' MIN val hif   t '//TRIM(fct_str(MINVAL( dl_hift(:,:) )))//&
+         &                           ' f '//TRIM(fct_str(MINVAL( dl_hiff(:,:) )))//&
+         &                           ' u '//TRIM(fct_str(MINVAL( dl_hifu(:,:) )))//&
+         &                           ' v '//TRIM(fct_str(MINVAL( dl_hifv(:,:) ))) )
+      CALL logger_info(' MAX val hbat  t '//TRIM(fct_str(MAXVAL( tg_hbatt%d_value(:,:,1,1) )))//&
+         &                           ' f '//TRIM(fct_str(MAXVAL( tg_hbatf%d_value(:,:,1,1) )))//&
+         &                           ' u '//TRIM(fct_str(MAXVAL( tg_hbatu%d_value(:,:,1,1) )))//&
+         &                           ' v '//TRIM(fct_str(MAXVAL( tg_hbatv%d_value(:,:,1,1) ))) )
+      CALL logger_info(' MIN val hbat  t '//TRIM(fct_str(MINVAL( tg_hbatt%d_value(:,:,1,1) )))//&
+         &                           ' f '//TRIM(fct_str(MINVAL( tg_hbatf%d_value(:,:,1,1) )))//&
+         &                           ' u '//TRIM(fct_str(MINVAL( tg_hbatu%d_value(:,:,1,1) )))//&
+         &                           ' v '//TRIM(fct_str(MINVAL( tg_hbatv%d_value(:,:,1,1) ))) )
+!! helsinki
+
+      ! =======================
+      !   s-ccordinate fields     (gdep., e3.)
+      ! =======================
+      !
+      ! non-dimensional "sigma" for model level depth at w- and t-levels
+
+!========================================================================
+! Song and Haidvogel  1994 (ln_s_sh94=T)
+! Siddorn and Furner  2012 (ln_sf12=T)
+! or  tanh function        (both false)                    
+!========================================================================
+      IF( td_nam%l_s_sh94 ) THEN 
+         CALL grid_zgr__sco_s_sh94( td_nam,jpi,jpj,jpk, &
+         &                          dl_scosrf )
+      ELSEIF( td_nam%l_s_sf12 ) THEN
+         CALL grid_zgr__sco_s_sf12( td_nam,jpi,jpj,jpk, &
+         &                          dl_scosrf )
+      ELSE                 
+         CALL grid_zgr__sco_s_tanh( td_nam,jpi,jpj,jpk, &
+         &                          dl_scosrf, &
+         &                          dl_hift, dl_hifu, dl_hifv, dl_hiff )
+      ENDIF
+
+      DEALLOCATE(dl_scosrf)
+
+      DEALLOCATE(dl_hifv)
+      DEALLOCATE(dl_hiff)
+      DEALLOCATE(dl_hift)
+      DEALLOCATE(dl_hifu)
+
+      CALL lbc_lnk( tg_e3t_0%d_value(:,:,:,1) , 'T', td_nam%i_perio, 1._dp )
+      CALL lbc_lnk( tg_e3u_0%d_value(:,:,:,1) , 'U', td_nam%i_perio, 1._dp )
+      CALL lbc_lnk( tg_e3v_0%d_value(:,:,:,1) , 'V', td_nam%i_perio, 1._dp )
+      !CALL lbc_lnk( tg_e3f_0%d_value(:,:,:,1) , 'F', td_nam%i_perio, 1._dp )
+      CALL lbc_lnk( tg_e3w_0%d_value(:,:,:,1) , 'W', td_nam%i_perio, 1._dp )
+      !CALL lbc_lnk( tg_e3uw_0%d_value(:,:,:,1), 'U', td_nam%i_perio, 1._dp )
+      !CALL lbc_lnk( tg_e3vw_0%d_value(:,:,:,1), 'V', td_nam%i_perio, 1._dp )
+
+      IF( .NOT. td_nam%l_wd ) THEN
+         WHERE( tg_e3t_0%d_value(:,:,:,1) ==0_dp )  tg_e3t_0%d_value(:,:,:,1) = 1._dp
+         WHERE( tg_e3u_0%d_value(:,:,:,1) ==0_dp )  tg_e3u_0%d_value(:,:,:,1) = 1._dp
+         WHERE( tg_e3v_0%d_value(:,:,:,1) ==0_dp )  tg_e3v_0%d_value(:,:,:,1) = 1._dp
+         !WHERE( tg_e3f_0%d_value(:,:,:,1) ==0_dp )  tg_e3f_0%d_value(:,:,:,1) = 1._dp
+         WHERE( tg_e3w_0%d_value(:,:,:,1) ==0_dp )  tg_e3w_0%d_value(:,:,:,1) = 1._dp
+         !WHERE( tg_e3uw_0%d_value(:,:,:,1)==0_dp )  tg_e3uw_0%d_value(:,:,:,1)= 1._dp
+         !WHERE( tg_e3vw_0%d_value(:,:,:,1)==0_dp )  tg_e3vw_0%d_value(:,:,:,1)= 1._dp
+      ENDIF
+
+      ! HYBRID : 
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jk = 1, jpk-1
+               IF( dl_scobot(ji,jj) >= tg_gdept_0%d_value(ji,jj,jk,1) )THEN
+                  tg_mbathy%d_value(ji,jj,1,1) = REAL(MAX( 2, jk ),dp)
+               ENDIF
+            END DO
+
+            IF( td_nam%l_wd ) THEN
+               IF( dl_scobot(ji,jj) <= -(td_nam%d_wdld - td_nam%d_wdmin2) )THEN
+
+                  tg_mbathy%d_value(ji,jj,1,1) = 0._dp
+
+               ELSEIF( dl_scobot(ji,jj) <= td_nam%d_wdmin1 )THEN
+
+                  tg_mbathy%d_value(ji,jj,1,1) = 2._dp
+
+               ENDIF
+            ELSE
+               IF( dl_scobot(ji,jj) == 0._dp )THEN
+                  tg_mbathy%d_value(ji,jj,1,1) = 0._dp
+               ENDIF
+            ENDIF
+
+         ENDDO
+      ENDDO
+
+      DEALLOCATE(dl_scobot)
+
+      CALL logger_info(' MIN val mbathy MIN '//TRIM(fct_str(MINVAL( tg_mbathy%d_value(:,:,1,1) )))//&
+         &             ' MAX '//TRIM(fct_str(MAXVAL( tg_mbathy%d_value(:,:,1,1) ))) )
+      CALL logger_info(' MIN val depth t '//TRIM(fct_str(MINVAL( tg_gdept_0%d_value(:,:,:,1) )))//&
+         &                           ' w '//TRIM(fct_str(MINVAL( tg_gdepw_0%d_value(:,:,:,1) ))) )!//&
+         !&                           '3w '//TRIM(fct_str(MINVAL( tg_gdep3w_0%d_value(:,:,:,1)))) )
+
+      CALL logger_info(' MIN val e3    t '//TRIM(fct_str(MINVAL( tg_e3t_0%d_value(:,:,:,1) )))//&
+         !&                           ' f '//TRIM(fct_str(MINVAL( tg_e3f_0%d_value(:,:,:,1) )))//&
+         &                           ' u '//TRIM(fct_str(MINVAL( tg_e3u_0%d_value(:,:,:,1) )))//&
+         &                           ' v '//TRIM(fct_str(MINVAL( tg_e3v_0%d_value(:,:,:,1) )))//&
+         !&                          ' uw '//TRIM(fct_str(MINVAL( tg_e3uw_0%d_value(:,:,:,1) )))//&
+         !&                          ' vw '//TRIM(fct_str(MINVAL( tg_e3vw_0%d_value(:,:,:,1) )))//&
+         &                           ' w '//TRIM(fct_str(MINVAL( tg_e3w_0%d_value(:,:,:,1) ))) )
+
+      CALL logger_info(' MAX val depth t '//TRIM(fct_str(MAXVAL( tg_gdept_0%d_value(:,:,:,1) )))//&
+         &                           ' w '//TRIM(fct_str(MAXVAL( tg_gdepw_0%d_value(:,:,:,1) ))) )!//&
+         !&                           '3w '//TRIM(fct_str(MAXVAL( tg_gdep3w_0%d_value(:,:,:,1) ))) )
+
+      CALL logger_info(' MAX val e3    t '//TRIM(fct_str(MAXVAL( tg_e3t_0%d_value(:,:,:,1) )))//&
+         !&                           ' f '//TRIM(fct_str(MAXVAL( tg_e3f_0%d_value(:,:,:,1) )))//&
+         &                           ' u '//TRIM(fct_str(MAXVAL( tg_e3u_0%d_value(:,:,:,1) )))//&
+         &                           ' v '//TRIM(fct_str(MAXVAL( tg_e3v_0%d_value(:,:,:,1) )))//&
+         !&                          ' uw '//TRIM(fct_str(MAXVAL( tg_e3uw_0%d_value(:,:,:,1) )))//&
+         !&                          ' vw '//TRIM(fct_str(MAXVAL( tg_e3vw_0%d_value(:,:,:,1) )))//&
+         &                           ' w '//TRIM(fct_str(MAXVAL( tg_e3w_0%d_value(:,:,:,1) ))) )
+
+!================================================================================
+! check the coordinate makes sense
+!================================================================================
+      DO ji = 1, jpi
+         DO jj = 1, jpj
+
+            IF( tg_hbatt%d_value(ji,jj,1,1) > 0._dp) THEN
+               DO jk = 1, INT(tg_mbathy%d_value(ji,jj,1,1),i4)
+                  ! check coordinate is monotonically increasing
+                  IF( tg_e3w_0%d_value(ji,jj,jk,1) <= 0._dp .OR. &
+                    & tg_e3t_0%d_value(ji,jj,jk,1) <= 0._dp )THEN
+                     CALL logger_fatal(' GRID ZGR SCO:   e3w   or e3t   =< 0  at point ('//&
+                       &               TRIM(fct_str(ji))//","//&
+                       &               TRIM(fct_str(jj))//","//&
+                       &               TRIM(fct_str(jk))//")" )
+                    !WRITE(numout,*) 'e3w',fse3w(ji,jj,:)
+                    !WRITE(numout,*) 'e3t',fse3t(ji,jj,:)
+                  ENDIF
+                  ! and check it has never gone negative
+                  IF( tg_gdepw_0%d_value(ji,jj,jk,1) < 0._dp .OR. &
+                    & tg_gdept_0%d_value(ji,jj,jk,1) < 0._dp ) THEN
+                     CALL logger_fatal('GRId ZGR SCO :   gdepw or gdept =< 0  at point ('//&
+                       &               TRIM(fct_str(ji))//","//&
+                       &               TRIM(fct_str(jj))//","//&
+                       &               TRIM(fct_str(jk))//")" )
+                    !WRITE(numout,*) 'gdepw',fsdepw(ji,jj,:)
+                    !WRITE(numout,*) 'gdept',fsdept(ji,jj,:)
+                  ENDIF
+                  ! and check it never exceeds the total depth
+                  IF( tg_gdepw_0%d_value(ji,jj,jk,1) > tg_hbatt%d_value(ji,jj,1,1) ) THEN
+                     CALL logger_fatal('GRID ZGR SCO:   gdepw > hbatt  at point ('//&
+                       &               TRIM(fct_str(ji))//","//&
+                       &               TRIM(fct_str(jj))//","//&
+                       &               TRIM(fct_str(jk))//")" )
+                    !WRITE(numout,*) 'gdepw',fsdepw(ji,jj,:)
+                  ENDIF
+               ENDDO
+
+               DO jk = 1, INT(tg_mbathy%d_value(ji,jj,1,1),i4)-1
+                  ! and check it never exceeds the total depth
+                  IF( tg_gdept_0%d_value(ji,jj,jk,1) > tg_hbatt%d_value(ji,jj,1,1) ) THEN
+                    CALL logger_fatal('GRID ZGR SCO:   gdept > hbatt  at point ('//&
+                       &               TRIM(fct_str(ji))//","//&
+                       &               TRIM(fct_str(jj))//","//&
+                       &               TRIM(fct_str(jk))//")" )
+                    !WRITE(numout,*) 'gdept',fsdept(ji,jj,:)
+                  ENDIF
+               ENDDO
+
+            ENDIF
+
+         ENDDO
+      ENDDO
+
+   END SUBROUTINE grid_zgr__sco_fill
+   !-------------------------------------------------------------------
+   !> @brief This subroutine stretch the s-coordinate system
+   !>
+   !> @details
+   !> ** Method  :   s-coordinate stretch using the Song and Haidvogel 1994
+   !>                mixed S/sigma coordinate
+   !>
+   !> Reference : Song and Haidvogel 1994.   
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domzgr 
+   !> @date October, 2016
+   !> - add wetting and drying option
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !> @param[in] dd_scosrf
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__sco_s_sh94( td_nam,jpi,jpj,jpk, &
+         &                          dd_scosrf ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ),                 INTENT(IN   ) :: td_nam
+      INTEGER(i4),                 INTENT(IN   ) :: jpi
+      INTEGER(i4),                 INTENT(IN   ) :: jpj
+      INTEGER(i4),                 INTENT(IN   ) :: jpk
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_scosrf
+
+      ! local variable
+      REAL(dp) :: zcoeft
+      REAL(dp) :: zcoefw
+
+      REAL(wp) ::   ztmpu
+      REAL(wp) ::   ztmpv
+      REAL(wp) ::   ztmpf
+      REAL(wp) ::   ztmpu1
+      REAL(wp) ::   ztmpv1
+      REAL(wp) ::   ztmpf1
+
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_gsigw3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_gsigt3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_gsi3w3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigt3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigw3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigtu3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigtv3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigtf3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigwu3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigwv3
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      ALLOCATE( z_gsigw3(jpi,jpj,jpk))
+      ALLOCATE( z_gsigt3(jpi,jpj,jpk))
+      ALLOCATE( z_gsi3w3(jpi,jpj,jpk))
+      ALLOCATE( z_esigt3(jpi,jpj,jpk))
+      ALLOCATE( z_esigw3(jpi,jpj,jpk))
+      ALLOCATE( z_esigtu3(jpi,jpj,jpk))
+      ALLOCATE( z_esigtv3(jpi,jpj,jpk))
+      ALLOCATE( z_esigtf3(jpi,jpj,jpk))
+      ALLOCATE( z_esigwu3(jpi,jpj,jpk))
+      ALLOCATE( z_esigwv3(jpi,jpj,jpk))
+
+      z_gsigw3(:,:,:) =0._dp
+      z_gsigt3(:,:,:) =0._dp  
+      z_gsi3w3(:,:,:) =0._dp  
+      z_esigt3(:,:,:) =0._dp  
+      z_esigw3(:,:,:) =0._dp  
+
+      z_esigtu3(:,:,:)=0._dp 
+      z_esigtv3(:,:,:)=0._dp
+      z_esigtf3(:,:,:)=0._dp
+      z_esigwu3(:,:,:)=0._dp
+      z_esigwv3(:,:,:)=0._dp
+
+      DO ji = 1, jpi
+         DO jj = 1, jpj
+   
+            IF( tg_hbatt%d_value(ji,jj,1,1) > td_nam%d_hc ) THEN    !deep water, stretched sigma
+               DO jk = 1, jpk
+                  z_gsigw3(ji,jj,jk) = -grid_zgr__sco_fssig1( td_nam, jpk, REAL(jk,dp)-0.5_dp, td_nam%d_bb )
+                  z_gsigt3(ji,jj,jk) = -grid_zgr__sco_fssig1( td_nam, jpk, REAL(jk,dp)       , td_nam%d_bb )
+               END DO
+            ELSE ! shallow water, uniform sigma
+               DO jk = 1, jpk
+                  z_gsigw3(ji,jj,jk) =   REAL(jk-1,dp)            / REAL(jpk-1,dp)
+                  z_gsigt3(ji,jj,jk) = ( REAL(jk-1,dp) + 0.5_dp ) / REAL(jpk-1,dp)
+               END DO
+            ENDIF         
+
+            DO jk = 1, jpk-1
+               z_esigt3(ji,jj,jk  ) = z_gsigw3(ji,jj,jk+1) - z_gsigw3(ji,jj,jk)
+               z_esigw3(ji,jj,jk+1) = z_gsigt3(ji,jj,jk+1) - z_gsigt3(ji,jj,jk)
+            END DO            
+            z_esigw3(ji,jj,1  ) = 2._dp * ( z_gsigt3(ji,jj,1  ) - z_gsigw3(ji,jj,1  ) )
+            z_esigt3(ji,jj,jpk) = 2._dp * ( z_gsigt3(ji,jj,jpk) - z_gsigw3(ji,jj,jpk) )
+
+            ! Coefficients for vertical depth as the sum of e3w scale factors
+            z_gsi3w3(ji,jj,1) = 0.5_dp * z_esigw3(ji,jj,1)
+            DO jk = 2, jpk
+               z_gsi3w3(ji,jj,jk) = z_gsi3w3(ji,jj,jk-1) + z_esigw3(ji,jj,jk)
+            END DO
+            !
+            DO jk = 1, jpk
+               zcoeft = ( REAL(jk,dp) - 0.5_dp ) / REAL(jpk-1,dp)
+               zcoefw = ( REAL(jk,dp) - 1.0_dp ) / REAL(jpk-1,dp)
+               tg_gdept_0%d_value(ji,jj,jk,1)  = (  dd_scosrf(ji,jj) &
+                  &                              + (tg_hbatt%d_value(ji,jj,1,1)-td_nam%d_hc)*z_gsigt3(ji,jj,jk) &
+                  &                              +  td_nam%d_hc*zcoeft )
+               tg_gdepw_0%d_value(ji,jj,jk,1)  = (  dd_scosrf(ji,jj) &
+                  &                              + (tg_hbatt%d_value(ji,jj,1,1)-td_nam%d_hc)*z_gsigw3(ji,jj,jk) &
+                  &                              +  td_nam%d_hc*zcoefw )
+               !tg_gdep3w_0%d_value(ji,jj,jk,1) = (  dd_scosrf(ji,jj) &
+               !   &                              + (tg_hbatt%d_value(ji,jj,1,1)-td_nam%d_hc)*z_gsi3w3(ji,jj,jk) &
+               !   &                              +  td_nam%d_hc*zcoeft )
+            END DO
+
+         END DO   ! for all jj's
+      END DO    ! for all ji's
+
+      DO ji = 1, jpi-1
+         DO jj = 1, jpj-1
+            ! extended for Wetting/Drying case
+            ztmpu  = tg_hbatt%d_value(ji  ,jj  ,1,1) + tg_hbatt%d_value(ji+1,jj  ,1,1)
+            ztmpv  = tg_hbatt%d_value(ji  ,jj  ,1,1) + tg_hbatt%d_value(ji  ,jj+1,1,1)
+            ztmpf  = tg_hbatt%d_value(ji  ,jj  ,1,1) + tg_hbatt%d_value(ji+1,jj  ,1,1) + &
+                   & tg_hbatt%d_value(ji  ,jj+1,1,1) + tg_hbatt%d_value(ji+1,jj+1,1,1)
+
+            ztmpu1 = tg_hbatt%d_value(ji  ,jj  ,1,1) * tg_hbatt%d_value(ji+1,jj  ,1,1)
+            ztmpv1 = tg_hbatt%d_value(ji  ,jj  ,1,1) * tg_hbatt%d_value(ji  ,jj+1,1,1)
+            ztmpf1 =    MIN(tg_hbatt%d_value(ji  ,jj  ,1,1), tg_hbatt%d_value(ji+1,jj  ,1,1), &
+                   &        tg_hbatt%d_value(ji  ,jj+1,1,1), tg_hbatt%d_value(ji+1,jj+1,1,1)) &
+                   & *  MAX(tg_hbatt%d_value(ji  ,jj  ,1,1), tg_hbatt%d_value(ji+1,jj  ,1,1), &
+                   &        tg_hbatt%d_value(ji  ,jj+1,1,1), tg_hbatt%d_value(ji+1,jj+1,1,1))
+
+            DO jk = 1, jpk
+
+               IF( td_nam%l_wd .AND. &
+                 & ( ztmpu1 < 0._wp .OR. ABS(ztmpu) < td_nam%d_wdmin1 ) )THEN
+                  z_esigtu3(ji,jj,jk) = 0.5_wp * ( z_esigt3(ji,jj,jk) + z_esigt3(ji+1,jj,jk) )
+                  z_esigwu3(ji,jj,jk) = 0.5_wp * ( z_esigw3(ji,jj,jk) + z_esigw3(ji+1,jj,jk) )
+               ELSE
+                  z_esigtu3(ji,jj,jk) = ( tg_hbatt%d_value(ji  ,jj,1,1)*z_esigt3(ji  ,jj,jk) &
+                                      & + tg_hbatt%d_value(ji+1,jj,1,1)*z_esigt3(ji+1,jj,jk) ) / ztmpu
+                  z_esigwu3(ji,jj,jk) = ( tg_hbatt%d_value(ji  ,jj,1,1)*z_esigw3(ji  ,jj,jk) &
+                                      & + tg_hbatt%d_value(ji+1,jj,1,1)*z_esigw3(ji+1,jj,jk)) / ztmpu
+               ENDIF
+
+               IF( td_nam%l_wd .AND. &
+                 & ( ztmpv1 < 0._wp .OR. ABS(ztmpv) < td_nam%d_wdmin1 ) )THEN
+                  z_esigtv3(ji,jj,jk) = 0.5_wp * ( z_esigt3(ji,jj,jk) + z_esigt3(ji,jj+1,jk) )
+                  z_esigwv3(ji,jj,jk) = 0.5_wp * ( z_esigw3(ji,jj,jk) + z_esigw3(ji,jj+1,jk) )
+               ELSE
+                  z_esigtv3(ji,jj,jk) = ( tg_hbatt%d_value(ji,jj  ,1,1)*z_esigt3(ji,jj  ,jk) &
+                                      & + tg_hbatt%d_value(ji,jj+1,1,1)*z_esigt3(ji,jj+1,jk)) / ztmpv
+                  z_esigwv3(ji,jj,jk) = ( tg_hbatt%d_value(ji,jj  ,1,1)*z_esigw3(ji,jj  ,jk) &
+                                      & + tg_hbatt%d_value(ji,jj+1,1,1)*z_esigw3(ji,jj+1,jk)) / ztmpv
+               ENDIF
+
+               IF( td_nam%l_wd .AND. &
+                 & ( ztmpf1 < 0._wp .OR. ABS(ztmpf) < td_nam%d_wdmin1 ) )THEN
+                  z_esigtf3(ji,jj,jk) = 0.25_wp * ( z_esigt3(ji  ,jj  ,jk) &
+                                      &           + z_esigt3(ji+1,jj  ,jk) &
+                                      &           + z_esigt3(ji  ,jj+1,jk) &
+                                      &           + z_esigt3(ji+1,jj+1,jk) )
+               ELSE
+                  z_esigtf3(ji,jj,jk) = ( tg_hbatt%d_value(ji  ,jj  ,1,1)*z_esigt3(ji  ,jj  ,jk) &
+                                      & + tg_hbatt%d_value(ji+1,jj  ,1,1)*z_esigt3(ji+1,jj  ,jk) &
+                                      & + tg_hbatt%d_value(ji  ,jj+1,1,1)*z_esigt3(ji  ,jj+1,jk) &
+                                      & + tg_hbatt%d_value(ji+1,jj+1,1,1)*z_esigt3(ji+1,jj+1,jk) ) / ztmpf
+               ENDIF
+               !
+               tg_e3t_0%d_value(ji,jj,jk,1) = ( ( tg_hbatt%d_value(ji,jj,1,1) - td_nam%d_hc )*z_esigt3 (ji,jj,jk) &
+                  &                            + td_nam%d_hc / REAL(jpk-1,dp) )
+               tg_e3u_0%d_value(ji,jj,jk,1) = ( ( tg_hbatu%d_value(ji,jj,1,1) - td_nam%d_hc )*z_esigtu3(ji,jj,jk) &
+                  &                            + td_nam%d_hc / REAL(jpk-1,dp) )
+               tg_e3v_0%d_value(ji,jj,jk,1) = ( ( tg_hbatv%d_value(ji,jj,1,1) - td_nam%d_hc )*z_esigtv3(ji,jj,jk) &
+                  &                            + td_nam%d_hc / REAL(jpk-1,dp) )
+               !tg_e3f_0%d_value(ji,jj,jk,1) = ( (tg_hbatf%d_value(ji,jj,1,1)-td_nam%d_hc)*z_esigtf3(ji,jj,jk) + td_nam%d_hc/REAL(jpk-1,dp) )
+               !
+               tg_e3w_0%d_value (ji,jj,jk,1)= ( ( tg_hbatt%d_value(ji,jj,1,1) - td_nam%d_hc )*z_esigw3 (ji,jj,jk) &
+                  &                            + td_nam%d_hc / REAL(jpk-1,dp) )
+               !tg_e3uw_0%d_value(ji,jj,jk,1)= ( (tg_hbatu%d_value(ji,jj,1,1)-td_nam%d_hc)*z_esigwu3(ji,jj,jk) + td_nam%d_hc/REAL(jpk-1,dp) )
+               !tg_e3vw_0%d_value(ji,jj,jk,1)= ( (tg_hbatv%d_value(ji,jj,1,1)-td_nam%d_hc)*z_esigwv3(ji,jj,jk) + td_nam%d_hc/REAL(jpk-1,dp) )
+            END DO
+        END DO
+      END DO
+
+      DEALLOCATE( z_gsigw3  )
+      DEALLOCATE( z_gsigt3  )
+      DEALLOCATE( z_gsi3w3  )
+      DEALLOCATE( z_esigt3  )
+      DEALLOCATE( z_esigw3  )
+      DEALLOCATE( z_esigtu3 )
+      DEALLOCATE( z_esigtv3 )
+      DEALLOCATE( z_esigtf3 )
+      DEALLOCATE( z_esigwu3 )
+      DEALLOCATE( z_esigwv3 )
+
+   END SUBROUTINE grid_zgr__sco_s_sh94
+   !-------------------------------------------------------------------
+   !> @brief This subroutine stretch the s-coordinate system
+   !>
+   !> ** Method  :   s-coordinate stretch using the Siddorn and Furner 2012?
+   !>                mixed S/sigma/Z coordinate
+   !>
+   !>                This method allows the maintenance of fixed surface and or
+   !>                bottom cell resolutions (cf. geopotential coordinates) 
+   !>                within an analytically derived stretched S-coordinate framework.
+   !>
+   !>
+   !> Reference : Siddorn and Furner 2012 (submitted Ocean modelling).   
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domzgr 
+   !> @date October, 2016
+   !> - add wetting and drying option
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !> @param[in] dd_scosrf
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__sco_s_sf12( td_nam,jpi,jpj,jpk, &
+         &                          dd_scosrf ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ),                 INTENT(IN   ) :: td_nam
+      INTEGER(i4),                 INTENT(IN   ) :: jpi
+      INTEGER(i4),                 INTENT(IN   ) :: jpj
+      INTEGER(i4),                 INTENT(IN   ) :: jpk
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_scosrf
+
+      ! local variable
+      REAL(dp) ::   zsmth     ! smoothing around critical depth
+      REAL(dp) ::   zzs, zzb  ! Surface and bottom cell thickness in sigma space
+
+      REAL(wp) ::   ztmpu
+      REAL(wp) ::   ztmpv
+      REAL(wp) ::   ztmpf
+      REAL(wp) ::   ztmpu1
+      REAL(wp) ::   ztmpv1
+      REAL(wp) ::   ztmpf1
+
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_gsigw3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_gsigt3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_gsi3w3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigt3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigw3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigtu3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigtv3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigtf3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigwu3
+      REAL(dp), DIMENSION(:,:,:), ALLOCATABLE :: z_esigwv3
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+      ALLOCATE( z_gsigw3(jpi,jpj,jpk))
+      ALLOCATE( z_gsigt3(jpi,jpj,jpk))
+      ALLOCATE( z_gsi3w3(jpi,jpj,jpk))
+      ALLOCATE( z_esigt3(jpi,jpj,jpk))
+      ALLOCATE( z_esigw3(jpi,jpj,jpk))
+      ALLOCATE( z_esigtu3(jpi,jpj,jpk))
+      ALLOCATE( z_esigtv3(jpi,jpj,jpk))
+      ALLOCATE( z_esigtf3(jpi,jpj,jpk))
+      ALLOCATE( z_esigwu3(jpi,jpj,jpk))
+      ALLOCATE( z_esigwv3(jpi,jpj,jpk))
+
+      z_gsigw3(:,:,:) =0._dp
+      z_gsigt3(:,:,:) =0._dp  
+      z_gsi3w3(:,:,:) =0._dp  
+      z_esigt3(:,:,:) =0._dp  
+      z_esigw3(:,:,:) =0._dp  
+      z_esigtu3(:,:,:)=0._dp 
+      z_esigtv3(:,:,:)=0._dp
+      z_esigtf3(:,:,:)=0._dp
+      z_esigwu3(:,:,:)=0._dp
+      z_esigwv3(:,:,:)=0._dp
+
+      DO ji = 1, jpi
+         DO jj = 1, jpj
+
+          IF( tg_hbatt%d_value(ji,jj,1,1) > td_nam%d_hc )THEN !deep water, stretched sigma
+              
+             ! this forces a linear bottom cell depth relationship with H,.
+             ! could be changed by users but care must be taken to do so carefully
+              zzb = tg_hbatt%d_value(ji,jj,1,1)*td_nam%d_zb_a + td_nam%d_zb_b
+
+              zzb = 1.0_dp-(zzb/tg_hbatt%d_value(ji,jj,1,1))
+            
+              zzs = td_nam%d_zs / tg_hbatt%d_value(ji,jj,1,1) 
+              
+              IF( td_nam%d_efold /= 0.0_dp )THEN
+                zsmth   = tanh( (tg_hbatt%d_value(ji,jj,1,1)- td_nam%d_hc ) / td_nam%d_efold )
+              ELSE
+                zsmth = 1.0_dp 
+              ENDIF
+               
+              DO jk = 1, jpk
+                z_gsigw3(ji,jj,jk) =  REAL(jk-1,dp)        /REAL(jpk-1,dp)
+                z_gsigt3(ji,jj,jk) = (REAL(jk-1,dp)+0.5_dp)/REAL(jpk-1,dp)
+              ENDDO
+              z_gsigw3(ji,jj,:) = grid_zgr__sco_fgamma( td_nam, jpk, z_gsigw3(ji,jj,:), zzb, zzs, zsmth  )
+              z_gsigt3(ji,jj,:) = grid_zgr__sco_fgamma( td_nam, jpk, z_gsigt3(ji,jj,:), zzb, zzs, zsmth  )
+ 
+          ELSE IF( td_nam%l_sigcrit )THEN ! shallow water, uniform sigma
+
+            DO jk = 1, jpk
+              z_gsigw3(ji,jj,jk) =  REAL(jk-1,dp)     /REAL(jpk-1,dp)
+              z_gsigt3(ji,jj,jk) = (REAL(jk-1,dp)+0.5)/REAL(jpk-1,dp)
+            END DO
+
+          ELSE  ! shallow water, z coordinates
+
+            DO jk = 1, jpk
+              z_gsigw3(ji,jj,jk) =  REAL(jk-1,dp)        /REAL(jpk-1,dp)*(td_nam%d_hc/tg_hbatt%d_value(ji,jj,1,1))
+              z_gsigt3(ji,jj,jk) = (REAL(jk-1,dp)+0.5_wp)/REAL(jpk-1,dp)*(td_nam%d_hc/tg_hbatt%d_value(ji,jj,1,1))
+            END DO
+
+          ENDIF
+
+          DO jk = 1, jpk-1
+             z_esigt3(ji,jj,jk  ) = z_gsigw3(ji,jj,jk+1) - z_gsigw3(ji,jj,jk)
+             z_esigw3(ji,jj,jk+1) = z_gsigt3(ji,jj,jk+1) - z_gsigt3(ji,jj,jk)
+          END DO
+          z_esigw3(ji,jj,1  ) = 2.0_dp * (z_gsigt3(ji,jj,1  ) - z_gsigw3(ji,jj,1  ))
+          z_esigt3(ji,jj,jpk) = 2.0_dp * (z_gsigt3(ji,jj,jpk) - z_gsigw3(ji,jj,jpk))
+
+          ! Coefficients for vertical depth as the sum of e3w scale factors
+          z_gsi3w3(ji,jj,1) = 0.5_dp * z_esigw3(ji,jj,1)
+          DO jk = 2, jpk
+             z_gsi3w3(ji,jj,jk) = z_gsi3w3(ji,jj,jk-1) + z_esigw3(ji,jj,jk)
+          END DO
+
+          DO jk = 1, jpk
+             tg_gdept_0%d_value (ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatt%d_value(ji,jj,1,1))*z_gsigt3(ji,jj,jk)
+             tg_gdepw_0%d_value (ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatt%d_value(ji,jj,1,1))*z_gsigw3(ji,jj,jk)
+             !tg_gdep3w_0%d_value(ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatt%d_value(ji,jj,1,1))*z_gsi3w3(ji,jj,jk)
+          END DO
+
+        ENDDO   ! for all jj's
+      ENDDO    ! for all ji's
+
+      DO ji=1,jpi-1
+        DO jj=1,jpj-1
+
+           ! extend to suit for Wetting/Drying case
+           ztmpu  = tg_hbatt%d_value(ji  ,jj  ,1,1) + tg_hbatt%d_value(ji+1,jj  ,1,1)
+           ztmpv  = tg_hbatt%d_value(ji  ,jj  ,1,1) + tg_hbatt%d_value(ji  ,jj+1,1,1)
+           ztmpf  = tg_hbatt%d_value(ji  ,jj  ,1,1) + tg_hbatt%d_value(ji+1,jj  ,1,1) + &
+                  & tg_hbatt%d_value(ji  ,jj+1,1,1) + tg_hbatt%d_value(ji+1,jj+1,1,1)
+
+           ztmpu1 = tg_hbatt%d_value(ji  ,jj  ,1,1) * tg_hbatt%d_value(ji+1,jj  ,1,1)
+           ztmpv1 = tg_hbatt%d_value(ji  ,jj  ,1,1) * tg_hbatt%d_value(ji  ,jj+1,1,1)
+           ztmpf1 =    MIN(tg_hbatt%d_value(ji  ,jj  ,1,1), tg_hbatt%d_value(ji+1,jj  ,1,1), &
+                  &        tg_hbatt%d_value(ji  ,jj+1,1,1), tg_hbatt%d_value(ji+1,jj+1,1,1)) & 
+                  &  * MAX(tg_hbatt%d_value(ji  ,jj  ,1,1), tg_hbatt%d_value(ji+1,jj  ,1,1), &
+                  &        tg_hbatt%d_value(ji  ,jj+1,1,1), tg_hbatt%d_value(ji+1,jj+1,1,1))
+
+          DO jk = 1, jpk
+
+            IF( td_nam%l_wd .AND. &
+              & ( ztmpu1 < 0._wp .OR. ABS(ztmpu) < td_nam%d_wdmin1 ) )THEN
+               z_esigtu3(ji,jj,jk) = 0.5_wp * ( z_esigt3(ji,jj,jk) + z_esigt3(ji+1,jj,jk) )
+               z_esigwu3(ji,jj,jk) = 0.5_wp * ( z_esigw3(ji,jj,jk) + z_esigw3(ji+1,jj,jk) )
+            ELSE
+               z_esigtu3(ji,jj,jk) = ( tg_hbatt%d_value(ji  ,jj,1,1)*z_esigt3(ji  ,jj,jk) &
+                                   & + tg_hbatt%d_value(ji+1,jj,1,1)*z_esigt3(ji+1,jj,jk)) / ztmpu
+               z_esigwu3(ji,jj,jk) = ( tg_hbatt%d_value(ji  ,jj,1,1)*z_esigw3(ji  ,jj,jk) &
+                                   & + tg_hbatt%d_value(ji+1,jj,1,1)*z_esigw3(ji+1,jj,jk)) / ztmpu
+            ENDIF
+
+            IF( td_nam%l_wd .AND. &
+              & ( ztmpv1 < 0._wp .OR. ABS(ztmpv) < td_nam%d_wdmin1 ) )THEN
+               z_esigtv3(ji,jj,jk) = 0.5_wp * ( z_esigt3(ji,jj,jk) + z_esigt3(ji,jj+1,jk) )
+               z_esigwv3(ji,jj,jk) = 0.5_wp * ( z_esigw3(ji,jj,jk) + z_esigw3(ji,jj+1,jk) )
+            ELSE
+               z_esigtv3(ji,jj,jk) = ( tg_hbatt%d_value(ji,jj  ,1,1)*z_esigt3(ji,jj  ,jk) &
+                                   & + tg_hbatt%d_value(ji,jj+1,1,1)*z_esigt3(ji,jj+1,jk)) / ztmpv
+               z_esigwv3(ji,jj,jk) = ( tg_hbatt%d_value(ji,jj  ,1,1)*z_esigw3(ji,jj  ,jk) &
+                                   & + tg_hbatt%d_value(ji,jj+1,1,1)*z_esigw3(ji,jj+1,jk)) / ztmpv
+            ENDIF
+
+            IF( td_nam%l_wd .AND. &
+              & ( ztmpf1 < 0._wp .OR. ABS(ztmpf) < td_nam%d_wdmin1 ) )THEN
+               z_esigtf3(ji,jj,jk) = 0.25_wp * ( z_esigt3(ji  ,jj  ,jk) &
+                                   &           + z_esigt3(ji+1,jj  ,jk) &
+                                   &           + z_esigt3(ji  ,jj+1,jk) &
+                                   &           + z_esigt3(ji+1,jj+1,jk) )
+            ELSE
+               z_esigtf3(ji,jj,jk) = ( tg_hbatt%d_value(ji  ,jj  ,1,1)*z_esigt3(ji  ,jj  ,jk) &
+                                   & + tg_hbatt%d_value(ji+1,jj  ,1,1)*z_esigt3(ji+1,jj  ,jk) &
+                                   & + tg_hbatt%d_value(ji  ,jj+1,1,1)*z_esigt3(ji  ,jj+1,jk) &
+                                   & + tg_hbatt%d_value(ji+1,jj+1,1,1)*z_esigt3(ji+1,jj+1,jk) ) / ztmpf
+            ENDIF
+
+             tg_e3t_0%d_value(ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatt%d_value(ji,jj,1,1))*z_esigt3 (ji,jj,jk)
+             tg_e3u_0%d_value(ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatu%d_value(ji,jj,1,1))*z_esigtu3(ji,jj,jk)
+             tg_e3v_0%d_value(ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatv%d_value(ji,jj,1,1))*z_esigtv3(ji,jj,jk)
+             !tg_e3f_0%d_value(ji,jj,jk,1) = (dd_scosrf(ji,jj)+tg_hbatf%d_value(ji,jj,1,1))*z_esigtf3(ji,jj,jk)
+             !
+             tg_e3w_0%d_value (ji,jj,jk,1) = tg_hbatt%d_value(ji,jj,1,1)*z_esigw3 (ji,jj,jk)
+             !tg_e3uw_0%d_value(ji,jj,jk,1) = tg_hbatu%d_value(ji,jj,1,1)*z_esigwu3(ji,jj,jk)
+             !tg_e3vw_0%d_value(ji,jj,jk,1) = tg_hbatv%d_value(ji,jj,1,1)*z_esigwv3(ji,jj,jk)
+          END DO
+
+        ENDDO
+      ENDDO
+
+      CALL lbc_lnk(tg_e3t_0 %d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp) 
+      CALL lbc_lnk(tg_e3u_0 %d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp)
+      CALL lbc_lnk(tg_e3v_0 %d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp) 
+      !CALL lbc_lnk(tg_e3f_0 %d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp)
+      CALL lbc_lnk(tg_e3w_0 %d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp)
+      !CALL lbc_lnk(tg_e3uw_0%d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp) 
+      !CALL lbc_lnk(tg_e3vw_0%d_value(:,:,:,1),'T', td_nam%i_perio, 1._dp)
+
+      DEALLOCATE( z_gsigw3  )
+      DEALLOCATE( z_gsigt3  )
+      DEALLOCATE( z_gsi3w3  )
+      DEALLOCATE( z_esigt3  )
+      DEALLOCATE( z_esigw3  )
+      DEALLOCATE( z_esigtu3 )
+      DEALLOCATE( z_esigtv3 )
+      DEALLOCATE( z_esigtf3 )
+      DEALLOCATE( z_esigwu3 )
+      DEALLOCATE( z_esigwv3 )
+
+   END SUBROUTINE grid_zgr__sco_s_sf12
+   !-------------------------------------------------------------------
+   !> @brief This subroutine stretch the s-coordinate system
+   !>
+   !>
+   !> ** Method  :   s-coordinate stretch 
+   !>
+   !> Reference : Madec, Lott, Delecluse and Crepon, 1996. JPO, 26, 1393-1408.   
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domzgr
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !> @param[in] dd_scosrf
+   !> @param[in] dd_hift 
+   !> @param[in] dd_hifu 
+   !> @param[in] dd_hifv 
+   !> @param[in] dd_hiff 
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr__sco_s_tanh( td_nam,jpi,jpj,jpk, &
+         &                          dd_scosrf, &
+         &                          dd_hift, dd_hifu, dd_hifv, dd_hiff ) 
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ),                 INTENT(IN   ) :: td_nam
+      INTEGER(i4),                 INTENT(IN   ) :: jpi
+      INTEGER(i4),                 INTENT(IN   ) :: jpj
+      INTEGER(i4),                 INTENT(IN   ) :: jpk
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_scosrf
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_hift
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_hifu
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_hifv
+      REAL(dp)   , DIMENSION(:,:), INTENT(IN   ) :: dd_hiff
+
+      ! local variable
+      REAL(dp) :: zcoeft
+      REAL(dp) :: zcoefw
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      tg_gsigt%d_value(1,1,:,1) =0._dp  
+      tg_gsigw%d_value(1,1,:,1) =0._dp
+      tg_gsi3w%d_value(1,1,:,1) =0._dp  
+      tg_esigt%d_value(1,1,:,1) =0._dp  
+      tg_esigw%d_value(1,1,:,1) =0._dp
+
+      DO jk = 1, jpk
+        tg_gsigw%d_value(1,1,jk,1) = -grid_zgr__sco_fssig( td_nam, jpk, REAL(jk,dp)-0.5_dp )
+        tg_gsigt%d_value(1,1,jk,1) = -grid_zgr__sco_fssig( td_nam, jpk, REAL(jk,dp)        )
+      END DO
+      CALL logger_info('z_gsigw 1 jpk '//TRIM(fct_str(tg_gsigw%d_value(1,1,1,1)))//&
+         &             TRIM(fct_str(tg_gsigw%d_value(1,1,jpk,1))) )
+
+      ! Coefficients for vertical scale factors at w-, t- levels
+!!gm bug :  define it from analytical function, not like juste bellow....
+!!gm        or betteroffer the 2 possibilities....
+      DO jk = 1, jpk-1
+         tg_esigt%d_value(1,1,jk  ,1) = tg_gsigw%d_value(1,1,jk+1,1) - tg_gsigw%d_value(1,1,jk,1)
+         tg_esigw%d_value(1,1,jk+1,1) = tg_gsigt%d_value(1,1,jk+1,1) - tg_gsigt%d_value(1,1,jk,1)
+      END DO
+      tg_esigw%d_value(1,1, 1 ,1) = 2._dp * ( tg_gsigt%d_value(1,1,1  ,1) - tg_gsigw%d_value(1,1,1  ,1) ) 
+      tg_esigt%d_value(1,1,jpk,1) = 2._dp * ( tg_gsigt%d_value(1,1,jpk,1) - tg_gsigw%d_value(1,1,jpk,1) )
+
+      ! Coefficients for vertical depth as the sum of e3w scale factors
+      tg_gsi3w%d_value(1,1,1,1) = 0.5_dp * tg_esigw%d_value(1,1,1,1)
+      DO jk = 2, jpk
+         tg_gsi3w%d_value(1,1,jk,1) = tg_gsi3w%d_value(1,1,jk-1,1) + tg_esigw%d_value(1,1,jk,1)
+      END DO
+!!gm: depuw, depvw can be suppressed (modif in ldfslp) and depw=dep3w can be set (save 3 3D arrays)
+      DO jk = 1, jpk
+         zcoeft = ( REAL(jk,dp) - 0.5_dp ) / REAL(jpk-1,dp)
+         zcoefw = ( REAL(jk,dp) - 1.0_dp ) / REAL(jpk-1,dp)
+         tg_gdept_0%d_value (:,:,jk,1) = dd_scosrf(:,:) + ( tg_hbatt%d_value(:,:,1 ,1) - dd_hift(:,:) ) &
+            &                                             * tg_gsigt%d_value(1,1,jk,1) + dd_hift(:,:)*zcoeft
+         tg_gdepw_0%d_value (:,:,jk,1) = dd_scosrf(:,:) + ( tg_hbatt%d_value(:,:,1 ,1) - dd_hift(:,:) ) &
+            &                                             * tg_gsigw%d_value(1,1,jk,1) + dd_hift(:,:)*zcoefw
+         !tg_gdep3w_0%d_value(:,:,jk,1) = dd_scosrf(:,:) + ( tg_hbatt%d_value(:,:,1 ,1) - dd_hift(:,:)) &
+         !                                                 * tg_gsi3w%d_value(1,1,jk,1) + dd_hift(:,:)*zcoeft
+      END DO
+!!gm: e3uw, e3vw can be suppressed  (modif in dynzdf, dynzdf_iso, zdfbfr) (save 2 3D arrays)
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jk = 1, jpk
+              tg_e3t_0%d_value(ji,jj,jk,1) = ( (tg_hbatt%d_value(ji,jj,1 ,1) - dd_hift(ji,jj)) &
+                 &                            * tg_esigt%d_value(1 ,1 ,jk,1) + dd_hift(ji,jj)/REAL(jpk-1,dp) )
+              tg_e3u_0%d_value(ji,jj,jk,1) = ( (tg_hbatu%d_value(ji,jj,1 ,1) - dd_hifu(ji,jj)) &
+                 &                            * tg_esigt%d_value(1 ,1 ,jk,1) + dd_hifu(ji,jj)/REAL(jpk-1,dp) )
+              tg_e3v_0%d_value(ji,jj,jk,1) = ( (tg_hbatv%d_value(ji,jj,1 ,1) - dd_hifv(ji,jj)) &
+                 &                            * tg_esigt%d_value(1 ,1 ,jk,1) + dd_hifv(ji,jj)/REAL(jpk-1,dp) )
+              !tg_e3f_0%d_value(ji,jj,jk,1) = ( (tg_hbatf%d_value(ji,jj,1 ,1) - dd_hiff(ji,jj)) &
+              !   &                            * tg_esigt%d_value(1 ,1, jk,1) + dd_hiff(ji,jj)/REAL(jpk-1,dp) )
+               
+              tg_e3w_0%d_value (ji,jj,jk,1)= ( (tg_hbatt%d_value(ji,jj,1 ,1) - dd_hift(ji,jj)) &
+                 &                            * tg_esigw%d_value(1 ,1 ,jk,1) + dd_hift(ji,jj)/REAL(jpk-1,dp) )
+              !tg_e3uw_0%d_value(ji,jj,jk,1)= ( (tg_hbatu%d_value(ji,jj,1 ,1) - dd_hifu(ji,jj)) &
+              !   &                            * tg_esigw%d_value(1 ,1 ,jk,1) + dd_hifu(ji,jj)/REAL(jpk-1,dp) )
+              !tg_e3vw_0%d_value(ji,jj,jk,1)= ( (tg_hbatv%d_value(ji,jj,1 ,1) - dd_hifv(ji,jj)) &
+              !   &                            * tg_esigw%d_value(1 ,1 ,jk,1) + dd_hifv(ji,jj)/REAL(jpk-1,dp) )
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE grid_zgr__sco_s_tanh
+   !!----------------------------------------------------------------------
+   !> @brief This function provide the analytical function in s-coordinate
+   !>        
+   !> @details
+   !> ** Method  :   the function provide the non-dimensional position of
+   !>                T and W (i.e. between 0 and 1)
+   !>                T-points at integer values (between 1 and jpk)
+   !>                W-points at integer values - 1/2 (between 0.5 and jpk-0.5)
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domzgr
+   !>
+   !> @param[in] td_nam 
+   !> @param[in] jpk
+   !> @param[in] pk
+   !!----------------------------------------------------------------------
+   FUNCTION grid_zgr__sco_fssig( td_nam, jpk, pk ) RESULT( pf )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      REAL(dp)   , INTENT(IN   ) :: pk   ! continuous "k" coordinate
+      REAL(dp)                   :: pf   ! sigma value
+      !!----------------------------------------------------------------------
+      !
+      pf =   (   TANH( td_nam%d_theta * ( -(pk-0.5_dp) / REAL(jpk-1) + td_nam%d_thetb )  )   &
+         &     - TANH( td_nam%d_thetb * td_nam%d_theta                                )  )   &
+         & * (   COSH( td_nam%d_theta                           )                      &
+         &     + COSH( td_nam%d_theta * ( 2._dp * td_nam%d_thetb - 1._dp ) )  )              &
+         & / ( 2._dp * SINH( td_nam%d_theta ) )
+      !
+   END FUNCTION grid_zgr__sco_fssig
+   !!----------------------------------------------------------------------
+   !> @brief This function provide the Song and Haidvogel version of the analytical function in s-coordinate
+   !>
+   !> @details
+   !> ** Method  :   the function provides the non-dimensional position of
+   !>                T and W (i.e. between 0 and 1)
+   !>                T-points at integer values (between 1 and jpk)
+   !>                W-points at integer values - 1/2 (between 0.5 and jpk-0.5)
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domzgr
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] pk1 
+   !> @param[in] pbb
+   !!----------------------------------------------------------------------
+   FUNCTION grid_zgr__sco_fssig1( td_nam, jpk, pk1, pbb ) RESULT( pf1 )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      REAL(dp)   , INTENT(IN   ) :: pk1   ! continuous "k" coordinate
+      REAL(dp)   , INTENT(IN   ) :: pbb   ! Stretching coefficient
+      REAL(dp)                   :: pf1   ! sigma value
+      !!----------------------------------------------------------------------
+      !
+      IF ( td_nam%d_theta == 0 ) then      ! uniform sigma
+         pf1 = - ( pk1 - 0.5_dp ) / REAL( jpk-1 )
+      ELSE                        ! stretched sigma
+         pf1 =   ( 1._dp - pbb ) * ( SINH( td_nam%d_theta*(-(pk1-0.5_dp)/REAL(jpk-1)) ) ) / SINH( td_nam%d_theta )              &
+            &  + pbb * (  (TANH( td_nam%d_theta*( (-(pk1-0.5_dp)/REAL(jpk-1)) + 0.5_dp) ) - TANH( 0.5_dp * td_nam%d_theta )  )  &
+            &        / ( 2._dp * TANH( 0.5_dp * td_nam%d_theta ) )  )
+      ENDIF
+      !
+   END FUNCTION grid_zgr__sco_fssig1
+   !!----------------------------------------------------------------------
+   !> @brief This function provide analytical function for the s-coordinate
+   !>
+   !> @details
+   !> ** Method  :   the function provides the non-dimensional position of
+   !>                T and W (i.e. between 0 and 1)
+   !>                T-points at integer values (between 1 and jpk)
+   !>                W-points at integer values - 1/2 (between 0.5 and jpk-0.5)
+   !>
+   !>                This method allows the maintenance of fixed surface and or
+   !>                bottom cell resolutions (cf. geopotential coordinates) 
+   !>                within an analytically derived stretched S-coordinate framework.
+   !>
+   !> Reference  :   Siddorn and Furner, in prep
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domzgr 
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpk
+   !> @param[in] pk1 
+   !> @param[in] pzb
+   !> @param[in] pzs
+   !> @param[in] pzsmth
+   !!----------------------------------------------------------------------
+   FUNCTION grid_zgr__sco_fgamma( td_nam, jpk, pk1, pzb, pzs, psmth) RESULT( p_gamma )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpk
+      REAL(dp)   , INTENT(IN   ) :: pk1(jpk)       ! continuous "k" coordinate
+      REAL(dp)                   :: p_gamma(jpk)   ! stretched coordinate
+      REAL(dp)   , INTENT(IN   ) :: pzb           ! Bottom box depth
+      REAL(dp)   , INTENT(IN   ) :: pzs           ! surface box depth
+      REAL(dp)   , INTENT(IN   ) :: psmth       ! Smoothing parameter
+      REAL(dp)                   :: za1,za2,za3    ! local variables
+      REAL(dp)                   :: zn1,zn2        ! local variables
+      REAL(dp)                   :: za,zb,zx       ! local variables
+
+      ! loop indices
+      INTEGER(i4)             ::   jk
+      !!----------------------------------------------------------------------
+      !
+      zn1  =  1./(jpk-1.)
+      zn2  =  1. -  zn1
+
+      za1 = (td_nam%d_alpha+2.0_dp)*zn1**(td_nam%d_alpha+1.0_dp)-(td_nam%d_alpha+1.0_dp)*zn1**(td_nam%d_alpha+2.0_dp) 
+      za2 = (td_nam%d_alpha+2.0_dp)*zn2**(td_nam%d_alpha+1.0_dp)-(td_nam%d_alpha+1.0_dp)*zn2**(td_nam%d_alpha+2.0_dp)
+      za3 = (zn2**3.0_dp - za2)/( zn1**3.0_dp - za1)
+     
+      za = pzb - za3*(pzs-za1)-za2
+      za = za/( zn2-0.5_dp*(za2+zn2**2.0_dp) - za3*(zn1-0.5_dp*(za1+zn1**2.0_dp) ) )
+      zb = (pzs - za1 - za*( zn1-0.5_dp*(za1+zn1**2.0_dp ) ) ) / (zn1**3.0_dp - za1)
+      zx = 1.0_dp-za/2.0_dp-zb
+ 
+      DO jk = 1, jpk
+        p_gamma(jk) = za*(pk1(jk)*(1.0_dp-pk1(jk)/2.0_dp))+zb*pk1(jk)**3.0_dp +  &
+                    & zx*( (td_nam%d_alpha+2.0_dp)*pk1(jk)**(td_nam%d_alpha+1.0_dp)- &
+                    &      (td_nam%d_alpha+1.0_dp)*pk1(jk)**(td_nam%d_alpha+2.0_dp) )
+        p_gamma(jk) = p_gamma(jk)*psmth+pk1(jk)*(1.0_dp-psmth)
+      ENDDO 
+
+      !
+   END FUNCTION grid_zgr__sco_fgamma
+   !-------------------------------------------------------------------
+   !> @brief This subroutine stretch the s-coordinate system
+   !>
+   !>
+   !> ** Method  :   s-coordinate stretch 
+   !>
+   !> Reference : Madec, Lott, Delecluse and Crepon, 1996. JPO, 26, 1393-1408.   
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - rewrite from domain (dom_stiff) 
+   !>
+   !> @param[in] td_nam
+   !> @param[in] jpi
+   !> @param[in] jpj
+   !> @param[in] jpk
+   !-------------------------------------------------------------------
+   SUBROUTINE grid_zgr_sco_stiff(td_nam, jpi,jpj,jpk)
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TNAMZ), INTENT(IN   ) :: td_nam
+      INTEGER(i4), INTENT(IN   ) :: jpi
+      INTEGER(i4), INTENT(IN   ) :: jpj
+      INTEGER(i4), INTENT(IN   ) :: jpk
+
+      ! local variable
+      REAL(dp) ::   zrxmax
+      REAL(dp), DIMENSION(4) :: zr1
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+      tg_rx1%d_value(:,:,1,1) = 0._dp
+
+      zrxmax   = 0._dp
+      zr1(:)   = 0._dp
+
+      DO ji = 2, jpi-1
+         DO jj = 2, jpj-1
+            DO jk = 1, jpk-1
+               zr1(1) = tg_umask%d_value(ji-1,jj  ,jk,1) &
+                  &            * ABS( ( tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1) &
+                  &                   - tg_gdepw_0%d_value(ji-1,jj  ,jk  ,1) & 
+                  &                   + tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1) &
+                  &                   - tg_gdepw_0%d_value(ji-1,jj  ,jk+1,1) ) &
+                  &                 / ( tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1) &
+                  &                   + tg_gdepw_0%d_value(ji-1,jj  ,jk  ,1) &
+                  &                   - tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1) &
+                  &                   - tg_gdepw_0%d_value(ji-1,jj  ,jk+1,1) &
+                  &                   + dp_eps) )
+               zr1(2) = tg_umask%d_value(ji  ,jj  ,jk,1) &
+                  &            * ABS( ( tg_gdepw_0%d_value(ji+1,jj  ,jk  ,1) &
+                  &                   - tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1) &
+                  &                   + tg_gdepw_0%d_value(ji+1,jj  ,jk+1,1) &
+                  &                   - tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1) ) &
+                  &                 / ( tg_gdepw_0%d_value(ji+1,jj  ,jk  ,1)&
+                  &                   + tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1)&
+                  &                   - tg_gdepw_0%d_value(ji+1,jj  ,jk+1,1)&
+                  &                   - tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1)&
+                  &                   + dp_eps) )
+               zr1(3) = tg_vmask%d_value(ji  ,jj  ,jk,1) &
+                  &              * ABS( ( tg_gdepw_0%d_value(ji  ,jj+1,jk  ,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1)&
+                  &                     + tg_gdepw_0%d_value(ji  ,jj+1,jk+1,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1) ) &
+                  &                   / ( tg_gdepw_0%d_value(ji  ,jj+1,jk  ,1)&
+                  &                     + tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj+1,jk+1,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1)&
+                  &                     + dp_eps) )
+               zr1(4) = tg_vmask%d_value(ji  ,jj-1,jk,1) &
+                  &              * ABS( ( tg_gdepw_0%d_value(ji  ,jj  ,jk  ,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj-1,jk  ,1)&
+                  &                     + tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj-1,jk+1,1) ) &
+                  &                 / ( tg_gdepw_0%d_value  (ji  ,jj  ,jk  ,1)&
+                  &                     + tg_gdepw_0%d_value(ji  ,jj-1,jk  ,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj  ,jk+1,1)&
+                  &                     - tg_gdepw_0%d_value(ji  ,jj-1,jk+1,1)&
+                  &                     + dp_eps) )
+               zrxmax = MAXVAL(zr1(1:4))
+               tg_rx1%d_value(ji,jj,1,1) = MAX(tg_rx1%d_value(ji,jj,1,1), zrxmax)
+            END DO
+         END DO
+      END DO
+
+      CALL lbc_lnk( tg_rx1%d_value(:,:,1,1), 'T', td_nam%i_perio, 1._dp )
+
+      zrxmax = MAXVAL(tg_rx1%d_value(:,:,1,1))
+      CALL logger_info(' GRID ZGR SCO STIFF: maximum grid stiffness ratio: '//&
+         &  TRIM(fct_str(zrxmax)) )
+
+   END SUBROUTINE grid_zgr_sco_stiff
+END MODULE grid_zgr
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/iom.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/iom.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/iom.f90	(revision 7025)
@@ -157,5 +157,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date October, 2016
+   !> - open cdf4 file as cdf
+   !>
    !> @param[inout] td_file file structure
    !-------------------------------------------------------------------
@@ -172,5 +174,5 @@
       SELECT CASE(TRIM(ADJUSTL(fct_lower(td_file%c_type))))
 
-         CASE('cdf')
+         CASE('cdf','cdf4')
             CALL iom_cdf_open(td_file)
          CASE('dimg')
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 7025)
@@ -652,5 +652,5 @@
          &  " IOM CDF READ DIM: no id associated to file "//TRIM(td_file%c_name))
 
-      ELSE      
+      ELSE
 
          CALL logger_trace( &
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/lbc.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/lbc.f90	(revision 7025)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/lbc.f90	(revision 7025)
@@ -0,0 +1,804 @@
+!----------------------------------------------------------------------
+! NEMO system team, System and Interface for oceanic RElocable Nesting
+!----------------------------------------------------------------------
+!
+! MODULE: math
+!
+! DESCRIPTION:
+!> @brief
+!> This module groups lateral boundary conditions subroutine.
+!>
+!> @details
+!>
+!> @warning keep only non mpp case
+!>
+!> @author
+!> G. Madec
+! REVISION HISTORY:
+!>  @date June, 1997 - Original code
+!> @date September, 2002
+!> - F90: Free form and module
+!>  @date Marsh, 2009
+!> - R. Benshila : External north fold treatment  
+!>  @date December, 2012
+!> - S.Mocavero, I. Epicoco : Add 'lbc_bdy_lnk' and lbc_obc_lnk' routine to optimize the BDY/OBC communications
+!> @date December, 2012
+!> - R. Bourdalle-Badie and G. Reffray : add a C1D case 
+!> @date January, 2015 
+!> - J.Paul : rewrite with SIREN coding rules
+!> @date Marsh, 2015 
+!> - J.Paul : add hide subroutine
+!
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!----------------------------------------------------------------------
+MODULE lbc
+   USE kind                            ! F90 kind parameter
+   ! NOTE_avoid_public_variables_if_possible
+
+   ! function and subroutine
+   PUBLIC :: lbc_lnk 
+   PUBLIC :: lbc_nfd  
+   PUBLIC :: lbc_hide  
+
+   PRIVATE :: lbc__lnk_3d
+   PRIVATE :: lbc__lnk_2d
+   PRIVATE :: lbc__nfd_3d
+   PRIVATE :: lbc__nfd_2d
+   PRIVATE :: lbc__hide_lnk_2d
+   PRIVATE :: lbc__hide_nfd
+   PRIVATE :: lbc__hide_nfd_2d
+
+   INTERFACE lbc_lnk
+      MODULE PROCEDURE   lbc__lnk_3d
+      MODULE PROCEDURE   lbc__lnk_2d
+   END INTERFACE
+
+   INTERFACE lbc_nfd
+      MODULE PROCEDURE   lbc__nfd_3d
+      MODULE PROCEDURE   lbc__nfd_2d
+   END INTERFACE
+
+   INTERFACE lbc_hide
+      MODULE PROCEDURE   lbc__hide_lnk_2d
+   END INTERFACE
+
+   INTERFACE lbc__hide_nfd
+      MODULE PROCEDURE   lbc__hide_nfd_2d
+   END INTERFACE
+    
+CONTAINS
+   !------------------------------------------------------------------- 
+   !> @brief This subroutine set lateral boundary conditions on a 3D array (non mpp case) 
+   !>
+   !> @details
+   !>             dd_psign = -1 :    change the sign across the north fold
+   !>                      =  1 : no change of the sign across the north fold
+   !>                      =  0 : no change of the sign across the north fold and
+   !>                             strict positivity preserved: use inner row/column
+   !>                             for closed boundaries.
+   !> @author J.Paul 
+   !> - January, 2015- rewrite with SIREN coding rules 
+   ! 
+   !> @param[inout] dd_array  3D array 
+   !> @param[in] cd_type point grid
+   !> @param[in] id_perio NEMO periodicity of the grid
+   !> @param[in] dd_psgn 
+   !> @param[in] dd_fill   fillValue
+   !-------------------------------------------------------------------
+   SUBROUTINE lbc__lnk_3d( dd_array, cd_type, id_perio, dd_psgn, dd_fill )
+      IMPLICIT NONE
+      ! Argument
+      REAL(dp), DIMENSION(:,:,:), INTENT(INOUT) :: dd_array
+      CHARACTER(LEN=*)          , INTENT(IN   ) :: cd_type
+      INTEGER(i4)               , INTENT(IN   ) :: id_perio
+      REAL(dp),                   INTENT(IN   ) :: dd_psgn
+      REAL(dp),                   INTENT(IN   ), OPTIONAL :: dd_fill
+
+      ! local variable
+      REAL(dp)    :: dl_fill
+
+      INTEGER(i4) :: il_jpi
+      INTEGER(i4) :: il_jpj
+      INTEGER(i4) :: il_jpim1
+      !----------------------------------------------------------------
+      IF( PRESENT( dd_fill ) ) THEN   ;   dl_fill = dd_fill      ! set FillValue (zero by default)
+      ELSE                            ;   dl_fill = 0._dp
+      ENDIF
+
+      il_jpi=SIZE(dd_array(:,:,:),DIM=1)
+      il_jpj=SIZE(dd_array(:,:,:),DIM=2)
+
+      il_jpim1=il_jpi-1
+      !
+      !                                     ! East-West boundaries
+      !                                     ! ====================
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 1 , 4 , 6 )                       !**  cyclic east-west
+         dd_array(    1 ,:,:) = dd_array(il_jpim1,:,:)            ! all points
+         dd_array(il_jpi,:,:) = dd_array(     2  ,:,:)
+         !
+      CASE DEFAULT                             !**  East closed  --  West closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+            dd_array(    1 ,:,:) = dl_fill
+            dd_array(il_jpi,:,:) = dl_fill
+         CASE ( 'F' )                               ! F-point
+            dd_array(il_jpi,:,:) = dl_fill
+         END SELECT
+         !
+      END SELECT
+      !
+      !                                     ! North-South boundaries
+      !                                     ! ======================
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 2 )                               !**  South symmetric  --  North closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+            dd_array(:,    1 ,:) = dd_array(:,3,:)
+            dd_array(:,il_jpj,:) = dl_fill
+         CASE ( 'V' , 'F' )                         ! V-, F-points
+            dd_array(:,    1 ,:) = dd_psgn * dd_array(:,2,:)
+            dd_array(:,il_jpj,:) = dl_fill
+         END SELECT
+         !
+      CASE ( 3 , 4 , 5 , 6 )                   !**  North fold  T or F-point pivot  --  South closed
+         SELECT CASE ( TRIM(cd_type) )                    ! South : closed
+         CASE ( 'T' , 'U' , 'V' , 'W' , 'I' )             ! all points except F-point
+            dd_array(:, 1 ,:) = dl_fill
+         END SELECT
+         !                                          ! North fold
+         CALL lbc_nfd( dd_array(:,:,:), cd_type, id_perio, dd_psgn )
+         !
+      CASE DEFAULT                             !**  North closed  --  South closed
+         SELECT CASE ( cd_type )
+         CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+            dd_array(:,    1 ,:) = dl_fill
+            dd_array(:,il_jpj,:) = dl_fill
+         CASE ( 'F' )                               ! F-point
+            dd_array(:,il_jpj,:) = dl_fill
+         END SELECT
+         !
+      END SELECT
+
+   END SUBROUTINE lbc__lnk_3d
+   !------------------------------------------------------------------- 
+   !> @brief This subroutine set lateral boundary conditions on a 2D array (non mpp case) 
+   !>
+   !> @details
+   !>             dd_psign = -1 :    change the sign across the north fold
+   !>                      =  1 : no change of the sign across the north fold
+   !>                      =  0 : no change of the sign across the north fold and
+   !>                             strict positivity preserved: use inner row/column
+   !>                             for closed boundaries.
+   !> @author J.Paul 
+   !> - January, 2015- rewrite with SIREN coding rules
+   ! 
+   !> @param[inout] dd_array  2D array 
+   !> @param[in] cd_type point grid
+   !> @param[in] id_perio NEMO periodicity of the grid
+   !> @param[in] dd_psgn 
+   !> @param[in] dd_fill   fillValue
+   !-------------------------------------------------------------------
+   SUBROUTINE lbc__lnk_2d( dd_array, cd_type, id_perio, dd_psgn, dd_fill )
+      IMPLICIT NONE
+      ! Argument
+      REAL(dp), DIMENSION(:,:), INTENT(INOUT) :: dd_array
+      CHARACTER(LEN=*)        , INTENT(IN   ) :: cd_type
+      INTEGER(i4)             , INTENT(IN   ) :: id_perio
+      REAL(dp)                , INTENT(IN   ) :: dd_psgn
+      REAL(dp)                , INTENT(IN   ), OPTIONAL :: dd_fill
+
+      ! local variable
+      REAL(dp)    :: dl_fill
+
+      INTEGER(i4) :: il_jpi
+      INTEGER(i4) :: il_jpj
+      INTEGER(i4) :: il_jpim1
+      !----------------------------------------------------------------
+      IF( PRESENT( dd_fill ) ) THEN   ;   dl_fill = dd_fill      ! set FillValue (zero by default)
+      ELSE                            ;   dl_fill = 0._dp
+      ENDIF
+
+      il_jpi=SIZE(dd_array(:,:),DIM=1)
+      il_jpj=SIZE(dd_array(:,:),DIM=2)
+
+      il_jpim1=il_jpi-1
+
+      !
+      !                                     ! East-West boundaries
+      !                                     ! ====================
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 1 , 4 , 6 )                       !** cyclic east-west
+         dd_array(    1 ,:) = dd_array(il_jpim1,:)               ! all points
+         dd_array(il_jpi,:) = dd_array(     2  ,:)
+         !
+      CASE DEFAULT                             !** East closed  --  West closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )            ! T-, U-, V-, W-points
+            dd_array(    1 ,:) = dl_fill
+            dd_array(il_jpi,:) = dl_fill
+         CASE ( 'F' )                              ! F-point
+            dd_array(il_jpi,:) = dl_fill
+         END SELECT
+         !
+      END SELECT
+      !
+      !                                     ! North-South boundaries
+      !                                     ! ======================
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 2 )                               !**  South symmetric  --  North closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+            dd_array(:,   1  ) = dd_array(:,3)
+            dd_array(:,il_jpj) = dl_fill
+         CASE ( 'V' , 'F' )                         ! V-, F-points
+            dd_array(:,   1  ) = dd_psgn * dd_array(:,2)
+            dd_array(:,il_jpj) = dl_fill
+         END SELECT
+         !
+      CASE ( 3 , 4 , 5 , 6 )                   !**  North fold  T or F-point pivot  --  South closed
+         SELECT CASE ( TRIM(cd_type) )                    ! South : closed
+         CASE ( 'T' , 'U' , 'V' , 'W' , 'I' )             ! all points except F-point
+            dd_array(:, 1 ) = dl_fill
+         END SELECT
+         !                                          ! North fold
+         CALL lbc_nfd( dd_array(:,:), cd_type, id_perio, dd_psgn )
+         !
+      CASE DEFAULT                             !**  North closed  --  South closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+            dd_array(:,   1  ) = dl_fill
+            dd_array(:,il_jpj) = dl_fill
+         CASE ( 'F' )                               ! F-point
+            dd_array(:,il_jpj) = dl_fill
+         END SELECT
+         !
+      END SELECT
+
+   END SUBROUTINE lbc__lnk_2d
+   !------------------------------------------------------------------- 
+   !> @brief This subroutine manage 3D lateral boundary condition : 
+   !> North fold treatment without processor exchanges. 
+   !>
+   !> @warning keep only non mpp case
+   !>
+   !> @author J.Paul 
+   !> - January, 2015- rewrite with SIREN coding rules
+   ! 
+   !> @param[inout] dd_array  3D array 
+   !> @param[in] cd_type point grid
+   !> @param[in] id_perio NEMO periodicity of the grid
+   !> @param[in] dd_psgn 
+   !-------------------------------------------------------------------
+   SUBROUTINE lbc__nfd_3d( dd_array, cd_type, id_perio, dd_psgn )
+      IMPLICIT NONE
+      ! Argument
+      REAL(dp), DIMENSION(:,:,:), INTENT(INOUT) :: dd_array
+      CHARACTER(LEN=*)          , INTENT(IN   ) :: cd_type
+      INTEGER(i4)               , INTENT(IN   ) :: id_perio
+      REAL(dp)                  , INTENT(IN   ) :: dd_psgn
+
+      ! local variable
+      INTEGER(i4) :: il_jpi
+      INTEGER(i4) :: il_jpj
+      INTEGER(i4) :: il_jpk
+      INTEGER(i4) :: il_jpim1
+      INTEGER(i4) :: il_jpjm1
+
+      INTEGER(i4) :: ijt
+      INTEGER(i4) :: iju
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+      
+      il_jpi=SIZE(dd_array(:,:,:),DIM=1)
+      il_jpj=SIZE(dd_array(:,:,:),DIM=2)
+      il_jpk=SIZE(dd_array(:,:,:),DIM=3)
+
+      il_jpim1=il_jpi-1
+      il_jpjm1=il_jpj-1
+
+      DO jk = 1, il_jpk
+         !
+         SELECT CASE ( id_perio )
+         !
+         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
+            !
+            SELECT CASE ( TRIM(cd_type) )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 2, il_jpi
+                  ijt = il_jpi-ji+2
+                  dd_array(ji,il_jpj,jk) = dd_psgn * dd_array(ijt,il_jpj-2,jk)
+               END DO
+               dd_array(1,il_jpj,jk) = dd_psgn * dd_array(3,il_jpj-2,jk)
+               DO ji = il_jpi/2+1, il_jpi
+                  ijt = il_jpi-ji+2
+                  dd_array(ji,il_jpjm1,jk) = dd_psgn * dd_array(ijt,il_jpjm1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, il_jpi-1
+                  iju = il_jpi-ji+1
+                  dd_array(ji,il_jpj,jk) = dd_psgn * dd_array(iju,il_jpj-2,jk)
+               END DO
+               dd_array(   1  ,il_jpj,jk) = dd_psgn * dd_array(    2   ,il_jpj-2,jk)
+               dd_array(il_jpi,il_jpj,jk) = dd_psgn * dd_array(il_jpi-1,il_jpj-2,jk) 
+               DO ji = il_jpi/2, il_jpi-1
+                  iju = il_jpi-ji+1
+                  dd_array(ji,il_jpjm1,jk) = dd_psgn * dd_array(iju,il_jpjm1,jk)
+               END DO
+            CASE ( 'V' )                               ! V-point
+               DO ji = 2, il_jpi
+                  ijt = il_jpi-ji+2
+                  dd_array(ji,il_jpj-1,jk) = dd_psgn * dd_array(ijt,il_jpj-2,jk)
+                  dd_array(ji,il_jpj  ,jk) = dd_psgn * dd_array(ijt,il_jpj-3,jk)
+               END DO
+               dd_array(1,il_jpj,jk) = dd_psgn * dd_array(3,il_jpj-3,jk) 
+            CASE ( 'F' )                               ! F-point
+               DO ji = 1, il_jpi-1
+                  iju = il_jpi-ji+1
+                  dd_array(ji,il_jpj-1,jk) = dd_psgn * dd_array(iju,il_jpj-2,jk)
+                  dd_array(ji,il_jpj  ,jk) = dd_psgn * dd_array(iju,il_jpj-3,jk)
+               END DO
+               dd_array(   1  ,il_jpj,jk) = dd_psgn * dd_array(    2   ,il_jpj-3,jk)
+               dd_array(il_jpi,il_jpj,jk) = dd_psgn * dd_array(il_jpi-1,il_jpj-3,jk) 
+            END SELECT
+            !
+         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
+            !
+            SELECT CASE ( TRIM(cd_type) )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 1, il_jpi
+                  ijt = il_jpi-ji+1
+                  dd_array(ji,il_jpj,jk) = dd_psgn * dd_array(ijt,il_jpj-1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, il_jpi-1
+                  iju = il_jpi-ji
+                  dd_array(ji,il_jpj,jk) = dd_psgn * dd_array(iju,il_jpj-1,jk)
+               END DO
+               dd_array(il_jpi,il_jpj,jk) = dd_psgn * dd_array(1,il_jpj-1,jk)
+            CASE ( 'V' )                               ! V-point
+               DO ji = 1, il_jpi
+                  ijt = il_jpi-ji+1
+                  dd_array(ji,il_jpj,jk) = dd_psgn * dd_array(ijt,il_jpj-2,jk)
+               END DO
+               DO ji = il_jpi/2+1, il_jpi
+                  ijt = il_jpi-ji+1
+                  dd_array(ji,il_jpjm1,jk) = dd_psgn * dd_array(ijt,il_jpjm1,jk)
+               END DO
+            CASE ( 'F' )                               ! F-point
+               DO ji = 1, il_jpi-1
+                  iju = il_jpi-ji
+                  dd_array(ji,il_jpj  ,jk) = dd_psgn * dd_array(iju,il_jpj-2,jk)
+               END DO
+               dd_array(il_jpi,il_jpj,jk) = dd_psgn * dd_array(1,il_jpj-2,jk)
+               DO ji = il_jpi/2+1, il_jpi-1
+                  iju = il_jpi-ji
+                  dd_array(ji,il_jpjm1,jk) = dd_psgn * dd_array(iju,il_jpjm1,jk)
+               END DO
+            END SELECT
+            !
+         CASE DEFAULT                           ! *  closed : the code probably never go through
+            !
+            SELECT CASE ( TRIM(cd_type))
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               dd_array(:, 1  ,jk) = 0.e0
+               dd_array(:,il_jpj,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               dd_array(:,il_jpj,jk) = 0.e0
+            END SELECT
+            !
+         END SELECT     !  id_perio
+         !
+      END DO
+   END SUBROUTINE lbc__nfd_3d
+   !------------------------------------------------------------------- 
+   !> @brief This subroutine manage 2D lateral boundary condition : 
+   !> North fold treatment without processor exchanges. 
+   !>
+   !> @warning keep only non mpp case
+   !> @warning do not use additional halos
+   !>
+   !> @author J.Paul 
+   !> - January, 2015- rewrite with SIREN coding rules
+   ! 
+   !> @param[inout] dd_array  2D array 
+   !> @param[in] cd_type point grid
+   !> @param[in] id_perio NEMO periodicity of the grid
+   !> @param[in] dd_psgn 
+   !-------------------------------------------------------------------
+   SUBROUTINE lbc__nfd_2d( dd_array, cd_type, id_perio, dd_psgn )
+      IMPLICIT NONE
+      ! Argument
+      REAL(dp), DIMENSION(:,:), INTENT(INOUT) :: dd_array
+      CHARACTER(LEN=*)        , INTENT(IN   ) :: cd_type
+      INTEGER(i4)             , INTENT(IN   ) :: id_perio
+      REAL(dp)                , INTENT(IN   ) :: dd_psgn
+
+      ! local variable
+      INTEGER(i4) :: il_jpi
+      INTEGER(i4) :: il_jpj
+      INTEGER(i4) :: il_jpim1
+      INTEGER(i4) :: il_jpjm1
+
+      INTEGER(i4) :: ijt
+      INTEGER(i4) :: iju
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+      il_jpi=SIZE(dd_array(:,:),DIM=1)
+      il_jpj=SIZE(dd_array(:,:),DIM=2)
+
+      il_jpim1=il_jpi-1
+      il_jpjm1=il_jpj-1
+
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+         !
+         SELECT CASE ( TRIM(cd_type) )
+         !
+         CASE ( 'T' , 'W' )                               ! T- , W-points
+            DO ji = 2, il_jpi
+               ijt=il_jpi-ji+2
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(ijt,il_jpj-2)
+            END DO
+            dd_array(1,il_jpj)   = dd_psgn * dd_array(3,il_jpj-2)
+            dd_array(1,il_jpj-1) = dd_psgn * dd_array(3,il_jpj-1)
+            DO ji = il_jpi/2+1, il_jpi
+               ijt=il_jpi-ji+2
+               dd_array(ji,il_jpj-1) = dd_psgn * dd_array(ijt,il_jpj-1)
+            END DO
+         CASE ( 'U' )                                     ! U-point
+            DO ji = 1, il_jpi-1
+               iju = il_jpi-ji+1
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-2)
+            END DO
+            dd_array(   1  ,il_jpj  ) = dd_psgn * dd_array(    2   ,il_jpj-2)
+            dd_array(il_jpi,il_jpj  ) = dd_psgn * dd_array(il_jpi-1,il_jpj-2)
+            dd_array(1     ,il_jpj-1) = dd_psgn * dd_array(il_jpi  ,il_jpj-1)   
+            DO ji = il_jpi/2, il_jpi-1
+               iju = il_jpi-ji+1
+               dd_array(ji,il_jpjm1) = dd_psgn * dd_array(iju,il_jpjm1)
+            END DO
+         CASE ( 'V' )                                     ! V-point
+            DO ji = 2, il_jpi
+               ijt = il_jpi-ji+2
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(ijt,il_jpj-3)
+            END DO
+            dd_array( 1 ,il_jpj)   = dd_psgn * dd_array( 3 ,il_jpj-3) 
+         CASE ( 'F' )                                     ! F-point
+            DO ji = 1, il_jpi-1
+               iju = il_jpi-ji+1
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-3)
+            END DO
+            dd_array(   1  ,il_jpj)   = dd_psgn * dd_array(    2   ,il_jpj-3)
+            dd_array(il_jpi,il_jpj)   = dd_psgn * dd_array(il_jpi-1,il_jpj-3)
+            dd_array(il_jpi,il_jpj-1) = dd_psgn * dd_array(il_jpi-1,il_jpj-2)      
+            dd_array(   1  ,il_jpj-1) = dd_psgn * dd_array(    2   ,il_jpj-2)      
+         CASE ( 'I' )                                     ! ice U-V point (I-point)
+            dd_array(2,il_jpj) = dd_psgn * dd_array(3,il_jpj-1)
+            DO ji = 3, il_jpi
+               iju = il_jpi - ji + 3
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-1)
+            END DO
+         CASE ( 'J' )                                     ! first ice U-V point
+            dd_array(2,il_jpj) = dd_psgn * dd_array(3,il_jpj-1)
+            DO ji = 3, il_jpi
+               iju = il_jpi - ji + 3
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-1)
+            END DO
+         CASE ( 'K' )                                     ! second ice U-V point
+            dd_array(2,il_jpj) = dd_psgn * dd_array(3,il_jpj-1)
+            DO ji = 3, il_jpi
+               iju = il_jpi - ji + 3
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-1)
+            END DO
+         END SELECT
+         !
+      CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+         !
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'W' )                               ! T-, W-point
+            DO ji = 1, il_jpi
+               ijt = il_jpi-ji+1
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(ijt,il_jpj-1)
+            END DO
+         CASE ( 'U' )                                     ! U-point
+            DO ji = 1, il_jpi-1
+               iju = il_jpi-ji
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-1)
+            END DO
+            dd_array(il_jpi,il_jpj) = dd_psgn * dd_array(1,il_jpj-1)
+         CASE ( 'V' )                                     ! V-point
+            DO ji = 1, il_jpi
+               ijt = il_jpi-ji+1
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(ijt,il_jpj-2)
+            END DO
+            DO ji = il_jpi/2+1, il_jpi
+               ijt = il_jpi-ji+1
+               dd_array(ji,il_jpjm1) = dd_psgn * dd_array(ijt,il_jpjm1)
+            END DO
+         CASE ( 'F' )                               ! F-point
+            DO ji = 1, il_jpi-1
+               iju = il_jpi-ji
+               dd_array(ji,il_jpj) = dd_psgn * dd_array(iju,il_jpj-2)
+            END DO
+            dd_array(il_jpi,il_jpj) = dd_psgn * dd_array(1,il_jpj-2)
+            DO ji = il_jpi/2+1, il_jpi-1
+               iju = il_jpi-ji
+               dd_array(ji,il_jpjm1) = dd_psgn * dd_array(iju,il_jpjm1)
+            END DO
+         CASE ( 'I' )                                  ! ice U-V point (I-point)
+            dd_array( 2 ,il_jpj) = 0.e0
+            DO ji = 2 , il_jpi-1
+               ijt = il_jpi - ji + 2
+               dd_array(ji,il_jpj)= 0.5 * ( dd_array(ji,il_jpj-1) + dd_psgn * dd_array(ijt,il_jpj-1) )
+            END DO
+         CASE ( 'J' )                                  ! first ice U-V point
+            dd_array( 2 ,il_jpj) = 0.e0
+            DO ji = 2 , il_jpi-1
+               ijt = il_jpi - ji + 2
+               dd_array(ji,il_jpj)= dd_array(ji,il_jpj-1)
+            END DO
+         CASE ( 'K' )                                  ! second ice U-V point
+            dd_array( 2 ,il_jpj) = 0.e0
+            DO ji = 2 , il_jpi-1
+               ijt = il_jpi - ji + 2
+               dd_array(ji,il_jpj)= dd_array(ijt,il_jpj-1)
+            END DO
+         END SELECT
+         !
+      CASE DEFAULT                           ! *  closed : the code probably never go through
+         !
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )                 ! T-, U-, V-, W-points
+            dd_array(:, 1    ) = 0.e0
+            dd_array(:,il_jpj) = 0.e0
+         CASE ( 'F' )                                   ! F-point
+            dd_array(:,il_jpj) = 0.e0
+         CASE ( 'I' )                                   ! ice U-V point
+            dd_array(:, 1    ) = 0.e0
+            dd_array(:,il_jpj) = 0.e0
+         CASE ( 'J' )                                   ! first ice U-V point
+            dd_array(:, 1    ) = 0.e0
+            dd_array(:,il_jpj) = 0.e0
+         CASE ( 'K' )                                   ! second ice U-V point
+            dd_array(:, 1    ) = 0.e0
+            dd_array(:,il_jpj) = 0.e0
+         END SELECT
+         !
+      END SELECT
+   END SUBROUTINE lbc__nfd_2d
+   !------------------------------------------------------------------- 
+   !> @brief This subroutine hide lateral boundary conditions on a 2D array (non mpp case) 
+   !>
+   !> @details
+   !>             dd_psign = -1 :    change the sign across the north fold
+   !>                      =  1 : no change of the sign across the north fold
+   !>                      =  0 : no change of the sign across the north fold and
+   !>                             strict positivity preserved: use inner row/column
+   !>                             for closed boundaries.
+   !> @author J.Paul 
+   !> - Marsh, 2015- initial version
+   ! 
+   !> @param[inout] dd_array  2D array 
+   !> @param[in] cd_type point grid
+   !> @param[in] id_perio NEMO periodicity of the grid
+   !> @param[in] dd_psgn 
+   !> @param[in] dd_fill   fillValue
+   !-------------------------------------------------------------------
+   SUBROUTINE lbc__hide_lnk_2d( dd_array, cd_type, id_perio, dd_psgn, dd_fill )
+      IMPLICIT NONE
+      ! Argument
+      REAL(dp), DIMENSION(:,:), INTENT(INOUT) :: dd_array
+      CHARACTER(LEN=*)        , INTENT(IN   ) :: cd_type
+      INTEGER(i4)             , INTENT(IN   ) :: id_perio
+      REAL(dp)                , INTENT(IN   ) :: dd_psgn
+      REAL(dp)                , INTENT(IN   ), OPTIONAL :: dd_fill
+
+      ! local variable
+      REAL(dp)    :: dl_fill
+
+      INTEGER(i4) :: il_jpi
+      INTEGER(i4) :: il_jpj
+      INTEGER(i4) :: il_jpim1
+      !----------------------------------------------------------------
+      IF( PRESENT( dd_fill ) ) THEN   ;   dl_fill = dd_fill      ! set FillValue (zero by default)
+      ELSE                            ;   dl_fill = 0._dp
+      ENDIF
+
+      il_jpi=SIZE(dd_array(:,:),DIM=1)
+      il_jpj=SIZE(dd_array(:,:),DIM=2)
+
+      il_jpim1=il_jpi-1
+
+      !
+      !                                     ! East-West boundaries
+      !                                     ! ====================
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 1 , 4 , 6 )                       !** cyclic east-west
+         dd_array(    1 ,:) = dl_fill               ! all points
+         dd_array(il_jpi,:) = dl_fill
+         !
+      CASE DEFAULT                             !** East closed  --  West closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )            ! T-, U-, V-, W-points
+            dd_array(    1 ,:) = dl_fill
+            dd_array(il_jpi,:) = dl_fill
+         CASE ( 'F' )                              ! F-point
+            dd_array(il_jpi,:) = dl_fill
+         END SELECT
+         !
+      END SELECT
+      !
+      !                                     ! North-South boundaries
+      !                                     ! ======================
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 2 )                               !**  South symmetric  --  North closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+            dd_array(:,   1  ) = dl_fill
+            dd_array(:,il_jpj) = dl_fill
+         CASE ( 'V' , 'F' )                         ! V-, F-points
+            dd_array(:,   1  ) = dl_fill
+            dd_array(:,il_jpj) = dl_fill
+         END SELECT
+         !
+      CASE ( 3 , 4 , 5 , 6 )                   !**  North fold  T or F-point pivot  --  South closed
+         SELECT CASE ( TRIM(cd_type) )                    ! South : closed
+         CASE ( 'T' , 'U' , 'V' , 'W' , 'I' )             ! all points except F-point
+            dd_array(:, 1 ) = dl_fill
+         END SELECT
+         !                                          ! North fold
+         CALL lbc__hide_nfd( dd_array(:,:), cd_type, id_perio, dd_psgn, &
+         &                   dd_fill=dl_fill )
+         !
+      CASE DEFAULT                             !**  North closed  --  South closed
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+            dd_array(:,   1  ) = dl_fill
+            dd_array(:,il_jpj) = dl_fill
+         CASE ( 'F' )                               ! F-point
+            dd_array(:,il_jpj) = dl_fill
+         END SELECT
+         !
+      END SELECT
+
+   END SUBROUTINE lbc__hide_lnk_2d
+   !------------------------------------------------------------------- 
+   !> @brief This subroutine manage 2D lateral boundary condition : 
+   !> hide North fold treatment without processor exchanges. 
+   !>
+   !> @warning keep only non mpp case
+   !> @warning do not use additional halos
+   !>
+   !> @author J.Paul 
+   !> - Marsh, 2015- initial version
+   ! 
+   !> @param[inout] dd_array  2D array 
+   !> @param[in] cd_type point grid
+   !> @param[in] id_perio NEMO periodicity of the grid
+   !> @param[in] dd_psgn 
+   !> @param[in] dd_fill 
+   !-------------------------------------------------------------------
+   SUBROUTINE lbc__hide_nfd_2d( dd_array, cd_type, id_perio, dd_psgn, dd_fill )
+      IMPLICIT NONE
+      ! Argument
+      REAL(dp), DIMENSION(:,:), INTENT(INOUT) :: dd_array
+      CHARACTER(LEN=*)        , INTENT(IN   ) :: cd_type
+      INTEGER(i4)             , INTENT(IN   ) :: id_perio
+      REAL(dp)                , INTENT(IN   ) :: dd_psgn
+      REAL(dp)                , INTENT(IN   ), OPTIONAL :: dd_fill
+
+      ! local variable
+      REAL(dp)    :: dl_fill
+
+      INTEGER(i4) :: il_jpi
+      INTEGER(i4) :: il_jpj
+      INTEGER(i4) :: il_jpim1
+      INTEGER(i4) :: il_jpjm1
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+      IF( PRESENT( dd_fill ) ) THEN   ;   dl_fill = dd_fill      ! set FillValue (zero by default)
+      ELSE                            ;   dl_fill = 0._dp
+      ENDIF
+
+      il_jpi=SIZE(dd_array(:,:),DIM=1)
+      il_jpj=SIZE(dd_array(:,:),DIM=2)
+
+      il_jpim1=il_jpi-1
+      il_jpjm1=il_jpj-1
+
+      SELECT CASE ( id_perio )
+      !
+      CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+         !
+         SELECT CASE ( TRIM(cd_type) )
+         !
+         CASE ( 'T' , 'W' )                               ! T- , W-points
+            DO ji = 2, il_jpi
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            dd_array(1,il_jpj)   = dl_fill
+            DO ji = il_jpi/2+2, il_jpi
+               dd_array(ji,il_jpj-1) = dl_fill
+            END DO
+         CASE ( 'U' )                                     ! U-point
+            DO ji = 1, il_jpi-1
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            dd_array(   1  ,il_jpj  ) = dl_fill 
+            dd_array(il_jpi,il_jpj  ) = dl_fill
+            dd_array(1     ,il_jpj-1) = dl_fill
+            DO ji = il_jpi/2+1, il_jpi-1
+               dd_array(ji,il_jpjm1) = dl_fill
+            END DO
+         CASE ( 'V' )                                     ! V-point
+            DO ji = 2, il_jpi
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            dd_array( 1 ,il_jpj)   = dl_fill 
+         CASE ( 'F' )                                     ! F-point
+            DO ji = 1, il_jpi-1
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            dd_array(   1  ,il_jpj)   = dl_fill
+            dd_array(il_jpi,il_jpj)   = dl_fill
+            dd_array(il_jpi,il_jpj-1) = dl_fill 
+            dd_array(   1  ,il_jpj-1) = dl_fill
+         END SELECT
+         !
+      CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+         !
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'W' )                               ! T-, W-point
+            DO ji = 1, il_jpi
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+         CASE ( 'U' )                                     ! U-point
+            DO ji = 1, il_jpi-1
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            dd_array(il_jpi,il_jpj) = dl_fill
+         CASE ( 'V' )                                     ! V-point
+            DO ji = 1, il_jpi
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            DO ji = il_jpi/2+2, il_jpi
+               dd_array(ji,il_jpjm1) = dl_fill
+            END DO
+         CASE ( 'F' )                               ! F-point
+            DO ji = 1, il_jpi-1
+               dd_array(ji,il_jpj) = dl_fill
+            END DO
+            dd_array(il_jpi,il_jpj) = dl_fill
+            DO ji = il_jpi/2+2, il_jpi-1
+               dd_array(ji,il_jpjm1) = dl_fill
+            END DO
+         END SELECT
+         !
+      CASE DEFAULT                           ! *  closed : the code probably never go through
+         !
+         SELECT CASE ( TRIM(cd_type) )
+         CASE ( 'T' , 'U' , 'V' , 'W' )                 ! T-, U-, V-, W-points
+            dd_array(:, 1    ) = dl_fill
+            dd_array(:,il_jpj) = dl_fill
+         CASE ( 'F' )                                   ! F-point
+            dd_array(:,il_jpj) = dl_fill
+         END SELECT
+         !
+      END SELECT
+   END SUBROUTINE lbc__hide_nfd_2d
+END MODULE lbc
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/mpp.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 7025)
@@ -266,5 +266,5 @@
    PRIVATE :: mpp__copy_arr            ! copy array of mpp structure
    PRIVATE :: mpp__get_use_unit        ! get sub domains to be used (which cover "zoom domain")
-   PRIVATE :: mpp__init_mask           ! initialise mpp structure, given file name
+   PRIVATE :: mpp__init_mask           ! initialise mpp structure, given mask array
    PRIVATE :: mpp__init_var            ! initialise mpp structure, given variable strcuture
    PRIVATE :: mpp__init_file           ! initialise a mpp structure, given file structure 
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/phycst.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 7025)
@@ -49,5 +49,5 @@
    REAL(dp), PARAMETER :: dp_siday = dp_day / ( 1._wp + dp_day / dp_siyea )
 
-   REAL(dp), PARAMETER :: dp_delta=1.e-6
+   REAL(dp), PARAMETER :: dp_delta=1.e-5
    REAL(dp), PARAMETER :: dp_omega= 2._dp * dp_pi / dp_siday
 END MODULE phycst
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/vgrid.f90
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 7024)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 7025)
@@ -14,5 +14,5 @@
 !>    CALL vgrid_zgr_z(dd_gdepw(:), dd_gdept(:), dd_e3w(:), dd_e3t(:), 
 !>                     dd_ppkth, dd_ppkth2, dd_ppacr, dd_ppacr2, 
-!>                     dd_ppdzmin, dd_pphmax, dd_pp_to_be_computed, 
+!>                     dd_ppdzmin, dd_pphmax, 
 !>                     dd_ppa0, dd_ppa1, dd_ppa2, dd_ppsur)
 !> @endcode
@@ -26,5 +26,4 @@
 !>       - dd_ppdzmin            see NEMO documentation
 !>       - dd_pphmax             see NEMO documentation
-!>       - dd_pp_to_be_computed  see NEMO documentation
 !>       - dd_ppa1               see NEMO documentation
 !>       - dd_ppa2               see NEMO documentation
@@ -133,5 +132,4 @@
    !> @param[in] dd_ppdzmin
    !> @param[in] dd_pphmax 
-   !> @param[in] dd_pp_to_be_computed
    !> @param[in] dd_ppa1
    !> @param[in] dd_ppa2 
@@ -140,7 +138,7 @@
    !-------------------------------------------------------------------
    SUBROUTINE vgrid_zgr_z( dd_gdepw, dd_gdept, dd_e3w, dd_e3t,          &
-   &                       dd_e3w_1d, dd_e3t_1d, &
+   &                       dd_e3w_1d, dd_e3t_1d,                        &
    &                       dd_ppkth, dd_ppkth2, dd_ppacr, dd_ppacr2,    &
-   &                       dd_ppdzmin, dd_pphmax, dd_pp_to_be_computed, &
+   &                       dd_ppdzmin, dd_pphmax,                       &
    &                       dd_ppa0, dd_ppa1, dd_ppa2, dd_ppsur )
       IMPLICIT NONE
@@ -160,5 +158,5 @@
       REAL(dp)              , INTENT(IN   ) :: dd_ppdzmin
       REAL(dp)              , INTENT(IN   ) :: dd_pphmax
-      REAL(dp)              , INTENT(IN   ) :: dd_pp_to_be_computed
+      REAL(dp), PARAMETER                   :: dp_pp_to_be_computed = NF90_FILL_DOUBLE
 
       REAL(dp)              , INTENT(IN   ) :: dd_ppa0
@@ -207,7 +205,7 @@
       !  za0, za1, zsur are computed from ppdzmin , pphmax, ppkth, ppacr
       !
-       IF(  dd_ppa1  == dd_pp_to_be_computed  .AND.  &
-         &  dd_ppa0  == dd_pp_to_be_computed  .AND.  &
-         &  dd_ppsur == dd_pp_to_be_computed           ) THEN
+       IF(  dd_ppa1  == dp_pp_to_be_computed  .AND.  &
+         &  dd_ppa0  == dp_pp_to_be_computed  .AND.  &
+         &  dd_ppsur == dp_pp_to_be_computed           ) THEN
          dl_za1 = ( dl_zdzmin - dl_zhmax / REAL((il_jpk-1),dp) ) &
              &     / ( TANH((1-dl_zkth)/dl_zacr) - dl_zacr/REAL((il_jpk-1),dp) &
@@ -667,5 +665,4 @@
 
       !namelist (intialise with GLORYS 75 levels parameters)
-      REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
       REAL(dp)                                :: dn_ppsur     = -3958.951371276829_dp
       REAL(dp)                                :: dn_ppa0      =   103.9530096000000_dp
@@ -684,5 +681,4 @@
       !----------------------------------------------------------------
       NAMELIST /namzgr/ &
-      &  dn_pp_to_be_computed, &
       &  dn_ppsur,     &
       &  dn_ppa0,      &
@@ -788,5 +784,5 @@
       &                 dl_e3w_1d, dl_e3t_1d, &
       &                 dn_ppkth, dn_ppkth2, dn_ppacr, dn_ppacr2,       &
-      &                 dn_ppdzmin, dn_pphmax, dn_pp_to_be_computed,    &
+      &                 dn_ppdzmin, dn_pphmax, &
       &                 dn_ppa0, dn_ppa1, dn_ppa2, dn_ppsur )
 
Index: /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/templates/create_meshmask.nam
===================================================================
--- /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/templates/create_meshmask.nam	(revision 7025)
+++ /branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/templates/create_meshmask.nam	(revision 7025)
@@ -0,0 +1,121 @@
+&namlog
+   cn_logfile  ="meshmask_out.log"
+   cn_verbosity=
+   in_maxerror =
+/
+
+&namcfg
+   cn_varcfg="./cfg/variable.cfg"
+   cn_dumcfg="./cfg/dummy.cfg"
+/
+
+&namin
+   cn_bathy =   !< Bathymetry file
+   cn_coord =   !< Coordinate file (in_mshhgr=0)
+   cn_isfdep=   !< Iceshelf draft  (ln_isfcav=true)
+   in_perio =   !< NEMO periodicity
+   ln_closea=
+/
+
+&namhgr
+   in_mshhgr  =
+   dn_ppglam0 =
+   dn_ppgphi0 =
+   dn_ppe1_deg=
+   dn_ppe2_deg=
+   dn_ppe1_m  =
+   dn_ppe2_m  =
+/
+
+&namzgr
+   ln_zco     =
+   ln_zps     =
+   ln_sco     =
+   ln_isfcav  =  !< presence of ISF
+   ln_iscpl   =  !< coupling with ice sheet
+   ln_wd      =  !< Wetting/drying activation
+   in_nlevel  =
+/
+
+&namdmin
+   dn_hmin    =
+   dn_isfhmin =
+/
+
+&namzco
+   dn_ppsur   =
+   dn_ppa0    =
+   dn_ppa1    =
+   dn_ppkth   =
+   dn_ppacr   =
+   dn_ppdzmin =
+   dn_pphmax  =
+   ln_dbletanh=
+   dn_ppa2    =
+   dn_ppkth2  =
+   dn_ppacr2  =
+/
+
+&namzps
+   dn_e3zps_min
+   dn_e3zps_rat
+   in_msh
+/
+
+&namsco
+   ln_s_sh94  =
+   ln_s_sf12  =
+   dn_sbot_min=
+   dn_sbot_max=
+   dn_hc      =
+   dn_rmax    =   !< if ln_s_sh94
+   dn_theta   =   !< if ln_s_sh94
+   dn_thetb   =   !< if ln_s_sh94
+   dn_bb      =   !< if ln_s_sh94
+   ln_sigcrit =   !< if ln_s_sf12
+   dn_alpha   =   !< if ln_s_sf12
+   dn_efold   =   !< if ln_s_sf12
+   dn_zs      =   !< if ln_s_sf12
+   dn_zb_a    =   !< if ln_s_sf12
+   dn_zb_b    =   !< if ln_s_sf12
+/
+
+&namcla
+   in_cla =
+/
+
+&namlbc
+   rn_shlat =
+/
+
+&namwd            !< wetting and drying
+  dn_wdmin1 =
+  dn_wdmin2 =
+  dn_wdld   =
+/
+
+&namgrd
+   cn_cfg   =
+   in_cfg   =
+   in_bench =
+   ln_zoom  =
+   ln_c1d   =
+/
+
+
+&namzoom
+   cn_cfz   =
+   in_izoom =
+   in_jzoom =
+   ln_zoom_s=
+   ln_zoom_e=
+   ln_zoom_w=
+   ln_zoom_n=
+/
+
+&namout
+   in_msh    =   !< number of output file (1,2,3)
+   in_nproc  =   !< number of processor to be used
+   in_niproc =   
+   in_njproc =
+/
