change readme.md

This commit is contained in:
baol 2024-05-13 16:31:48 +08:00
parent fc6d81dd84
commit 001e7c692c

View File

@ -4,3 +4,14 @@
* a FORTRAN90 subroutine or function expects all its arguments to be passed by reference. This generally means simply that the C++ function must pass scalar variables by reference, not value.
* typically, when the FORTRAN90 compiler compiles the FORTRAN90 code, the names of functions and subroutines are stored with an appended underscore. In order for these names to be found by the C++ code, it is necessary that the C++ code declare and invoke the FORTRAN90 functions and subroutines with the underscore explicitly appended to the name.
* in many cases, a FORTRAN90 compiler is simply a "front end" to a corresponding C++ compiler, as in the case of the GNU compilers gfortran and g++, or the Intel compilers ifort and icpp. This means that, as long as the corresponding compilers are used to compile the FORTRAN90 and C++ codes, it is probably possible to use either compiler to link and load the object codes; however, the load command may need to specify explicitly certain libraries associated with one of the languages. For instance, if loading using the gcc command, it is necessary to include "-l gfortran" so that the FORTRAN90 I/O libraries, among others, are included in the build.
## use bind(C) in F90
``` shell
gfortran -shared -o math_module.so math_module.f90
g++ hello.cpp -L. -lmath_module -o main
g++ hello.cpp /path/to/math_module.so -o main
```