1 ! (c) 2009 Joe Groff, see BSD license
2 USING: accessors alien alien.c-types alien.complex
3 alien.fortran alien.fortran.private alien.strings classes.struct
4 arrays assocs byte-arrays combinators fry
5 generalizations io.encodings.ascii kernel macros
6 macros.expander namespaces sequences shuffle tools.test ;
7 IN: alien.fortran.tests
9 << intel-unix-abi "(alien.fortran-tests)" (add-fortran-library) >>
10 LIBRARY: (alien.fortran-tests)
11 STRUCT: FORTRAN_TEST_RECORD
16 intel-unix-abi fortran-abi [
18 ! fortran-name>symbol-name
20 [ "fun_" ] [ "FUN" fortran-name>symbol-name ] unit-test
21 [ "fun_times_" ] [ "Fun_Times" fortran-name>symbol-name ] unit-test
22 [ "funtimes__" ] [ "FunTimes_" fortran-name>symbol-name ] unit-test
27 [ "integer*2" fortran-type>c-type ] unit-test
30 [ "integer*4" fortran-type>c-type ] unit-test
33 [ "INTEGER" fortran-type>c-type ] unit-test
36 [ "iNteger*8" fortran-type>c-type ] unit-test
39 [ "integer(*)" fortran-type>c-type ] unit-test
42 [ "integer(3,*)" fortran-type>c-type ] unit-test
45 [ "integer(3)" fortran-type>c-type ] unit-test
48 [ "integer(3,2)" fortran-type>c-type ] unit-test
51 [ "integer(4,3,2)" fortran-type>c-type ] unit-test
54 [ "character" fortran-type>c-type ] unit-test
57 [ "character*1" fortran-type>c-type ] unit-test
60 [ "character*17" fortran-type>c-type ] unit-test
63 [ "character(17)" fortran-type>c-type ] unit-test
66 [ "logical" fortran-type>c-type ] unit-test
69 [ "real" fortran-type>c-type ] unit-test
72 [ "double-precision" fortran-type>c-type ] unit-test
75 [ "real*4" fortran-type>c-type ] unit-test
78 [ "real*8" fortran-type>c-type ] unit-test
81 [ "complex" fortran-type>c-type ] unit-test
84 [ "double-complex" fortran-type>c-type ] unit-test
87 [ "complex*8" fortran-type>c-type ] unit-test
90 [ "complex*16" fortran-type>c-type ] unit-test
92 [ "fortran_test_record" ]
93 [ "fortran_test_record" fortran-type>c-type ] unit-test
95 ! fortran-arg-type>c-type
98 [ "integer" fortran-arg-type>c-type ] unit-test
101 [ "integer(3)" fortran-arg-type>c-type ] unit-test
104 [ "integer(*)" fortran-arg-type>c-type ] unit-test
106 [ "fortran_test_record*" { } ]
107 [ "fortran_test_record" fortran-arg-type>c-type ] unit-test
110 [ "character" fortran-arg-type>c-type ] unit-test
113 [ "character(1)" fortran-arg-type>c-type ] unit-test
115 [ "char*" { "long" } ]
116 [ "character(17)" fortran-arg-type>c-type ] unit-test
118 ! fortran-ret-type>c-type
121 [ "character(1)" fortran-ret-type>c-type ] unit-test
123 [ "void" { "char*" "long" } ]
124 [ "character(17)" fortran-ret-type>c-type ] unit-test
127 [ "integer" fortran-ret-type>c-type ] unit-test
130 [ "logical" fortran-ret-type>c-type ] unit-test
133 [ "real" fortran-ret-type>c-type ] unit-test
135 [ "void" { "float*" } ]
136 [ "real(*)" fortran-ret-type>c-type ] unit-test
139 [ "double-precision" fortran-ret-type>c-type ] unit-test
141 [ "void" { "complex-float*" } ]
142 [ "complex" fortran-ret-type>c-type ] unit-test
144 [ "void" { "complex-double*" } ]
145 [ "double-complex" fortran-ret-type>c-type ] unit-test
147 [ "void" { "int*" } ]
148 [ "integer(*)" fortran-ret-type>c-type ] unit-test
150 [ "void" { "fortran_test_record*" } ]
151 [ "fortran_test_record" fortran-ret-type>c-type ] unit-test
155 [ "float" { "int*" "char*" "float*" "double*" "long" } ]
156 [ "real" { "integer" "character*17" "real" "real*8" } fortran-sig>c-sig ]
159 [ "char" { "char*" "char*" "int*" "long" } ]
160 [ "character(1)" { "character*17" "character" "integer" } fortran-sig>c-sig ]
163 [ "void" { "char*" "long" "char*" "char*" "int*" "long" } ]
164 [ "character*18" { "character*17" "character" "integer" } fortran-sig>c-sig ]
167 [ "void" { "complex-float*" "char*" "char*" "int*" "long" } ]
168 [ "complex" { "character*17" "character" "integer" } fortran-sig>c-sig ]
174 ! [fortran-args>c-args]
177 [ ascii string>alien ]
183 [ { [ length ] [ drop ] [ drop ] [ drop ] [ drop ] } spread ]
187 "void" "funpack" "funtimes_"
188 { "char*" "longlong*" "float*" "complex-float*" "short*" "long" }
192 shuffle( aa ba ca da ea ab -- aa ab ba ca da ea )
202 f "funpack" "FUNTIMES" { "CHARACTER*12" "INTEGER*8" "!REAL" "COMPLEX" "LOGICAL*2" }
207 ! [fortran-args>c-args]
210 [ { [ drop ] } spread ]
213 [ "float" "funpack" "fun_times_" { "float*" } alien-invoke ]
216 shuffle( reta aa -- reta aa )
217 { [ ] [ drop ] } spread
219 "REAL" "funpack" "FUN_TIMES" { "REAL(*)" }
225 [ "complex-float" <c-object> ] 1 ndip
226 ! [fortran-args>c-args]
227 { [ { [ ] } spread ] [ { [ drop ] } spread ] } 1 ncleave
230 "void" "funpack" "fun_times_"
231 { "complex-float*" "float*" }
235 shuffle( reta aa -- reta aa )
236 { [ *complex-float ] [ drop ] } spread
238 "COMPLEX" "funpack" "FUN_TIMES" { "REAL(*)" }
244 [ 20 <byte-array> 20 ] 0 ndip
247 "void" "funpack" "fun_times_"
252 shuffle( reta retb -- reta retb )
253 { [ ] [ ascii alien>nstring ] } spread
255 "CHARACTER*20" "funpack" "FUN_TIMES" { }
261 [ 10 <byte-array> 10 ] 3 ndip
262 ! [fortran-args>c-args]
265 [ ascii string>alien ]
267 [ ascii string>alien ]
269 [ { [ length ] [ drop ] [ length ] } spread ]
273 "void" "funpack" "fun_times_"
274 { "char*" "long" "char*" "float*" "char*" "long" "long" }
278 shuffle( reta retb aa ba ca ab cb -- reta retb aa ab ba ca cb )
281 [ ascii alien>nstring ]
283 [ ascii alien>nstring ]
286 [ ascii alien>nstring ]
289 "CHARACTER*10" "funpack" "FUN_TIMES" { "!CHARACTER*20" "!REAL" "!CHARACTER*30" }
293 ] with-variable ! intel-unix-abi
295 intel-windows-abi fortran-abi [
297 [ "FUN" ] [ "FUN" fortran-name>symbol-name ] unit-test
298 [ "FUN_TIMES" ] [ "Fun_Times" fortran-name>symbol-name ] unit-test
299 [ "FUNTIMES_" ] [ "FunTimes_" fortran-name>symbol-name ] unit-test
303 f2c-abi fortran-abi [
306 [ "character(1)" fortran-type>c-type ] unit-test
308 [ "char*" { "long" } ]
309 [ "character" fortran-arg-type>c-type ] unit-test
311 [ "void" { "char*" "long" } ]
312 [ "character" fortran-ret-type>c-type ] unit-test
315 [ "real" fortran-ret-type>c-type ] unit-test
317 [ "void" { "float*" } ]
318 [ "real(*)" fortran-ret-type>c-type ] unit-test
320 [ "fun_" ] [ "FUN" fortran-name>symbol-name ] unit-test
321 [ "fun_times__" ] [ "Fun_Times" fortran-name>symbol-name ] unit-test
322 [ "funtimes___" ] [ "FunTimes_" fortran-name>symbol-name ] unit-test
326 gfortran-abi fortran-abi [
329 [ "real" fortran-ret-type>c-type ] unit-test
331 [ "void" { "float*" } ]
332 [ "real(*)" fortran-ret-type>c-type ] unit-test
334 [ "complex-float" { } ]
335 [ "complex" fortran-ret-type>c-type ] unit-test
337 [ "complex-double" { } ]
338 [ "double-complex" fortran-ret-type>c-type ] unit-test
341 [ "character(1)" fortran-type>c-type ] unit-test
343 [ "char*" { "long" } ]
344 [ "character" fortran-arg-type>c-type ] unit-test
346 [ "void" { "char*" "long" } ]
347 [ "character" fortran-ret-type>c-type ] unit-test
349 [ "complex-float" { } ]
350 [ "complex" fortran-ret-type>c-type ] unit-test
352 [ "complex-double" { } ]
353 [ "double-complex" fortran-ret-type>c-type ] unit-test
355 [ "void" { "complex-double*" } ]
356 [ "double-complex(3)" fortran-ret-type>c-type ] unit-test