Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27425 Discussions

Select case block vs array of function pointers

FilippoMonari
Beginner
416 Views

Hi all, 

I would like some advice about the following. I have a quite big SELECT CASE block where cases are unique integers. The block includes about 200 cases representing different functions. I was wondering if I could get any benefit in terms of speed by replacing the big SELECT CASE block with an array pointers pointing to functions to apply. Thanks in advance.

Regards,

Filippo

0 Kudos
1 Solution
3 Replies
JohnNichols
Valued Contributor II
387 Views

Pick the one that is easy to maintain - although 200 seems a lot 

FortranFan
Honored Contributor II
384 Views

@FilippoMonari ,

Since your question is general Fortran, you may want to consider posting it at Fortran Discourse site (and possibly also USENET based comp.lang.fortran) for wider feedback: 

By the way, here's a long thread toward a similar discussion at comp.lang.fortran a while ago that may help you with some pointers:  https://groups.google.com/g/comp.lang.fortran/c/6uROcAIvPcQ/m/ULl1Muz0CAAJ

Ultimately I think you'll have to figure out what works best for you.

FortranFan
Honored Contributor II
382 Views
Reply