add example0

This commit is contained in:
baol 2024-05-13 16:26:36 +08:00
parent 7aec933580
commit fc6d81dd84
10 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,16 @@
--2024-05-13 16:25:52-- https://www.osti.gov/servlets/purl/1649607
Resolving www.osti.gov (www.osti.gov)... 192.107.175.222
Connecting to www.osti.gov (www.osti.gov)|192.107.175.222|:443... connected.
HTTP request sent, awaiting response... 302
Location: https://www.osti.gov/biblio/1649607 [following]
--2024-05-13 16:25:53-- https://www.osti.gov/biblio/1649607
Reusing existing connection to www.osti.gov:443.
HTTP request sent, awaiting response... 200
Length: unspecified [text/html]
Saving to: 1649607
0K .......... .......... .......... .......... .......... 93.0K
50K .......... .......... .......... ... 131K=0.8s
2024-05-13 16:25:54 (105 KB/s) - 1649607 saved [86013]

BIN
example0/hello Executable file

Binary file not shown.

14
example0/hello.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
extern "C" {
void add_number(float x, float y, float* sum);
}
int main() {
float a = 5.0;
float b = 10.0;
float result;
add_number(a, b, &result);
std::cout << "the sum of the numbers is " << result << std::endl;
return 0;
}

13
example0/hello.f90 Normal file
View File

@ -0,0 +1,13 @@
program main
use math_module
implicit none
real :: a, b, result
a = 5.0
b = 10.0
call add_number(a, b, result)
print *, "the sum of the number is : ", result
end program main

BIN
example0/hello.o Normal file

Binary file not shown.

BIN
example0/main Executable file

Binary file not shown.

14
example0/math_module.f90 Normal file
View File

@ -0,0 +1,14 @@
module math_module
use, intrinsic :: iso_c_binding
implicit none
contains
subroutine add_number(x, y, sum) bind(C, name="add_number")
implicit none
real(c_float), intent(in), value :: x, y
real(c_float), intent(out) :: sum
sum = x + y
end subroutine add_number
end module math_module

BIN
example0/math_module.mod Normal file

Binary file not shown.

BIN
example0/math_module.o Normal file

Binary file not shown.

BIN
example0/math_module.so Executable file

Binary file not shown.