明白了,谢谢 |
本帖最后由 vvt 于 2019-11-14 19:40 编辑 5<=z<18 等效于 (5<=z)<18 那么 情况1: 如果 5<=z 是 .true. 而.true. 一般在内存里是 0x01 或 0x0001 之类,或者 0xFF 之类的 .true. < 18 等效于 1<18 或 -1<18,结果是 .true. 情况2: 如果 5<=z 是 .false 而.false. 一般在内存里是 0x00 或 0x0000 之类的 .false. < 18 等效于 0<18,结果也是 .true. 所以,不管怎样,这个表达式的结果都是 .true. |
fcode 发表于 2019-11-14 09:01 谢谢了。改了就对了 |
5<=z<18 这是新的写法吗?可以编译成功但是结果不对。 |
其实你的函数可以简化一下。 [Fortran] 纯文本查看 复制代码 MODULE MOD_FUNC ! module contains functions for P and S-wave velocities, density and ! quality factors in sediments (1st layer) IMPLICIT NONE CONTAINS !==================== 1D INHOMOGENEOUS MEDIUM ========================= !------------------------------------------------- P or S-wave velocity FUNCTION FUNCV (Z) USE NRTYPE, ONLY: WP REAL(WP), INTENT(IN) :: Z REAL(WP) :: FUNCV if (z<5) then !layer funcv = 180 else if(5<=z<18) then !layer funcv = 200 else if(18<=z<54) then !layer funcv = 360 else if(54<=z<92) then !layer funcv = 400 else if(92<=z<130) then !layer funcv = 440 else if(130<=z<165) then !layer funcv = 460 else !halfspace funcv = 970 end if END FUNCTION FUNCV !--------------------------------------------------------------- Density FUNCTION FUNCRHO (Z) USE NRTYPE, ONLY: WP REAL(WP), INTENT(IN) :: Z REAL(WP) :: FUNCRHO if(z<5) then !layer funcrho = 1220 else if(5<=z<18) then !layer funcrho = 1487 else if(18<=z<54) then !layer funcrho = 1945 else if(54<=z<92) then !layer funcrho = 1966 else if(92<=z<130) then !layer funcrho = 1966 else if(130<=z<165) then !layer funcrho = 1966 else !halfspace funcrho = 2123 end if END FUNCTION FUNCRHO !------------------------------------------- P or S-wave quality factor FUNCTION FUNCQ (Z) USE NRTYPE, ONLY: WP REAL(WP), INTENT(IN) :: Z REAL(WP) :: FUNCQ if(z<165) then !layer funcq = 50 else !halfspace funcq = 10000 end if END FUNCTION FUNCQ END MODULE 这样更易读、易修改、易扩展 |
130<=z .and. z<165 |
捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )
GMT+8, 2024-11-23 19:49