How to Compile MSES Software with Unexpected Syntax in Fortran?

  • Context: Fortran 
  • Thread starter Thread starter jasonbot
  • Start date Start date
  • Tags Tags
    Software
Click For Summary
SUMMARY

The forum discussion focuses on compiling the MSES software, written in Fortran by Mark Drela, specifically addressing issues with the subroutine dplot.f. The main problem arises from the use of the dollar sign ($) in variable names, which is not standard in Fortran. Users are advised to compile the code using the gfortran compiler with the option -fdollar-ok to allow this syntax. Additionally, the discussion highlights the importance of adhering to standard naming conventions to avoid complications with different compilers.

PREREQUISITES
  • Familiarity with Fortran programming language
  • Understanding of gfortran compiler options
  • Basic knowledge of subroutines and modules in Fortran
  • Awareness of standard naming conventions in programming
NEXT STEPS
  • Research gfortran compiler options, specifically -fdollar-ok
  • Learn about standard naming conventions in Fortran
  • Explore the use of logical operators in Fortran, including .xor.
  • Investigate the differences between Fortran compilers, such as gfortran and ifort
USEFUL FOR

This discussion is beneficial for Fortran developers, software engineers working with legacy code, and anyone involved in compiling scientific software that utilizes non-standard syntax.

jasonbot
Messages
16
Reaction score
0
Hello,

I'm trying to compile some software called MSES, its written by Mark Drela in some fortran flavour. I've successfully compiled a number of subroutines through make files but there is one subroutine giving me grief. It's called dplot.f.

It has a strage syntax I can't seem to work around:

Code:
     SUBROUTINE DPLOT
      INCLUDE 'STATE.INC'     
      INCLUDE 'MPLOT.INC'
C-----------------------------------------------------------
C     Reads in data file or reference profiles and plots them
C     superimposed on calculated profiles.  The profiles are
C     plotted in proper location on actual airfoil.
C-----------------------------------------------------------
C
      CHARACTER*40 FNAME, LINE, uname
      PARAMETER (IPRX=40,KPRX=240)
      DIMENSION XX(KPRX), YY(KPRX)
      DIMENSION APR(IPRX), XPR(IPRX), YPR(KPRX,IPRX), UPR(KPRX,IPRX)
      DIMENSION YADD(IPRX), YPRFAC(IPRX), UPRFAC(IPRX)
      DIMENSION DSPR(IPRX), THPR(IPRX), TSPR(IPRX)
      INTEGER KK(IPRX), NXPR(IPRX)
      LOGICAL LUPR, LTPR
c
      parameter (jprx=isx*200)
      dimension nsum$(jprx)
      dimension y$(jprx), u$(jprx), uinv$(jprx), udef$(jprx)

...

the dollar sign after a variable name, as in nsum$, makes no sense to me. Coming from MATLAB this wouldn't be a valid variable name and in my fortran compiler (tried both f77 and gfortran) it tells me a number of different errors about invalid forms and type disagreements. Removing the dollar signs gives errors relating to invalid declarations.

Does anyone have any idea how to fix my code?
 
Technology news on Phys.org
Use gfortran -fdollar-ok

Use gfortran with option -fdollar-ok:

Sample
Code:
c    file foo.f
      program foo
      real pi$
      parameter (pi$ = acos(-1.0)) 
      write(*,*) pi$   
      end program foo

Reproducing the error
Code:
gfortran foo.f
foo.f:3.14:

      real pi$                                                          
              1
Error: Invalid character '$' at (1). Use -fdollar-ok to allow it as an extension
foo.f:4.20:

      parameter (pi$ = acos(-1.0))                                      
                    1
Error: Invalid character '$' at (1). Use -fdollar-ok to allow it as an extension
foo.f:5.20:

      write(*,*) pi$                                                    
                    1
Error: Invalid character '$' at (1). Use -fdollar-ok to allow it as an extension

Fixing it
Code:
gfortran -fdollar-ok foo.f
echo $?
0
But despite this fix I would strongly discourage using non-standard names in self-written code.

Cheers, Solkar
 
  • Like
Likes   Reactions: 1 person
Thank you Solkar.

What do you mean by using non standard names?

I'm new to fortran and wouldn't say I'm keen to learn it. I just need to use the programme for some work.

After using your suggestion it seemed to have compiled correctly although now I have some problems with additional modules with the error:

CHANGE = CHANGE .OR. (LMOD1(K,IP).XOR.LMOD(K,IP))
1
Error: Unknown operator 'xor' at (1)

I don't think ill bother investigating it because its a module I don't need.
 
jasonbot said:
Thank you Solkar.
What do you mean by using non standard names?
Names which require tricking the compiler into eating them, like those ending with a "$" you asked for.

jasonbot said:
CHANGE = CHANGE .OR. (LMOD1(K,IP).XOR.LMOD(K,IP))
1
Error: Unknown operator 'xor' at (1)

I think intel's ifort has .xor. defined by default, but gfortran apparently doesn't.
Standard Fortran has
Code:
A .neqv. B
for XORing of logical A,B, and it's common wisdom that most compilers support
Code:
ieor(i,j)
for bitwise XORing of integer i,j.
 
  • Like
Likes   Reactions: 1 person

Similar threads

  • · Replies 3 ·
Replies
3
Views
12K