1 // Copyright (c) 2017-2026, 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 for example, -DPREFIX=jl_ transforms fail -> jl_fail 17 * a prefix for all external FORTRAN function names for example, -DFPREFIX=jlf_ transforms gs_setup_ -> jlf_gs_setup_ 18 */ 19 20 /* the following macro functions like a##b, but will expand a and/or b if they are themselves macros */ 21 #define TOKEN_PASTE_(a, b) a##b 22 #define TOKEN_PASTE(a, b) TOKEN_PASTE_(a, b) 23 24 #ifdef PREFIX 25 #define PREFIXED_NAME(x) TOKEN_PASTE(PREFIX, x) 26 #else 27 #define PREFIXED_NAME(x) x 28 #endif 29 30 #ifdef FPREFIX 31 #define FPREFIXED_NAME(x) TOKEN_PASTE(FPREFIX, x) 32 #else 33 #define FPREFIXED_NAME(x) x 34 #endif 35 36 #if defined(UPCASE) 37 #define FORTRAN_NAME(low, up) FPREFIXED_NAME(up) 38 #define FORTRAN_UNPREFIXED(low, up) up 39 #elif defined(UNDERSCORE) 40 #define FORTRAN_NAME(low, up) FPREFIXED_NAME(TOKEN_PASTE(low, _)) 41 #define FORTRAN_UNPREFIXED(low, up) TOKEN_PASTE(low, _) 42 #else 43 #define FORTRAN_NAME(low, up) FPREFIXED_NAME(low) 44 #define FORTRAN_UNPREFIXED(low, up) low 45 #endif 46 47 #endif // CEED_FORTRAN_NAME_H 48