How can I implement the syntax highlight under the Linux OS?

Does the PGI Fotran Compiler support the syntax highlight under the Linux operating system in the .cuf file?

And how should I set it up?

Hi OceanCloud,

The compilers themselves don’t support syntax highlighting; that would be something a text editor or IDE would do. Are you asking about a particular editor?

I personally just use command line vi, without any sort of highlighting so may not be the best person to answer, but if you can give more information then maybe another user can help.

  • Mat

Thanks anyway, Mat

It’s my fault that I didn’t point out the edit.

I aslo use command line vi, when the source code has a .f90 suffix, the key words highlighting themselves, but when writing CUDA Fortran routines, the .cuf suffix is suggested and the syntax highlight become invalid.

Is there someone can recommend an edit?

You can customize emacs to treat .cuf files as Fortran files and highlight the syntax accordingly.

I have a setup on my boxes where I do syntax highlighting of CUDA Fortran files. I’ve even made up a syntax/cudafor.vim file so it highlights all the CUDA Fortran keywords (as of maybe a year ago, so it’s possible I’m missing some…I should update those). I’ll gladly share them if wanted.

That said, the way one can get vim to see a .cuf as a Fortran is to put in your .vimrc:

   au BufNewFile,BufRead *.cuf,*.CUF set ft=fortran
   au BufRead,BufNewFile *.cuf,*.CUF let b:fortran_do_enddo=1
   au BufRead,BufNewFile *.cuf,*.CUF set tw=132

The first line essentially means if it reads or creates a .cuf or .CUF file, it sets the filetype to ‘fortran’ and treats it as such. I also add that fortran_do_enddo one because I like my Fortran loops indented and I set the textwidth to 132 so I don’t wrap my code to early.

Now, as I said, on my systems I have a set of cudafor.vim files which, essentially, are the fortran.vim ones, but with some extra syntax highlighting for CUDA words.

Hi, TheMatt

What you’ve said is just what I have been searching.

Can you send me your cudafor.vim file to me, my email is hbdyfhy@gmail.com

Great thankful in advance.

OceanCloud,

Sure thing. I’ll send it…and then you can obscure your email address so you don’t get spammed to infinity!

Also, I’ve been in contact with the person who does the Fortran syntax highlighting for Vim. I’m hoping working with him, we can find a way to get some sort of CUDA Fortran highlighting in Vim.

Matt