Commit baa53815 authored by Marco Govoni's avatar Marco Govoni
Browse files

Adding Libraries.

parent b610e50f
# Makefile for Json
include ../../../make.inc
# location of needed modules
MODFLAGS= $(MOD_FLAG).
IFLAGS=
JSON_OBJS = \
json_kinds.o \
json_parameters.o \
json_string_utilities.o \
json_value_module.o \
json_file_module.o \
json_module.o
#TLDEPS= bindir mods libs pw
#all : title tldeps libjson.a
all : title libjson.a copy
#tldeps:
# test -n "$(TLDEPS)" && ( cd ../.. ; $(MAKE) $(MFLAGS) $(TLDEPS) || exit 1) || :
libjson.a : $(JSON_OBJS)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
copy :
- cp libjson.a ../
clean :
- /bin/rm -f *.x *.o *.a *~ *_tmp.f90 *.d *.mod *.i *.L
- /bin/rm -f libjson.a
title :
@echo " "
@echo "##############"
@echo "### Json ####"
@echo "##############"
@echo " "
include make.depend
This diff is collapsed.
! The argument list for the various `initialize` subroutines.
logical(LK),intent(in),optional :: verbose
!! mainly useful for debugging (default is false)
logical(LK),intent(in),optional :: compact_reals
!! to compact the real number strings for output (default is true)
logical(LK),intent(in),optional :: print_signs
!! always print numeric sign (default is false)
character(kind=CDK,len=*),intent(in),optional :: real_format
!! Real number format: 'E' [default], '*', 'G', 'EN', or 'ES'
integer(IK),intent(in),optional :: spaces_per_tab
!! number of spaces per tab for indenting (default is 2)
logical(LK),intent(in),optional :: strict_type_checking
!! if true, no integer, double, or logical type
!! conversions are done for the `get` routines
!! (default is false)
logical(LK),intent(in),optional :: trailing_spaces_significant
!! for name and path comparisons, is trailing
!! space to be considered significant.
!! (default is false)
logical(LK),intent(in),optional :: case_sensitive_keys
!! for name and path comparisons, are they
!! case sensitive. (default is true)
logical(LK),intent(in),optional :: no_whitespace
!! if true, printing the JSON structure is
!! done without adding any non-significant
!! spaces or linebreaks (default is false)
logical(LK),intent(in),optional :: unescape_strings
!! If false, then the raw escaped
!! string is returned from [[json_get_string]]
!! and similar routines. If true [default],
!! then the string is returned unescaped.
character(kind=CK,len=1),intent(in),optional :: comment_char
!! If present, this character is used
!! to denote comments in the JSON file,
!! which will be ignored if present.
!! Example: `!` or `#`. Setting this
!! to a blank string disables the
!! ignoring of comments. (Default is `!`).
integer(IK),intent(in),optional :: path_mode
!! How the path strings are interpreted in the
!! `get_by_path` routines:
!! * 1 -- Default way (see [[json_get_by_path_default]])
!! [Default]
!! * 2 -- as RFC 6901 "JSON Pointer" paths
!! (see [[json_get_by_path_rfc6901]])
character(kind=CK,len=1),intent(in),optional :: path_separator
!! The `path` separator to use
!! in the "default" mode for
!! the paths in the various
!! `get_by_path` routines.
!! Example: `.` [default] or `%`.
!! Note: if `path_mode/=1`
!! then this is ignored.
logical(LK),intent(in),optional :: compress_vectors
!! If true, then arrays of integers,
!! nulls, doubles, and logicals are
!! printed all on one line.
!! [Note: `no_whitespace` will
!! override this option if necessary].
!! (Default is False).
!*****************************************************************************************
!> author: Jacob Williams
! license: BSD
!
! JSON-Fortran kind definitions.
!
!### License
! * JSON-Fortran is released under a BSD-style license.
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
! file for details.
!
!@note ```-DUSE_UCS4``` is an optional preprocessor flag.
! When present, Unicode support is enabled. Note that this
! is currently only supported with the gfortran compiler.
! Example: ```gfortran -DUSE_UCS4 ... ```
#ifdef USE_UCS4
# pragma push_macro("USE_UCS4")
# undef USE_UCS4
! The documentation given here assumes ```USE_UCS4``` **is** defined.
# pragma pop_macro("USE_UCS4")
#else
! The documentation given here assumes ```USE_UCS4``` **is not** defined.
#endif
!
!@warning ```CK``` and ```CDK``` are the JSON-Fortran character kind and JSON-Fortran default
! character kind respectively. Client code **MUST** ensure characters of ```kind=CK```
! are used for all character variables and strings passed to the JSON-Fortran
! library *EXCEPT* for file names which must be of ```'DEFAULT'``` character kind,
! provided here as ```CDK```. In particular, any variable that is a: json path, string
! value or object name passed to the JSON-Fortran library **MUST** be of type ```CK```.
!
!@note Most string literal constants of default kind are fine to pass as arguments to
! JSON-Fortran procedures since they have been overloaded to accept ```intent(in)```
! character arguments of the default (```CDK```) kind. If you find a procedure which does
! not accept an ```intent(in)``` literal string argument of default kind, please
! [file an issue](https://github.com/jacobwilliams/json-fortran/issues/new) on GitHub.
!
!@note The default real kind (`RK`) and the default integer kind (`IK`) can be
! changed using optional preprocessor flags. This library was built with kinds:
#ifdef REAL32
! real(kind=real32) [4 bytes]
#elif REAL64
! real(kind=real64) [8 bytes]
#elif REAL128
! real(kind=real128) [16 bytes]
#else
! real(kind=real64) [8 bytes]
#endif
! and
#ifdef INT8
! integer(kind=int8) [1 byte]
#elif INT16
! integer(kind=int16) [2 bytes]
#elif INT32
! integer(kind=int32) [4 bytes]
#elif INT64
! integer(kind=int64) [8 bytes]
#else
! integer(kind=int32) [4 bytes]
#endif
! .
module json_kinds
use,intrinsic :: iso_fortran_env
implicit none
private
#ifdef REAL32
integer,parameter,public :: RK = real32 !! Default real kind [4 bytes]
#elif REAL64
integer,parameter,public :: RK = real64 !! Default real kind [8 bytes]
#elif REAL128
integer,parameter,public :: RK = real128 !! Default real kind [16 bytes]
#else
integer,parameter,public :: RK = real64 !! Default real kind if not specified [8 bytes]
#endif
#ifdef INT8
integer,parameter,public :: IK = int8 !! Default integer kind [1 byte]
#elif INT16
integer,parameter,public :: IK = int16 !! Default integer kind [2 bytes]
#elif INT32
integer,parameter,public :: IK = int32 !! Default integer kind [4 bytes]
#elif INT64
integer,parameter,public :: IK = int64 !! Default integer kind [8 bytes]
#else
integer,parameter,public :: IK = int32 !! Default integer kind if not specified [4 bytes]
#endif
!*********************************************************
!>
! Processor dependendant 'DEFAULT' character kind.
! This is 1 byte for the Intel and Gfortran compilers.
integer,parameter,public :: CDK = selected_char_kind('DEFAULT')
!*********************************************************
!*********************************************************
!>
! Default logical kind.
! This is 4 bytes for the Intel and Gfortran compilers
! (and perhaps others).
! The declaration ensures a valid kind
! if the compiler doesn't have a logical_kinds(3).
integer,parameter,public :: LK = logical_kinds(min(3,size(logical_kinds)))
!*********************************************************
!*********************************************************
!>
! String kind preprocessor macro.
#if defined __GFORTRAN__ && defined USE_UCS4
! gfortran compiler AND UCS4 support requested:
character(kind=CDK,len=*),parameter :: json_fortran_string_kind = 'ISO_10646'
#else
! this is the string kind to use unless compiling with GFortran AND
! UCS4/ISO 10646 support is requested
character(kind=CDK,len=*),parameter :: json_fortran_string_kind = 'DEFAULT'
#endif
!*********************************************************
!*********************************************************
!>
! Default character kind used by JSON-Fortran.
! If ISO 10646 (UCS4) support is available, use that,
! otherwise, gracefully fall back on 'DEFAULT' characters.
! Currently only gfortran >= 4.9.2 will correctly support
! UCS4 which is stored in 4 bytes.
! (and perhaps others).
integer,parameter,public :: CK = selected_char_kind(json_fortran_string_kind)
!*********************************************************
end module json_kinds
!*****************************************************************************************
! JSON-Fortran preprocessor macros.
!
! License
! JSON-Fortran is released under a BSD-style license.
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
! file for details.
!*********************************************************
! File encoding preprocessor macro.
!
#if defined __GFORTRAN__ && defined USE_UCS4
! gfortran compiler AND UCS4 support requested, & silence redefine warning:
! Make sure we output files with utf-8 encoding too
#define FILE_ENCODING ,encoding='UTF-8'
#else
! don't ask for utf-8 file encoding unless using UCS4
! this may let us use unformatted stream io to read in files more quickly
! even with unicode support turned on `inquire( ... encoding=FL_ENCODING)`
! may be able to detect json files in which each character is exactly one
! byte
#define FILE_ENCODING
#endif
!*********************************************************
!*********************************************************
! This C preprocessor macro will take a procedure name as an
! input, and output either that same procedure name if the
! code is compiled without USE_UCS4 being defined or it will
! expand the procedure name to the original procedure name,
! followed by a comma and then the original procedure name
! with 'wrap_' prepended to it. This is suitable for creating
! overloaded interfaces that will accept UCS4 character actual
! arguments as well as DEFAULT/ASCII character arguments,
! based on whether or not ISO 10646 is supported and requested.
!
# ifdef USE_UCS4
# ifdef __GFORTRAN__
! gfortran uses cpp in old-school compatibility mode so
! the # stringify and ## concatenate operators don't work
! but we can use C/C++ style comment to ensure PROCEDURE is
! correctly tokenized and prepended with 'wrap_' when the
! macro is expanded
# define MAYBEWRAP(PROCEDURE) PROCEDURE , wrap_/**/PROCEDURE
# endif
! ifdef __INTEL_COMPILER
! Intel's fpp does support the more contemporary ## concatenation
! operator, but doesn't treat the C/C++ comments the same way.
! If you use the gfortran approach and pass the -noB switch to
! fpp, the macro will expand, but with a space between wrap_ and
! whatever PROCEDURE expands to
! Intel doesn't support ISO 10646 yet, but this is here to
! ease the transition once they do.
! define MAYBEWRAP(PROCEDURE) PROCEDURE , wrap_##PROCEDURE
! endif
# else
# define MAYBEWRAP(PROCEDURE) PROCEDURE
# endif
!*********************************************************
!*****************************************************************************************
!> author: Jacob Williams
! license: BSD
!
! A Fortran 2008 JSON (JavaScript Object Notation) API.
!
! This module provides access to [[json_value_module]] and
! [[json_file_module]]. For normal JSON-Fortran use, using this module
! is all that is necessary.
!
! Note that this module renames the kind definition variables from [[json_kinds]]
! from [`RK`, `IK`, `LK`, `CK`, and `CDK`] to [`json_RK`, `json_IK`, `json_LK`,
! `json_CK`, and `json_CDK`] so as to avoid namespace pollution with short
! variable names.
!
#ifdef USE_UCS4
#pragma push_macro("USE_UCS4")
#undef USE_UCS4
! Since ```USE_UCS4``` **is** defined, this module also exports the
! operators `==`, `/=`, and `//` from [[json_string_utilities]] for
! `CK` and `CDK` operations.
#pragma pop_macro("USE_UCS4")
#endif
!
!## License
! * JSON-Fortran is released under a BSD-style license.
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
! file for details.
!
!## History
! * Joseph A. Levin : March 2012 : Original [FSON](https://github.com/josephalevin/fson)
! code [retrieved on 12/2/2013].
! * Jacob Williams : 2/8/2014 : Extensive modifications to the original FSON code.
! The original F95 code was split into four files:
! fson_path_m.f95, fson_string_m.f95, fson_value_m.f95, and fson.f95.
! The new code has been extensively updated, refactored and combined into this
! one module (json_module.f90).
! Various Fortran 2003/2008 features are now used
! (e.g., allocatable strings, newunit, generic, class, and abstract interface).
! * Development continues at: [Github](http://github.com/jacobwilliams/json-fortran)
!
!## See also
! * [json-fortran development site](http://github.com/jacobwilliams/json-fortran)
! * [json-fortran online documentation](http://jacobwilliams.github.io/json-fortran)
! * [JSON website](http://www.json.org/)
! * [JSON validator](http://jsonlint.com/)
!
!@note Originally JSON-Fortran was entirely contained within this module.
module json_module
use json_kinds, only: json_RK => RK, &
json_IK => IK, &
json_LK => LK, &
json_CK => CK, &
json_CDK => CDK
#ifdef USE_UCS4
use json_string_utilities, only: operator(==),&
operator(//),&
operator(/=)
#endif
use json_parameters, only: json_unknown,&
json_null, &
json_object, &
json_array, &
json_logical,&
json_integer,&
json_double, &
json_string
use json_value_module
use json_file_module
implicit none
public
end module json_module
!*****************************************************************************************
!*****************************************************************************************
!> author: Jacob Williams
! license: BSD
!
! Other parameters used by JSON-Fortran.
! This is a low-level module not meant to be used by a JSON-Fortran user.
!
!## License
! * JSON-Fortran is released under a BSD-style license.
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
! file for details.
module json_parameters
use json_kinds
implicit none
public
character(kind=CDK,len=*),parameter :: json_ext = '.json' !! JSON file extension
! The types of JSON data.
integer(IK),parameter :: json_unknown = 0 !! Unknown JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_null = 1 !! Null JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_object = 2 !! Object JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_array = 3 !! Array JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_logical = 4 !! Logical JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_integer = 5 !! Integer JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_double = 6 !! Double JSON data type
!! (see [[json_file_variable_info]] and [[json_info]])
integer(IK),parameter :: json_string = 7 !! String JSON data type
!special JSON characters
character(kind=CK,len=*),parameter :: space = CK_' '
character(kind=CK,len=*),parameter :: start_object = CK_'{'
character(kind=CK,len=*),parameter :: end_object = CK_'}'
character(kind=CK,len=*),parameter :: start_array = CK_'['
character(kind=CK,len=*),parameter :: end_array = CK_']'
character(kind=CK,len=*),parameter :: delimiter = CK_','
character(kind=CK,len=*),parameter :: colon_char = CK_':'
character(kind=CK,len=*),parameter :: start_array_alt = CK_'(' !! for [[json_get_by_path]]
character(kind=CK,len=*),parameter :: end_array_alt = CK_')' !! for [[json_get_by_path]]
character(kind=CK,len=*),parameter :: root = CK_'$' !! for [[json_get_by_path]]
character(kind=CK,len=*),parameter :: this = CK_'@' !! for [[json_get_by_path]]
character(kind=CK,len=*),parameter :: dot = CK_'.' !! for [[json_get_by_path]]
character(kind=CK,len=*),parameter :: tilde = CK_'~' !! RFC 6901 escape character
character(kind=CK,len=*),parameter :: percent = CK_'%' !! Fortran path separator
character(kind=CK,len=*),parameter :: bspace = achar(8, kind=CK)
character(kind=CK,len=*),parameter :: horizontal_tab = achar(9, kind=CK)
character(kind=CK,len=*),parameter :: newline = achar(10, kind=CK)
character(kind=CK,len=*),parameter :: formfeed = achar(12, kind=CK)
character(kind=CK,len=*),parameter :: carriage_return = achar(13, kind=CK)
character(kind=CK,len=*),parameter :: quotation_mark = achar(34, kind=CK)
character(kind=CK,len=*),parameter :: slash = achar(47, kind=CK)
character(kind=CK,len=*),parameter :: backslash = achar(92, kind=CK)
character(kind=CDK,len=*),parameter :: default_real_fmt = '(ss,E27.17E4)'
!! default real number format statement (for writing real values to strings and files).
!! Note that this can be overridden by calling [[json_initialize]].
character(kind=CK,len=*),parameter :: star = CK_'*' !! for invalid numbers and
!! list-directed real output
#if defined __GFORTRAN__
!not parameters due to gfortran bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65141)
character(kind=CK,len=26),protected :: upper = CK_'ABCDEFGHIJKLMNOPQRSTUVWXYZ' !! uppercase characters
character(kind=CK,len=26),protected :: lower = CK_'abcdefghijklmnopqrstuvwxyz' !! lowercase characters
#else
character(kind=CK,len=*),parameter :: upper = CK_'ABCDEFGHIJKLMNOPQRSTUVWXYZ' !! uppercase characters
character(kind=CK,len=*),parameter :: lower = CK_'abcdefghijklmnopqrstuvwxyz' !! lowercase characters
#endif
#if defined __GFORTRAN__
!not parameters due to gfortran bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65141)
character(kind=CK,len=4),protected :: null_str = CK_'null' !! JSON Null variable string
character(kind=CK,len=4),protected :: true_str = CK_'true' !! JSON logical True string
character(kind=CK,len=5),protected :: false_str = CK_'false' !! JSON logical False string
#else
character(kind=CK,len=*),parameter :: null_str = CK_'null' !! JSON Null variable string
character(kind=CK,len=*),parameter :: true_str = CK_'true' !! JSON logical True string
character(kind=CK,len=*),parameter :: false_str = CK_'false' !! JSON logical False string
#endif
integer, private :: i_ !! just a counter for `control_chars` array
character(kind=CK,len=*),dimension(32),parameter :: control_chars = &
[(achar(i_,kind=CK),i_=1,31), achar(127,kind=CK)] !! Control characters, possibly in unicode
!find out the precision of the floating point number system
!and set safety factors
integer(IK),parameter :: rp_safety_factor = 1_IK
integer(IK),parameter :: rp_addl_safety = 2_IK
integer(IK),parameter :: real_precision = rp_safety_factor*precision(1.0_RK) + &
rp_addl_safety
!Get the number of possible digits in the exponent when using decimal number system
integer(IK),parameter :: maxexp = maxexponent(1.0_RK)
integer(IK),parameter :: minexp = minexponent(1.0_RK)
integer(IK),parameter :: real_exponent_digits = floor( 1 + log10( &
real(max(maxexp,abs(maxexp)),&
kind=RK) ) )
integer(IK),parameter :: max_numeric_str_len = real_precision + real_exponent_digits + 6
!! 6 = sign + leading 0 + decimal + 'E' + exponent sign + 1 extra
character(kind=CDK,len=*),parameter :: int_fmt = '(ss,I0)' !! minimum width format for integers
integer(IK),parameter :: max_integer_str_len = 256 !! maximum string length of an integer.
!! This is totally arbitrary (any way
!! to get the compiler to tell us this?)
integer(IK),parameter :: chunk_size = 100_IK !! for allocatable strings: allocate chunks of this size
integer(IK),parameter :: unit2str = -1_IK !! unit number to cause stuff to be
!! output to strings rather than files.
!! See 9.5.6.12 in the F2003/08 standard
integer(IK),parameter :: seq_chunk_size = 256_IK !! chunk size for reading sequential files
integer(IK),parameter :: pushed_char_size = 10_IK !! size for `pushed_char`
!! array in [[json_core(type)]]
end module json_parameters
!*****************************************************************************************
This diff is collapsed.
This diff is collapsed.
bar.o : ../../Modules/io_global.o
bar.o : ../../Modules/kind.o
bar.o : io_push.o
destroy_pw_arrays.o : ../../Modules/becmod.o
destroy_pw_arrays.o : ../../Modules/constants.o
destroy_pw_arrays.o : ../../Modules/control_flags.o
destroy_pw_arrays.o : ../../Modules/fft_base.o
destroy_pw_arrays.o : ../../Modules/funct.o
destroy_pw_arrays.o : ../../Modules/io_files.o
destroy_pw_arrays.o : ../../Modules/io_global.o
destroy_pw_arrays.o : ../../Modules/kind.o
destroy_pw_arrays.o : ../../Modules/mp.o
destroy_pw_arrays.o : ../../Modules/mp_global.o
destroy_pw_arrays.o : ../../Modules/noncol.o
destroy_pw_arrays.o : ../../Modules/uspp.o
destroy_pw_arrays.o : ../../Modules/wavefunctions.o
destroy_pw_arrays.o : ../../PW/src/buffers.o
destroy_pw_arrays.o : ../../PW/src/newd.o
destroy_pw_arrays.o : ../../PW/src/pwcom.o
destroy_pw_arrays.o : ../../PW/src/scf_mod.o
do_setup.o : ../../Modules/cell_base.o
do_setup.o : ../../Modules/constants.o
do_setup.o : ../../Modules/control_flags.o
do_setup.o : ../../Modules/io_global.o
do_setup.o : ../../Modules/kind.o
do_setup.o : ../../Modules/mp.o
do_setup.o : ../../Modules/mp_global.o
do_setup.o : ../../Modules/noncol.o
do_setup.o : ../../PW/src/pwcom.o
do_setup.o : io_push.o
get_alpha_pv.o : ../../Modules/kind.o
get_alpha_pv.o : ../../Modules/mp.o
get_alpha_pv.o : ../../Modules/mp_global.o
get_alpha_pv.o : ../../PW/src/pwcom.o
get_nbndval.o : ../../Modules/constants.o
get_nbndval.o : ../../Modules/io_global.o
get_nbndval.o : ../../Modules/kind.o
get_nbndval.o : ../../Modules/noncol.o
get_nbndval.o : ../../PW/src/pwcom.o
human_readable_time.o : ../../Modules/kind.o
init_pw_arrays.o : ../../Modules/becmod.o
init_pw_arrays.o : ../../Modules/constants.o
init_pw_arrays.o : ../../Modules/control_flags.o
init_pw_arrays.o : ../../Modules/fft_base.o
init_pw_arrays.o : ../../Modules/funct.o
init_pw_arrays.o : ../../Modules/io_files.o
init_pw_arrays.o : ../../Modules/io_global.o
init_pw_arrays.o : ../../Modules/kind.o
init_pw_arrays.o : ../../Modules/mp.o
init_pw_arrays.o : ../../Modules/mp_global.o
init_pw_arrays.o : ../../Modules/noncol.o
init_pw_arrays.o : ../../Modules/uspp.o
init_pw_arrays.o : ../../Modules/wavefunctions.o
init_pw_arrays.o : ../../PW/src/buffers.o
init_pw_arrays.o : ../../PW/src/newd.o
init_pw_arrays.o : ../../PW/src/pwcom.o
init_pw_arrays.o : ../../PW/src/scf_mod.o
io_push.o : ../../Modules/io_global.o
io_push.o : ../../Modules/kind.o
linear_algebra_kernel.o : ../../Modules/kind.o
set_iks_l2g.o : ../../Modules/kind.o
set_iks_l2g.o : ../../Modules/mp.o
set_iks_l2g.o : ../../Modules/mp_global.o
set_iks_l2g.o : ../../PW/src/pwcom.o
set_iks_l2g.o : ../../West/Modules/westcom.o
set_isz.o : ../../Modules/cell_base.o
set_isz.o : ../../Modules/constants.o
set_isz.o : ../../Modules/kind.o
set_isz.o : ../../West/Modules/westcom.o
# Makefile for Libraries
default: all
all: json_do
json_do:
if test -d Json ; then \
( cd Json ; if test "$(MAKE)" = "" ; then make $(MFLAGS) all; \
else $(MAKE) $(MFLAGS) all ; fi ) ; fi
clean: json_undo
json_undo: