mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-12-09 07:32:32 +08:00
[svn-r15849] Description:
Changed the datatype test programs such that we don't distinguish between writeDoubleToFiles and writeFloatToFiles so that we only define c_float_4, c_float_8, and c_float_16 in H5f90i_gen.h Added the definition of real_4_f, real_8_f, real_16_f depending on if they are available, also in H5f90i_gen.h
This commit is contained in:
parent
6176a8a286
commit
c22b3f133b
@ -1,4 +1,5 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
@ -8,8 +9,8 @@
|
||||
* of the source code distribution tree; Copyright.html can be found at the *
|
||||
* root level of an installed copy of the electronic HDF5 document set and *
|
||||
* is linked from the top-level documents page. It can also be found at *
|
||||
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
||||
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
||||
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
||||
* access to either file, you may request a copy from help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* C Program to match C types to Fortran types
|
||||
@ -39,7 +40,7 @@ initCfile(void)
|
||||
{
|
||||
fprintf(c_header,
|
||||
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *\n\
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *\n\
|
||||
* All rights reserved. *\n\
|
||||
* *\n\
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *\n\
|
||||
@ -110,12 +111,6 @@ void writeFloatTypedef(const char* c_type, unsigned int size)
|
||||
fprintf(c_header, "#define c_float_%d %s\n", size, c_type);
|
||||
}
|
||||
|
||||
/* Define a c_double_x type in the C header */
|
||||
void writeDoubleTypedef(const char* c_type, unsigned int size)
|
||||
{
|
||||
fprintf(c_header, "#define c_double_%d %s\n", size, c_type);
|
||||
}
|
||||
|
||||
/* Call this function if there is no matching C type for sizes > 1 */
|
||||
void writeTypedefDefault(unsigned int size)
|
||||
{
|
||||
@ -139,21 +134,17 @@ void writeFloatToFiles(const char* fortran_type, const char* c_type, unsigned in
|
||||
fprintf(c_header, "typedef c_float_%d %s;\n", size, c_type);
|
||||
}
|
||||
|
||||
/* Create matching Fortran and C floating types by writing to both files */
|
||||
void writeDoubleToFiles(const char* fortran_type, const char* c_type, unsigned int size)
|
||||
{
|
||||
fprintf(fort_header, " INTEGER, PARAMETER :: %s = %d\n", fortran_type, size);
|
||||
|
||||
fprintf(c_header, "typedef c_double_%d %s;\n", size, c_type);
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
/* Open target files */
|
||||
c_header = fopen(CFILE, "w");
|
||||
fort_header = fopen(FFILE, "w");
|
||||
|
||||
int FoundIntSize[4];
|
||||
int FoundRealSize[3];
|
||||
int i,j,flag;
|
||||
char chrA[20],chrB[20];
|
||||
|
||||
/* Write copyright, boilerplate to both files */
|
||||
initCfile();
|
||||
initFfile();
|
||||
@ -217,7 +208,7 @@ int main()
|
||||
|
||||
/* Define c_float_x */
|
||||
|
||||
#if defined H5_FORTRAN_HAS_REAL_NATIVE_4
|
||||
#if defined H5_FORTRAN_HAS_REAL_NATIVE_4 || defined H5_FORTRAN_HAS_REAL_4
|
||||
if(sizeof(long double) == 4)
|
||||
writeFloatTypedef("long double", 4);
|
||||
else if(sizeof(double) == 4)
|
||||
@ -231,7 +222,7 @@ int main()
|
||||
}
|
||||
#endif /*H5_FORTRAN_HAS_REAL_NATIVE_4*/
|
||||
|
||||
#if defined H5_FORTRAN_HAS_REAL_NATIVE_8
|
||||
#if defined H5_FORTRAN_HAS_REAL_NATIVE_8 || defined H5_FORTRAN_HAS_REAL_8
|
||||
if(sizeof(long double) == 8)
|
||||
writeFloatTypedef("long double", 8);
|
||||
else if(sizeof(double) == 8)
|
||||
@ -245,7 +236,7 @@ int main()
|
||||
}
|
||||
#endif /*H5_FORTRAN_HAS_REAL_NATIVE_8*/
|
||||
|
||||
#if defined H5_FORTRAN_HAS_REAL_NATIVE_16
|
||||
#if defined H5_FORTRAN_HAS_REAL_NATIVE_16 || defined H5_FORTRAN_HAS_REAL_16
|
||||
if(sizeof(long double) == 16)
|
||||
writeFloatTypedef("long double", 16);
|
||||
else if(sizeof(double) == 16)
|
||||
@ -259,36 +250,6 @@ int main()
|
||||
}
|
||||
#endif /*H5_FORTRAN_HAS_REAL_NATIVE_16*/
|
||||
|
||||
/* Define c_double_x */
|
||||
|
||||
#if defined H5_FORTRAN_HAS_DOUBLE_NATIVE_8
|
||||
if(sizeof(long double) == 8)
|
||||
writeDoubleTypedef("long double", 8);
|
||||
else if(sizeof(double) == 8)
|
||||
writeDoubleTypedef("double", 8);
|
||||
else if(sizeof(float) == 8)
|
||||
writeDoubleTypedef("float", 8);
|
||||
else
|
||||
{ printf("Fortran DOUBLE is 16 bytes, no corresponding C floating type\n");
|
||||
printf("Quitting....\n");
|
||||
return -1;
|
||||
}
|
||||
#endif /*H5_FORTRAN_HAS_DOUBLE_NATIVE_8*/
|
||||
|
||||
#if defined H5_FORTRAN_HAS_DOUBLE_NATIVE_16
|
||||
if(sizeof(long double) == 16)
|
||||
writeDoubleTypedef("long double", 16);
|
||||
else if(sizeof(double) == 16)
|
||||
writeDoubleTypedef("double", 16);
|
||||
else if(sizeof(float) == 16)
|
||||
writeDoubleTypedef("float", 16);
|
||||
else
|
||||
{ printf("Fortran DOUBLE is 16 bytes, no corresponding C floating type\n");
|
||||
printf("Quitting....\n");
|
||||
return -1;
|
||||
}
|
||||
#endif /*H5_FORTRAN_HAS_DOUBLE_NATIVE_16*/
|
||||
|
||||
/* Now begin defining fortran types. */
|
||||
fprintf(c_header, "\n");
|
||||
/* haddr_t */
|
||||
@ -362,6 +323,148 @@ int main()
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
|
||||
/* int_1, int_2, int_4, int_8 */
|
||||
|
||||
/* Defined different KINDs of integers: */
|
||||
/* if the integer kind is not available then we assign */
|
||||
/* it a value of the next larger one, but if the next */
|
||||
/* higher one is not available we assigned it the next lowest */
|
||||
|
||||
FoundIntSize[0] = -1;
|
||||
FoundIntSize[1] = -2;
|
||||
FoundIntSize[2] = -4;
|
||||
FoundIntSize[3] = -8;
|
||||
|
||||
#if defined H5_FORTRAN_HAS_INTEGER_1
|
||||
FoundIntSize[0] = 1;
|
||||
#endif
|
||||
#if defined H5_FORTRAN_HAS_INTEGER_2
|
||||
FoundIntSize[1] = 2;
|
||||
#endif
|
||||
#if defined H5_FORTRAN_HAS_INTEGER_4
|
||||
FoundIntSize[2] = 4;
|
||||
#endif
|
||||
#if defined H5_FORTRAN_HAS_INTEGER_8
|
||||
FoundIntSize[3] = 8;
|
||||
#endif
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
if( FoundIntSize[i] > 0) /* Found the integer type */
|
||||
{
|
||||
sprintf(chrA, "Fortran_INTEGER_%d", FoundIntSize[i]);
|
||||
sprintf(chrB, "int_%d_f", FoundIntSize[i]);
|
||||
writeToFiles(chrA, chrB, FoundIntSize[i]);
|
||||
}
|
||||
else /* Did not find the integer type */
|
||||
{
|
||||
flag = 0; /* flag indicating if found the next highest */
|
||||
for(j=i+1;j<4;j++) /* search for next highest */
|
||||
{
|
||||
if( FoundIntSize[j] > 0) /* Found the next highest */
|
||||
{
|
||||
sprintf(chrA, "Fortran_INTEGER_%d", (-1)*FoundIntSize[i]);
|
||||
sprintf(chrB, "int_%d_f", (-1)*FoundIntSize[i]);
|
||||
writeToFiles(chrA, chrB, FoundIntSize[j]);
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(flag == 0) /* No higher one found, so find next lowest */
|
||||
{
|
||||
for(j=2;j>-1;j--) /* Search for next lowest */
|
||||
{
|
||||
if( FoundIntSize[j] > 0) /* Found the next lowest */
|
||||
{
|
||||
sprintf(chrA, "Fortran_INTEGER_%d", (-1)*FoundIntSize[i]);
|
||||
sprintf(chrB, "int_%d_f", (-1)*FoundIntSize[i]);
|
||||
writeToFiles(chrA, chrB, FoundIntSize[j]);
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag == 0) /* No higher or lower one found, indicating an error */
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* real_4, real_8, real_16 */
|
||||
|
||||
/* Defined different KINDs of reals: */
|
||||
/* if the REAL kind is not available then we assign */
|
||||
/* it a value of the next larger one, but if the next */
|
||||
/* higher one is not available we assigned it the next lowest */
|
||||
|
||||
FoundRealSize[0] = -4;
|
||||
FoundRealSize[1] = -8;
|
||||
FoundRealSize[2] = -16;
|
||||
|
||||
#if defined H5_FORTRAN_HAS_REAL_4
|
||||
FoundRealSize[0] = 4;
|
||||
#endif
|
||||
#if defined H5_FORTRAN_HAS_REAL_8
|
||||
FoundRealSize[1] = 8;
|
||||
#endif
|
||||
#if defined H5_FORTRAN_HAS_REAL_16
|
||||
FoundRealSize[2] = 16;
|
||||
#endif
|
||||
|
||||
for(i=0;i<3;i++) {
|
||||
if( FoundRealSize[i] > 0) /* Found the real type */
|
||||
{
|
||||
sprintf(chrA, "Fortran_REAL_%d", FoundRealSize[i]);
|
||||
sprintf(chrB, "real_%d_f", FoundRealSize[i]);
|
||||
writeFloatToFiles(chrA, chrB, FoundRealSize[i]);
|
||||
}
|
||||
else /* Did not find the real type */
|
||||
{
|
||||
flag = 0; /* flag indicating if found the next highest */
|
||||
for(j=i+1;j<3;j++) /* search for next highest */
|
||||
{
|
||||
if( FoundRealSize[j] > 0) /* Found the next highest */
|
||||
{
|
||||
sprintf(chrA, "Fortran_REAL_%d", (-1)*FoundRealSize[i]);
|
||||
sprintf(chrB, "real_%d_f", (-1)*FoundRealSize[i]);
|
||||
if(FoundRealSize[j]>4) {
|
||||
writeFloatToFiles(chrA, chrB, FoundRealSize[j]);
|
||||
flag = 1;
|
||||
}
|
||||
/* else { */
|
||||
/* writeFloatToFiles(chrA, chrB, FoundRealSize[j]); */
|
||||
/* } */
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(flag == 0) /* No higher one found, so find next lowest */
|
||||
{
|
||||
for(j=1;j>-1;j--) /* Search for next lowest */
|
||||
{
|
||||
if( FoundRealSize[j] > 0) /* Found the next lowest */
|
||||
{
|
||||
sprintf(chrA, "Fortran_REAL_%d", (-1)*FoundRealSize[i]);
|
||||
sprintf(chrB, "real_%d_f", (-1)*FoundRealSize[i]);
|
||||
if(FoundRealSize[j]>4) {
|
||||
writeFloatToFiles(chrA, chrB, FoundRealSize[j]);
|
||||
}
|
||||
/* else { */
|
||||
/* writeFloatToFiles(chrA, chrB, FoundRealSize[j]); */
|
||||
/* } */
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag == 0) /* No higher or lower one found, indicating an error */
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* hid_t */
|
||||
#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_HID_T >= 8
|
||||
writeToFiles("HID_T", "hid_t_f", 8);
|
||||
@ -392,9 +495,9 @@ int main()
|
||||
|
||||
/* double_f */
|
||||
#if defined H5_FORTRAN_HAS_DOUBLE_NATIVE_16
|
||||
writeDoubleToFiles("Fortran_DOUBLE", "double_f", 16);
|
||||
writeFloatToFiles("Fortran_DOUBLE", "double_f", 16);
|
||||
#elif defined H5_FORTRAN_HAS_DOUBLE_NATIVE_8
|
||||
writeDoubleToFiles("Fortran_DOUBLE", "double_f", 8);
|
||||
writeFloatToFiles("Fortran_DOUBLE", "double_f", 8);
|
||||
#else
|
||||
/* Error: couldn't find a size for real_f */
|
||||
return -1;
|
||||
|
@ -1,4 +1,26 @@
|
||||
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
!****h* fortran/src/H5test_kind.f90
|
||||
!
|
||||
! NAME
|
||||
! H5test_kind
|
||||
!
|
||||
! FUNCTION
|
||||
! This stand alone program is used at build time to generate the program
|
||||
! H5fortran_detect.f90. It cycles through all the available KIND parameters for
|
||||
! integers and reals. The appropriate program and subroutines are then generated
|
||||
! depending on which of the KIND values are found.
|
||||
!
|
||||
! NOTES
|
||||
! This program is depreciated in favor of H5test_kind_SIZEOF.f90 and is only
|
||||
! used when the Fortran intrinsic function SIZEOF is not available. It generates
|
||||
! code that does not make use of SIZEOF in H5fortran_detect.f90 which is less
|
||||
! portable in comparison to using SIZEOF.
|
||||
!
|
||||
! The availability of SIZEOF is checked at configure time and the TRUE/FALSE
|
||||
! condition is set in the configure variable "FORTRAN_HAVE_SIZEOF".
|
||||
!
|
||||
! COPYRIGHT
|
||||
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
! Copyright by The HDF Group. *
|
||||
! Copyright by the Board of Trustees of the University of Illinois. *
|
||||
! All rights reserved. *
|
||||
! *
|
||||
@ -8,17 +30,18 @@
|
||||
! of the source code distribution tree; Copyright.html can be found at the *
|
||||
! root level of an installed copy of the electronic HDF5 document set and *
|
||||
! is linked from the top-level documents page. It can also be found at *
|
||||
! http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
||||
! access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
||||
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
||||
! access to either file, you may request a copy from help@hdfgroup.org. *
|
||||
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
!
|
||||
! H5test_kind.f90
|
||||
!
|
||||
! This fortran program generates H5fortran_detect.f90
|
||||
!
|
||||
! AUTHOR
|
||||
! Elena Pourma
|
||||
!
|
||||
!*****
|
||||
|
||||
PROGRAM test_kind
|
||||
INTEGER :: i, j, ii, last, kind_numbers(10)
|
||||
IMPLICIT NONE
|
||||
INTEGER :: i, j, ii, ir, last, ikind_numbers(10), rkind_numbers(10)
|
||||
INTEGER :: jr, jd
|
||||
last = -1
|
||||
ii = 0
|
||||
@ -28,13 +51,67 @@ PROGRAM test_kind
|
||||
IF(j .NE. last) THEN
|
||||
IF(last .NE. -1) THEN
|
||||
ii = ii + 1
|
||||
kind_numbers(ii) = last
|
||||
ikind_numbers(ii) = last
|
||||
ENDIF
|
||||
last = j
|
||||
IF(j .EQ. -1) EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
last = -1
|
||||
ir = 0
|
||||
DO i = 1,100
|
||||
j = SELECTED_REAL_KIND(i)
|
||||
IF(j .NE. last) THEN
|
||||
IF(last .NE. -1) THEN
|
||||
ir = ir + 1
|
||||
rkind_numbers(ir) = last
|
||||
ENDIF
|
||||
last = j
|
||||
IF(j .EQ. -1) EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
! Generate program information:
|
||||
|
||||
WRITE(*,'(40(A,/))') &
|
||||
'!****h* fortran/src/H5fortran_detect.f90',&
|
||||
'!',&
|
||||
'! NAME',&
|
||||
'! H5fortran_detect',&
|
||||
'! ',&
|
||||
'! FUNCTION',&
|
||||
'! This stand alone program is used at build time to generate the header file',&
|
||||
'! H5fort_type_defines.h. The source code itself was automatically generated by',&
|
||||
'! the program H5test_kind.f90',&
|
||||
'!',&
|
||||
'! NOTES',&
|
||||
'! This source code does not make use of the Fortran intrinsic function SIZEOF because',&
|
||||
'! the availability of the intrinsic function was determined to be not available at',&
|
||||
'! configure time',&
|
||||
'!',&
|
||||
'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',&
|
||||
'! Copyright by The HDF Group. *',&
|
||||
'! Copyright by the Board of Trustees of the University of Illinois. *',&
|
||||
'! All rights reserved. *',&
|
||||
'! *',&
|
||||
'! This file is part of HDF5. The full HDF5 copyright notice, including *',&
|
||||
'! terms governing use, modification, and redistribution, is contained in *',&
|
||||
'! the files COPYING and Copyright.html. COPYING can be found at the root *',&
|
||||
'! of the source code distribution tree; Copyright.html can be found at the *',&
|
||||
'! root level of an installed copy of the electronic HDF5 document set and *',&
|
||||
'! is linked from the top-level documents page. It can also be found at *',&
|
||||
'! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *',&
|
||||
'! access to either file, you may request a copy from help@hdfgroup.org. *',&
|
||||
'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',&
|
||||
'!',&
|
||||
'! AUTHOR',&
|
||||
'! H5test_kind.f90',&
|
||||
'!',&
|
||||
'!*****'
|
||||
|
||||
! Generate a program
|
||||
|
||||
WRITE(*,*) "PROGRAM int_kind"
|
||||
WRITE(*,*) "WRITE(*,*) "" /*generating header file*/ """
|
||||
j = 0
|
||||
@ -44,9 +121,13 @@ PROGRAM test_kind
|
||||
jd = 0
|
||||
WRITE(*, "("" CALL d"", i2.2,""()"")") jd
|
||||
DO i = 1, ii
|
||||
j = kind_numbers(i)
|
||||
j = ikind_numbers(i)
|
||||
WRITE(*, "("" CALL i"", i2.2,""()"")") j
|
||||
ENDDO
|
||||
DO i = 1, ir
|
||||
j = rkind_numbers(i)
|
||||
WRITE(*, "("" CALL r"", i2.2,""()"")") j
|
||||
ENDDO
|
||||
WRITE(*,*) "END PROGRAM int_kind"
|
||||
j = 0
|
||||
WRITE(*, "("" SUBROUTINE i"", i2.2,""()"")") j
|
||||
@ -109,7 +190,7 @@ PROGRAM test_kind
|
||||
WRITE(*,*)" RETURN"
|
||||
WRITE(*,*)"END SUBROUTINE"
|
||||
DO i = 1, ii
|
||||
j = kind_numbers(i)
|
||||
j = ikind_numbers(i)
|
||||
WRITE(*, "("" SUBROUTINE i"", i2.2,""()"")") j
|
||||
WRITE(*,*)" IMPLICIT NONE"
|
||||
WRITE(*,*)" INTEGER(",j,") :: a = 0"
|
||||
@ -133,6 +214,28 @@ PROGRAM test_kind
|
||||
WRITE(*,*)" RETURN"
|
||||
WRITE(*,*)" END SUBROUTINE"
|
||||
ENDDO
|
||||
DO i = 1, ir
|
||||
j = rkind_numbers(i)
|
||||
WRITE(*, "("" SUBROUTINE r"", i2.2,""()"")") j
|
||||
WRITE(*,*)" IMPLICIT NONE"
|
||||
WRITE(*,*)" REAL(KIND=",j,") :: b(32)"
|
||||
WRITE(*,*)" INTEGER :: a(1)"
|
||||
WRITE(*,*)" INTEGER :: a_size"
|
||||
WRITE(*,*)" INTEGER :: real_size"
|
||||
WRITE(*,*)" a_size = BIT_SIZE(a(1)) ! Size in bits for integer"
|
||||
WRITE(*,*)" real_size = (SIZE(TRANSFER(b,a))*a_size)/SIZE(b)"
|
||||
WRITE(*,*)" IF (real_size .EQ. 32) THEN"
|
||||
WRITE(*,*)" WRITE(*,*) ""#define H5_FORTRAN_HAS_REAL_4"" "
|
||||
WRITE(*,*)" ENDIF"
|
||||
WRITE(*,*)" IF (real_size .EQ. 64) THEN"
|
||||
WRITE(*,*)" write(*,*) ""#define H5_FORTRAN_HAS_REAL_8"" "
|
||||
WRITE(*,*)" endif"
|
||||
WRITE(*,*)" IF (real_size .EQ. 128) THEN"
|
||||
WRITE(*,*)" write(*,*) ""#define H5_FORTRAN_HAS_REAL_16"" "
|
||||
WRITE(*,*)" ENDIF"
|
||||
WRITE(*,*)" RETURN"
|
||||
WRITE(*,*)" END SUBROUTINE"
|
||||
ENDDO
|
||||
END PROGRAM test_kind
|
||||
|
||||
|
||||
|
@ -1,4 +1,25 @@
|
||||
!****h* fortran/src/H5test_kind_SIZEOF.f90
|
||||
!
|
||||
! NAME
|
||||
! H5test_kind
|
||||
!
|
||||
! FUNCTION
|
||||
! This stand alone program is used at build time to generate the program
|
||||
! H5fortran_detect.f90. It cycles through all the available KIND parameters for
|
||||
! integers and reals. The appropriate program and subroutines are then generated
|
||||
! depending on which of the KIND values are found.
|
||||
!
|
||||
! NOTES
|
||||
! This program is used in place of H5test_kind.f90 when the Fortran intrinsic
|
||||
! function SIZEOF is available. It generates code that makes use of SIZEOF in
|
||||
! H5fortran_detect.f90 which is a portable solution.
|
||||
!
|
||||
! The availability of SIZEOF is checked at configure time and the TRUE/FALSE
|
||||
! condition is set in the configure variable "FORTRAN_HAVE_SIZEOF".
|
||||
!
|
||||
! COPYRIGHT
|
||||
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
! Copyright by The HDF Group. *
|
||||
! Copyright by the Board of Trustees of the University of Illinois. *
|
||||
! All rights reserved. *
|
||||
! *
|
||||
@ -8,32 +29,86 @@
|
||||
! of the source code distribution tree; Copyright.html can be found at the *
|
||||
! root level of an installed copy of the electronic HDF5 document set and *
|
||||
! is linked from the top-level documents page. It can also be found at *
|
||||
! http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
||||
! access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
||||
! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
||||
! access to either file, you may request a copy from help@hdfgroup.org. *
|
||||
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
!
|
||||
! H5test_kind_SIZEOF.f90
|
||||
!
|
||||
! This fortran program generates H5fortran_detect.f90
|
||||
!
|
||||
! AUTHOR
|
||||
! M.S. Breitenfeld
|
||||
!
|
||||
!*****
|
||||
|
||||
PROGRAM test_kind
|
||||
INTEGER :: i, j, ii, last, kind_numbers(10)
|
||||
IMPLICIT NONE
|
||||
INTEGER :: i, j, ii, ir, last, ikind_numbers(10),rkind_numbers(10)
|
||||
INTEGER :: jr, jd
|
||||
last = -1
|
||||
ii = 0
|
||||
j = SELECTED_INT_KIND(18)
|
||||
DO i = 1,100
|
||||
j = SELECTED_INT_KIND(i)
|
||||
IF(j .NE. last) THEN
|
||||
IF(last .NE. -1) THEN
|
||||
ii = ii + 1
|
||||
kind_numbers(ii) = last
|
||||
ikind_numbers(ii) = last
|
||||
ENDIF
|
||||
last = j
|
||||
IF(j .EQ. -1) EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
last = -1
|
||||
ir = 0
|
||||
DO i = 1,100
|
||||
j = SELECTED_REAL_KIND(i)
|
||||
IF(j .NE. last) THEN
|
||||
IF(last .NE. -1) THEN
|
||||
ir = ir + 1
|
||||
rkind_numbers(ir) = last
|
||||
ENDIF
|
||||
last = j
|
||||
IF(j .EQ. -1) EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
! Generate program information:
|
||||
|
||||
WRITE(*,'(40(A,/))') &
|
||||
'!****h* fortran/src/H5fortran_detect.f90',&
|
||||
'!',&
|
||||
'! NAME',&
|
||||
'! H5fortran_detect',&
|
||||
'! ',&
|
||||
'! FUNCTION',&
|
||||
'! This stand alone program is used at build time to generate the header file',&
|
||||
'! H5fort_type_defines.h. The source code itself was automatically generated by',&
|
||||
'! the program H5test_kind_SIZEOF.f90',&
|
||||
'!',&
|
||||
'! NOTES',&
|
||||
'! This source code makes use of the Fortran intrinsic function SIZEOF because',&
|
||||
'! the availability of the intrinsic function was determined to be available at',&
|
||||
'! configure time',&
|
||||
'!',&
|
||||
'! COPYRIGHT',&
|
||||
'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',&
|
||||
'! Copyright by The HDF Group. *',&
|
||||
'! Copyright by the Board of Trustees of the University of Illinois. *',&
|
||||
'! All rights reserved. *',&
|
||||
'! *',&
|
||||
'! This file is part of HDF5. The full HDF5 copyright notice, including *',&
|
||||
'! terms governing use, modification, and redistribution, is contained in *',&
|
||||
'! the files COPYING and Copyright.html. COPYING can be found at the root *',&
|
||||
'! of the source code distribution tree; Copyright.html can be found at the *',&
|
||||
'! root level of an installed copy of the electronic HDF5 document set and *',&
|
||||
'! is linked from the top-level documents page. It can also be found at *',&
|
||||
'! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *',&
|
||||
'! access to either file, you may request a copy from help@hdfgroup.org. *',&
|
||||
'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',&
|
||||
'!',&
|
||||
'! AUTHOR',&
|
||||
'! H5test_kind_SIZEOF.f90',&
|
||||
'!',&
|
||||
'!*****'
|
||||
|
||||
! Generate a program
|
||||
WRITE(*,*) "PROGRAM int_kind"
|
||||
WRITE(*,*) "WRITE(*,*) "" /*generating header file*/ """
|
||||
@ -44,9 +119,13 @@ PROGRAM test_kind
|
||||
jd = 0
|
||||
WRITE(*, "("" CALL d"", i2.2,""()"")") jd
|
||||
DO i = 1, ii
|
||||
j = kind_numbers(i)
|
||||
j = ikind_numbers(i)
|
||||
WRITE(*, "("" CALL i"", i2.2,""()"")") j
|
||||
ENDDO
|
||||
DO i = 1, ir
|
||||
j = rkind_numbers(i)
|
||||
WRITE(*, "("" CALL r"", i2.2,""()"")") j
|
||||
ENDDO
|
||||
WRITE(*,*) "END PROGRAM int_kind"
|
||||
j = 0
|
||||
WRITE(*, "("" SUBROUTINE i"", i2.2,""()"")") j
|
||||
@ -82,7 +161,7 @@ PROGRAM test_kind
|
||||
WRITE(*,*)" RETURN"
|
||||
WRITE(*,*)"END SUBROUTINE"
|
||||
DO i = 1, ii
|
||||
j = kind_numbers(i)
|
||||
j = ikind_numbers(i)
|
||||
WRITE(*, "("" SUBROUTINE i"", i2.2,""()"")") j
|
||||
WRITE(*,*)" IMPLICIT NONE"
|
||||
WRITE(*,*)" INTEGER(",j,") :: a"
|
||||
@ -94,6 +173,19 @@ PROGRAM test_kind
|
||||
WRITE(*,*)" RETURN"
|
||||
WRITE(*,*)"END SUBROUTINE"
|
||||
ENDDO
|
||||
DO i = 1, ir
|
||||
j = rkind_numbers(i)
|
||||
WRITE(*, "("" SUBROUTINE r"", i2.2,""()"")") j
|
||||
WRITE(*,*)" IMPLICIT NONE"
|
||||
WRITE(*,*)" REAL(KIND=",j,") :: a"
|
||||
WRITE(*,*)" INTEGER :: a_size"
|
||||
WRITE(*,*)" CHARACTER(LEN=2) :: ichr2"
|
||||
WRITE(*,*)" a_size = SIZEOF(a)"
|
||||
WRITE(*,*)" WRITE(ichr2,'(I2)') a_size"
|
||||
WRITE(*,*)' WRITE(*,*) "#define H5_FORTRAN_HAS_REAL_"'//"//ADJUSTL(ichr2)"
|
||||
WRITE(*,*)" RETURN"
|
||||
WRITE(*,*)"END SUBROUTINE"
|
||||
ENDDO
|
||||
END PROGRAM test_kind
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user