Skip to content

Commit 75eecda

Browse files
authored
Merge pull request #18 from scemama/master
Changes for 4.2
2 parents f78c4e4 + 4008684 commit 75eecda

File tree

5 files changed

+46
-14
lines changed

5 files changed

+46
-14
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ $ export ZMQ_H=/usr/include/zmq.h
4747
$ make
4848
```
4949

50+
Two files will be created, one in free-format (``f77_zmq_free.h``), and one
51+
in fixed-format (``f77_zmq.h``).
52+
5053
## Differences with the C API
5154

5255
In Fortran77 structs don't exist. They have been introduced with Fortran90.

create_f77_zmq_h_py2.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ def create_dict_of_defines(lines,file_out):
4343
if line.startswith("#define"):
4444
buffer = line.split()
4545
key = buffer[1]
46-
value = " ".join(buffer[2:])
47-
if key[0] == '_' or '(' in key or ',' in value:
46+
try:
47+
value = int(eval(" ".join(buffer[2:]).strip()))
48+
except:
4849
continue
49-
command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals()
50+
if key[0] == '_' or '(' in key:
51+
continue
52+
d[key] = value
53+
command = "%(key)s=%(value)d\nd['%(key)s']=%(key)s"%locals()
5054
command = re.sub("/\*.*?\*/", "", command)
5155
exec command in locals()
5256

5357
# Add the version number:
54-
d['ZMQ_VERSION'] = ZMQ_VERSION_MAJOR*10000 + ZMQ_VERSION_MINOR*100 + ZMQ_VERSION_PATCH
58+
d['ZMQ_VERSION'] = int(d['ZMQ_VERSION_MAJOR'])*10000 + int(d['ZMQ_VERSION_MINOR'])*100 + int(d['ZMQ_VERSION_PATCH'])
5559
d['ZMQ_PTR'] = ctypes.sizeof(ctypes.c_voidp)
5660
print "==========================================="
5761
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):
6367
for k in keys:
6468
print >>file_out, " integer %s"%(k)
6569
for k in keys:
66-
print >>file_out, " parameter ( %-20s = %s )"%(k, d[k])
70+
buffer = " parameter(%s=%s)"%(k, d[k])
71+
if len(buffer) > 72:
72+
buffer = " parameter(\n & %s=%s)"%(k, d[k])
73+
print >>file_out, buffer
74+
6775
return None
6876

6977
def create_prototypes(lines,file_out):
@@ -126,6 +134,13 @@ def main():
126134

127135
file_out.close()
128136

137+
file_in = open('f77_zmq.h','r')
138+
file_out = open('f77_zmq_free.h','w')
139+
file_out.write(file_in.read().replace('\n &',' &\n '))
140+
file_in.close()
141+
file_out.close()
142+
143+
129144

130145
if __name__ == '__main__':
131146
main()

create_f77_zmq_h_py3.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ def create_dict_of_defines(lines,file_out):
4343
if line.startswith("#define"):
4444
buffer = line.split()
4545
key = buffer[1]
46-
value = " ".join(buffer[2:])
47-
if key[0] == '_' or '(' in key or ',' in value:
46+
try:
47+
value = int(eval(" ".join(buffer[2:]).strip()))
48+
except:
49+
continue
50+
if key[0] == '_' or '(' in key:
4851
continue
4952
d[key] = value
50-
command = "%(key)s=%(value)s\nd['%(key)s']=%(key)s"%locals()
53+
command = "%(key)s=%(value)d\nd['%(key)s']=%(key)s"%locals()
5154
command = re.sub("/\*.*?\*/", "", command)
5255
exec(command, locals())
5356

@@ -64,7 +67,11 @@ def create_dict_of_defines(lines,file_out):
6467
for k in keys:
6568
print(" integer %s"%(k), file=file_out)
6669
for k in keys:
67-
print(" parameter ( %-20s = %s )"%(k, d[k]), file=file_out)
70+
buffer = " parameter(%s=%s)"%(k, d[k])
71+
if len(buffer) > 72:
72+
buffer = " parameter(\n & %s=%s)"%(k, d[k])
73+
print(buffer, file=file_out)
74+
6875
return None
6976

7077
def create_prototypes(lines,file_out):
@@ -127,6 +134,13 @@ def main():
127134

128135
file_out.close()
129136

137+
file_in = open('f77_zmq.h','r')
138+
file_out = open('f77_zmq_free.h','w')
139+
file_out.write(file_in.read().replace('\n &',' &\n '))
140+
file_in.close()
141+
file_out.close()
142+
143+
130144

131145
if __name__ == '__main__':
132146
main()

examples/wuclient.f

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ program wuclient
3939
total_temp = total_temp + temperature
4040
enddo
4141
print *, 'Average temperature for zipcode "'//trim(filter)//
42-
& '" was ', int(total_temp/100.), "F"
42+
& '" was ', int(real(total_temp)/100.), "F"
4343
rc = f77_zmq_close(subscriber)
4444
rc = f77_zmq_ctx_destroy(context)
4545

travis_ci/install_zmq.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Tests the build distribution
44

55

6-
VERSION=4.1.4
6+
VERSION=4.2.5
77
ZMQ_TGZ="zeromq-${VERSION}.tar.gz"
88

99
export C_INCLUDE_PATH=${C_INCLUDE_PATH}:./
@@ -13,7 +13,7 @@ export C_INCLUDE_PATH=${C_INCLUDE_PATH}:./
1313

1414
if [[ ! -f ${ZMQ_TGZ} ]]
1515
then
16-
wget --no-check-certificate "http://download.zeromq.org/zeromq-${VERSION}.tar.gz"
16+
wget --no-check-certificate "https://github.com/zeromq/libzmq/releases/download/v${VERSION}/${ZMQ_TGZ}"
1717
if [[ $? -ne 0 ]]
1818
then
1919
echo "Unable to download ${ZMQ_TGZ}"
@@ -30,8 +30,8 @@ tar -zxf ${ZMQ_TGZ}
3030
pushd ${ZMQ_TGZ%.tar.gz}
3131
./configure --without-libsodium || exit 1
3232
make -j 8 || exit 1
33-
cp .libs/libzmq.a ../lib
34-
cp .libs/libzmq.so ../lib/libzmq.so.5
33+
cp src/.libs/libzmq.a ../lib
34+
cp src/.libs/libzmq.so ../lib/libzmq.so.5
3535
cp include/{zmq.h,zmq_utils.h} ../lib
3636
popd
3737
pushd lib

0 commit comments

Comments
 (0)