- Timestamp:
- Jul 24, 2024, 4:23:34 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_interpolation.f90
r5116 r5117 36 36 do while (ju - jl > 1) 37 37 jm = (ju + jl) / 2 ! Compute a midpoint, 38 if(ascnd .eqv. (x >= xx(jm))) THEN38 IF (ascnd .eqv. (x >= xx(jm))) THEN 39 39 jl = jm ! and replace either the lower limit 40 40 else … … 44 44 ! {ju == jl + 1} 45 45 46 ! {(ascnd . and. xx(jl) <= x < xx(jl+1))46 ! {(ascnd .AND. xx(jl) <= x < xx(jl+1)) 47 47 ! .neqv. 48 ! (. not. ascnd .and. xx(jl+1) <= x < xx(jl))}48 ! (.NOT. ascnd .AND. xx(jl+1) <= x < xx(jl))} 49 49 50 50 ! Then set the output, being careful with the endpoints: 51 if(x == xx(1)) THEN51 IF (x == xx(1)) THEN 52 52 locate = 1 53 else if(x == xx(n)) THEN53 ELSE IF (x == xx(n)) THEN 54 54 locate = n - 1 55 55 else … … 81 81 ascnd = (xx(n) >= xx(1)) 82 82 ! (True if ascending order of table, false otherwise.) 83 if (jlo < 0 .or. jlo > n) THEN83 IF (jlo < 0 .OR. jlo > n) THEN 84 84 ! Input guess not useful. Go immediately to bisection. 85 85 jlo = 0 … … 87 87 else 88 88 inc = 1 ! Set the hunting increment. 89 if(jlo == 0) THEN89 IF (jlo == 0) THEN 90 90 hunt_up = .TRUE. 91 91 else 92 92 hunt_up = x >= xx(jlo) .eqv. ascnd 93 93 end if 94 if(hunt_up) then ! Hunt up:95 do94 IF (hunt_up) then ! Hunt up: 95 DO 96 96 jhi = jlo + inc 97 if(jhi > n) then ! Done hunting, since off end of table.97 IF (jhi > n) then ! Done hunting, since off end of table. 98 98 jhi = n + 1 99 99 exit 100 100 else 101 if(x < xx(jhi) .eqv. ascnd) exit101 IF (x < xx(jhi) .eqv. ascnd) exit 102 102 jlo = jhi ! Not done hunting, 103 103 inc = inc + inc ! so double the increment … … 106 106 else ! Hunt down: 107 107 jhi = jlo 108 do108 DO 109 109 jlo = jhi - inc 110 if(jlo < 1) then ! Done hunting, since off end of table.110 IF (jlo < 1) then ! Done hunting, since off end of table. 111 111 jlo = 0 112 112 exit 113 113 else 114 if(x >= xx(jlo) .eqv. ascnd) exit114 IF (x >= xx(jlo) .eqv. ascnd) exit 115 115 jhi = jlo ! Not done hunting, 116 116 inc = inc + inc ! so double the increment … … 121 121 122 122 do ! Hunt is done, so begin the final bisection phase: 123 if(jhi - jlo <= 1) THEN124 if(x == xx(n)) jlo = n - 1125 if(x == xx(1)) jlo = 1123 IF (jhi - jlo <= 1) THEN 124 IF (x == xx(n)) jlo = n - 1 125 IF (x == xx(1)) jlo = 1 126 126 exit 127 127 else 128 128 jm = (jhi + jlo) / 2 129 if(x >= xx(jm) .eqv. ascnd) THEN129 IF (x >= xx(jm) .eqv. ascnd) THEN 130 130 jlo = jm 131 131 else
Note: See TracChangeset
for help on using the changeset viewer.