使用逻辑变量 result = (a == b) if (result) then print *, 'a is equal to b' else print *, 'a is not equal to b' end if end program if_example ``` #### 2. 嵌套IF语句 有时需要根据多个条件进行判断,这时可以使用嵌套的`IF`语句。 ```fortran prog
// NOT Equal 1 2 3 4 5 6 7 五、逻辑变量和赋值 常用于IF statement .AND. .OR. .NOT. Logical a, b a=.TRUE. b = a .AND 3 .LT. 5/2 1 2 3 4 5 6 7 六、if 语句 条件语句在任何编程语言中都占有重要的位置。在Fortran中最常见的条件语句就是IF语句。IF语句有好几种形式。 1、...
/ = (not equal) • > (greater than) • >= (greater than or equal) They are used to form relational expressions involving pairs of operands of numeric or character type, as in mass < limit. All these operators may be used to form expressions involving abstract data types; however, ...
.NOT. 6 .AND. 7 .OR. 8 .EQV. .NEQV. 9 2.2.3逻辑IF语句 IF语句不是一种选择结构,只是一条语句,它在算法较简单的场合下,可以灵活地完成二分叉选择算法。逻辑IF语句判别逻辑表达式的值是否为“真”,并执行一操作。其一般形式为:IF(逻辑表达式) 执行语句。如果条件成立(即逻辑表达式值是‘真’),则执行...
在实际问题中,常常要根据不同的条件执行不同的语句,这就需要用到选择结构。在FORTRAN90中主要用块IF结构和块CASE结构来实现选择结构。本章将先介绍关系表达式和逻辑表达式,然后详细介绍选择结构的实现方法。3.1关系运算和逻辑运算 关系运算符 关系运算符 .LT..LE.<<= 英语含义 LessThanLessThanOrEqualTo 数学...
Fortran的讲义第三章 第三章改变程序流程 基本的程序结构 顺序结构 AB 基本的程序结构 选择结构 条件 A B …基本的程序结构 循环结构 条件 False True A A False 条件True 当型循环结构 直到型循环结构 基本的程序结构 goto语句(不提倡使用)例:100print*,‘请输入一个实数‘read*,aprint*,‘...
Fortran 运行中给出的系统错误及解决方法.doc,Severe_Messages Must be corrected. The programs execution is terminated when the error is encountered, unless for I/O statements the program uses the END or ERR I/O statement specifiers to transfer control, perh
(x == y) END FUNCTION NotEqual FUNCTION Compare( x, y ) RESULT( is_equal ) CLASS(my_type), INTENT(IN) :: x, y LOGICAL :: is_equal is_equal = .TRUE. IF ( x%j /= y%j ) THEN print *, 'J component of my objects are different' is_equal = .FALSE. END IF IF ...
CSetboundarytemperatureequaltocelltemperaturesubroutinezeroGradT(result,size,fc,T)useStarRealModimplicit noneinteger,intent(in)::sizereal(StarReal),intent(out)::result(size)integer,intent(in)::fc(2,*)real(StarReal),intent(in)::T(*)integeriCLoopthroughallentitiesapplyingT_boundary=T_cellCfc(1,i...
3 Fortran 程序设计3-选择结构 关于提交作业:1.将已经运行通过的若干Fortran源文件:*.f90(或者*.for)文件压缩2.压缩文件名请自己命名为:09大气+学号或者:09应气+学号 3.将压缩文件以附件发送到本人邮箱 关于作业:1.文件名——尽量用以英文字母开头的、包含英文以及英文书写状态下的数字和下划线等其它符号)...