Skip to content

Commit

Permalink
Merge pull request #18 from scemama/master
Browse files Browse the repository at this point in the history
Changes for 4.2
  • Loading branch information
scemama authored Jul 27, 2018
2 parents f78c4e4 + 4008684 commit 75eecda
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 20 additions & 5 deletions create_f77_zmq_h_py2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down Expand Up @@ -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()
22 changes: 18 additions & 4 deletions create_f77_zmq_h_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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):
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion examples/wuclient.f
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions travis_ci/install_zmq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}:./
Expand All @@ -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}"
Expand All @@ -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
Expand Down

0 comments on commit 75eecda

Please sign in to comment.