[Mesa-users] f90 modules in f77

RICHARD H D TOWNSEND townsend at astro.wisc.edu
Fri Dec 8 14:03:20 EST 2017


Yes, more or less!

> On Dec 8, 2017, at 1:02 PM, Travis Metcalfe <travis at spsci.org> wrote:
> 
> Thanks, this is helpful. When I add "use [module], only: [variable]" to my fixed-source code, I can then "print *,[variable]" as long as the variable is declared as "public" in the module. Works just like a common block.
> 
> Travis
> 
> 
> On Fri, 8 Dec 2017, Rob Farmer wrote:
> 
>>> However, we're not using any F77 compilers. The F77 program will be
>> compiled with an F90 compiler, right? In that case, it should be no
>> problem. Just add the "use blahblah" to the F77 program.
>> 
>>> As an aside: thinking of a file as 'F77' or 'F90' is not quite right. You
>> should think of .f files as 'fixed-source' files (with formatting
>> constraints, e.g. start on the 6th column); and .f90 files are
>> 'free-source' files (without these constraints). Both can contain valid
>> Fortran 77/90/95/2003/etc code. In that respect, any valid fixed-source
>> Fortran 77 file is automatically a valid fixed-source Fortran 90 file.
>> 
>> As an example look at the code in $MESA_DIR/net/test/src These are .f files
>> but have use module statements, some are modules themselves
>> 
>> Rob
>> 
>> On 8 December 2017 at 19:14, RICHARD H D TOWNSEND via Mesa-users <
>> mesa-users at lists.mesastar.org> wrote:
>> 
>>> I think it would be difficult to use an F90 module from an F77 program
>>> compiled with an F77 compiler.
>>> 
>>> However, we're not using any F77 compilers. The F77 program will be
>>> compiled with an F90 compiler, right? In that case, it should be no
>>> problem. Just add the "use blahblah" to the F77 program.
>>> 
>>> As an aside: thinking of a file as 'F77' or 'F90' is not quite right. You
>>> should think of .f files as 'fixed-source' files (with formatting
>>> constraints, e.g. start on the 6th column); and .f90 files are
>>> 'free-source' files (without these constraints). Both can contain valid
>>> Fortran 77/90/95/2003/etc code. In that respect, any valid fixed-source
>>> Fortran 77 file is automatically a valid fixed-source Fortran 90 file.
>>> 
>>> cheers,
>>> 
>>> Rich
>>> 
>>>> On Dec 8, 2017, at 12:05 PM, Travis Metcalfe <travis at spsci.org> wrote:
>>>> 
>>>> Hello,
>>>> 
>>>> I'm looking for a way to share data between some older f77 code and the
>>> MESA/GYRE modules. In f77, subroutines could share data with each other
>>> through common blocks. This appears to be replaced with modules and "use
>>> [module name]" in f90.
>>>> 
>>>> What I have been unable to find online or in the mesa-users archive is
>>> how to use an f90 module from an f77 program. Is it possible?
>>>> 
>>>> Thanks,
>>>> 
>>>> Travis
>>> 
>>> 
>> 




More information about the Mesa-users mailing list