NCAR / MOM6

NCAR/CESM fork of the Modular Ocean Model v.6 (MOM6)
Other
3 stars 20 forks source link

Incorrect use of atan intrinsic function #324

Open jedwards4b opened 1 day ago

jedwards4b commented 1 day ago

the intrinsic function atan has only one argument, but it is used with two here. This is causing an error in the nvhpc compiler. I'm not sure why the other compilers do not complain?

marshallward commented 1 day ago

Hi Jim, the standard supports interfaces with both one and two arguments. This could be an Nvidia bug.

marshallward commented 1 day ago

I think changing this atan2 might be a safe option.

jedwards4b commented 1 day ago

@marshallward Thanks, I found a reference here. I'll try atan2 and also see if I can file an issue with nvidia.

jedwards4b commented 1 day ago

Using atan2 appears to work. This was tested with nvhpc/24.3 and nvhpc/24.9 using test:

program test_atan2
  real(4) :: x = 1.e0_4, y = 0.5e0_4
  real(4) :: z
  z = atan(y,x)
  print *,'atan(',y,',',x,') =',z 
  z = atan2(y,x)
  print *,'atan2(',y,',',x,') =',z
end program test_atan2

nvfortran testatan.F90 /usr/bin/ld: /glade/derecho/scratch/cesmrt/tmp/nvfortranYcyvwwAdBk4T.o: in function `MAIN': /glade/u/home/cesmrt/testatan.F90:4: undefined reference to `atan'