Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Select case block vs array of function pointers

FilippoMonari
Beginner
1,383 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 III
1,354 Views

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

0 Kudos
FortranFan
Honored Contributor III
1,351 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 III
1,349 Views
0 Kudos
Reply