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

Better a select vs. Character or Integer?

Allamarein
Beginner
771 Views
I have to run a select to interpret a variable. Actually the select case is based on character(len=10) variable, but I could substitute that with an integer. If I did that, would I improve the speed of my code? Pratically speaking, dealing with character vars slows the code? Regards
0 Kudos
2 Replies
Steven_L_Intel1
Employee
771 Views

My first advice is to use whichever makes the program easier to understand. If you have analyzed performance and found the SELECT to be a bottleneck, then changing to integer may help because the compiler can better optimize that. I wouldn't waste any time on this, however, unless it was demonstrated to be a problem.

0 Kudos
Allamarein
Beginner
771 Views
In fact I preferred using character, because it allows to better understand the meaning. Using an integer as an identification code would require a table to browser each time to guess what the code does. I will follow your advice. Perhaps this is the last of my problem today. Thanks
0 Kudos
Reply