From bf29f0a640f3bf669185482f6b7462a4c5f093d4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 8 Jun 2017 21:29:25 +0200 Subject: [PATCH 1/7] [master] Removed eventual C comment in command in create_dict_of_defines (#2) --- create_f77_zmq_h_py2.py | 13 +++++++------ create_f77_zmq_h_py3.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/create_f77_zmq_h_py2.py b/create_f77_zmq_h_py2.py index c3c2742..4267f83 100755 --- a/create_f77_zmq_h_py2.py +++ b/create_f77_zmq_h_py2.py @@ -1,8 +1,8 @@ #!/usr/bin/env python2 # # f77_zmq : Fortran 77 bindings for the ZeroMQ library -# Copyright (C) 2014 Anthony Scemama -# +# Copyright (C) 2014 Anthony Scemama +# # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,7 @@ # 31062 Toulouse Cedex 09, France - +import re import sys import ctypes @@ -47,6 +47,7 @@ def create_dict_of_defines(lines,file_out): if key[0] == '_' or '(' in key or ',' in value: continue command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() + command = re.sub("/\*.*?\*/", "", command) exec command in locals() # Add the version number: @@ -70,9 +71,9 @@ def create_prototypes(lines,file_out): typ_conv = { 'long' : 'integer*8' , 'int' : 'integer' , - 'float' : 'real', - 'char*' : 'character*(64)', - 'double' : 'double precision', + 'float' : 'real', + 'char*' : 'character*(64)', + 'double' : 'double precision', 'void*' : 'integer*%d'%(ctypes.sizeof(ctypes.c_voidp)), 'void' : None } diff --git a/create_f77_zmq_h_py3.py b/create_f77_zmq_h_py3.py index 65b6f6d..fdd7e18 100755 --- a/create_f77_zmq_h_py3.py +++ b/create_f77_zmq_h_py3.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 # # f77_zmq : Fortran 77 bindings for the ZeroMQ library -# Copyright (C) 2014 Anthony Scemama -# +# Copyright (C) 2014 Anthony Scemama +# # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,7 @@ # 31062 Toulouse Cedex 09, France - +import re import sys import ctypes @@ -48,6 +48,7 @@ def create_dict_of_defines(lines,file_out): continue d[key] = value command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() + command = re.sub("/\*.*?\*/", "", command) exec(command, locals()) # Add the version number: @@ -71,9 +72,9 @@ def create_prototypes(lines,file_out): typ_conv = { 'long' : 'integer*8' , 'int' : 'integer' , - 'float' : 'real', - 'char*' : 'character*(64)', - 'double' : 'double precision', + 'float' : 'real', + 'char*' : 'character*(64)', + 'double' : 'double precision', 'void*' : 'integer*%d'%(ctypes.sizeof(ctypes.c_voidp)), 'void' : None } From 3932ff9a4e76515afc32b0629b6f65949e4a6dab Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 27 Apr 2018 15:44:43 +0200 Subject: [PATCH 2/7] Minor changes for 4.2 --- create_f77_zmq_h_py2.py | 4 +++- create_f77_zmq_h_py3.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/create_f77_zmq_h_py2.py b/create_f77_zmq_h_py2.py index 4267f83..7bedaa0 100755 --- a/create_f77_zmq_h_py2.py +++ b/create_f77_zmq_h_py2.py @@ -43,7 +43,9 @@ def create_dict_of_defines(lines,file_out): if line.startswith("#define"): buffer = line.split() key = buffer[1] - value = " ".join(buffer[2:]) + value = " ".join(buffer[2:]).strip() + if value == "" or value.startswith("_"): + continue if key[0] == '_' or '(' in key or ',' in value: continue command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() diff --git a/create_f77_zmq_h_py3.py b/create_f77_zmq_h_py3.py index fdd7e18..ddfc784 100755 --- a/create_f77_zmq_h_py3.py +++ b/create_f77_zmq_h_py3.py @@ -43,7 +43,9 @@ def create_dict_of_defines(lines,file_out): if line.startswith("#define"): buffer = line.split() key = buffer[1] - value = " ".join(buffer[2:]) + value = " ".join(buffer[2:]).strip() + if value == "" or value.startswith("_"): + continue if key[0] == '_' or '(' in key or ',' in value: continue d[key] = value From 1e4223d5ce42d3c718c27a39729e8ee98756c7ea Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 27 Apr 2018 16:21:31 +0200 Subject: [PATCH 3/7] Fixed fixed/free format issue --- README.md | 3 +++ create_f77_zmq_h_py2.py | 22 ++++++++++++++++++---- create_f77_zmq_h_py3.py | 18 ++++++++++++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a5fb9ff..02261ae 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ $ export ZMQ_H=/usr/include/zmq.h $ make ``` +Two files will be created, one in free-format (``f77_zmq_free.h``), and one +in fixed-format (``f77_zmq.h``). + ## Differences with the C API In Fortran77 structs don't exist. They have been introduced with Fortran90. diff --git a/create_f77_zmq_h_py2.py b/create_f77_zmq_h_py2.py index 7bedaa0..53e509d 100755 --- a/create_f77_zmq_h_py2.py +++ b/create_f77_zmq_h_py2.py @@ -43,12 +43,15 @@ def create_dict_of_defines(lines,file_out): if line.startswith("#define"): buffer = line.split() key = buffer[1] - value = " ".join(buffer[2:]).strip() + try: + value = int(eval(" ".join(buffer[2:]).strip())) + except: + continue if value == "" or value.startswith("_"): continue - if key[0] == '_' or '(' in key or ',' in value: + if key[0] == '_' or '(' in key: continue - command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() + command = "%(key)s=%(value)d\nd['%(key)s']=%(key)s"%locals() command = re.sub("/\*.*?\*/", "", command) exec command in locals() @@ -65,7 +68,11 @@ def create_dict_of_defines(lines,file_out): for k in keys: print >>file_out, " integer %s"%(k) for k in keys: - print >>file_out, " parameter ( %-20s = %s )"%(k, d[k]) + buffer = " parameter(%s=%s)"%(k, d[k]) + if len(buffer > 72): + buffer = " parameter(\n & %s=%s)"%(k, d[k]) + print >>file_out, buffer + return None def create_prototypes(lines,file_out): @@ -128,6 +135,13 @@ def main(): file_out.close() + file_in = open('f77_zmq.h','r') + file_out = open('f77_zmq_free.h','w') + file_out.write(file_in.read().replace('\n &',' &\n ')) + file_in.close() + file_out.close() + + if __name__ == '__main__': main() diff --git a/create_f77_zmq_h_py3.py b/create_f77_zmq_h_py3.py index ddfc784..28ae272 100755 --- a/create_f77_zmq_h_py3.py +++ b/create_f77_zmq_h_py3.py @@ -43,10 +43,11 @@ def create_dict_of_defines(lines,file_out): if line.startswith("#define"): buffer = line.split() key = buffer[1] - value = " ".join(buffer[2:]).strip() - if value == "" or value.startswith("_"): + try: + value = int(eval(" ".join(buffer[2:]).strip())) + except: continue - if key[0] == '_' or '(' in key or ',' in value: + if key[0] == '_' or '(' in key: continue d[key] = value command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() @@ -66,7 +67,10 @@ def create_dict_of_defines(lines,file_out): for k in keys: print(" integer %s"%(k), file=file_out) for k in keys: - print(" parameter ( %-20s = %s )"%(k, d[k]), file=file_out) + buffer = " parameter(%s=%s)"%(k, d[k]) + if len(buffer) > 72: + buffer = " parameter(\n & %s=%s)"%(k, d[k]) + print(buffer, file=file_out) return None def create_prototypes(lines,file_out): @@ -129,6 +133,12 @@ def main(): file_out.close() + file_in = open('f77_zmq.h','r') + file_out = open('f77_zmq_free.h','w') + file_out.write(file_in.read().replace('\n &',' &\n ')) + file_in.close() + file_out.close() + if __name__ == '__main__': main() From 746a9f28c07f8f895f41bd2b76a8487b9ad1dcad Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 27 Apr 2018 16:25:53 +0200 Subject: [PATCH 4/7] Updated travis --- examples/wuclient.f | 2 +- travis_ci/install_zmq.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/wuclient.f b/examples/wuclient.f index 7317065..d6599c3 100644 --- a/examples/wuclient.f +++ b/examples/wuclient.f @@ -39,7 +39,7 @@ program wuclient total_temp = total_temp + temperature enddo print *, 'Average temperature for zipcode "'//trim(filter)// - & '" was ', int(total_temp/100.), "F" + & '" was ', int(real(total_temp)/100.), "F" rc = f77_zmq_close(subscriber) rc = f77_zmq_ctx_destroy(context) diff --git a/travis_ci/install_zmq.sh b/travis_ci/install_zmq.sh index 0ffff26..a9ade05 100755 --- a/travis_ci/install_zmq.sh +++ b/travis_ci/install_zmq.sh @@ -3,7 +3,7 @@ # Tests the build distribution -VERSION=4.1.4 +VERSION=4.2.5 ZMQ_TGZ="zeromq-${VERSION}.tar.gz" export C_INCLUDE_PATH=${C_INCLUDE_PATH}:./ From 812828bf51067a13f5ade8d7e520bd5abc8dec26 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 27 Apr 2018 16:29:50 +0200 Subject: [PATCH 5/7] Updated travis --- travis_ci/install_zmq.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis_ci/install_zmq.sh b/travis_ci/install_zmq.sh index a9ade05..854bd79 100755 --- a/travis_ci/install_zmq.sh +++ b/travis_ci/install_zmq.sh @@ -13,7 +13,7 @@ export C_INCLUDE_PATH=${C_INCLUDE_PATH}:./ if [[ ! -f ${ZMQ_TGZ} ]] then - wget --no-check-certificate "http://download.zeromq.org/zeromq-${VERSION}.tar.gz" + wget --no-check-certificate "https://github.com/zeromq/libzmq/releases/download/v${VERSION}/${ZMQ_TGZ}" if [[ $? -ne 0 ]] then echo "Unable to download ${ZMQ_TGZ}" From 556f435a98421e27cab55f77814ee0fc8e32e0c6 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 27 Apr 2018 16:37:16 +0200 Subject: [PATCH 6/7] Fixed travis --- create_f77_zmq_h_py2.py | 7 +++---- create_f77_zmq_h_py3.py | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/create_f77_zmq_h_py2.py b/create_f77_zmq_h_py2.py index 53e509d..0c85ee3 100755 --- a/create_f77_zmq_h_py2.py +++ b/create_f77_zmq_h_py2.py @@ -47,16 +47,15 @@ def create_dict_of_defines(lines,file_out): value = int(eval(" ".join(buffer[2:]).strip())) except: continue - if value == "" or value.startswith("_"): - continue if key[0] == '_' or '(' in key: continue + d[key] = value command = "%(key)s=%(value)d\nd['%(key)s']=%(key)s"%locals() command = re.sub("/\*.*?\*/", "", command) exec command in locals() # Add the version number: - d['ZMQ_VERSION'] = ZMQ_VERSION_MAJOR*10000 + ZMQ_VERSION_MINOR*100 + ZMQ_VERSION_PATCH + d['ZMQ_VERSION'] = int(d['ZMQ_VERSION_MAJOR'])*10000 + int(d['ZMQ_VERSION_MINOR'])*100 + int(d['ZMQ_VERSION_PATCH']) d['ZMQ_PTR'] = ctypes.sizeof(ctypes.c_voidp) print "===========================================" print "ZMQ_PTR set to %d (for %d-bit architectures)"%(d['ZMQ_PTR'],d['ZMQ_PTR']*8) @@ -69,7 +68,7 @@ def create_dict_of_defines(lines,file_out): print >>file_out, " integer %s"%(k) for k in keys: buffer = " parameter(%s=%s)"%(k, d[k]) - if len(buffer > 72): + if len(buffer) > 72: buffer = " parameter(\n & %s=%s)"%(k, d[k]) print >>file_out, buffer diff --git a/create_f77_zmq_h_py3.py b/create_f77_zmq_h_py3.py index 28ae272..51ee7e5 100755 --- a/create_f77_zmq_h_py3.py +++ b/create_f77_zmq_h_py3.py @@ -50,7 +50,7 @@ def create_dict_of_defines(lines,file_out): if key[0] == '_' or '(' in key: continue d[key] = value - command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() + command = "%(key)s=%(value)d\nd['%(key)s']=%(key)s"%locals() command = re.sub("/\*.*?\*/", "", command) exec(command, locals()) @@ -71,6 +71,7 @@ def create_dict_of_defines(lines,file_out): if len(buffer) > 72: buffer = " parameter(\n & %s=%s)"%(k, d[k]) print(buffer, file=file_out) + return None def create_prototypes(lines,file_out): @@ -140,5 +141,6 @@ def main(): file_out.close() + if __name__ == '__main__': main() From 4008684d6c87cbc707cc4a48bc38d3b47f9e471a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 27 Apr 2018 16:42:55 +0200 Subject: [PATCH 7/7] Travis --- travis_ci/install_zmq.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis_ci/install_zmq.sh b/travis_ci/install_zmq.sh index 854bd79..3fafd08 100755 --- a/travis_ci/install_zmq.sh +++ b/travis_ci/install_zmq.sh @@ -30,8 +30,8 @@ tar -zxf ${ZMQ_TGZ} pushd ${ZMQ_TGZ%.tar.gz} ./configure --without-libsodium || exit 1 make -j 8 || exit 1 -cp .libs/libzmq.a ../lib -cp .libs/libzmq.so ../lib/libzmq.so.5 +cp src/.libs/libzmq.a ../lib +cp src/.libs/libzmq.so ../lib/libzmq.so.5 cp include/{zmq.h,zmq_utils.h} ../lib popd pushd lib