Skip to content

Commit 5bcbde6

Browse files
Fix Debug compilation (#800)
Update (and simplify) the Intel "Debug" compile flags to match those required by NCO. Minor updates to the regional_esg_grid code so it can be compiled in "Debug" mode on WCOSS2. Fixes #735.
1 parent 7aebdfe commit 5bcbde6

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ endif()
6464
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
6565
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback")
6666
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model precise")
67-
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check -check noarg_temp_created -check nopointer -fp-stack-check -fstack-protector-all -fpe0 -debug -ftrapuv")
67+
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check all -ftrapuv")
6868
if(APPLE)
6969
# The linker on macOS does not include `common symbols` by default.
7070
# Passing the -c flag includes them and fixes an error with undefined symbols.
@@ -77,9 +77,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
7777
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz")
7878
endif()
7979
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
80-
# set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -Wall")
81-
set(CMAKE_Fortran_FLAGS_DEBUG "-O1 -ggdb -Wall -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -fno-omit-frame-pointer -fno-optimize-sibling-calls")
82-
# set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -Wall -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -fno-omit-frame-pointer -fno-optimize-sibling-calls")
80+
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=all")
8381
endif()
8482

8583
if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")

sorc/grid_tools.fd/regional_esg_grid.fd/pesg.f90

+3-2
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,14 @@ subroutine xmtoxc_vak1(ak,xm,xc,xcd,xc1,xcd1,ff)! [xmtoxc_ak]
406406
logical, intent(out):: ff
407407
real(dp),dimension(3,2,2):: xcdd
408408
real(dp),dimension(2,2,2):: xsd1,xsdd
409-
real(dp),dimension(2,2) :: xtd,xsd,xs1,xtd1,xsdk
409+
real(dp),dimension(2,2) :: xtd,xsd,xs1,xtd1,xsdk,mat22
410410
real(dp),dimension(2) :: xt,xt1,xs,xsk
411411
integer(spi) :: i
412412
call xmtoxt1(ak(1),xm,xt,xtd,xt1,xtd1,ff); if(ff)return
413413
call xttoxs1(ak(2),xt,xs,xsd,xsdd,xsk,xsdk,ff); if(ff)return
414414
xs1(:,2)=xsk; xs1(:,1)=matmul(xsd,xt1)
415-
xsd1(:,:,1)=matmul(xsd,xtd1)+matmul(xsdd(:,:,1)*xt1(1)+xsdd(:,:,2)*xt1(2),xtd)
415+
mat22=xsdd(:,:,1)*xt1(1)+xsdd(:,:,2)*xt1(2)
416+
xsd1(:,:,1)=matmul(xsd,xtd1)+matmul(mat22,xtd)
416417
xsd1(:,:,2)=matmul(xsdk,xtd)
417418
xsd=matmul(xsd,xtd)
418419
call xstoxc(xs,xc,xcd,xcdd)

sorc/grid_tools.fd/regional_esg_grid.fd/psym2.f90

+7-4
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ subroutine logsym2d(x,z,zd)! [logsym2]
411411
real(dp),dimension(2,2), intent(in ):: x
412412
real(dp),dimension(2,2), intent(out):: z
413413
real(dp),dimension(2,2,2,2),intent(out):: zd
414-
real(dp),dimension(2,2):: vv,oo,d11,d12,d22,pqr
414+
real(dp),dimension(2,2):: vv,oo,d11,d12,d22,pqr,d11pqr,d12pqr,d22pqr
415415
real(dp) :: c,s,cc,cs,ss,c2h,p,q,r,lp,lq,L
416416
integer(spi) :: i
417417
call eigensym2(x,vv,oo)
@@ -424,9 +424,12 @@ subroutine logsym2d(x,z,zd)! [logsym2]
424424
d12(1,:)=(/-cs,c2h/); d12(2,:)=(/c2h,cs/)
425425
d22(1,:)=(/ ss,-cs/); d22(2,:)=(/-cs,cc/)
426426
pqr(1,:)=(/p,r/) ; pqr(2,:)=(/r,q/)
427-
zd(:,:,1,1)=matmul(vv,matmul(d11*pqr,transpose(vv)))
428-
zd(:,:,1,2)=matmul(vv,matmul(d12*pqr,transpose(vv)))
429-
zd(:,:,2,2)=matmul(vv,matmul(d22*pqr,transpose(vv)))
427+
d11pqr=d11*pqr
428+
d12pqr=d12*pqr
429+
d22pqr=d22*pqr
430+
zd(:,:,1,1)=matmul(vv,matmul(d11pqr,transpose(vv)))
431+
zd(:,:,1,2)=matmul(vv,matmul(d12pqr,transpose(vv)))
432+
zd(:,:,2,2)=matmul(vv,matmul(d22pqr,transpose(vv)))
430433
zd(:,:,2,1)=zd(:,:,1,2)
431434
end subroutine logsym2d
432435

0 commit comments

Comments
 (0)