----------------------------------------------------------------------------------
@MSGID: 1@dont-email.me> ef8c0300
@REPLY: <klobumFfoflU1@mid.individual.net>
79f86c57
@REPLYADDR db <dieterhansbritz@gmail.com>
@REPLYTO 2:5075/128 db
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: 1@dont-email.me>
@RFC-References: 1@dont-email.me>
<klobumFfoflU1@mid.individual.net>
@TZUTC: 0200
@PID: Mozilla/5.0 (X11; Linux x86_64; rv:102.0)
Gecko/20100101 Thunderbird/102.15.0
@TID: FIDOGATE-5.12-ge4e8b94
On 05.09.2023 11.50, pehache wrote:
> Le 04/09/2023 ? 16:43, db a ?crit :
>> I see that rather than try to convert a C++ function to
>> Fortran, it might be better to call it from a Fortran
>> program. So I found a description of how to do it
It resulted in a Forytran program that calls a Fortran function
that calls the C++ function IBAND (exists as iband.cpp). Here is
the code (sorry for the length)
module STUFF
integer, parameter :: dbl=selected_real_kind(14)
integer, parameter :: qud=selected_real_kind(30)
end module STUFF
program JBAND_TEST
use STUFF; implicit none
real(dbl) :: curr, FORTJBAND
real(qud) :: tbar
do
read *, tbar
if (tbar < 0) exit
curr = FORTJBAND (tbar)
print `(" curr =", f10.4)`, curr
enddo
end program JBAND_TEST
function FORTJBAND (tbar)
use STUFF; implicit none
interface
function JBAND (tbar) bind(c)
import JBAND, c_long_double
import tbar, c_long_double
end function JBAND
end interface
real(dbl) :: FORTJBAND
real(qud) :: tbar, JBAND
FORTJBAND = JBAND (tbar)
end function FORTJBAND
The file jband.cpp is large. It is declared as long double and so
is the input to it, tbar.
I then wrote a script for running it, reproducing what the link
tells me:
cpp -o jband.o jband.cpp
gfortran -o jbandtest.o jbandtest.f90
gfortran jband.o jbandtest.o
./a.out << eoi
1.0
10.0
-1
eoi
When I run this, I get this:
~/ownlib90/tests> ./jbandtest
cpp: fatal error: cannot execute `cc1plus`: execvp: No such file or
directory
compilation terminated.
jbandtest.f90:21:31:
21 | import JBAND, c_long_double
| 1
Error: Cannot IMPORT `c_long_double` from host scoping unit at (1) -
does not exist.
jbandtest.f90:22:30:
22 | import tbar, c_long_double
| 1
Error: Cannot IMPORT `c_long_double` from host scoping unit at (1) -
does not exist.
jbandtest.f90:27:14:
27 | FORTJBAND = JBAND (tbar)
| 1
Error: Type mismatch in argument `tbar` at (1); passed REAL(16) to REAL(4)
etc, What is cc1plus, where does that come in? Why is long double
not recognised? What do I do to get this running?
--
Dieter Britz
--- Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
* Origin: A noiseless patient Spider (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441