Skip to content

Commit 8b89695

Browse files
committed
Merge pull request #125 from zbeekman/small-fixes
Small fixes
2 parents 997e4f9 + e19691b commit 8b89695

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ A Fortran 2008 JSON API
88

99
- [Status](#status)
1010
- [Brief description](#brief-description)
11-
- [Download](#download-)
11+
- [Download](#download)
1212
- [Building the library](#building-the-library)
1313
- [Reading JSON from a file](#reading-json-from-a-file)
1414
- [Reading JSON from a string](#reading-json-from-a-string)
1515
- [Modifying variables in a JSON file](#modifying-variables-in-a-json-file)
1616
- [Writing a JSON file](#writing-a-json-file)
1717
- [Building a JSON file from scratch](#building-a-json-file-from-scratch)
1818
- [Documentation](#documentation)
19-
- [Contributing](#contributing-)
19+
- [Contributing](#contributing)
2020
- [License](#license)
2121
- [Miscellaneous](#miscellaneous)
2222

@@ -29,18 +29,20 @@ Status
2929
[![codecov.io](http://codecov.io/github/jacobwilliams/json-fortran/coverage.svg?branch=master)](http://codecov.io/github/jacobwilliams/json-fortran?branch=master)<br/>
3030
[![GitHub issues](https://img.shields.io/github/issues/jacobwilliams/json-fortran.png?style=plastic)](https://github.com/jacobwilliams/json-fortran/issues)
3131
[![Blocked by Vendor Bug](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=vendor%20bug&title=Blocked%20by%20Vendor%20Bug)](https://waffle.io/jacobwilliams/json-fortran)
32-
[![Ready in backlog](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Ready&title=Ready)](https://github.com/jacobwilliams/json-fortran/#contributing-)
32+
[![Ready in backlog](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Ready&title=Ready)](https://github.com/jacobwilliams/json-fortran/#contributing)
3333
[![In Progress](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=In%20Progress&title=In%20Progress)](https://waffle.io/jacobwilliams/json-fortran)
3434
[![Needs Review](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Needs%20Review&title=Needs%20Review)](https://waffle.io/jacobwilliams/json-fortran)
3535

36-
[top](#json-fortran-)
36+
[top](#json-fortran)
37+
3738
Brief description
3839
---------------
3940

4041
A user-friendly and object-oriented API for reading and writing JSON files, written in
4142
modern Fortran. The source code is a single Fortran module file ([json_module.F90](https://github.com/jacobwilliams/json-fortran/blob/master/src/json_module.F90)).
4243

43-
[top](#json-fortran-)
44+
[top](#json-fortran)
45+
4446
Download [![GitHub release](https://img.shields.io/github/release/jacobwilliams/json-fortran.svg?style=plastic)](https://github.com/jacobwilliams/json-fortran/releases)
4547
--------------------
4648

@@ -68,7 +70,8 @@ multiple Fortran compilers, please follow the CMake installation
6870
instructions below, as the homebrew installation is only intended to
6971
support a single Fortran compiler. Cheers! :beers:
7072

71-
[top](#json-fortran-)
73+
[top](#json-fortran)
74+
7275
Building the library
7376
--------------------
7477

@@ -123,7 +126,8 @@ foreach ( UNIT_TEST ${JF_TEST_SRCS} )
123126
endforeach()
124127
```
125128

126-
[top](#json-fortran-)
129+
[top](#json-fortran)
130+
127131
Reading JSON from a file
128132
---------------
129133

@@ -165,14 +169,18 @@ for more examples. The source files may be found in `src/tests/`.
165169
end program example1
166170
```
167171

168-
[top](#json-fortran-)
172+
[top](#json-fortran)
173+
169174
Reading JSON from a string
170175
---------------
176+
171177
JSON can also be read directly from a character string like so:
172178
```fortran
173179
call json%load_from_string('{"name": "Leonidas"}')
174180
```
175181

182+
[top](#json-fortran)
183+
176184
Modifying variables in a JSON file
177185
---------------
178186

@@ -185,7 +193,8 @@ After reading a JSON file, if you want to change the values of some of the varia
185193
call json%update('version.patch',0,found) !change patch to 0
186194
```
187195

188-
[top](#json-fortran-)
196+
[top](#json-fortran)
197+
189198
Writing a JSON file
190199
---------------
191200

@@ -196,7 +205,8 @@ To print the JSON file (either to a file or the console), the `print_file` metho
196205
call json%print_file(iunit) !prints to the file connected to iunit
197206
```
198207

199-
[top](#json-fortran-)
208+
[top](#json-fortran)
209+
200210
Building a JSON file from scratch
201211
---------------
202212

@@ -272,23 +282,27 @@ The code above produces the file:
272282
}
273283
```
274284

275-
[top](#json-fortran-)
285+
[top](#json-fortran)
286+
276287
Documentation
277288
--------------
278289

279290
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.
280291

281-
[top](#json-fortran-)
282-
Contributing [![Ready in backlog](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Ready&title=Ready)](CONTRIBUTING.md)
292+
[top](#json-fortran)
293+
294+
Contributing [![Ready in backlog](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Ready&title=Ready)](https://github.com/jacobwilliams/json-fortran/blob/master/CONTRIBUTING.md)
283295
------------
284-
Want to help? Take a quick look at our [contributing guidelines](CONTRIBUTING.md) then claim something in [the "ready" column on our Waffle.io](https://waffle.io/jacobwilliams/json-fortran) and [Fork. Commit. Pull request.](https://help.github.com/articles/fork-a-repo)
296+
Want to help? Take a quick look at our [contributing guidelines](https://github.com/jacobwilliams/json-fortran/blob/master/CONTRIBUTING.md) then claim something in [the "ready" column on our Waffle.io](https://waffle.io/jacobwilliams/json-fortran) and [Fork. Commit. Pull request.](https://help.github.com/articles/fork-a-repo)
297+
298+
[top](#json-fortran)
285299

286-
[top](#json-fortran-)
287300
License
288301
--------
289302
The json-fortran source code and related files and documentation are distributed under a permissive free software license (BSD-style). See the [LICENSE](https://raw.githubusercontent.com/jacobwilliams/json-fortran/master/LICENSE) file for more details.
290303

291-
[top](#json-fortran-)
304+
[top](#json-fortran)
305+
292306
Miscellaneous
293307
---------------
294308

@@ -298,4 +312,4 @@ Miscellaneous
298312
* [json-fortran on Waffle.IO](https://waffle.io/jacobwilliams/json-fortran)
299313
* [json-fortran on Codecov.IO](https://codecov.io/github/jacobwilliams/json-fortran?branch=master)
300314

301-
[top](#json-fortran-)
315+
[top](#json-fortran)

build.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ fi
237237
if [[ $CODE_COVERAGE == [yY]* ]]; then
238238
echo "Trying to compile with code coverage instrumentation."
239239
COVERAGE="-coverage"
240-
FCOMPILERFLAGS+=' -O0'
241240
fi
242241

243242
if [[ $CODE_PROFILE == [yY]* ]]; then
@@ -262,9 +261,6 @@ fi
262261
echo ""
263262
echo "Building library..."
264263

265-
# work around for FoBiS.py PR #45
266-
[ -d "$LIBDIR" ] || mkdir "$LIBDIR"
267-
268264
FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags "${FCOMPILERFLAGS} ${DEFINES}" ${COVERAGE} ${PROFILING} -dbld ${LIBDIR} -s ${SRCDIR} -dmod ./ -dobj ./ -t ${MODCODE} -o ${LIBOUT} -mklib static -colors
269265

270266
#build the unit tests (uses the above library):

src/json_module.F90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,8 @@ end subroutine array_callback_func
11191119
!6 = sign + leading 0 + decimal + 'E' + exponent sign + 1 extra
11201120
integer(IK),parameter :: max_numeric_str_len = real_precision + real_exponent_digits + 6
11211121
! real format set by library initialization
1122-
character(kind=CDK,len=*),parameter :: int_fmt = '(I0)' !minimum width format for integers
1123-
character(kind=CK, len=*),parameter :: star = '*' !for invalid numbers
1122+
character(kind=CDK,len=*),parameter :: int_fmt = '(ss,I0)' !minimum width format for integers
1123+
character(kind=CK, len=*),parameter :: star = '*' !for invalid numbers
11241124

11251125
!real string printing:
11261126
character(kind=CDK,len=:),allocatable :: real_fmt !the format string to use for real numbers
@@ -2153,13 +2153,13 @@ subroutine json_initialize(verbose,compact_reals)
21532153
! set the default output/input format for reals:
21542154
! [this only needs to be done once, since it can't change]
21552155
if (.not. allocated(real_fmt)) then
2156-
write(w,'(I0)',iostat=istat) max_numeric_str_len
2157-
if (istat==0) write(d,'(I0)',iostat=istat) real_precision
2158-
if (istat==0) write(e,'(I0)',iostat=istat) real_exponent_digits
2156+
write(w,'(ss,I0)',iostat=istat) max_numeric_str_len
2157+
if (istat==0) write(d,'(ss,I0)',iostat=istat) real_precision
2158+
if (istat==0) write(e,'(ss,I0)',iostat=istat) real_exponent_digits
21592159
if (istat==0) then
2160-
real_fmt = '(E' // trim(w) // '.' // trim(d) // 'E' // trim(e) // ')'
2160+
real_fmt = '(ss,E' // trim(w) // '.' // trim(d) // 'E' // trim(e) // ')'
21612161
else
2162-
real_fmt = '(E30.16E3)' !just use this one (should never happen)
2162+
real_fmt = '(ss,E30.16E3)' !just use this one (should never happen)
21632163
end if
21642164
end if
21652165

@@ -8042,7 +8042,7 @@ subroutine compact_real_string(str)
80428042
decimal_pos = scan(str,CK_'.')
80438043
if (exp_start /= 0) separator = str(exp_start:exp_start)
80448044

8045-
if (exp_start > 0 .and. exp_start < decimal_pos) then !signed, exponent-less float
8045+
if ( exp_start < decimal_pos ) then !possibly signed, exponent-less float
80468046

80478047
significand = str
80488048
sig_trim = len(trim(significand))

0 commit comments

Comments
 (0)