jeudi 13 août 2020

Compact if check involving multiple strings in Fortran

Is there a way to check if a string is equal to any of the list together instead of individually explicitly check with a ==? For example,

if(color=='violet' .or. color=='indigo' .or. color=='blue' .or.&
   color=='green' .or. color=='yellow' .or. color=='orange' .or. color=='red') then
   print *, "It is a rainbow color"
end if

Is there a way compact way to do this? Something like if(color=='violet|indigo|blue|green|yellow|orange|red') ?

Aucun commentaire:

Enregistrer un commentaire