Skip to content
Snippets Groups Projects
Commit a3b990a2 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Enable PURE implementation by exposing variable.

parent 942b674a
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,7 @@ libyaxt_c_la_SOURCES = \
xt_xmap_intersection.c \
xt_xmap_intersection_common.h \
xt_xmap_intersection_ext.c \
xt_init_internal.h \
xt_init.c \
core/core.c \
core/core.h \
......
......@@ -148,6 +148,13 @@ MODULE xt_core
PUBLIC :: set_abort_handler, xt_restore_default_abort_hndl
ENUM, BIND( C )
ENUMERATOR :: xt_lib_pre_init, &
xt_lib_initialized, &
xt_lib_finalized
END ENUM
INTEGER(c_int), PUBLIC, BIND(c, name='xt_lib_state') :: xt_lib_state
CONTAINS
SUBROUTINE xt_abort4(comm, msg, source, line)
......@@ -174,28 +181,14 @@ CONTAINS
stripe%stride, ', ', stripe%nstrides, ')'
END FUNCTION xt_stripe2char
FUNCTION xt_initialized() RESULT(is_initialized)
PURE FUNCTION xt_initialized() RESULT(is_initialized)
LOGICAL :: is_initialized
INTERFACE
FUNCTION xt_initialized_c() BIND(c, name='xt_initialized') &
RESULT(is_initialized)
IMPORT :: c_int
INTEGER(c_int) :: is_initialized
END FUNCTION xt_initialized_c
END INTERFACE
is_initialized = xt_initialized_c() /= 0
is_initialized = xt_lib_state > xt_lib_pre_init
END FUNCTION xt_initialized
FUNCTION xt_finalized() RESULT(is_finalized)
PURE FUNCTION xt_finalized() RESULT(is_finalized)
LOGICAL :: is_finalized
INTERFACE
FUNCTION xt_finalized_c() BIND(c, name='xt_finalized') &
RESULT(is_finalized)
IMPORT :: c_int
INTEGER(c_int) :: is_finalized
END FUNCTION xt_finalized_c
END INTERFACE
is_finalized = xt_finalized_c() /= 0
is_finalized = xt_lib_state == xt_lib_finalized
END FUNCTION xt_finalized
ELEMENTAL FUNCTION xt_pos_ext_eq(a, b) RESULT(p)
......
......@@ -48,7 +48,9 @@
#endif
#include <stdlib.h>
#include "core/core.h"
#include "xt_init_internal.h"
#include "xt_config_internal.h"
#include "xt_idxlist_internal.h"
#include "xt_idxstripes_internal.h"
......@@ -60,11 +62,8 @@
INSTR_DEF(instr,"YAXT_lifetime")
static enum {
xt_lib_pre_init,
xt_lib_initialized,
xt_lib_finalized,
} xt_lib_state = xt_lib_pre_init;
int xt_lib_state __attribute__((aligned(16),common));
void
xt_initialize(MPI_Comm default_comm)
......
/**
* @file xt_init_internal.h
*
* @copyright Copyright (C) 2021 Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* @author Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*/
/*
* Keywords:
* Maintainer: Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
* URL: https://doc.redmine.dkrz.de/yaxt/html/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the DKRZ GmbH nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef XT_INIT_INTERNAL_H
#define XT_INIT_INTERNAL_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* must be kept in sync with Fortran declaration in xt_core_f.f90 */
enum xt_init_states {
xt_lib_pre_init = 0, /* this entry must be zero so that
* xt_lib_state in common matches that */
xt_lib_initialized,
xt_lib_finalized,
};
#ifndef __GNUC__
#define __attribute__(att)
#endif
extern int xt_lib_state __attribute__((aligned(16),common));
#endif
/*
* Local Variables:
* c-basic-offset: 2
* coding: utf-8
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment