is there a better way to code this ?

327 views
Skip to first unread message

Lynn McGuire

unread,
Jun 12, 2022, 6:46:32 PMJun 12
to
So, is there a better way to code this ?

C CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
C 10 - no equal sign required
C 11 - equal sign required
C
LEQUL=.TRUE.
IF (ICEP .GT. 100) GO TO 1002
C ICEP = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
GO TO( 10, 11, 11, 10, 10, 11, 11, 11, 10, 11, 10, 11, 11, 10, 10,
C ICEP = 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
* 10, 10, 11, 11, 11, 10, 10, 10, 10, 11, 10, 11, 11, 11, 11,
C ICEP = 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
* 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 11,
C ICEP = 46 47 48 79 50
* 10, 11, 11, 11, 11,
C ICEP = 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
* 10, 10, 11, 11, 10, 11, 11, 10, 11, 11, 10, 11, 10, 11, 11,
C ICEP = 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
* 11, 10, 10, 11, 10, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11,
C ICEP 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
* 11, 11, 10, 10, 11, 11, 11, 11, 11, 10, 10, 10, 10, 11, 11,
C ICEP 96 97 98 99 100
* 11, 10, 10, 11, 11), icep
1002 IF (ICEP .GT. 200) GO TO 1004
NN = ICEP - 100
C ICEP = 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
GO TO( 11, 10, 10, 10, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10,
C ICEP 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
* 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
C ICEP 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
* 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
C ICEP 146 147 148 149 150
* 11, 10, 11, 11, 11,
C ICEP = 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
* 10, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 10, 11,
C ICEP 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
* 11, 10, 10, 10, 10, 10, 10, 10, 11, 10, 11, 11, 11, 10, 11,
C ICEP 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
* 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 11, 11, 11, 10, 11,
C 196 197 198 199 200
* 11, 11, 11, 11, 10), NN
1004 IF (ICEP .GT. 300) goto 1006
NN = ICEP - 200
C ICEP = 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
GO TO( 11, 10, 11, 11, 11, 11, 10, 11, 11, 11, 10, 10, 11, 11, 10,
C 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
* 11, 11, 11, 11, 10, 10, 10, 10, 11, 10, 10, 10, 10, 11, 11,
C 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
* 11, 11, 11, 11, 11, 10, 11, 10, 10, 10, 11, 11, 11, 11, 10,
C 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
* 11, 11, 11, 10, 11, 11, 10, 10, 10, 11, 11, 11, 11, 11, 11,
C 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
* 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11,
C 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
* 10, 11, 10, 10, 10, 10, 10, 11, 11, 10, 11, 11, 11, 10, 11,
C 291 292 293 294 295 296 297 298 299 300
* 11, 11, 11, 10, 10, 10, 10, 10, 10, 10), NN
1006 IF (ICEP .GT. gen_maxcep) GO TO 1111
NN = ICEP - 300
C 301 302 303 304 305 306 307 308 309 310
GO TO ( 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
C 311 312 313 314 315 316 317 318 319 320
* 11, 11, 11, 11, 11, 10, 10, 10, 10, 10,
C 321 322 323 324 325 326 327 328 329 330
* 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
C 331 332 333 334 335 336 337 338 339 340
* 10, 10, 11, 11, 11, 11, 10, 10, 10, 10,
C 341 342 343 344 345 346 347 348 349 350
* 11, 11, 11, 11, 10, 11, 11, 11, 10, 10 ), NN

Thanks,
Lynn

gah4

unread,
Jun 12, 2022, 7:05:50 PMJun 12
to
Since there are only two places to go, a look-up table
and then a two-way branch would do it.

You could even us the same values as array initializers
instead, and then make the branch based on 10 or 11.

It is probably about the same in speed.

pmk

unread,
Jun 12, 2022, 9:40:16 PMJun 12
to
integer, parameter :: cmdsNeedingEq(*) = [2,3, 6, 7, 8, 10, 12, 13, &
! und so weiter...
346, 347, 348 ]
integer, parameter :: gen_maxcep = 350
logical, parameter :: cmdNeedsEq(*) = [(any(j==cmdsNeedingEq),j=1,gen_maxcep)]
! ...
lequl = .false. ! unless I have reversed the logic
if (icep >= 1 .and. icep <= gen_maxcep) lequl = cmdNeedsEq(icep)

On Sunday, June 12, 2022 at 3:46:32 PM UTC-7, Lynn McGuire wrote:

gah4

unread,
Jun 12, 2022, 10:06:19 PMJun 12
to
C CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
C 10 - no equal sign required
C 11 - equal sign required

integer needs(350)
data needs/
C ICEP = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
* 10, 11, 11, 10, 10, 11, 11, 11, 10, 11, 10, 11, 11, 10, 10,
C ICEP = 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
* 10, 10, 11, 11, 11, 10, 10, 10, 10, 11, 10, 11, 11, 11, 11,
C ICEP = 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
* 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 11,
C ICEP = 46 47 48 79 50
* 10, 11, 11, 11, 11,
C ICEP = 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
* 10, 10, 11, 11, 10, 11, 11, 10, 11, 11, 10, 11, 10, 11, 11,
C ICEP = 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
* 11, 10, 10, 11, 10, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11,
C ICEP 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
* 11, 11, 10, 10, 11, 11, 11, 11, 11, 10, 10, 10, 10, 11, 11,
C ICEP 96 97 98 99 100
* 11, 10, 10, 11, 11,
C ICEP = 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
* 11, 10, 10, 10, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10,
C ICEP 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
* 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
C ICEP 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
* 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
C ICEP 146 147 148 149 150
* 11, 10, 11, 11, 11,
C ICEP = 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
* 10, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 10, 11,
C ICEP 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
* 11, 10, 10, 10, 10, 10, 10, 10, 11, 10, 11, 11, 11, 10, 11,
C ICEP 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
* 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 11, 11, 11, 10, 11,
C 196 197 198 199 200
* 11, 11, 11, 11, 10,
C ICEP = 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
* 11, 10, 11, 11, 11, 11, 10, 11, 11, 11, 10, 10, 11, 11, 10,
C 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
* 11, 11, 11, 11, 10, 10, 10, 10, 11, 10, 10, 10, 10, 11, 11,
C 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
* 11, 11, 11, 11, 11, 10, 11, 10, 10, 10, 11, 11, 11, 11, 10,
C 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
* 11, 11, 11, 10, 11, 11, 10, 10, 10, 11, 11, 11, 11, 11, 11,
C 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
* 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11,
C 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
* 10, 11, 10, 10, 10, 10, 10, 11, 11, 10, 11, 11, 11, 10, 11,
C 291 292 293 294 295 296 297 298 299 300
* 11, 11, 11, 10, 10, 10, 10, 10, 10, 10,
C 301 302 303 304 305 306 307 308 309 310
* 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
C 311 312 313 314 315 316 317 318 319 320
* 11, 11, 11, 11, 11, 10, 10, 10, 10, 10,
C 321 322 323 324 325 326 327 328 329 330
* 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
C 331 332 333 334 335 336 337 338 339 340
* 10, 10, 11, 11, 11, 11, 10, 10, 10, 10,
C 341 342 343 344 345 346 347 348 349 350
* 11, 11, 11, 11, 10, 11, 11, 11, 10, 10 /

gah4

unread,
Jun 12, 2022, 10:07:10 PMJun 12
to

C CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
C 10 - no equal sign required
C 11 - equal sign required

integer needs(35)
data needs/
C ICEP = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
* 10, 11, 11, 10, 10, 11, 11, 11, 10, 11, 10, 11, 11, 10, 10,
C ICEP = 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
* 10, 10, 11, 11, 11, 10, 10, 10, 10, 11, 10, 11, 11, 11, 11,
C ICEP = 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
* 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 11,
C ICEP = 46 47 48 79 50
* 10, 11, 11, 11, 11,
C ICEP = 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
* 10, 10, 11, 11, 10, 11, 11, 10, 11, 11, 10, 11, 10, 11, 11,
C ICEP = 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
* 11, 10, 10, 11, 10, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11,
C ICEP 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
* 11, 11, 10, 10, 11, 11, 11, 11, 11, 10, 10, 10, 10, 11, 11,
C ICEP 96 97 98 99 100
* 11, 10, 10, 11, 11,
C ICEP = 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
* 11, 10, 10, 10, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10,
C ICEP 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
* 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
C ICEP 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
* 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
C ICEP 146 147 148 149 150
* 11, 10, 11, 11, 11,
C ICEP = 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
* 10, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 10, 11,
C ICEP 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
* 11, 10, 10, 10, 10, 10, 10, 10, 11, 10, 11, 11, 11, 10, 11,
C ICEP 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
* 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 11, 11, 11, 10, 11,
C 196 197 198 199 200
* 11, 11, 11, 11, 10,
C ICEP = 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
* 11, 10, 11, 11, 11, 11, 10, 11, 11, 11, 10, 10, 11, 11, 10,
C 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
* 11, 11, 11, 11, 10, 10, 10, 10, 11, 10, 10, 10, 10, 11, 11,
C 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
* 11, 11, 11, 11, 11, 10, 11, 10, 10, 10, 11, 11, 11, 11, 10,
C 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
* 11, 11, 11, 10, 11, 11, 10, 10, 10, 11, 11, 11, 11, 11, 11,
C 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
* 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11,
C 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
* 10, 11, 10, 10, 10, 10, 10, 11, 11, 10, 11, 11, 11, 10, 11,
C 291 292 293 294 295 296 297 298 299 300
* 11, 11, 11, 10, 10, 10, 10, 10, 10, 10,
C 301 302 303 304 305 306 307 308 309 310
* 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
C 311 312 313 314 315 316 317 318 319 320
* 11, 11, 11, 11, 11, 10, 10, 10, 10, 10,
C 321 322 323 324 325 326 327 328 329 330
* 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
C 331 332 333 334 335 336 337 338 339 340
* 10, 10, 11, 11, 11, 11, 10, 10, 10, 10,
C 341 342 343 344 345 346 347 348 349 350
* 11, 11, 11, 11, 10, 11, 11, 11, 10, 10 /

Lynn McGuire

unread,
Jun 13, 2022, 4:23:22 PMJun 13
to
Does regular Fortran allow 35 lines of continuation lines in a data
statement ?

Thanks,
Lynn

jfh

unread,
Jun 13, 2022, 5:08:48 PMJun 13
to
Depends on what you mean by regular Fortran. In f2003 and later the limit is 255, but in f95 it's 39 in free form, 19 in fixed form.

gah4

unread,
Jun 13, 2022, 7:28:43 PMJun 13
to
On Monday, June 13, 2022 at 1:23:22 PM UTC-7, Lynn McGuire wrote:
> On 6/12/2022 9:06 PM, gah4 wrote:
> > C CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
> > C 10 - no equal sign required
> > C 11 - equal sign required
> >
> > integer needs(350)
> > data needs/
> > C ICEP = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
> > * 10, 11, 11, 10, 10, 11, 11, 11, 10, 11, 10, 11, 11, 10, 10,

(snip)

> > * 11, 11, 11, 11, 10, 11, 11, 11, 10, 10 /\
> Does regular Fortran allow 35 lines of continuation lines in a data
> statement ?

I don't think it is less than for a computed GOTO statement.

As well as I remember, some compilers have a larger limit for DATA,
as it is useful for initializing large arrays.


Lynn McGuire

unread,
Jun 13, 2022, 7:29:18 PMJun 13
to
I meant Standard Fortran.

Thanks !

Lynn

gah4

unread,
Jun 13, 2022, 8:19:52 PMJun 13
to
On Monday, June 13, 2022 at 4:29:18 PM UTC-7, Lynn McGuire wrote:

(snip)

> > Depends on what you mean by regular Fortran. In f2003 and later the limit is 255, but in f95 it's 39 in free form, 19 in fixed form.
> I meant Standard Fortran.

66, 77, 90, 95, 2008, 2013, or 2018?

There is a famous quote:

"The nice thing about standards is that we have so many to choose from."

Lynn McGuire

unread,
Jun 14, 2022, 3:34:32 PMJun 14
to
Heh.

F77 apparently allowed 19 continuation lines. Open Watcom Fortran 77 is
extended to allow up to 61 continuation lines.

Lynn



gah4

unread,
Jun 14, 2022, 4:22:27 PMJun 14
to
On Tuesday, June 14, 2022 at 12:34:32 PM UTC-7, Lynn McGuire wrote:

(snip)

> F77 apparently allowed 19 continuation lines. Open Watcom Fortran 77 is
> extended to allow up to 61 continuation lines.

When I wrote above about how many lines of computed GOTO, I had forgotten
that you split that one up.

You could split up the DATA with EQUIVALENCE and two or three or four arrays.

I thought that was a good way, as it keeps your comments (which don't count
for continuation lines), but also the numbers. So no transcribing mistakes.
(Not that you ever do that.)

And yes the Watcom compiler is my favorite Fortran 77 compiler.
(Well, maybe VS Fortran, but I don't have one of those.)



Lynn McGuire

unread,
Jun 14, 2022, 6:15:26 PMJun 14
to
I am slowly porting to Intel Fortran on Windows. I have got to go 64
bit. I may have to turn off the automatic module creation for now to
speed up my port. 5,000 subroutines is a lot of arguments to fix to
meet the exact type used.

Lynn

Lynn McGuire

unread,
Jun 14, 2022, 6:18:15 PMJun 14
to
On 6/14/2022 3:22 PM, gah4 wrote:
I also have this computed goto that is going be even harder:

IF (ICEP .EQ. -1) GO TO 562
IF (ICEP .GT. 100) GO TO 283
C ICEP 1 2 3 4 5 6 7 8 9 10
GO TO (900 ,510 ,510 ,580 ,564 ,900 ,636 ,518 ,564 ,514 ,
C ICEP 11 12 13 14 15 16 17 18 19 20
* 564 ,530 ,677 ,580 ,564 ,564 ,580 ,668 ,900 ,668 ,
C 21 22 23 24 25 26 27 28 29 30
* 564 ,580 ,900 ,580 ,562 ,564 ,620 ,513 ,510 ,900 ,
C 31 32 33 34 35 36 37 38 39 40
* 900 ,562 ,514 ,514 ,668 ,514 ,520 ,550 ,604 ,615 ,
C 41 42 43 44 45 46 47 48 49 50
* 564 ,580 ,580 ,403 ,550 ,580 ,514 ,900 ,900 ,521,
C 51 52 53 54 55 56 57 58 59 60
* 564 ,580 ,514 ,668 ,565 ,530 ,530 ,5520, 668 ,517 ,
C 61 62 63 64 65 66 67 68 69 70
* 580 , 668, 580 ,900 ,510 ,519 ,580 ,564 ,550 ,564 ,
C 71 72 73 74 75 76 77 78 79 80
* 500 ,530 ,561 ,510 ,560 ,554 ,530 ,439 ,439 ,604 ,
C 81 82 83 84 85 86 87 88 89 90
* 689 ,510 ,900 ,564 ,689 ,689 ,570 ,668 ,668 ,580 ,
C 91 92 93 94 95 96 97 98 99 100
* 580 ,580 ,580 ,651 ,650 ,651 ,564 ,900 ,522 ,530 ), icep
283 IF(ICEP.GT. 200) GO TO 285
NN = ICEP - 100
C ICEP 101 102 103 104 105 106 107 108 109 110
GO TO (530 ,900 ,511 ,511 ,511 ,674 ,675 ,553 ,553 ,553 ,
C 111 112 113 114 115 116 117 118 119 120
* 553 ,553 ,553 ,553 ,564 ,580 ,551 ,516 ,580 ,580 ,
C 121 122 123 124 125 126 127 128 129 130
* 515 ,564 ,580 ,553 ,564 ,580 ,564 ,580 ,551 ,551 ,
C 131 132 133 134 135 136 137 138 139 140
* 668 ,653 ,653 ,900 ,565 ,568 ,552 ,565 ,571 ,551 ,
C 141 142 143 144 145 146 147 148 149 150
* 553 ,900 ,673 ,900 ,677 ,692 ,680 ,6842,6842,6842,
C 151 152 153 154 155 156 157 158 159 160
* 680 ,760 ,900 ,900 ,751 ,6829,6829,6829,6829,6829,
C 161 162 163 164 165 166 167 168 169 170
* 900 ,900 ,900 ,5630, 16500, 16500, 6829,565 ,569 ,5620,
C 171 172 173 174 175 176 177 178 179 180
* 563 ,564 ,564 ,752 ,753 ,653 ,900 ,900 ,17900, 900,
C 181 182 183 184 185 186 187 188 189 190
* 761 ,762 ,763 ,6840,5525,5631,5662,5663,5664,5665,
C 191 192 193 194 195 196 197 198 199 200
* 5666, 774, 774,5632, 523, 653,6843, 900,6845,6200), NN
285 if (icep .gt. 300) goto 287
NN = ICEP - 200
C ICEP 201 202 203 204 205 206 207 208 209 210
GO TO (6846,6847,6848,6849,6850,6851,6852,6844,6854,6855,
C 211 212 213 214 215 216 217 218 219 220
* 5632,565 , 440, 598,6010, 441, 442, 514, 530, 5633,
C 221 222 223 224 225 226 227 228 229 230
* 580, 564, 553,5634, 580, 564, 580, 564,6361, 596,
C 231 232 233 234 235 236 237 238 239 240
* 597,6364, 900, 900, 900, 553,6020, 580, 564, 553,
C 241 242 243 244 245 246 247 248 249, 250,
* 5635,4389,6030,6030,6040, 692, 692,6100, 5526,900,
C 251 252 253 254 255 256 257 258 259 260
* 510, 580, 564, 553,1255,1256,1257,1258,1259,1260,
C 261 262 263 264 265 266 267 268
* 2261,2262, 1760, 900, 653, 1264, 12641, 12642,
C 269 270 271 272 273 274 275 276
* 12643, 27000, 27100, 27200, 27300, 514, 530, 514,
C 277 278 279 280 281 282 283 284 285
* 530, 5301, 5302, 5303, 5304, 6461, 5560, 12644, 6461,
C 286 287 288 289 290 291 292 293 294
* 28600, 28700, 28800, 28900, 29000, 692, 692, 900, 29400,
C 295 296 297 298 299 300
* 29500, 29600, 29700, 29800, 29900, 30000), nn
287 if (icep .gt. gen_maxcep) goto 289
NN = ICEP - 300
C 301 302 303 304 305 306 307 308
go to (30100, 30200, 30300, 30400, 30500, 30600, 30700, 30800,
C 309 310 311 312 313 314 315 316
* 30900, 31000, 31100, 31200, 31300, 31400, 31500, 31600,
C 317 318 319 320 321 322 323 324
* 31700, 31800, 31900, 32000, 32100, 32200, 32300, 32400,
C 325 326 327 328 329 330 331 332
* 32500, 32600, 32700, 32800, 32900, 33000, 900, 900,
C 333 334 335 336 337 338 339 340
* 33300, 33400, 33500, 33600, 33700, 33800, 33900, 34000,
C 341 342 343 344 345 346 347 348
* 34100, 34200, 34300, 34400, 34500, 34600, 34700, 34800,
C 349 350 351 352 353 354 355 356
* 34900, 35000, 35100, 35200), NN

289 call scrwri (' ')
write (screenbuffer, 99902) icep
99902 format ('ERROR: icep', i4, ' command not handled (ingen2)')
call scrwri (screenbuffer)
call scrwri (' ')
setstp = .true.
GOTO 900

Lynn


Gary Scott

unread,
Jun 14, 2022, 7:56:12 PMJun 14
to
On 6/14/2022 3:22 PM, gah4 wrote:
VS Fortran was one of my favs. I wrote lots of tools including one
giant interactive graphics editing program that rivaled out Mentor
Graphics workstations. Of course you had to have a graphics capable
high function terminal (3270PC AT/GX) for it to work well, but lesser
capable graphics terminals also worked where I could think of a workaround.

gah4

unread,
Jun 14, 2022, 10:45:40 PMJun 14
to
On Tuesday, June 14, 2022 at 3:18:15 PM UTC-7, Lynn McGuire wrote:

(snip)

> I also have this computed goto that is going be even harder:

> IF (ICEP .EQ. -1) GO TO 562
> IF (ICEP .GT. 100) GO TO 283
> C ICEP 1 2 3 4 5 6 7 8 9 10
> GO TO (900 ,510 ,510 ,580 ,564 ,900 ,636 ,518 ,564 ,514 ,
> C ICEP 11 12 13 14 15 16 17 18 19 20
> * 564 ,530 ,677 ,580 ,564 ,564 ,580 ,668 ,900 ,668 ,
> C 21 22 23 24 25 26 27 28 29 30
> * 564 ,580 ,900 ,580 ,562 ,564 ,620 ,513 ,510 ,900 ,
> C 31 32 33 34 35 36 37 38 39 40
> * 900 ,562 ,514 ,514 ,668 ,514 ,520 ,550 ,604 ,615 ,

(snip)

OK, this one has 190 different places to go.

Are these places more complicated than assigning some value,
or something else that can be done using lookup table data?

This is sort of close to the point that you could use a look up
table and 190 way computed GOTO statement. I might suggest
that when it is less than about 1/3 of the choices.

Using AWK:

/^[^C]/ {
gsub("[^0-9]"," ")
if(NF<4) next
for(i=1; i<=NF; i++) x[$i]++
}

END {
j=l=0
for(k in x) j++
for(k in x) l += x[k]
print j,"of",l
}




Lynn McGuire

unread,
Jun 15, 2022, 12:28:18 AMJun 15
to
It is truly spaghetti code. A value assignment and hundreds of gotos.
It has grown like topsy over the years. Probably a SELECT would work well.

Lynn


Ev. Drikos

unread,
Jun 15, 2022, 6:04:17 AMJun 15
to
On 13/06/2022 01:46, Lynn McGuire wrote:
> So, is there a better way to code this ?
>

Better no, maybe more compact. If performance is an
issue one can declare ie the string as a parameter.



---------------- icep.f90 -----------------------------
! CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
! 10 - no equal sign required
! 11 - equal sign required

interface
function atoi(in) bind(c)
use, intrinsic :: iso_c_binding
integer(c_int) :: atoi
character(c_char) :: in(*)
end function
end interface

character(350) :: go
character :: ch
integer :: icep = 314 !ie
integer :: nn

!234567890123456789012345678901234567890123456789012345678901234567890xx
go(001:052)='1212121212121212121212121212121212121212121121212112'
go(053:104)='1212121212121212121212121212121212121212121121212112'
go(105:156)='1212121212121212121212121212121212121212121121212112'
go(157:208)='1212121212121212121212121212121212121212121121212112'
go(209:260)='1212121212121212121212121212121212121212121121212112'
go(261:312)='1212121212121212121212121212121212121212121121212112'
go(313:350)='12121212121212121212121212121212121212'


ch=go(icep:icep)
nn=atoi(ch)

print *, 'ch=', ch
print *, 'nn=', nn
print *, 'go=', go

goto(10,11) nn

10 print *, '10', 'go=', go(icep:icep)
goto 999
11 print *, '11', 'go=', go(icep:icep)
goto 999
999 end

Robin Vowels

unread,
Jun 15, 2022, 8:24:54 AMJun 15
to
On Monday, June 13, 2022 at 8:46:32 AM UTC+10, Lynn McGuire wrote:
> So, is there a better way to code this ?
.
Yes, in PL/I you need to write only GO TO LAB(NN);
.

John

unread,
Jun 16, 2022, 12:33:44 AMJun 16
to
Well, for the first one for maintainability (and not wanting to even mention ASSIGN statements) and primarily for human intelligibility I might go with a way that worked even pre-f90;. It would probably be more efficient if populated with logicals but this format has a few advantages when a human has to manually
maintain the information

program testit
implicit none
integer :: nn
integer,parameter :: EQUALS(*)=[&
+1, -2, -3, +4, +5, -6, -7, -8, +9, -10, &
+11, -12, -13, +14, +15, +16, +17, -18, -19, -20, &
+21, +22, +23, +24, -25, +26, -27, -28, -29, -30, &
-31, +32, -33, -34, -35, -36, -37, -38, -39, -40, &
+41, +42, +43, +44, -45, +46, -47, -48, -49, -50, &
+51, +52, -53, -54, +55, -56, -57, +58, -59, -60, &
+61, -62, +63, -64, -65, -66, +67, +68, -69, +70, &
-71, -72, +73, -74, -75, -76, -77, -78, -79, -80, &
-81, -82, +83, +84, -85, -86, -87, -88, -89, +90, &
+91, +92, +93, -94, -95, -96, +97, +98, -99, -100, &
-101, +102, +103, +104, -105, -106, -107, +108, +109, +110, &
+111, +112, +113, +114, +115, +116, +117, +118, +119, +120, &
+121, +122, +123, +124, +125, +126, +127, +128, +129, +130, &
-131, -132, -133, +134, +135, +136, +137, +138, +139, +140, &
+141, -142, -143, -144, -145, -146, +147, -148, -149, -150, &
+151, -152, -153, -154, -155, -156, -157, -158, -159, +160, &
-161, -162, -163, +164, -165, -166, +167, +168, +169, +170, &
+171, +172, +173, -174, +175, -176, -177, -178, +179, -180, &
-181, -182, -183, -184, +185, +186, +187, +188, +189, +190, &
-191, -192, -193, +194, -195, -196, -197, -198, -199, +200, &
-201, +202, -203, -204, -205, -206, +207, -208, -209, -210, &
+211, +212, -213, -214, +215, -216, -217, -218, -219, +220, &
+221, +222, +223, -224, +225, +226, +227, +228, -229, -230, &
-231, -232, -233, -234, -235, +236, -237, +238, +239, +240, &
-241, -242, -243, -244, +245, -246, -247, -248, +249, -250, &
-251, +252, +253, +254, -255, -256, -257, -258, -259, -260, &
-261, -262, -263, -264, -265, -266, -267, -268, -269, -270, &
-271, -272, -273, +274, -275, +276, -277, +278, +279, +280, &
+281, +282, -283, -284, +285, -286, -287, -288, +289, -290, &
-291, -292, -293, +294, +295, +296, +297, +298, +299, +300, &
-301, -302, -303, -304, -305, -306, -307, -308, -309, -310, &
-311, -312, -313, -314, -315, +316, +317, +318, +319, +320, &
+321, +322, +323, +324, +325, +326, +327, +328, -329, -330, &
+331, +332, -333, -334, -335, -336, +337, +338, +339, +340, &
-341, -342, -343, -344, +345, -346, -347, -348, +349, +350]
! CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
! + no equal sign required
! - equal sign required
write(*,*)size(equals)==350
do nn=1,size(equals)
if(equals(nn)>0)then
write(*,*)nn,'equal sign required'
else
write(*,*)nn,'equal sign not required'
endif
enddo
end program testit

Robin Vowels

unread,
Jun 17, 2022, 3:43:33 AMJun 17
to
On Thursday, June 16, 2022 at 2:33:44 PM UTC+10, John wrote:
> Well, for the first one for maintainability (and not wanting to even mention ASSIGN statements) and primarily for human intelligibility I might go with a way that worked even pre-f90;. It would probably be more efficient if populated with logicals but this format has a few advantages when a human has to manually
> maintain the information
.
GO TO LAB(NN);
is still simpler in PL/I.
.

Lynn McGuire

unread,
Jun 18, 2022, 4:05:16 PMJun 18
to
So ? We are not talking about PL/I.

Lynn

Lynn McGuire

unread,
Jun 18, 2022, 4:10:44 PMJun 18
to
On 6/12/2022 9:06 PM, gah4 wrote:
I have to admit, this is my favorite. Especially if I could put the
data statement in the middle of the code.

One of my favorite things about C++ is that I can declare variables all
over the place. With an average of 2,000 lines of code per subroutine,
it would be nice to locate the variable declarations at their usage.

Lynn

Ev. Drikos

unread,
Jun 19, 2022, 6:05:35 AMJun 19
to
On 15/06/2022 13:04, Ev. Drikos wrote:
> On 13/06/2022 01:46, Lynn McGuire wrote:
>> So, is there a better way to code this ?
>>
>
> Better no, maybe more compact. If performance is an
> issue one can declare ie the string as a parameter.
> ...

Admittedly, maintaining a packed array is likely more
difficult than a usual array of integers but i thought
that this wouldn't be a big problem for an experienced
programmer. Now, I focus to another problem i faced.

To my surprise, if one defined the packed array as a
parameter, the following statement would become invalid:

icep.f:20:1:
read(goes(icep:icep),*) nn
^
Expression at (^) has incorrect data type or rank for its context

Does anybody know why there is such a restriction?


----------------------------------------------
$ gfc --version 2>&1 | head -n1
GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
(Red Hat Linux 3.2.2-5)
$ gfc icep.f && ./a.out
11: goes=2

$
--------------- icep.f -------------------------------
! CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
! 10 - no equal sign required
! 11 - equal sign required

integer :: icep = 302 !ie
integer :: nn
character(350) :: goes = &
& '12121212121212121212121212121212121212121211212121'
& !001-050 21-70
& // '12121212121212121212121212121212121212121211212121'
& !051-100 21-70
& // '12121212121212121212121212121212121212121211212121'
& !101-150 21-70
& // '12121212121212121212121212121212121212121211212121'
& !151-200 21-70
& // '12121212121212121212121212121212121212121211212121'
& !201-250 21-70
& // '12121212121212121212121212121212121212121211212121'
& !251-300 21-70
& // '12121212121212121212121212121212121212121212121212'
!301-350 21-70
! __20 25 30 35 40 45 50 55 60 65 70__
! cells col.
!234567890123456789012345678901234567890123456789012345678901234567890xx

read(goes(icep:icep),*) nn
goto(10,11) nn

10 print *, '10: ', 'goes=', goes(icep:icep)
goto 999
11 print *, '11: ', 'goes=', goes(icep:icep)
goto 999
999 end

Thomas Koenig

unread,
Jun 19, 2022, 6:12:47 AMJun 19
to
Ev. Drikos <drik...@gmail.com> schrieb:

> Does anybody know why there is such a restriction?
>
>
> ----------------------------------------------
> $ gfc --version 2>&1 | head -n1
> GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
> (Red Hat Linux 3.2.2-5)

Without looking at the code: g77 has not been maintained for a really
long time, and it only implements f77 + some extensions. I would not
be surprised by any restrictions of anything f90-like or later.

Ev. Drikos

unread,
Jun 19, 2022, 6:22:02 AMJun 19
to
Thanks for the feedback, the OP discussed F77. In this case version 8
issues a similar error as well:

$ gfortran8 -ffixed-form icep.f
icep.f:20:11:

read(goes(icep:icep),*) nn
1
Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable

Ev. Drikos

unread,
Jun 19, 2022, 9:49:42 AMJun 19
to
On 19/06/2022 13:21, Ev. Drikos wrote:
> ...
>
> $ gfortran8 -ffixed-form icep.f
> icep.f:20:11:
>
>        read(goes(icep:icep),*) nn
>            1
> Error: UNIT specification at (1) must be an INTEGER expression or a
> CHARACTER variable
>

Ok, an extra assignment to a variable could solve this issue, ie:

ch = go(icep:icep) !an extra assignment to a variable
read(ch, *) nn
goto(10,11) nn

Due to the fixed form format, the example is readable in my gists:
https://gist.github.com/drikosev/7f24acb6435f441d5d6f7be220efdbe9

Yet, the question remains open. Is it perhaps a compiler specific bug
or a standard restriction?

Thomas Koenig

unread,
Jun 19, 2022, 10:17:39 AMJun 19
to
Ev. Drikos <drik...@gmail.com> schrieb:
OK.

A look at the F2018 standard tells us, in 12.4, "Internal Files":

An internal file is a record file with the following properties.

• The file is a variable of default, ASCII, or ISO 10646 character
kind that is not an array section with a vector subscript.

and a bit further down

R1201 io-unit is file-unit-number
or *
or internal-file-variable

R1203 internal-file-variable is char-variable

and further up

R905 char-variable is variable
C905 (R905) char-variable shall be of type character.

and finally

R903 variable-name is name
C903 (R903) variable-name shall be the name of a variable.

And if anybody wonders what a variable is, it's defined in

3.154 variable
data entity that can be defined and redefined during execution of a program

So, since a parameter cannot be redefined during execution, using
an internal I/O statement on it is an error, and the processor
needs to be able to diagnose it.

Ron Shepard

unread,
Jun 19, 2022, 10:48:57 AMJun 19
to
It is a standard restriction in f77. I remember similar situations many
times in the 1980s.

12.2.5.1 Internal File Properties. An internal file has the following
properties:
(1) The file is a character variable, character array element, character
array, or character substring.

Most compiler writers interpreted that to mean that it could not be
either a literal or a parameter constant. I seem to recall there were
some exceptions, but I always took those exceptions as extensions to the
standard, so if portability was important, I avoided using parameters or
literal constants as internal files.

To be portable, you need to do the assignment, or you need to declare
goes(*) as a variable rather than a parameter. I never understood why
the limitation was in the standard. In my codes, I usually left a
comment explaining why the code was written that way so that I would not
change it a month later by mistake. That comment was, of course, a
separate line beginning with C or *, it was not on the same line. F77
was so limited in so many ways.

$.02 -Ron Shepard

gah4

unread,
Jun 20, 2022, 7:24:32 PMJun 20
to
On Sunday, June 19, 2022 at 7:48:57 AM UTC-7, Ron Shepard wrote:

(snip)

> It is a standard restriction in f77. I remember similar situations many
> times in the 1980s.

There were some strange restrictions in Fortran 66, some of which
were removed in Fortran 77.

The I/O list of READ and WRITE statements contains variables (and arrays)
but not constants or expressions. That is obvious for READ, but not
for WRITE.

I believe at the time, actually using WATFIV before 1977, that expressions
in the I/O list of WRITE statements was my favorite new feature.

In Fortran 66, the format part of a READ/WRITE statement is either a
statement number (of a FORMAT statement) or an array with a run-time
format, character data read in A format, or initialized in DATA statements.

Even if it fit i a scalar, it was required to be an array.

Fortran 77 added internal I/O, putting a character variable in place
of the unit number. There are some not so obvious restrictions on it,
but similar to above, can't be a constant.

And now, so many years later, we wonder why.


Phillip Helbig (undress to reply)

unread,
Jun 21, 2022, 6:38:52 AMJun 21
to
In article <66596868-5be6-48c3...@googlegroups.com>,
gah4 <ga...@u.washington.edu> writes:

> The I/O list of READ and WRITE statements contains variables (and arrays)
> but not constants or expressions. That is obvious for READ, but not
> for WRITE.

Vice versa?

Robin Vowels

unread,
Jun 21, 2022, 8:28:39 AMJun 21
to
On Wednesday, June 15, 2022 at 5:34:32 AM UTC+10, Lynn McGuire wrote:
> On 6/13/2022 7:19 PM, gah4 wrote:
> > On Monday, June 13, 2022 at 4:29:18 PM UTC-7, Lynn McGuire wrote:
> >
> > (snip)
> >
> >>> Depends on what you mean by regular Fortran. In f2003 and later the limit is 255, but in f95 it's 39 in free form, 19 in fixed form.
> >> I meant Standard Fortran.
> >
> > 66, 77, 90, 95, 2008, 2013, or 2018?
> >
> > There is a famous quote:
> >
> > "The nice thing about standards is that we have so many to choose from."
> Heh.
>
> F77 apparently allowed 19 continuation lines.
.
The standard required a minimum of 19 continuation lines.
.
> Open Watcom Fortran 77 is
> extended to allow up to 61 continuation lines.
.
Any compiler can exceed the minimum of 19.

Robin Vowels

unread,
Jun 21, 2022, 8:46:23 AMJun 21
to
.
> So ? We are not talking about PL/I.
.
Several languages have already been discussed in this thread, including PL/I.
.
PL/I can considerably shorten F77 code.
This instance, where a trivial PL/I statement can replace some 30-40 lines of F77,
might be worthy of further examination.

David Jones

unread,
Jun 21, 2022, 9:24:52 AMJun 21
to
John wrote:

> Well, for the first one for maintainability (and not wanting to even
> mention ASSIGN statements) and primarily for human intelligibility I
> might go with a way that worked even pre-f90;.

I don't think we were told enough about the context of all this. If
this bit of code is gone through often in a single execution, it may
well be worth doing some initialisation computations that can sort out
both maintainability and readability as well as overall speed of
execution. One could start with several lists of items of different
types, such as could be extended easily as necessary, and then go
through these lists automatically (once-only) to construct sufficient
cross-referencing etc. so that you can readily know what needs to be
done whenever a decision is needed.

Lynn McGuire

unread,
Jun 21, 2022, 7:44:51 PMJun 21
to
In this case, the software program is 850,000 lines of F77, C and C++.
90% currently F77. Adding anything PL/1 is simply not an option.

Lynn

Lynn McGuire

unread,
Jun 21, 2022, 7:46:52 PMJun 21
to
This code is used in initialization during the processing of the input
commands for the model. There can be thousands of input commands.

I am planning on converting this code from F77 to C++ some day and
wondering how this code will move across.

Lynn

gah4

unread,
Jun 21, 2022, 9:21:46 PMJun 21
to
On Tuesday, June 21, 2022 at 4:44:51 PM UTC-7, Lynn McGuire wrote:

(snip)
> In this case, the software program is 850,000 lines of F77, C and C++.
> 90% currently F77. Adding anything PL/1 is simply not an option.

PL/I has statement label variables, which in some cases make for
nicer or smaller code. For this problem, that doesn't help much.

One thing is that PL/I statement labels are alphanumeric,
(with initial letter) like variable names. Sometimes that makes
them more readable, if you give mnemonic names. If ...

It seems that Pascal uses numeric labels to discourage their use.
The WEB system used to write TeX has macros to give them names.

If it helped, you could use a macro system to rename your numeric
labels for readability. You might find that other parts could be made
more readable, too.

p.ki...@ic.ac.uk

unread,
Jul 12, 2022, 1:54:05 PMJul 12
to
Lynn McGuire <lynnmc...@gmail.com> wrote:
> One of my favorite things about C++ is that I can declare variables all
> over the place. With an average of 2,000 lines of code per subroutine,
> it would be nice to locate the variable declarations at their usage.

I did that once with some C ... and it then ran about
ten times slower :-/

#Paul

Lynn McGuire

unread,
Jul 12, 2022, 2:56:33 PMJul 12
to
That makes no sense whatsoever. I do not see that behavior in my
450,000 line C++ Windows user interface program.

Lynn

gah4

unread,
Jul 12, 2022, 3:05:10 PMJul 12
to
As well as I know it for C, I am less sure for C++, the allocation is the
same, independent of where the declarations are. It should not change
run time behavior.

I suppose that some optimizers might work different, depending on
such declarations, though that shouldn't actually happen.

Automatic variables are allocated on function entry.

Thomas Koenig

unread,
Jul 12, 2022, 3:53:52 PMJul 12
to
gah4 <ga...@u.washington.edu> schrieb:
Not necessarily - there is no need to reserve a stack slot
when the value is no longer needed.

Plus, sometimes it is cheaper to recompute than to spill
and reload, but that's one of the hardest decisions to
make in compilers :-)

jfh

unread,
Jul 12, 2022, 5:15:13 PMJul 12
to
Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.

gah4

unread,
Jul 12, 2022, 6:01:51 PMJul 12
to
On Tuesday, July 12, 2022 at 2:15:13 PM UTC-7, jfh wrote:

(snip)

> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.

Different question.

Blocks in ALGOL, BEGIN blocks in PL/I, and some others in other languages, allow for allocation of automatic variables.
(PL/I has DO blocks which are only for grouping, and not allocation or scoping.)

Actually, it might have changed over different versions of C, but at least for some there is no allocation.



Ron Shepard

unread,
Jul 13, 2022, 2:18:21 AMJul 13
to
On 7/12/22 4:15 PM, jfh wrote:
> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.

How exactly does this work in fortran. If you have a block with local
variables, are they allocated afresh when the block is entered and
deallocated upon block exit, or are they just allocated once? What if
the block is within a loop?

$.02 -Ron Shepard

pehache

unread,
Jul 13, 2022, 5:33:55 AMJul 13
to
I haven't checked, but to me a BLOCK is similar to a contained
subroutine, with the same rules concerning the variable that are
declared locally.

If the variable is "allocatable" it is automatically deallocated upon
exit of the the block.

If the variable is "save" then the compiler statically allocates it at
compile time.

For other cases it's up to the compiler to decide between a static
allocation at compile time or an automatic allocation on the stack at
runtime.

--
"...sois ouvert aux idées des autres pour peu qu'elles aillent dans le
même sens que les tiennes.", ST sur fr.bio.medecine
ST passe le mur du çon : <j3nn2h...@mid.individual.net>

Robin Vowels

unread,
Jul 13, 2022, 9:14:24 AMJul 13
to
On Wednesday, July 13, 2022 at 8:01:51 AM UTC+10, gah4 wrote:
> On Tuesday, July 12, 2022 at 2:15:13 PM UTC-7, jfh wrote:
>
> (snip)
> > Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.
> Different question.
>
> Blocks in ALGOL, BEGIN blocks in PL/I,
.
and PROCEDURE blocks in PL/I

> and some others in other languages, allow for allocation of automatic variables.
> (PL/I has DO blocks which are only for grouping, and not allocation or scoping.)
.
PL/I does not have DO blocks. PL/I has DO groups.

Thomas Koenig

unread,
Jul 13, 2022, 12:51:46 PMJul 13
to
Ron Shepard <nos...@nowhere.org> schrieb:
The compiler will look at the lifetime of the variable and allocate
it on the stack or in a register accordingly. A modern compiler
will, when optimizing, reuse stack slots if possible, with or
without help from the programmer through BLOCK statements.

Compilers have gotten quite good :-)

Also, the intermediate form that compilers use these days,
single static assignment, makes this optimization necessary.
Basically, any assignment to any variable creates a new
variable, so something like

i = 42
j = 2
i = i + j
j = j + i

will be translated to

i_1 = 42
j_1 = 2
i_2 = i_1 + j_1
j_2 = j_1 + i_2

and the compiler will determine that i_1 is no longer
in use, and will drop it.

Anything I learned in my C-64 Basic days about re-using
variables to save space, I had to unlearn :-)

Lynn McGuire

unread,
Jul 13, 2022, 2:28:33 PMJul 13
to
Yup, we are memory pigs nowadays. I only start to worry about variables
being too large when I declare double precision arrays of more than a
million members. It is just not worth my time to optimize the usage.
And the old memory optimizations in our code are a total pain now.

Lynn


Thomas Koenig

unread,
Jul 13, 2022, 2:49:08 PMJul 13
to
Lynn McGuire <lynnmc...@gmail.com> schrieb:
The nice thing about modern compilers is that, while they use
a lot of memory and a lot of CPU time, they are quite good at
efficient optimization, and also at saving memory if you specify
the right options. Using a modern compiler, the code two codes
above will eventually be optimized into two assignments.

James Van Buskirk

unread,
Jul 15, 2022, 12:47:21 PMJul 15
to
"Ron Shepard" wrote in message news:JstzK.25578$kY1....@fx06.iad...
In some instances allocation on entry and deallocation on exit will
definitely be required. Thus the simplest implementation would be
to always do so.

D:\gfortran\clf\blockloop>type blockloop.f90
program blockloop
implicit none
integer i
do i = 1, 15
BLOCK
character(i) fun
write(*,'(*(g0))') fun()
END BLOCK
end do
end program blockloop

function fun()
implicit none
character(*) fun
integer i
do i = 1, len(fun)
fun(i:i) = achar(iachar('0')+modulo(i,10))
end do
end function fun
D:\gfortran\clf\blockloop>gfortran blockloop.f90 -oblockloop

D:\gfortran\clf\blockloop>blockloop
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345

Reply all
Reply to author
Forward
0 new messages