复制代码 #else:与#if或#ifdef/#ifndef一起使用,指定在条件不成立时执行的代码 #ifdef DEBUG write(*,*) "Debugging information" #else write(*,*) "No debugging information" #endif 复制代码 #endif:结束条件编译代码块 #ifdef DEBUG write(*,*) "Debugging information" #endif 复制代码 需要注意的是...
gfortran -DDEBUG myprogram.f90 -o myprogram 复制代码 在编译时指定了条件变量后,当编译器遇到 #ifdef 指令时,会编译被 #ifdef 和#endif 包围的部分;如果没有定义条件变量,则编译器会忽略被 #ifdef 和#endif 包围的部分。 通过以上步骤,可以实现在Fortran程序中进行条件编译,根据不同的条件来编译不同的代码部...
fortran居然没有断言啊 自己加一个吧 assert.F90文件 #ifdef NDEBUG#define ASSERT(EXPR)#else#define ASSERT(EXPR) call assert(EXPR, #EXPR ,__FILE__,__LINE__)subroutineassert(should_be_true,msg,fname,iline)implicit nonelogical,intent(in)::should_be_truecharacter(len=*),intent(in)::msg,fname...
6:#ifdef __cplusplus 7:extern"C"{ 8:#endif 9: 10:intcheckdir_c_(char* dir) 11:{ 12:if(_access(dir, 0) != -1) 13:return0; 14:else 15:if(_mkdir(dir) == 0) 16:return0; 17:else 18:return-1; 19:} 20: 21:#ifdef __cplusplus 22:} 23:#endif 24: 25:#endif/* CHECKD...
可以指定 #ifdef __THA_NOTIFY 保护对 libtha(3) 例程的调用。 此选项还设置 -g。 3.4.136 –xinterval[ ={widestneed|strict| no}] (SPARC) 启用区间运算扩展。 可选值可以是 no、widestneed 或strict。如果未指定,则缺省值为 widestneed。 no 未启用区间运算扩展。 widestneed 将任何混合模式...
#ifdef _ _sparc 缺省情况下,f95 使用 fpp(1) 预处理程序。与 C 预处理程序 cpp(1) 一样,fpp 会扩展源代码宏并允许对代码进行条件编译。与 cpp 不同的是,fpp 能够识别 Fortran 语法,并作为首选的 Fortran 预处理程序。使用 -xpp=cpp 标志可以强制编译器明确使用 cpp 而非fpp。 3.4.11 –dalign 对...
#ifdef __cplusplus } #endif 这样,在Fortran或者C++的程序里面就可以直接调用了。 假设是一个Fortran函数SUBROUTINE FFUNCTION(); 那么,在C++头文件里进行如下的定义就可以了: #ifdef __cplusplus extern “C” void { #endif extern void __stdcall ffunction(); ...
左边的代码使用OpenMP在CPU线程之间并行化代码中的循环。为了维护代码的串行和并行版本,开发人员使用了#ifdef宏和编译器pragmas。结果是重复代码,并在源代码中引入了额外的API,OpenMP。 右边的代码是相同的例程,但使用C++transform_reduce算法重写。由此产生的代码更加紧凑,使其更不容易出错,更容易阅读,更易于维护。它还...
but when I compile this code , there are a error exist, I have open the "/fpp" and " /fpp:"/m" ",can we use the preprocessor (ex: #ifdef) in the function routine?, my OS is Windows XP, and Compiler: CVF 6.6, the error is below: Error: U...
注意,Fortran的字符集不包括中括号[],因此与c语言的风格不同,Fortran对数组分量的操作全都是使用小...