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 4267f83..0c85ee3 100755 --- a/create_f77_zmq_h_py2.py +++ b/create_f77_zmq_h_py2.py @@ -43,15 +43,19 @@ def create_dict_of_defines(lines,file_out): if line.startswith("#define"): buffer = line.split() key = buffer[1] - value = " ".join(buffer[2:]) - if key[0] == '_' or '(' in key or ',' in value: + try: + value = int(eval(" ".join(buffer[2:]).strip())) + except: continue - command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals() + 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) @@ -63,7 +67,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): @@ -126,6 +134,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 fdd7e18..51ee7e5 100755 --- a/create_f77_zmq_h_py3.py +++ b/create_f77_zmq_h_py3.py @@ -43,11 +43,14 @@ def create_dict_of_defines(lines,file_out): if line.startswith("#define"): buffer = line.split() key = buffer[1] - value = " ".join(buffer[2:]) - if key[0] == '_' or '(' in key or ',' in value: + try: + value = int(eval(" ".join(buffer[2:]).strip())) + except: + continue + 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()) @@ -64,7 +67,11 @@ 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): @@ -127,6 +134,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/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..3fafd08 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}:./ @@ -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}" @@ -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