Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
27549 Discussions

Select case block vs array of function pointers

FilippoMonari
Beginner
437 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
408 Views

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

FortranFan
Honored Contributor II
405 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
403 Views
Reply