.m and .sm file extension

Hello,
I would like to ask that, is it possible to have .m and .sm file extension for module and submodule files respectively. I think it will create a visual means to differentiate files just by its extension alone. Then .f90 can be reserved for the main file.

Thank you

.m is the extension for MATLAB and GNU Octave scripts.

You can force gfortran to treat any file as (free) form source using option -x f95 filename(s). But I’d say it’s not a good idea. If you really want to make a visual distinction in file names, use xxx_m.f90, xxx_sm.f90

3 Likes

I agree with others that using .m for module source files is not a good idea. All of my main program files start with the letter x, and if there is a module stats.f90 to compute statistics there will be a main program named xstats.f90 to test it.

I’ll also comment that you can have a mix of program unit types in a single source file. It’s bad enough that some compilers (and users) try to use file types to indicate standard version (or so they think), corrupting it even more for program unit type is untenable.

Thank you. I didn’t know matlab and Octave used .m file extension but I can see the confusion it will create.

Thank you for the tip, I am going to do it as you suggested.

Thank you @Beliavsky and @sblionel for clarifying, why it’s not a good idea to use .m and .sm file extension and the problem it will create.

Don’t let the reactions discourage you :slight_smile: Even if an idea turns out to be bad for reasons you did not think of, it can inspire discussions and other ideas, but also clarify things. And in general, we are a friendly lot.

Please don’t worry about it. I am not discouraged at all, in fact I am thinking how about using .fm and .fsm for module and submodule :sweat_smile:. These will read as fortran module and fortran submodule respectively.

I have stuck to . F90 and _subm.F90 for submodules, and this leaves the defaults to operate normally for preprocessor etc, but I have not looked at the stdlib conventions, and that may be the best long term option. Enjoy