Skip to content

Commit a587e8e

Browse files
committed
check Fortran data type integer*8
1 parent a94ae91 commit a587e8e

5 files changed

+28
-0
lines changed

CMakeExtras/MatchNetCDFFortranTypes.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# check sizes of C types
66
check_type_size(int SIZEOF_INT)
77
check_type_size(long SIZEOF_LONG)
8+
check_type_size("long long" SIZEOF_LONG_LONG)
89
check_type_size(float SIZEOF_FLOAT)
910
check_type_size(double SIZEOF_DOUBLE)
1011
check_type_size("signed char" SIZEOF_SIGNED_CHAR)
@@ -16,6 +17,7 @@ SET(NCBYTE_T "byte") # 1 byte
1617
SET(NCSHORT_T "integer*2") # 2 bytes
1718
SET(NF_INT1_T "integer*1") # 1 byte
1819
SET(NF_INT2_T "integer*2") # 2 bytes
20+
SET(NF_INT8_T "integer*8") # 8 bytes
1921

2022
# Checks the provided C types to see which ones have the number of bytes passed
2123
# Roughly equivalent to the Automake function UD_CHECK_CTYPE_FORTRAN
@@ -59,6 +61,7 @@ message("Matching Fortran types to C types")
5961
find_c_type_with_size(1 INT1 "signed char" short int long)
6062
find_c_type_with_size(2 INT2 short int long)
6163
find_c_type_with_size(4 INT int long)
64+
find_c_type_with_size(8 INT8 int "long long")
6265
find_c_type_with_size(4 REAL float double)
6366
find_c_type_with_size(8 DOUBLEPRECISION float double)
6467

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ ADD_DEFINITIONS(-DNF_INT2_IS_C_SHORT)
475475
#ADD_DEFINITIONS(-DNF_INT2_IS_C_LONG)
476476
ADD_DEFINITIONS(-DNF_INT_IS_C_INT)
477477
#ADD_DEFINITIONS(-DNF_INT_IS_C_LONG)
478+
ADD_DEFINITIONS(-DNF_INT8_IS_C_LONG_LONG)
478479
ADD_DEFINITIONS(-DNF_REAL_IS_C_FLOAT)
479480
#ADD_DEFINITIONS(-DNF_REAL_IS_C_DOUBLE)
480481
ADD_DEFINITIONS(-DNF_DOUBLEPRECISION_IS_C_DOUBLE)
@@ -683,10 +684,12 @@ ELSE()
683684
SET(NCSHORT_T "integer*2")
684685
SET(NF_INT1_T "byte")
685686
SET(NF_INT2_T "integer*2")
687+
SET(NF_INT8_T "integer*8")
686688
# Default is for following to be true. TODO: test instead
687689
SET(NF_INT1_IS_C_SIGNED_CHAR "1")
688690
SET(NF_INT2_IS_C_SHORT "1")
689691
SET(NF_INT_IS_C_INT "1")
692+
SET(NF_INT8_IS_C_LONG_LONG "1")
690693
SET(NF_REAL_IS_C_FLOAT "1")
691694
SET(NF_DOUBLEPRECISION_IS_C_DOUBLE "1")
692695
ENDIF(ENABLE_FORTRAN_TYPE_CHECKS)

acinclude.m4

+8
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ dnl UD_CHECK_FORTRAN_TYPE(NF_INT1_T, byte integer*1 "integer(kind(1))")
235235
dnl UD_CHECK_FORTRAN_TYPE(NF_INT2_T, integer*2 "integer(kind(2))")
236236
UD_CHECK_FORTRAN_TYPE(NF_INT1_T, byte integer*1 "integer(kind=1)" "integer(selected_int_kind(2))")
237237
UD_CHECK_FORTRAN_TYPE(NF_INT2_T, integer*2 "integer(kind=2)" "integer(selected_int_kind(4))")
238+
UD_CHECK_FORTRAN_TYPE(NF_INT8_T, integer*8 "integer(kind=8)" "integer(selected_int_kind(18))")
238239
239240
case "${NF_INT1_T}" in
240241
'') ;;
@@ -251,6 +252,13 @@ dnl UD_CHECK_FORTRAN_TYPE(NF_INT2_T, integer*2 "integer(kind(2))")
251252
UD_CHECK_CTYPE_FORTRAN($NF_INT2_T, long, INT2)
252253
;;
253254
esac
255+
case "${NF_INT8_T}" in
256+
'') ;;
257+
*) UD_CHECK_CTYPE_FORTRAN($NF_INT8_T, "short", INT8)
258+
UD_CHECK_CTYPE_FORTRAN($NF_INT8_T, "int", INT8)
259+
UD_CHECK_CTYPE_FORTRAN($NF_INT8_T, "long long", INT8)
260+
;;
261+
esac
254262
UD_CHECK_CTYPE_FORTRAN(integer, int long, INT)
255263
UD_CHECK_CTYPE_FORTRAN(real, float double, REAL)
256264
UD_CHECK_CTYPE_FORTRAN(doubleprecision, double float, DOUBLEPRECISION)

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ else
341341
AC_DEFINE(NCSHORT_T, integer*2)
342342
AC_DEFINE(NF_INT1_T, byte)
343343
AC_DEFINE(NF_INT2_T, integer*2)
344+
AC_DEFINE(NF_INT8_T, integer*8)
344345
AC_DEFINE(NF_INT1_IS_C_SIGNED_CHAR, 1, [default])
345346
AC_DEFINE(NF_INT2_IS_C_SHORT, 1, [default])
346347
AC_DEFINE(NF_INT_IS_C_INT, 1, [default])

fortran/module_netcdf_nc_data.F90

+13
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ Module netcdf_nc_data
149149
Integer, Parameter :: NFINT = IK4
150150
#endif
151151

152+
! INT8 KINDs
153+
154+
#ifdef NF_INT8_IS_C_SHORT
155+
Integer, Parameter :: CINT8 = C_SHORT
156+
Integer, Parameter :: NFINT8 = IK2
157+
#elif NF_INT8_IS_C_INT
158+
Integer, Parameter :: CINT8 = C_INT
159+
Integer, Parameter :: NFINT8 = IK4
160+
#else
161+
Integer, Parameter :: CINT8 = C_LONG_LONG
162+
Integer, Parameter :: NFINT8 = IK8
163+
#endif
164+
152165
! Set Fortran default real kind. This should
153166
! take care of the case were the default real
154167
! type is a 64 bit real (ala prehistoric CRAYs)

0 commit comments

Comments
 (0)