Skip to content

Commit 4907f50

Browse files
committed
Merge branch 'master' of https://github.com/jacobwilliams/json-fortran into get_alloc_string
2 parents 901a11a + ff13e47 commit 4907f50

File tree

5 files changed

+108
-64
lines changed

5 files changed

+108
-64
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: python
22

33
python:
4-
- 2.7
4+
- 3.5
55

66
sudo: false
77

@@ -57,6 +57,7 @@ install:
5757
- ln -fs /usr/bin/gfortran-4.9 "$HOME/.local/bin/gfortran" && gfortran --version
5858
- ls -l /usr/bin/gfortran-4.9
5959
- ln -fs /usr/bin/gcov-4.9 "$HOME/.local/bin/gcov" && gcov --version
60+
- perl --version
6061
- |
6162
if ! which f90split; then
6263
wget http://people.sc.fsu.edu/~jburkardt/f_src/f90split/f90split.f90 && \

build.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
# Jacob Williams : 12/27/2014
6969
#
7070

71+
#set -x
72+
#set -v
7173
set -o errexit
7274

7375
FORDMD='json-fortran.md' # FORD options file for building documentation
@@ -314,13 +316,19 @@ if [[ $JF_SKIP_TESTS != [yY]* ]] ; then
314316
# run next commands in subshell to avoid `cd -`
315317
(cd "$BINDIR"
316318
GLOBIGNORE='*.*'
317-
#
318-
for TEST in jf_test_*; do
319+
# from: http://stackoverflow.com/questions/7992689/bash-how-to-loop-all-files-in-sorted-order
320+
ls jf_test_* | sed 's/^\([^0-9]*\)\([0-9]*\)/\1 \2/' | sort -k2,2n | tr -d ' ' |
321+
while read TEST; do
319322
# It would be nice to run json output printed to stdout through jsonlint, however,
320323
# some tests output more than one json structure and these need to be split
324+
echo ""
325+
echo "======================================================"
326+
echo ""
321327
echo "Running ${TEST}"
322328
"./${TEST}"
323329
done)
330+
echo ""
331+
echo "======================================================"
324332
GLOBIGNORE="$OLD_IGNORES"
325333
if [[ $CODE_COVERAGE = [yY]* ]] ; then
326334
for SRCFILE in json_string_utilities.F90 json_value_module.F90 json_file_module.F90 ; do
@@ -337,6 +345,23 @@ if [[ $JF_SKIP_TESTS != [yY]* ]] ; then
337345
mv ${SRCFILE}.gcov ${SRCFILE}-no-unicode.gcov
338346
fi
339347
if [ -f ${SRCFILE}-unicode.gcov ] && [ -f ${SRCFILE}-no-unicode.gcov ]; then
348+
349+
############## for debugging
350+
#echo ""
351+
#echo "-------------------"
352+
#echo "no-unicode file"
353+
#echo "-------------------"
354+
#cat ${SRCFILE}-no-unicode.gcov
355+
#echo ""
356+
#echo "-------------------"
357+
#echo "unicode file"
358+
#echo "-------------------"
359+
#cat ${SRCFILE}-unicode.gcov
360+
#echo ""
361+
#./pages/development-resources/gccr.pl -n -c ${SRCFILE}-no-unicode.gcov no-unicode \
362+
# ${SRCFILE}-unicode.gcov unicode
363+
##############
364+
340365
# merge them
341366
./pages/development-resources/gccr.pl -n -c ${SRCFILE}-no-unicode.gcov no-unicode \
342367
${SRCFILE}-unicode.gcov unicode > ${SRCFILE}.gcov

pages/development-resources/gccr.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ ($$)
248248
if($save_raw) {
249249
$data{'line'}[$file_line_num]{'raw'} = $raw;
250250
}
251-
}elsif($line =~ /^\s+(\d+):\s*(\d+):(.*)/) {
251+
}elsif($line =~ /^\s*(\d+):\s*(\d+):(.*)/) {
252252

253253
# line was executed
254254

src/json_string_utilities.F90

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module json_string_utilities
6262
public :: integer_to_string
6363
public :: real_to_string
6464
public :: string_to_integer
65+
public :: string_to_real
6566
public :: valid_json_hex
6667
public :: to_unicode
6768
public :: escape_string
@@ -176,6 +177,35 @@ subroutine real_to_string(rval,real_fmt,compact_real,str)
176177
end subroutine real_to_string
177178
!*****************************************************************************************
178179

180+
!*****************************************************************************************
181+
!> author: Jacob Williams
182+
! date: 1/19/2014
183+
!
184+
! Convert a string into a `real(RK)`.
185+
!
186+
!# History
187+
! * Jacob Williams, 10/27/2015 : Now using `fmt=*`, rather than
188+
! `fmt=real_fmt`, since it doesn't work for some unusual cases
189+
! (e.g., when `str='1E-5'`).
190+
! * Jacob Williams : 2/6/2017 : moved core logic to this routine.
191+
192+
subroutine string_to_real(str,rval,status_ok)
193+
194+
implicit none
195+
196+
character(kind=CK,len=*),intent(in) :: str
197+
real(RK),intent(out) :: rval
198+
logical(LK),intent(out) :: status_ok !! true if there were no errors
199+
200+
integer(IK) :: ierr !! read iostat error code
201+
202+
read(str,fmt=*,iostat=ierr) rval
203+
status_ok = (ierr==0)
204+
if (.not. status_ok) rval = 0.0_RK
205+
206+
end subroutine string_to_real
207+
!*****************************************************************************************
208+
179209
!*****************************************************************************************
180210
!> author: Izaak Beekman
181211
! date: 02/24/2015
@@ -333,7 +363,7 @@ subroutine escape_string(str_in, str_out)
333363
!trim the string if necessary:
334364
if (ipos<len(str_out)+1) then
335365
if (ipos==1) then
336-
str_out = ''
366+
str_out = CK_''
337367
else
338368
#if defined __GFORTRAN__
339369
tmp = str_out(1:ipos-1) !workaround for bug in gfortran 6.1
@@ -718,7 +748,7 @@ pure elemental function lowercase_string(str) result(s_lower)
718748
integer :: i !! counter
719749
integer :: n !! length of input string
720750

721-
s_lower = ''
751+
s_lower = CK_''
722752
n = len_trim(str)
723753

724754
if (n>0) then
@@ -754,7 +784,7 @@ pure subroutine replace_string(str,s1,s2)
754784

755785
if (len(str)>0) then
756786

757-
tmp = '' ! initialize
787+
tmp = CK_'' ! initialize
758788
ilen1 = len(s1)
759789

760790
! .

0 commit comments

Comments
 (0)