1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 #ifndef _ceed_fortran_name_h 9 #define _ceed_fortran_name_h 10 11 /* establishes some macros to establish 12 * the FORTRAN naming convention 13 default gs_setup, etc. 14 -DUPCASE GS_SETUP, etc. 15 -DUNDERSCORE gs_setup_, etc. 16 * a prefix for all external (non-FORTRAN) function names 17 for example, -DPREFIX=jl_ transforms fail -> jl_fail 18 * a prefix for all external FORTRAN function names 19 for example, -DFPREFIX=jlf_ transforms gs_setup_ -> jlf_gs_setup_ 20 */ 21 22 /* the following macro functions like a##b, 23 but will expand a and/or b if they are themselves macros */ 24 #define TOKEN_PASTE_(a, b) a##b 25 #define TOKEN_PASTE(a, b) TOKEN_PASTE_(a, b) 26 27 #ifdef PREFIX 28 #define PREFIXED_NAME(x) TOKEN_PASTE(PREFIX, x) 29 #else 30 #define PREFIXED_NAME(x) x 31 #endif 32 33 #ifdef FPREFIX 34 #define FPREFIXED_NAME(x) TOKEN_PASTE(FPREFIX, x) 35 #else 36 #define FPREFIXED_NAME(x) x 37 #endif 38 39 #if defined(UPCASE) 40 #define FORTRAN_NAME(low, up) FPREFIXED_NAME(up) 41 #define FORTRAN_UNPREFIXED(low, up) up 42 #elif defined(UNDERSCORE) 43 #define FORTRAN_NAME(low, up) FPREFIXED_NAME(TOKEN_PASTE(low, _)) 44 #define FORTRAN_UNPREFIXED(low, up) TOKEN_PASTE(low, _) 45 #else 46 #define FORTRAN_NAME(low, up) FPREFIXED_NAME(low) 47 #define FORTRAN_UNPREFIXED(low, up) low 48 #endif 49 50 #endif 51