Skip to content

Commit

Permalink
Import @6240 um13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewrmshin committed Jul 27, 2022
1 parent d99dfae commit 4c3e33a
Show file tree
Hide file tree
Showing 8 changed files with 508 additions and 387 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PACK_PREREQ=STR_CONV CONSTS
# Horizontal Interpolation
#--------------
HORIZ_INTERP=shum_horizontal_field_interp
HORIZ_INTERP_PREREQ=
HORIZ_INTERP_PREREQ=NUMTOOLS

# Thread Utils
#--------------
Expand Down
2 changes: 1 addition & 1 deletion common/src/shumlib_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* where "X" is the release number in month "MM" of year "YYYY"
*/
#if !defined(SHUMLIB_VERSION)
#define SHUMLIB_VERSION 2021101
#define SHUMLIB_VERSION 2022071
#endif

/* 2-stage expansion which will replace in the including code:
Expand Down
34 changes: 10 additions & 24 deletions scripts/meto_install_shumlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# USAGE: (Note - must be run from the toplevel Shumlib directory!)
# scripts/meto_install_shumlib.sh [xc40|x86|ex1a]
#
# This script was used to install shumlib version 2022.02.1
# and was intended for use with the UM at UM 12.2
# This script was used to install shumlib version 2022.07.1
# and was intended for use with the UM at UM 13.0
#

set -eu
Expand Down Expand Up @@ -644,23 +644,15 @@ if [ $PLATFORM == "xc40" ] || [ $PLATFORM == $THIS ] ; then
fi
fi

# Crayftn/CrayCC 12.0.3
THIS="ex1a_cray_12.0.3"
# Crayftn/CrayCC 14.0.0
THIS="ex1a_cray_14.0.0"
if [ $PLATFORM == "ex1a" ] || [ $PLATFORM == $THIS ] ; then

(
module purge
module load PrgEnv-cray/8.2.0
module switch cce cce/12.0.3
module switch cray-mpich cray-mpich/8.1.10
module switch craype craype/2.7.11
module load craype-x86-milan
module load perftools-base
module load xpmem
module load craype-network-ofi
module load craype-hugepages4M
module switch PrgEnv-cray PrgEnv-cray/8.3.3
module load cpe/22.05
CONFIG=meto-ex1a-crayftn12.0.1+-craycc
LIBDIR=$BUILD_DESTINATION/meto-ex1a-crayftn-12.0.3-craycc-12.0.3
LIBDIR=$BUILD_DESTINATION/meto-ex1a-crayftn-14.0.0-craycc-14.0.0
build_openmp_onoff $CONFIG $LIBDIR $(sed -e "s/\bshum_fieldsfile_class\b//g" \
-e "s/\bshum_fieldsfile\b//g" \
<<< $LIB_DIRS)
Expand All @@ -676,15 +668,9 @@ THIS="ex1a_gnu_10.3.0"
if [ $PLATFORM == "ex1a" ] || [ $PLATFORM == $THIS ] ; then

(
module purge
module load PrgEnv-gnu/8.2.0
module switch gcc gcc/10.3.0
module load craype-x86-milan
module switch cray-mpich/8.1.10
module switch craype/2.7.11
module load perftools-base
module load xpmem
module load craype-network-ofi
module switch PrgEnv-cray PrgEnv-gnu/8.3.3
module load cpe/22.05
module switch gcc gcc/10.3.0
CONFIG=meto-ex1a-gfortran-gcc
LIBDIR=$BUILD_DESTINATION/meto-ex1a-gfortran-10.3.0-gcc-10.3.0
build_openmp_onoff $CONFIG $LIBDIR all_libs
Expand Down
8 changes: 4 additions & 4 deletions shum_byteswap/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ include ${COMMON_DIR}/Makefile-version

# Static library - uses archiver to create library
#-------------------------------------------------------------------------------
c_shum_byteswap.o: c_shum_byteswap.c c_shum_byteswap.h c_shum_byteswap_opt.h
${CC} ${CCFLAGS} -c -I${LIBDIR_OUT}/include $<
c_shum_byteswap.o: c_shum_byteswap.c c_shum_byteswap.h c_shum_byteswap_opt.h ${COMMON_DIR}/c_shum_compile_diag_suspend.h
${CC} ${CCFLAGS} -c -I${LIBDIR_OUT}/include -I${COMMON_DIR} $<

f_shum_byteswap.o: f_shum_byteswap.f90
${FC} ${FCFLAGS} -c -I${LIBDIR_OUT}/include $<
Expand All @@ -30,8 +30,8 @@ libshum_byteswap.a: c_shum_byteswap.o f_shum_byteswap.o ${VERSION_OBJECTS}
# are suffixed to keep them separate to the above (since the dynamic library
# required position-independent-code flags whilst the static version does not)
#-------------------------------------------------------------------------------
c_shum_byteswap_PIC.o: c_shum_byteswap.c c_shum_byteswap.h c_shum_byteswap_opt.h
${CC} ${CCFLAGS} ${CCFLAGS_PIC} -c -I${LIBDIR_OUT}/include $< -o $@
c_shum_byteswap_PIC.o: c_shum_byteswap.c c_shum_byteswap.h c_shum_byteswap_opt.h ${COMMON_DIR}/c_shum_compile_diag_suspend.h
${CC} ${CCFLAGS} ${CCFLAGS_PIC} -c -I${LIBDIR_OUT}/include -I${COMMON_DIR} $< -o $@

f_shum_byteswap_PIC.o: f_shum_byteswap.f90
${FC} ${FCFLAGS} ${FCFLAGS_PIC} -c -I${LIBDIR_OUT}/include $< -o $@
Expand Down
22 changes: 22 additions & 0 deletions shum_byteswap/src/c_shum_byteswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <inttypes.h>
#include "c_shum_byteswap.h"
#include "c_shum_byteswap_opt.h"
#include "c_shum_compile_diag_suspend.h"

#if defined(_OPENMP) && defined(SHUM_USE_C_OPENMP_VIA_THREAD_UTILS)
#include "c_shum_thread_utils.h"
Expand All @@ -53,6 +54,21 @@
#define INLINEQUAL static inline
#endif

/* We need to suspend compiler diagnostics for the expansion of byteswap macros
* on some systems, as they bring in reserved identifiers from system headers.
*/
#if defined(__clang__)
#if __clang_major__ >= 13
#define SUSPEND_RES_IDNET SHUM_COMPILE_DIAG_SUSPEND(-Wreserved-identifier)
#define RESUME_RES_IDENT SHUM_COMPILE_DIAG_RESUME
#endif
#endif

#if !defined(SUSPEND_RES_IDNET)
#define SUSPEND_RES_IDNET
#define RESUME_RES_IDENT
#endif

/* -------------------------------------------------------------------------- */
/* Prototypes and Typedefs */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -169,7 +185,9 @@ INLINEQUAL void c_shum_byteswap_par_swap64(void **const array,
#endif
for (i=0; i<=span; i=i+1)
{
SUSPEND_RES_IDNET
ptr_64[min+i*cincr] = (uint64_t)bswap_64(ptr_64[min+i*cincr]);
RESUME_RES_IDENT
}
}
}
Expand All @@ -193,7 +211,9 @@ INLINEQUAL void c_shum_byteswap_par_swap32(void **const array,
#endif
for (i=0; i<=span; i=i+1)
{
SUSPEND_RES_IDNET
ptr_32[min+i*cincr] = (uint32_t)bswap_32(ptr_32[min+i*cincr]);
RESUME_RES_IDENT
}
}
}
Expand All @@ -217,7 +237,9 @@ INLINEQUAL void c_shum_byteswap_par_swap16(void **const array,
#endif
for (i=0; i<=span; i=i+1)
{
SUSPEND_RES_IDNET
ptr_16[min+i*cincr] = (uint16_t)bswap_16(ptr_16[min+i*cincr]);
RESUME_RES_IDENT
}
}
}
Expand Down
64 changes: 54 additions & 10 deletions shum_byteswap/src/c_shum_byteswap_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,23 @@
* standard C99, so will always work.
*
* vi) If the user defines one of the macros C_USE_BSWAP_BITSHIFT,
* C_USE_BSWAP_BUILTINS, or C_USE_BSWAP_BYTESWAP_H, override the above
* cases and use the direct bit-shift based macros, the __builtin_bswap*()
* non-standard intrinsic functions, or the <byteswap.h> headers
* repectively, as per that choice.
* C_USE_BSWAP_BUILTINS, C_USE_BSWAP_BYTESWAP_H, or
* C_USE_BSWAP_OSBYTEORDER_H override the above cases and use the direct
* bit-shift based macros, the __builtin_bswap*() non-standard intrinsic
* functions, the <byteswap.h> headers, or the <libkern/osbyteorder.h>
* headers repectively, as per that choice.
*
* Note: the following cases were added to support more systems at a later date
* and so are out of sequence. A user choice (case vi) will still override
* these defaults
*
* vii) If we are usining a version of the Cray compiler (defines _CRAYC) with
* GNU extensions enabled (-hgnu) and has __GNUC__ greater than version
* 6.1, fall-back to the non-standard intrinsic __builtin_bswap*()
* functions for all data sizes.
*
* viii) If we are on a Mac OS X / Darwin system (defines __APPLE__) instead
* use the non-standard <libkern/osbyteorder.h> header
*/

/*----------------*/
Expand All @@ -87,21 +94,21 @@
#define C_SHUM_BSWAP_HASGNU 0
#endif

#if (C_SHUM_BSWAP_HASGNU && ((__GNUC__ > 4) || \
#if (C_SHUM_BSWAP_HASGNU && ((__GNUC__ > 4) || \
(__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define C_SHUM_BSWAP_HASGNU4_3 1
#else
#define C_SHUM_BSWAP_HASGNU4_3 0
#endif

#if (C_SHUM_BSWAP_HASGNU && ((__GNUC__ > 4) || \
#if (C_SHUM_BSWAP_HASGNU && ((__GNUC__ > 4) || \
(__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
#define C_SHUM_BSWAP_HASGNU4_8 1
#else
#define C_SHUM_BSWAP_HASGNU4_8 0
#endif

#if (C_SHUM_BSWAP_HASGNU && ((__GNUC__ > 6) || \
#if (C_SHUM_BSWAP_HASGNU && ((__GNUC__ > 6) || \
(__GNUC__ == 6 && __GNUC_MINOR__ >= 1)))
#define C_SHUM_BSWAP_HASGNU6_1 1
#else
Expand All @@ -123,27 +130,51 @@

/* test for user choice */

#if defined C_USE_BSWAP_BYTESWAP_H
#if defined(C_USE_BSWAP_BYTESWAP_H)

/* user choice is <byteswap.h> */
#define C_USE_BSWAP_USERCHOICE
#undef C_USE_BSWAP_OSBYTEORDER_H
#undef C_USE_BSWAP_BITSHIFT
#undef C_USE_BSWAP_BUILTINS

#elif defined(C_USE_BSWAP_OSBYTEORDER_H)

/* user choice is <libkern/OSByteOrder.h> */
#define C_USE_BSWAP_USERCHOICE
#undef C_USE_BSWAP_BYTESWAP_H
#undef C_USE_BSWAP_BITSHIFT
#undef C_USE_BSWAP_BUILTINS

#elif defined C_USE_BSWAP_BUILTINS
#elif defined(C_USE_BSWAP_BUILTINS)

/* user choice is __builtin_bswap*() */
#define C_USE_BSWAP_USERCHOICE
#define C_USE_BSWAP_BUILTINS_64
#define C_USE_BSWAP_BUILTINS_32
#define C_USE_BSWAP_BUILTINS_16
#undef C_USE_BSWAP_OSBYTEORDER_H
#undef C_USE_BSWAP_BYTESWAP_H
#undef C_USE_BSWAP_BITSHIFT

#elif defined C_USE_BSWAP_BITSHIFT
#elif defined(C_USE_BSWAP_BITSHIFT)

/* user choice is bit-shift macros */
#define C_USE_BSWAP_USERCHOICE
#define C_USE_BSWAP_64_BITSHIFT
#define C_USE_BSWAP_32_BITSHIFT
#define C_USE_BSWAP_16_BITSHIFT
#undef C_USE_BSWAP_OSBYTEORDER_H
#undef C_USE_BSWAP_BYTESWAP_H
#undef C_USE_BSWAP_BUILTINS

#endif

#if !defined(C_USE_BSWAP_USERCHOICE)
#undef C_USE_BSWAP_OSBYTEORDER_H
#undef C_USE_BSWAP_BYTESWAP_H
#undef C_USE_BSWAP_BITSHIFT
#undef C_USE_BSWAP_BUILTINS
#endif

/* test for used case */
Expand All @@ -152,6 +183,11 @@

/* case vi) */

#elif defined(__APPLE__)

/* case viii) */
#define C_USE_BSWAP_OSBYTEORDER_H

#elif C_SHUM_BSWAP_HASGNU && !C_SHUM_BSWAP_HASGNU4_3

/* case i) */
Expand Down Expand Up @@ -214,6 +250,14 @@
#include <byteswap.h>
#endif

#if defined(C_USE_BSWAP_OSBYTEORDER_H)
#include <libkern/OSByteOrder.h>
#define bswap_16(x) OSSwapInt16(x)
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#endif


#if defined(C_USE_BSWAP_64_BITSHIFT)

#define bswap_64(x) \
Expand Down
Loading

0 comments on commit 4c3e33a

Please sign in to comment.