extern void __stdcall FORTRANFUNCTION(const double *array1, const double *scalar1 [, etc.]); // Since FORTRAN typically expects arguments by reference, arguments are passed // as pointers. To pass values, the FORTRAN code must contain a compiler directive // telling the function to expect a value rather than an address. LRESULT mcadfunction(LPCOMPLEXARRAY array1, LPCCOMPLEXSCALAR scalar1, etc.) // this defines the function before FUNCTIONINFO, using the same variable names // called by the external FORTRAN function. { // some error checking goes here, followed by the // actual call to the FORTRAN function. For example, FORTRANFUNCTION(&array1->hReal[0][0], &scalar1->real [, etc.]); // Either the function call must be in UPPERCASE, or you will have to set // Settings->FORTRAN->External procedures->External name implementation // to "Upper case" in your FORTRAN compiler. Any other C functionality follows... return 0; }
ライブラリ内のリンク
1. MS Visual C++ または Visual Studio で既存の C プロジェクトを開いて「Linker」タブを選択し、次に「Category」メニューで「Input」を選択します。[myfortranlib].lib をリストの最後の Object/library modules テキストボックスに入力します。
• Fortran コードの中のすべての STOP 文を、エラーコードを返す特殊関数に置き換えて、スレッドを円滑に強制終了する C プログラムを呼び出すようにすると便利です。
• Fortran コードに文をコンソールに出力する PRINT が含まれる場合、コンソールをファイルに再割り当てすることで、画面ではなくファイルに出力されるよう変換できます。Fortran ルーチンがエラーで強制終了された場合、このログファイルを読み込んでウィンドウとして表示するように C++ のフロントエンドプロセッサをプログラムできます。この例を次に示します。
SUBROUTINE INIT_STDOUT () c this subro which redirects FORTRAN output to file use dfwin integer res c CALL close_stdout res=SETENVQQ("FOR_PRINT=C:\FORT_OUT.TXT") c PRINT *, 'Print a character to initialize ' PRINT *,' ' RETURN END