https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65975
Bug ID: 65975 Summary: !$ is not recognized as a comment when -fopenmp flag is used Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: CPonder at nVidia dot Com Target Milestone: --- I'm working with WRF, the Weather Research Forecasting model. One of the Fortran files contains these lines 1336 !$ external, logical:: omp_in_parallel 1337 !$ external, integer:: omp_get_thread_num Evidently the programmer decided to comment-out these declarations by changing !$OMP --> !$ By my reading of the Fortran standard, this is a legal comment, though I would much rather have done !$OMP --> !!$OMP since it's clearer on what had been commented-out. Regardless, if I compile the file using the -fopenmp flag, I get the error !$ external, logical:: omp_in_parallel 1 Error: Invalid character in name at (1) module_fr_fire_util.orig.F:1337:12: !$ external, integer:: omp_get_thread_num 1 Error: Invalid character in name at (1) This error does not happen if I don't use the -fopenmp flag, so it looks like the parser is insisting on the !$ form denoting a directive whether it is well-formed or not. Again, I believe this mal-formed directive is still valid as a comment under the Fortran standard, and should be treated as such, not triggering an error. Perhaps a warning would be better? !$ external, logical:: omp_in_parallel 1 Warning: possible mal-formed OMP or ACC directive at (1) (if -fopenmp was used, I'd flag it as a possible OMP directive; if -fopenacc had been used, I would flag it as a possible ACC directive. I both flags are used, I'd state as above). As an aside, the PGI compiler doesn't trigger any error here. Also we're working on changing the WRF source code to clean this up.