libsim Versione 7.2.6
|
◆ ptr_c
kind for an integer having the same size of a C pointer Definizione alla linea 266 del file kinds.F90. 266! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
267! authors:
268! Davide Cesari <dcesari@arpa.emr.it>
269! Paolo Patruno <ppatruno@arpa.emr.it>
270
271! This program is free software; you can redistribute it and/or
272! modify it under the terms of the GNU General Public License as
273! published by the Free Software Foundation; either version 2 of
274! the License, or (at your option) any later version.
275
276! This program is distributed in the hope that it will be useful,
277! but WITHOUT ANY WARRANTY; without even the implied warranty of
278! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
279! GNU General Public License for more details.
280
281! You should have received a copy of the GNU General Public License
282! along with this program. If not, see <http://www.gnu.org/licenses/>.
283#include "config.h"
284!> \defgroup base Libsim package, base library.
285!! The libsim base library defines modules and classes of general
286!! use for scientifical applications in Fortran 90. In order to
287!! compile and link programs using this library, you have to insert
288!! the required \c USE statements in the program units involved,
289!! specify the location of module files when compiling (tipically \c
290!! -I/usr/lib/gfortran/modules or \c -I/usr/lib64/gfortran/modules or
291!! \c -I/usr/include) and indicate the library name \c -lsim_base when
292!! linking, assuming that the library has been installed in a default
293!! location.
294
295!> Definition of constants to be used for declaring variables of a
296!! desired type. This module defines constants that can be portably
297!! used when declaring variables (through the \c KIND attribute) and
298!! when defining constants (through the underscore character \c _ ) in
299!! order to be sure that the desired type is used.
300!!
301!! There is a subtle difference between platform-default single and
302!! double precision real, obtained by declaring a variable of type \c
303!! REAL or \c DOUBLE \c PRECISION respectively, and single and double
304!! precision IEEE (4 and 8 bytes respectively) which are the standard
305!! IEEE data types and which are declared through \c REAL(kind=fp_s)
306!! and \c REAL(kind=fp_d) respectively: these two pairs of types
307!! usually coincide, but it may be not the case on some platforms, so
308!! you should choose one or the other approach depending on situation.
309!!
310!! Example of typical use:
311!! \code
312!! USE kinds
313!! ...
314!! INTEGER(kind=int_b) :: ab, bb
315!! REAL(kind=fp_d) :: dd
316!!
317!! ab = 13_int_b
318!! dd = REAL(ab, kind=fp_d)
319!! ...
320!! \endcode
321!! \ingroup base
323IMPLICIT NONE
324
325INTEGER, PARAMETER :: int_b = selected_int_kind(1) !< 1-byte integer (byte)
326INTEGER, PARAMETER :: int_s = selected_int_kind(4) !< 2-byte integer (short)
327INTEGER, PARAMETER :: int_l = selected_int_kind(8) !< 4-byte integer (long)
328INTEGER, PARAMETER, PRIVATE :: &
329 int_ll_t = selected_int_kind(16)
330!> 8-byte integer (long long) if supported, otherwise 4-byte integer
331INTEGER, PARAMETER :: int_ll = &
332 ( ( ( 1 + sign( 1, int_ll_t ) ) / 2 ) * int_ll_t ) + &
333 ( ( ( 1 - sign( 1, int_ll_t ) ) / 2 ) * int_l )
334
335INTEGER, PARAMETER :: fp_s = selected_real_kind(6) !< single precision floating point (4 byte IEEE)
336INTEGER, PARAMETER :: fp_d = selected_real_kind(15) !< double precision floating point (8 byte IEEE)
337INTEGER, PARAMETER, PRIVATE :: fp_q_t = selected_real_kind(20)
338!> quad precision floating point (16 byte IEEE) if supported, otherwise double precision floating point
339INTEGER, PARAMETER :: fp_q = &
340 ( ( ( 1 + sign( 1, fp_q_t ) ) / 2 ) * fp_q_t ) + &
341 ( ( ( 1 - sign( 1, fp_q_t ) ) / 2 ) * fp_d )
342
343INTEGER, PARAMETER :: ptr_c = sizeof_ptr_c !< kind for an integer having the same size of a C pointer
344
Definition of constants to be used for declaring variables of a desired type. Definition kinds.F90:245 |