diff --git a/.travis.yml b/.travis.yml index 20cc0c7a69..445c1434c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,10 @@ env: # CMake build with unit tests, no documentation, with coverage analysis # No unicode so that coverage combined with the build script will cover unicode # and non-unicode code paths - - BUILD_SCRIPT="mkdir cmake-build && cd cmake-build && cmake -DSKIP_DOC_GEN:BOOL=TRUE -DCMAKE_BUILD_TYPE=COVERAGE .. && make -j 4 check" + - BUILD_SCRIPT="mkdir cmake-build && cd cmake-build && cmake -DCMAKE_BUILD_TYPE=COVERAGE .. && make -j 4 check" SPECIFIC_DEPENDS="cmake nodejs" JLINT="yes" - DOCS="no" + DOCS="yes" FoBiS="no" CODE_COVERAGE="yes" @@ -50,7 +50,7 @@ install: - sudo ln -fs /usr/bin/gcov-4.9 /usr/bin/gcov && gcov --version - if [[ $FoBiS == [yY]* ]]; then sudo -H pip install FoBiS.py && FoBiS.py --version; fi - if [[ $DOCS == [yY]* ]]; then sudo -H pip install ford && ford --version; fi - - if [[ $CHECK_README_PROGS == [yY]* ]]; then gfortran -o f90split f90split.f90 && ./f90split README.md && shopt -s extglob && for f in !(README|CONTRIBUTING).md; do mv $f src/tests/jf_test_${f%.md}.f90; done; rm f90split.f90 f90split; fi + - if [[ $CHECK_README_PROGS == [yY]* ]]; then gfortran -o f90split f90split.f90 && ./f90split README.md && for f in example*.md; do mv $f src/tests/jf_test_${f%.md}.f90; done; rm f90split.f90 f90split; fi script: - echo $BUILD_SCRIPT @@ -61,4 +61,4 @@ after_success: - if [[ $CODE_COVERAGE == [yY]* ]]; then bash <(curl -s https://codecov.io/bash) ; fi - git config --global user.name "TRAVIS-CI-for-$(git --no-pager show -s --format='%cn' $TRAVIS_COMMIT)" - git config --global user.email "$(git --no-pager show -s --format='%ce' $TRAVIS_COMMIT)" - - ./deploy.sh #handles updating documentation for master branch as well as tags +#broken for now# - ./deploy.sh #handles updating documentation for master branch as well as tags diff --git a/CMakeLists.txt b/CMakeLists.txt index a60c5db4a3..b2e5b065b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,41 +138,46 @@ set_target_properties ( ${LIB_NAME} Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} ) #------------------------------------- -# Build the documentation with ROBODoc +# Build the documentation with FORD #------------------------------------- set ( SKIP_DOC_GEN FALSE CACHE BOOL - "Disable building the API documentation with ROBODoc" ) + "Disable building the API documentation with FORD" ) if ( NOT SKIP_DOC_GEN ) - find_program ( ROBODOC robodoc ) - if ( ROBODOC ) # Found - set ( ROBODOC_OPTIONS --rc ${CMAKE_SOURCE_DIR}/robodoc.rc - CACHE STRING "Options passed to robodoc to control building the documentation" ) - set ( DOC_DIR "${CMAKE_BINARY_DIR}/documentation" ) - set ( REQUIRED_ROBODOC_OPTIONS - --src "${CMAKE_SOURCE_DIR}/src" --doc "${DOC_DIR}" - --documenttitle "${CMAKE_PROJECT_NAME}" ) - # Dynamically generate the ROBODoc outputs list - message ( STATUS "Dynamically computing ROBODoc output information..." ) - execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR} - COMMAND ${CMAKE_COMMAND} -E make_directory ${DOC_DIR} - COMMAND "${ROBODOC}" ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS} ) - file ( GLOB_RECURSE ROBODOC_OUTPUTS - "${DOC_DIR}/*" ) - execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR} ) - message ( STATUS "Done dynamically computing ROBODoc outputs." ) + find_program ( FORD ford ) + if ( FORD ) # Found + file ( COPY "${CMAKE_SOURCE_DIR}/media" DESTINATION "${CMAKE_BINARY_DIR}/" ) + set ( DOC_DIR "${CMAKE_BINARY_DIR}/doc" ) + set ( FORD_PROJECT_FILE "${CMAKE_SOURCE_DIR}/json-fortran.md" ) + # Dynamically generate the FORD outputs list + message ( STATUS "Dynamically computing FORD output information..." ) + if ( NOT (DEFINED FORD_OUTPUTS_CACHED) ) + message ( STATUS "Running FORD to dynamically compute documentation outputs, this could take a while..." ) + execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOC_DIR} + COMMAND "${FORD}" -d "${CMAKE_SOURCE_DIR}/src" -o "${DOC_DIR}" "${FORD_PROJECT_FILE}" OUTPUT_QUIET ) + endif () + file ( GLOB_RECURSE FORD_OUTPUTS + "${DOC_DIR}/*.html" ) + file ( GLOB_RECURSE FORD_CLEAN_OUTPUTS + "${DOC_DIR}/*.*" ) + if ( (DEFINED FORD_OUTPUTS) AND ( NOT ( "${FORD_OUTPUTS}" STREQUAL "" ) ) ) + set ( FORD_OUTPUTS_CACHED "${FORD_OUTPUTS}" + CACHE INTERNAL "internal variable to attempt to prevent rebuilding FORD docs" FORCE ) + endif () + message ( STATUS "Done dynamically computing FORD outputs." ) foreach ( SRC_FILE ${JF_LIB_SRCS} ${JF_TEST_SRCS} ) - list ( APPEND ROBO_DEPENDS "${SRC_FILE}" ) + list ( APPEND FORD_DEPENDS "${SRC_FILE}" ) endforeach ( SRC_FILE ) - add_custom_command ( OUTPUT ${ROBODOC_OUTPUTS} - COMMAND "${CMAKE_COMMAND}" -E make_directory "${DOC_DIR}" # Ensure DOC_DIR exists at build time - COMMAND "${ROBODOC}" ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS} - DEPENDS ${ROBO_DEPENDS} - COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using ROBODoc" ) + add_custom_command ( OUTPUT ${FORD_OUTPUTS_CACHED} + COMMAND "${FORD}" -d "${CMAKE_SOURCE_DIR}/src" -o "${DOC_DIR}" "${FORD_PROJECT_FILE}" + MAIN_DEPENDENCY "${FORD_PROJECT_FILE}" + DEPENDS ${FORD_DEPENDS} + COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using FORD" ) add_custom_target ( documentation ALL - DEPENDS ${ROBODOC_OUTPUTS} ) + DEPENDS ${FORD_OUTPUTS} ) set ( INSTALL_API_DOCUMENTATION TRUE - CACHE BOOL "Install ROBODoc generated documentation?" ) + CACHE BOOL "Install FORD generated documentation?" ) if ( INSTALL_API_DOCUMENTATION ) if ( USE_GNU_INSTALL_CONVENTION ) install ( DIRECTORY "${DOC_DIR}/" DESTINATION "${CMAKE_INSTALL_DOCDIR}" ) @@ -182,7 +187,7 @@ if ( NOT SKIP_DOC_GEN ) endif () else () # Not found message ( WARNING - "ROBODoc not found! Please set the CMake cache variable ROBODOC to point to the installed ROBODoc binary, and reconfigure or disable building the documentation. ROBODoc can be installed from: http://www.xs4all.nl/~rfsber/Robo/ If you do not wish to install ROBODoc and build the json-fortran documentation, then please set the CMake cache variable SKIP_DOC_GEN to TRUE." ) + "FORD not found! Please set the CMake cache variable FORD to point to the installed FORD executable, and reconfigure or disable building the documentation. FORD can be installed from PYPI with `sudo pip install FORD` or from If you do not wish to install FORD and build the json-fortran documentation, then please set the CMake cache variable SKIP_DOC_GEN to TRUE." ) endif () endif () @@ -209,7 +214,7 @@ if ( ENABLE_TESTS ) set ( DATA_DIR "${CMAKE_BINARY_DIR}/files" ) set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES - "${DATA_DIR}/test2.json;${DATA_DIR}/test4.json" ) + "${DATA_DIR}/test2.json;${DATA_DIR}/test4.json;${FORD_CLEAN_OUTPUTS}" ) # Validate input if ( JSONLINT ) @@ -222,7 +227,7 @@ if ( ENABLE_TESTS ) get_filename_component ( TESTNAME "${VALID_JSON}" NAME ) add_test ( NAME validate-${TESTNAME} WORKING_DIRECTORY "${DATA_DIR}/inputs" - COMMAND ${JSONLINT} "${VALID_JSON}" ) + COMMAND ${JSONLINT} "--allow=nonescape-characters" "${VALID_JSON}" ) endforeach () foreach ( INVALID ${INVALID_JSON} ) @@ -267,7 +272,7 @@ if ( ENABLE_TESTS ) get_filename_component ( TESTNAME ${JSON_FILE} NAME ) add_test ( NAME validate-output-${TESTNAME} WORKING_DIRECTORY "${DATA_DIR}" - COMMAND ${JSONLINT} ${TESTNAME} ) + COMMAND ${JSONLINT} "--allow=nonescape-characters" ${TESTNAME} ) set_property ( TEST validate-output-${TESTNAME} APPEND PROPERTY diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b1ad237d2..7629084c32 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ git rebase upstream/master - Please adhere to the code indentation and formatting as it currently exists, aligning common elements vertically, etc. Tab characters are not allowed. Indentations should be done with *4* space characters. - *Do NOT* allow your editor to make a bunch of indentation or white space changes, that will introduce non-substantive changes on lines that you have not actually edited. - The coding style is modern free-form Fortran, consistent with the Fortran 2008 standard. Note that the two supported compilers (ifort and gfortran) do not currently include the entire Fortran 2008 standard. Therefore, only those language features supported by Gfortran 4.9 and Intel 13.1.0 are currently allowed. This also means that previous versions of these compilers are not supported, and major changes to the code to support earlier compilers (or Fortran 95) will not be accepted. At some point in the future (when compiler support has improved), all Fortran 2008 features will be allowed. -- All subroutines and functions *must* be properly documented. This includes useful inline comments as well as comment blocks using the [ROBODoc](http://rfsber.home.xs4all.nl/Robo/manual.html) syntax. +- All subroutines and functions *must* be properly documented. This includes useful inline comments as well as comment blocks using the [FORD](https://github.com/cmacmackin/ford/wiki/Writing-Documentation) syntax. - For simplicity, json-fortran currently consists of one module file. It is not envisioned that it will ever need to expand to include multiple files (if it does, there would need to be a very good reason). [top](#contributing-to-json-fortran) diff --git a/README.md b/README.md index 8409da0aac..7b97127d7b 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ brew install --with-unicode-support json-fortran _Please note_, if you wish to support usage of json-fortran with multiple Fortran compilers, please follow the CMake installation instructions below, as the homebrew installation is only intended to -support a single Fortran compiler. Cheers! :beers: +support a single Fortran compiler. Cheers! [top](#json-fortran-) Building the library @@ -276,7 +276,7 @@ The code above produces the file: Documentation -------------- -The API documentation for the latest release version can be found [here](http://jacobwilliams.github.io/json-fortran). The documentation can also be generated by processing the source files with [RoboDoc](http://rfsber.home.xs4all.nl/Robo/). Note that both the shell script, CMake, and SCons will also generate these files automatically in the documentation folder, assuming you have RoboDoc installed. +The API documentation for the latest release version can be found [here](http://jacobwilliams.github.io/json-fortran). The documentation can also be generated by processing the source files with [FORD](https://github.com/cmacmackin/ford). Note that both the shell script, CMake, and SCons will also generate these files automatically in the documentation folder, assuming you have FORD installed. [top](#json-fortran-) Contributing [![Ready in backlog](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Ready&title=Ready)](CONTRIBUTING.md) diff --git a/build.sh b/build.sh index f84ca61a7b..4a7671471d 100755 --- a/build.sh +++ b/build.sh @@ -20,7 +20,7 @@ # profiling flags # with : # unit tests enabled -# documentation (if ROBODoc is installed) +# documentation (if FORD is installed) # # More recent (right-most) flags will override preceding flags # flags: @@ -51,11 +51,11 @@ # fortran unit tests # # --skip-documentation [{yes|no}]: Skip (or don't skip) building the json- -# fortran documentation using ROBODoc +# fortran documentation using FORD # # REQUIRES # FoBiS.py : https://github.com/szaghi/FoBiS [version 1.2.5 or later required] -# RoboDoc : http://rfsber.home.xs4all.nl/Robo/ [version 4.99.38 is the one tested] +# FORD : https://github.com/cmacmackin/ford [version 3.0.2 is the one tested] # # AUTHOR # Jacob Williams : 12/27/2014 @@ -63,7 +63,6 @@ set -e -#PROJECTNAME='jsonfortran' # project name for robodoc (example: jsonfortran_2.0.0) FORDMD='json-fortran.md' # FORD options file for building documentation DOCDIR='./documentation/' # build directory for documentation SRCDIR='./src/' # library source directory diff --git a/json-fortran.md b/json-fortran.md index d98bd71ad1..d80d729bbe 100644 --- a/json-fortran.md +++ b/json-fortran.md @@ -1,10 +1,15 @@ project: json-fortran +favicon: ./media/json-fortran-32x32.png project_dir: ./src +macro: USE_UCS4 output_dir: ./doc +media_dir: ./media project_github: https://github.com/jacobwilliams/json-fortran summary: JSON-FORTRAN -- A Fortran 2008 JSON API author: Jacob Williams github: https://github.com/jacobwilliams +website: http://degenerateconic.com +twitter: https://twitter.com/degenerateconic predocmark_alt: > predocmark: < docmark_alt: @@ -12,9 +17,20 @@ docmark: ! exclude_dir: tests exclude_dir: introspection display: public -display: protected -display: private + protected + private source: true +md_extensions: markdown.extensions.toc(anchorlink=True) + markdown.extensions.smarty(smart_quotes=False) + + + +[TOC] # Brief description diff --git a/media/json-fortran-32x32.png b/media/json-fortran-32x32.png new file mode 100644 index 0000000000..35280bb86d Binary files /dev/null and b/media/json-fortran-32x32.png differ diff --git a/logos/json-fortran-logo.svg b/media/json-fortran-logo.svg similarity index 100% rename from logos/json-fortran-logo.svg rename to media/json-fortran-logo.svg diff --git a/src/json_module.F90 b/src/json_module.F90 index f5206f9fb5..ef91768f1c 100644 --- a/src/json_module.F90 +++ b/src/json_module.F90 @@ -2,28 +2,40 @@ !> author: Jacob Williams ! license: BSD ! -! JSON-FORTRAN: A Fortran 2008 JSON (JavaScript Object Notation) API. +!# JSON-FORTRAN: +! A Fortran 2008 JSON (JavaScript Object Notation) API. +! +! [TOC] ! ! This module provides an interface for reading and writing JSON files. ! -!@note ```USE_UCS4``` is an optional preprocessor flag. -! When present, Unicode support is enabled. Note that this +!@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 -! The documentation given here assumes ```USE_UCS4``` **is** defined. +# 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. +! The documentation given here assumes ```USE_UCS4``` **is not** defined. #endif ! -!@note ```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: json path, character or string, or -! object name passed to the json-fortran library *MUST* be of type ```CK```. +!@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. ! -!# License +!## License ! ! **json-fortran License:** ! @@ -75,7 +87,7 @@ ! OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ! DEALINGS IN THE SOFTWARE. ! -!# History +!## History ! * Joseph A. Levin : March 2012 : Original 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: @@ -86,7 +98,7 @@ ! (e.g., allocatable strings, newunit, generic, class, and abstract interface). ! * Development continues at: [Github](http://github.com/jacobwilliams/json-fortran) ! -!# See also +!## 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/) @@ -105,7 +117,7 @@ module json_module integer,parameter :: IK = int32 !! Default integer kind [4 bytes]. !********************************************************* - !> + !> ! Processor dependendant 'DEFAULT' character kind. ! This is 1 byte for the Intel and Gfortran compilers. @@ -113,7 +125,7 @@ module json_module !********************************************************* !********************************************************* - !> + !> ! Default logical kind. ! This is 4 bytes for the Intel and Gfortran compilers ! (and perhaps others). @@ -122,9 +134,9 @@ module json_module ! integer,parameter :: LK = logical_kinds(min(3,size(logical_kinds))) !********************************************************* - + !********************************************************* - !> + !> ! String kind preprocessor macro. ! #if defined __GFORTRAN__ && defined USE_UCS4 @@ -138,7 +150,7 @@ module json_module !********************************************************* !********************************************************* - !> + !> ! Default character kind used by json-fortran. ! If ISO 10646 (UCS4) support is available, use that, ! otherwise, gracefully fall back on 'DEFAULT' characters. @@ -202,7 +214,7 @@ module json_module !********************************************************* !********************************************************* - !> + !> ! If Unicode is not enabled, then ! JSON files are opened using access='STREAM' and ! form='UNFORMATTED'. This allows the file to @@ -216,7 +228,7 @@ module json_module !********************************************************* !********************************************************* - !> + !> ! If Unicode is not enabled, then ! JSON files are opened using access='STREAM' and ! form='UNFORMATTED'. This allows the file to @@ -230,7 +242,7 @@ module json_module !********************************************************* !********************************************************* - !> + !> ! If Unicode is not enabled, then ! JSON files are opened using access='STREAM' and ! form='UNFORMATTED'. This allows the file to @@ -258,7 +270,7 @@ module json_module !********************************************************* !********************************************************* - !> + !> ! Type used to construct the linked-list JSON structure. ! Normally, this should always be a pointer variable. ! @@ -279,7 +291,7 @@ module json_module ![note: on Intel, the order of the variables below ! is significant to avoid the misaligned field warnings] sequence - + private !for the linked list: @@ -404,7 +416,7 @@ module json_module !********************************************************* !************************************************************************************* - !> + !> ! Array element callback function. Used by [[json_get_array]]. abstract interface @@ -431,12 +443,12 @@ end subroutine array_callback_func # endif !************************************************************************************* - !> + !> ! Get a child, either by index or name string. ! Both of these return a [[json_value]] pointer. ! !@note Formerly, this was called json_value_get_child - + interface json_get_child module procedure json_value_get_by_index module procedure MAYBEWRAP(json_value_get_by_name_chars) @@ -444,11 +456,11 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Add objects to a linked list of [[json_value]]s. ! !@note Formerly, this was called json_value_add - + interface json_add module procedure json_value_add_member module procedure MAYBEWRAP(json_value_add_integer) @@ -469,7 +481,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! These are like [[json_add]], except if a child with the same name is ! already present, then its value is simply updated. ! Note that currently, these only work for scalar variables. @@ -478,7 +490,7 @@ end subroutine array_callback_func ! !@note It should not be used to change the type of a variable in an array, ! or it may result in an invalid JSON file. - + interface json_update module procedure MAYBEWRAP(json_update_logical),& MAYBEWRAP(json_update_double),& @@ -492,14 +504,14 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Get data from a [[json_value]] linked list. ! !@note There are two versions (e.g. [[json_get_integer]] and [[json_get_integer_with_path]]). ! The first one gets the value from the [[json_value]] passed into the routine, ! while the second one gets the value from the [[json_value]] found by parsing the ! path. The path version is split up into unicode and non-unicode versions. - + interface json_get module procedure MAYBEWRAP(json_get_by_path) module procedure json_get_integer, MAYBEWRAP(json_get_integer_with_path) @@ -515,7 +527,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Print the json_value structure to an allocatable string. interface json_print_to_string @@ -524,7 +536,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Print the [[json_value]] to a file. ! !# Example @@ -534,7 +546,7 @@ end subroutine array_callback_func ! !... ! call json_print(p,'test.json') !this is [[json_print_2]] !``` - + interface json_print module procedure json_print_1 !input is unit number module procedure json_print_2 !input is file name @@ -542,7 +554,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Destructor routine for a [[json_value]] pointer. ! This must be called explicitly if it is no longer needed, ! before it goes out of scope. Otherwise, a memory leak will result. @@ -585,7 +597,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Remove a [[json_value]] from a linked-list structure. interface json_remove @@ -594,7 +606,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! If the child variable is present, then remove it. interface json_remove_if_present @@ -620,7 +632,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Allocate a [[json_value]] pointer and make it an array variable. ! The pointer should not already be allocated. ! @@ -637,7 +649,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Allocate a [[json_value]] pointer and make it an object variable. ! The pointer should not already be allocated. ! @@ -657,7 +669,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Allocate a json_value pointer and make it a null variable. ! The pointer should not already be allocated. ! @@ -674,7 +686,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Allocate a json_value pointer and make it a string variable. ! The pointer should not already be allocated. ! @@ -691,7 +703,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Allocate a json_value pointer and make it an integer variable. ! The pointer should not already be allocated. ! @@ -708,7 +720,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Allocate a json_value pointer and make it a logical variable. ! The pointer should not already be allocated. ! @@ -725,7 +737,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Parse the JSON file and populate the [[json_value]] tree. interface json_parse @@ -734,7 +746,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Convert a 'DEFAULT' kind character input to 'ISO_10646' kind and return it interface to_unicode @@ -743,7 +755,7 @@ end subroutine array_callback_func !************************************************************************************* !************************************************************************************* - !> + !> ! Throw an exception. interface throw_exception @@ -775,7 +787,7 @@ end subroutine array_callback_func public :: json_remove ! remove from a JSON structure public :: json_remove_if_present ! remove from a JSON structure (if it is present) public :: json_update ! update a value in a JSON structure - public :: json_print_error_message ! + public :: json_print_error_message ! public :: to_unicode ! Function to convert from 'DEFAULT' to 'ISO_10646' strings # ifdef USE_UCS4 @@ -858,10 +870,10 @@ end subroutine array_callback_func integer(IK),parameter :: chunk_size = 100 !! for allocatable strings: allocate chunks of this size integer(IK) :: ipos = 1 !! for allocatable strings: next character to read - integer(IK),parameter :: unit2str = -1 !! unit number to cause stuff to be + integer(IK),parameter :: unit2str = -1 !! unit number to cause stuff to be !! output to strings rather than files. !! See 9.5.6.12 in the F2003/08 standard - + contains !***************************************************************************************** @@ -982,7 +994,7 @@ end subroutine json_file_load_from_string !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_load_from_string]], where "str" is kind=CDK. subroutine wrap_json_file_load_from_string(me, str) @@ -1000,7 +1012,7 @@ end subroutine wrap_json_file_load_from_string !***************************************************************************************** !> author: Jacob Williams ! date: 1/11/2015 -! +! ! Print the JSON file to the console. subroutine json_file_print_to_console(me) @@ -1019,7 +1031,7 @@ end subroutine json_file_print_to_console !***************************************************************************************** !> author: Jacob Williams ! date: 12/9/2013 -! +! ! Prints the JSON file to the specified file unit number. subroutine json_file_print_1(me, iunit) @@ -1153,7 +1165,7 @@ end subroutine json_file_variable_info !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_variable_info]], where "path" is kind=CDK. subroutine wrap_json_file_variable_info(me,path,found,var_type,n_children) @@ -1212,7 +1224,7 @@ end subroutine json_file_get_object !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_object]], where "path" is kind=CDK. subroutine wrap_json_file_get_object(me, path, p, found) @@ -1250,7 +1262,7 @@ end subroutine json_file_get_integer !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_integer]], where "path" is kind=CDK. subroutine wrap_json_file_get_integer(me, path, val, found) @@ -1270,7 +1282,7 @@ end subroutine wrap_json_file_get_integer !***************************************************************************************** !> author: Jacob Williams ! date: 1/20/2014 -! +! ! Get an integer vector from a JSON file. subroutine json_file_get_integer_vec(me, path, vec, found) @@ -1288,7 +1300,7 @@ end subroutine json_file_get_integer_vec !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_integer_vec]], where "path" is kind=CDK. subroutine wrap_json_file_get_integer_vec(me, path, vec, found) @@ -1326,7 +1338,7 @@ end subroutine json_file_get_double !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_double]], where "path" is kind=CDK. subroutine wrap_json_file_get_double (me, path, val, found) @@ -1364,7 +1376,7 @@ end subroutine json_file_get_double_vec !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_double_vec]], where "path" is kind=CDK. subroutine wrap_json_file_get_double_vec(me, path, vec, found) @@ -1402,7 +1414,7 @@ end subroutine json_file_get_logical !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_logical]], where "path" is kind=CDK. subroutine wrap_json_file_get_logical(me,path,val,found) @@ -1440,7 +1452,7 @@ end subroutine json_file_get_logical_vec !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_logical_vec]], where "path" is kind=CDK. subroutine wrap_json_file_get_logical_vec(me, path, vec, found) @@ -1479,7 +1491,7 @@ end subroutine json_file_get_string !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_string]], where "path" is kind=CDK. subroutine wrap_json_file_get_string(me, path, val, found) @@ -1517,7 +1529,7 @@ end subroutine json_file_get_string_vec !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_get_string_vec]], where "path" is kind=CDK. subroutine wrap_json_file_get_string_vec(me, path, vec, found) @@ -1642,7 +1654,7 @@ end subroutine json_throw_exception !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_throw_exception]], where "msg" is kind=CDK. subroutine wrap_json_throw_exception(msg) @@ -1741,7 +1753,7 @@ end function json_failed !***************************************************************************************** !***************************************************************************************** -!> +!> ! Allocate a [[json_value]] pointer variable. ! This should be called before adding data to it. ! @@ -1952,7 +1964,7 @@ end subroutine json_value_remove_if_present !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_remove_if_present]], where "name" is kind=CDK. subroutine wrap_json_value_remove_if_present(p,name) @@ -1992,7 +2004,7 @@ end subroutine json_file_update_integer !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_update_integer]], where "name" is kind=CDK. subroutine wrap_json_file_update_integer(me,name,val,found) @@ -2033,7 +2045,7 @@ end subroutine json_file_update_logical !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_update_logical]], where "name" is kind=CDK. subroutine wrap_json_file_update_logical(me,name,val,found) @@ -2074,7 +2086,7 @@ end subroutine json_file_update_real !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_update_real]], where "name" is kind=CDK. subroutine wrap_json_file_update_real(me,name,val,found) @@ -2115,7 +2127,7 @@ end subroutine json_file_update_string !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_update_string]], where "name" and "val" are kind=CDK. subroutine wrap_json_file_update_string(me,name,val,found) @@ -2132,7 +2144,7 @@ end subroutine wrap_json_file_update_string !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_update_string]], where "name" is kind=CDK. subroutine json_file_update_string_name_ascii(me,name,val,found) @@ -2149,7 +2161,7 @@ end subroutine json_file_update_string_name_ascii !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_file_update_string]], where "val" is kind=CDK. subroutine json_file_update_string_val_ascii(me,name,val,found) @@ -2206,7 +2218,7 @@ end subroutine json_update_logical !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_update_logical]], where "name" is kind=CDK. subroutine wrap_json_update_logical(p,name,val,found) @@ -2264,7 +2276,7 @@ end subroutine json_update_double !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_update_double]], where "name" is kind=CDK. subroutine wrap_json_update_double(p,name,val,found) @@ -2322,7 +2334,7 @@ end subroutine json_update_integer !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_update_integer]], where "name" is kind=CDK. subroutine wrap_json_update_integer(p,name,val,found) @@ -2380,7 +2392,7 @@ end subroutine json_update_string !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_update_string]], where "name" and "value" are kind=CDK. subroutine wrap_json_update_string(p,name,val,found) @@ -2416,7 +2428,7 @@ end subroutine json_update_string_name_ascii !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_update_string]], where "val" is kind=CDK. subroutine json_update_string_val_ascii(p,name,val,found) @@ -2434,7 +2446,7 @@ end subroutine json_update_string_val_ascii !***************************************************************************************** !***************************************************************************************** -!> +!> ! Adds "member" as a child of "me". subroutine json_value_add_member(me, member) @@ -2504,7 +2516,7 @@ end subroutine json_value_add_double !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_add_double]] where "name" is kind=CDK. subroutine wrap_json_value_add_double(me, name, val) @@ -2559,7 +2571,7 @@ end subroutine json_value_add_double_vec !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_add_double_vec]] where "name" is kind=CDK. subroutine wrap_json_value_add_double_vec(me, name, val) @@ -2608,7 +2620,7 @@ end subroutine json_value_add_integer !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_add_integer]] where "name" is kind=CDK. subroutine wrap_json_value_add_integer(me, name, val) @@ -2712,7 +2724,7 @@ end subroutine json_value_add_logical !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_add_logical]] where "name" is kind=CDK. subroutine wrap_json_value_add_logical(me, name, val) @@ -2767,7 +2779,7 @@ end subroutine json_value_add_logical_vec !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_add_logical_vec]] where "name" is kind=CDK. subroutine wrap_json_value_add_logical_vec(me, name, val) @@ -2820,7 +2832,7 @@ end subroutine json_value_add_string !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_value_add_string]] where "name" and "val" are kind=CDK. subroutine wrap_json_value_add_string(me, name, val) @@ -3247,7 +3259,7 @@ subroutine json_print_1(me,iunit) type(json_value),pointer,intent(in) :: me integer(IK),intent(in) :: iunit !! the file unit (the file must already have been opened, can't be -1). - + character(kind=CK,len=:),allocatable :: dummy if (iunit/=unit2str) then @@ -3271,7 +3283,7 @@ subroutine json_print_2(me,filename) type(json_value),pointer,intent(in) :: me character(kind=CDK,len=*),intent(in) :: filename !! the filename to print to (should not already be open) - + integer(IK) :: iunit,istat open(newunit=iunit,file=filename,status='REPLACE',iostat=istat FILE_ENCODING ) @@ -3739,7 +3751,7 @@ end subroutine wrap_json_get_by_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Convert a string into an integer. ! !# History @@ -3754,7 +3766,7 @@ function string_to_integer(str) result(ival) character(kind=CK,len=*),intent(in) :: str integer(IK) :: ival - + character(kind=CDK,len=:),allocatable :: digits integer(IK) :: ndigits_digits,ndigits,ierr @@ -3997,7 +4009,7 @@ end subroutine json_get_integer_vec_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_integer_vec_with_path]], where "path" is kind=CDK subroutine wrap_json_get_integer_vec_with_path(me, path, vec, found) @@ -4099,7 +4111,7 @@ end subroutine json_get_double_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_double_with_path]], where "path" is kind=CDK subroutine wrap_json_get_double_with_path(me, path, value, found) @@ -4209,7 +4221,7 @@ end subroutine json_get_double_vec_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_double_vec_with_path]], where "path" is kind=CDK subroutine wrap_json_get_double_vec_with_path(me, path, vec, found) @@ -4303,7 +4315,7 @@ end subroutine json_get_logical_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_logical_with_path]], where "path" is kind=CDK subroutine wrap_json_get_logical_with_path(me, path, value, found) @@ -4413,7 +4425,7 @@ end subroutine json_get_logical_vec_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_logical_vec_with_path]], where "path" is kind=CDK subroutine wrap_json_get_logical_vec_with_path(me, path, vec, found) @@ -4645,7 +4657,7 @@ end subroutine json_get_string_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_string_with_path]], where "path" is kind=CDK subroutine wrap_json_get_string_with_path(me, path, value, found) @@ -4773,7 +4785,7 @@ end subroutine json_get_string_vec_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_string_vec_with_path]], where "path" is kind=CDK subroutine wrap_json_get_string_vec_with_path(me, path, vec, found) @@ -4880,7 +4892,7 @@ end subroutine json_get_array_with_path !***************************************************************************************** !***************************************************************************************** -!> +!> ! Alternate version of [[json_get_array_with_path]], where "path" is kind=CDK subroutine wrap_json_get_array_with_path(me, path, array_callback, found) @@ -5088,7 +5100,7 @@ subroutine annotate_invalid_json(iunit,str) !draw the arrow string that points to the current character: arrow_str = repeat('-',max( 0, char_count - 1) )//'^' - + if (line_count>0 .and. char_count>0) then if (iunit/=0) then @@ -6095,7 +6107,7 @@ subroutine parse_for_chars(unit, str, chars) implicit none - integer(IK),intent(in) :: unit !! file unit number (if parsing from a file) + integer(IK),intent(in) :: unit !! file unit number (if parsing from a file) character(kind=CK,len=*),intent(in) :: str !! JSON string (if parsing from a string) character(kind=CK,len=*),intent(in) :: chars !! the string to check for.