Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from MeteoSwiss-APN/master
Browse files Browse the repository at this point in the history
Merging the changes of the last few weeks for release `0.1`.
  • Loading branch information
andyspiros committed Jan 26, 2016
2 parents 21d1a32 + ae4978c commit 79411f5
Show file tree
Hide file tree
Showing 36 changed files with 620 additions and 245 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install/" CACHE PATH "installation
project( SerialBox )
enable_language (Fortran)
find_package( Boost )
include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )

set(ENABLE_DOC "OFF" CACHE BOOL "enable building doc" )
if(ENABLE_DOC)
Expand Down Expand Up @@ -45,13 +44,6 @@ if( CMAKE_HOST_UNIX )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINK_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
endif()

# Single precision
set( SINGLEPRECISION "OFF" CACHE BOOL "Single precision" )
if( SINGLEPRECISION )
add_definitions( -DSINGLEPRECISION )
endif( SINGLEPRECISION )


# OSX specific configuration
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

Expand All @@ -64,13 +56,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH "${CMAKE_INSTALL_RPATH}")
endif ()

# Serialization
include_directories( SYSTEM libs/libjson )
include_directories( libs/sha256 )
include_directories( libs/gmock-gtest)
include_directories( src)


# Python installation path
set (PYTHON_PATH "python")

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Release 0.1

* Seamlessly support single precision and double precision floating point values
* Fix issue with files larger than 2 GiB
* Support variable declaration in multiple lines in pp_ser
* Correctly install utils_ppser fortran module
* Python can access global metainformation of serializers, register fields
with nontrivial halo and use handle single precision numpy fields
5 changes: 3 additions & 2 deletions fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp ")
set(
SOURCES
"m_serialize.f90"
"utils_ppser.f90"
)

add_library(fortranser_files OBJECT ${SOURCES})

add_library(
FortranSer STATIC ${SOURCES}
)
Expand Down
6 changes: 3 additions & 3 deletions libs/libjson/_internal/Source/JSONNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class JSONNode {


json_string as_string(void) const json_nothrow json_read_priority;
int as_int(void) const json_nothrow json_read_priority;
json_int_t as_int(void) const json_nothrow json_read_priority;
json_number as_float(void) const json_nothrow json_read_priority;
bool as_bool(void) const json_nothrow json_read_priority;

Expand Down Expand Up @@ -666,9 +666,9 @@ inline void JSONNode::set_name(const json_string & newname) json_nothrow{
return static_cast<json_string>(*internal);
}

inline int JSONNode::as_int(void) const json_nothrow {
inline json_int_t JSONNode::as_int(void) const json_nothrow {
JSON_CHECK_INTERNAL();
return static_cast<int>(*internal);
return static_cast<json_int_t>(*internal);
}

inline json_number JSONNode::as_float(void) const json_nothrow {
Expand Down
8 changes: 3 additions & 5 deletions libs/libjson/_internal/Source/internalJSONNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class internalJSONNode {
DECL_CAST_OP(short)
DECL_CAST_OP(int)
DECL_CAST_OP(long)
DECL_CAST_OP(long long)
#ifndef JSON_ISO_STRICT
DECL_CAST_OP(long long)
operator long double() const json_nothrow;
#endif
operator float() const json_nothrow;
Expand Down Expand Up @@ -466,11 +466,9 @@ inline JSONNode * internalJSONNode::at(json_index_t pos) json_nothrow {
IMP_SMALLER_INT_CAST_OP(unsigned short, USHRT_MAX, 0)
IMP_SMALLER_INT_CAST_OP(int, INT_MAX, INT_MIN)
IMP_SMALLER_INT_CAST_OP(unsigned int, UINT_MAX, 0)
IMP_SMALLER_INT_CAST_OP(long long, LLONG_MAX, LLONG_MIN)
IMP_SMALLER_INT_CAST_OP(unsigned long long, ULLONG_MAX, 0)

#ifndef JSON_ISO_STRICT
IMP_SMALLER_INT_CAST_OP(long, LONG_MAX, LONG_MIN)
IMP_SMALLER_INT_CAST_OP(unsigned long, ULONG_MAX, 0)
#endif
#endif

inline internalJSONNode::operator json_string() const json_nothrow {
Expand Down
53 changes: 53 additions & 0 deletions libs/libjson/longint.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/libs/libjson/_internal/Source/JSONNode.h b/libs/libjson/_internal/Source/JSONNode.h
index 7812753..4ced605 100644
--- a/libs/libjson/_internal/Source/JSONNode.h
+++ b/libs/libjson/_internal/Source/JSONNode.h
@@ -161,7 +161,7 @@ public:


json_string as_string(void) const json_nothrow json_read_priority;
- int as_int(void) const json_nothrow json_read_priority;
+ json_int_t as_int(void) const json_nothrow json_read_priority;
json_number as_float(void) const json_nothrow json_read_priority;
bool as_bool(void) const json_nothrow json_read_priority;

@@ -666,9 +666,9 @@ inline void JSONNode::set_name(const json_string & newname) json_nothrow{
return static_cast<json_string>(*internal);
}

- inline int JSONNode::as_int(void) const json_nothrow {
+ inline json_int_t JSONNode::as_int(void) const json_nothrow {
JSON_CHECK_INTERNAL();
- return static_cast<int>(*internal);
+ return static_cast<json_int_t>(*internal);
}

inline json_number JSONNode::as_float(void) const json_nothrow {
diff --git a/libs/libjson/_internal/Source/internalJSONNode.h b/libs/libjson/_internal/Source/internalJSONNode.h
index 2dd3a1e..8372a13 100644
--- a/libs/libjson/_internal/Source/internalJSONNode.h
+++ b/libs/libjson/_internal/Source/internalJSONNode.h
@@ -156,8 +156,8 @@ public:
DECL_CAST_OP(short)
DECL_CAST_OP(int)
DECL_CAST_OP(long)
+ DECL_CAST_OP(long long)
#ifndef JSON_ISO_STRICT
- DECL_CAST_OP(long long)
operator long double() const json_nothrow;
#endif
operator float() const json_nothrow;
@@ -466,11 +466,9 @@ inline JSONNode * internalJSONNode::at(json_index_t pos) json_nothrow {
IMP_SMALLER_INT_CAST_OP(unsigned short, USHRT_MAX, 0)
IMP_SMALLER_INT_CAST_OP(int, INT_MAX, INT_MIN)
IMP_SMALLER_INT_CAST_OP(unsigned int, UINT_MAX, 0)
+ IMP_SMALLER_INT_CAST_OP(long long, LLONG_MAX, LLONG_MIN)
+ IMP_SMALLER_INT_CAST_OP(unsigned long long, ULLONG_MAX, 0)

- #ifndef JSON_ISO_STRICT
- IMP_SMALLER_INT_CAST_OP(long, LONG_MAX, LONG_MIN)
- IMP_SMALLER_INT_CAST_OP(unsigned long, ULONG_MAX, 0)
- #endif
#endif

inline internalJSONNode::operator json_string() const json_nothrow {
58 changes: 44 additions & 14 deletions python/pp_ser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#See LICENSE.txt for more information

from __future__ import print_function
import linecache


"""
pp_ser.py
Expand Down Expand Up @@ -438,6 +440,7 @@ def __ser_data(self, args, isacc = False):
self.__calls.add(self.methods['dataread'])
self.__calls.add(self.methods['getmode'])
l = ''
l = '! file: ' + self.infile + ' lineno: #' + str(self.__linenum) + '\n'
tab = ''
if if_statement:
l += 'IF (' + if_statement + ') THEN\n'
Expand Down Expand Up @@ -643,25 +646,52 @@ def __re_endmodule(self):
self.__module = ''
return m

def __check_intent_in(self, line):
lhs = re.sub(r'!.*', '', line) # Remove comments at end of the line
var_with_dim = [x.strip().replace(' ', '') for x in re.split(r',(?![^(]*\))', lhs)]
var = [re.sub(r'\(.*?\)', '', x) for x in var_with_dim]
fields_in_this_line = [x for x in self.intentin_to_remove if x in var]
self.intentin_removed.extend([x for x in fields_in_this_line if x not in self.intentin_removed])

if fields_in_this_line:
l = '#ifdef ' + self.ifdef + '\n'
r = re.compile(r', *intent *\(in\)', re.IGNORECASE)
l += r.sub('', self.__line)
l += '#else\n' + self.__line + '#endif\n'
self.__line = l
return fields_in_this_line


def __re_def(self):
r = re.compile(r'.*intent *\(in\)[^:]*::\s*([^!]*)\s*.*', re.IGNORECASE)
r_cont = re.compile(r'.*intent *\(in\)[^:]*::\s*([^!]*)\s*.*&', re.IGNORECASE)

# Line contains intent with continuation
m_cont = r_cont.search(self.__line)
m = r.search(self.__line)
if m:
if m_cont:
splitted = self.__line.split('::')
splitted[1] = re.sub(r'!.*', '', splitted[1]) # Remove comments at end of the line
if not self.__check_intent_in(splitted[1]):
# look ahead to find the variable
lookahead_index = self.__linenum
# set to line after the intent declaration
lookahead_index += 1
# look ahead
nextline = linecache.getline(os.path.join(self.infile), lookahead_index)
while nextline:
self.__check_intent_in(nextline)
if(nextline.find('&')!=-1):
lookahead_index += 1
nextline = linecache.getline(os.path.join(self.infile), lookahead_index)
else:
nextline = None

# Match a standard declaration with variable and intent on the same line
elif m:
splitted = self.__line.split('::')
splitted[1] = re.sub(r'!.*', '', splitted[1]) # Remove comments at end of the line
var_with_dim = [x.strip().replace(' ', '') for x in re.split(r',(?![^(]*\))', splitted[1])]
var = [re.sub(r'\(.*?\)', '', x) for x in var_with_dim]
fields_in_this_line = [x for x in self.intentin_to_remove if x in var]
self.intentin_removed.extend([x for x in fields_in_this_line if x not in self.intentin_removed])

if fields_in_this_line:
l = '#ifdef ' + self.ifdef + '\n'
r = re.compile(r', *intent *\(in\)', re.IGNORECASE)
l += r.sub('', self.__line)
l += '#else\n' + self.__line + '#endif\n'

self.__line = l
return fields_in_this_line
self.__check_intent_in(splitted[1])
return m

# evaluate one line
Expand Down
Loading

0 comments on commit 79411f5

Please sign in to comment.