Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary/unary operator precedence error on Cray compiler #72

Open
grantfirl opened this issue May 19, 2023 · 1 comment · Fixed by ufs-community/ufs-weather-model#1754
Labels
bug Something isn't working

Comments

@grantfirl
Copy link
Collaborator

This issue was reported by @michalakes

Description

There are violations of the Fortran standard that prevent module_bl_mynn.F90 and perhaps other components of CCPP physics from compiling with the Cray compiler on Narwhal (the DoD HPC system we’re using).

Gnu generates warning messages but compiles anyway. Cray just flat out generates an error:

ftn-855 ftn: ERROR MODULE_BL_MYNN, File = ccpp/ccpp-physics/physics/module_bl_mynn.F90, Line = 239, Column = 8

The compiler has detected errors in module "MODULE_BL_MYNN". No module information file will be created for this module.

ftn-1725 ftn: ERROR MYNN_MIX_CHEM, File = /ccpp/ccpp-physics/physics/module_bl_mynn.F90, Line = 5481, Column = 26

Unexpected syntax while parsing the assignment statement : "operand" was expected but found "-".

ftn-1725 ftn: ERROR PHIM, File = /ccpp/ccpp-physics/physics/module_bl_mynn.F90, Line = 7675, Column = 45

Unexpected syntax while parsing the assignment statement : "operand" was expected but found "-".

ftn-1725 ftn: ERROR PHIH, File = ccpp/ccpp-physics/physics/module_bl_mynn.F90, Line = 7726, Column = 45

Unexpected syntax while parsing the assignment statement : "operand" was expected but found "-".

In each of the referenced lines, there is an instance of a binary operator (*) followed immediately by a unary operator (-); for example,

5474 DO ic = 1,nchem

5475 k=kts

5476

5477 a(k)= -dtz(k)*khdz(k)*rhoinv(k)

5478 b(k)=1.+dtz(k)*(khdz(k+1)+khdz(k))rhoinv(k) - 0.5dtz(k)*rhoinv(k)*s_aw(k+1)

5479 c(k)= -dtz(k)*khdz(k+1)rhoinv(k) - 0.5dtz(k)*rhoinv(k)*s_aw(k+1)

5480 d(k)=chem1(k,ic) & !dtz(k)*flt !neglecting surface sources

5481 & + dtz(k) * -vd1(ic)*chem1(1,ic) &

5482 & - dtz(k)*rhoinv(k)*s_awchem(k+1,ic)

The Fortran standard explicitly (and, I would say, arbitrarily) disallows consecutive operators and requires the order of operations be made explicit with parentheses:

5481 & + dtz(k) * -(vd1(ic)*chem1(1,ic)) &

I was able to find a reference:

“Fortran doesn’t allow consecutive operators! (Many compilers, Intel Fortran for example,

will let you do this as an extension, but it’s non-standard). To conform to the standard you would

have to write this [using explicit parentheses]).”

https://stevelionel.com/drfortran/2021/04/03/doctor-fortran-in-order-order/

Steps to Reproduce

Compile module_bl_mynn.F90 with Cray compiler. Note that the GNU compiler issues warnings for this same issue.

@joeolson42
Copy link
Collaborator

Thanks John. We'll get this in immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants