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

updates for flang-new-17 #886

Merged
merged 14 commits into from
Oct 15, 2023
6 changes: 6 additions & 0 deletions .github/workflows/github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ jobs:
armci_network: MPI-TS
nwchem_modules: "nwdft driver solvation mp2_grad mcscf ccsd rimp2 fcidump nwc_columbus"
fc: ifx
- os: ubuntu-22.04
experimental: true
mpi_impl: mpich
armci_network: MPI-TS
nwchem_modules: "nwdft driver solvation"
fc: flang-new-17
fail-fast: false
env:
MPI_IMPL: ${{ matrix.mpi_impl }}
Expand Down
38 changes: 27 additions & 11 deletions src/config/makefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2181,10 +2181,14 @@ ifneq ($(TARGET),LINUX)
FOPTIONS += -ffast-math #-Wunused
endif
ifeq ($(V),-1)
ifeq ($(FLANG_LT_17),true)
FOPTIONS += -w
endif
COPTIONS += -w
else
FOPTIMIZE += -Wuninitialized
ifneq ($(USE_FLANG),1)
FOPTIMIZE += -Wuninitialized
endif
ifeq ($(_CC),$(findstring $(_CC),gcc clang))
COPTIONS += -Wall
endif
Expand All @@ -2193,20 +2197,28 @@ ifneq ($(TARGET),LINUX)
FOPTIMIZE += -Wno-maybe-uninitialized
endif
else
FOPTIONS += -Wuninitialized
ifneq ($(USE_FLANG),1)
FOPTIONS += -Wuninitialized
endif
endif
endif

DEFINES += -DGFORTRAN
DEFINES += -DCHKUNDFLW -DGCC4

ifeq ($(USE_FLANG),1)

GNU_GE_4_6=true
FOPTIONS+=-mcmodel=medium
FOPTIONS+=-mcmodel=medium -fno-backslash
COPTIONS+=-mcmodel=medium
CFLAGS_FORGA = -mcmodel=medium
FFLAGS_FORGA = -mcmodel=medium
FOPTIONS+=-fno-backslash
FLANG_VERSION=$(shell $(FC) --version |head -1 |cut -d ' ' -f 4 |cut -d . -f 1)
FLANG_LT_17 = $(shell [ $(FLANG_VERSION) -lt 17 ] && echo true)
ifeq ($(FLANG_LT_17),true)
FOPTIONS+=-mcmodel=medium
COPTIONS+=-mcmodel=medium
CFLAGS_FORGA = -mcmodel=medium
FFLAGS_FORGA = -mcmodel=medium
else
DEFINES += -D__FLANG
endif
else
GNUMAJOR=$(shell $(FC) -dM -E - < /dev/null 2> /dev/null | grep __GNUC__ |cut -c18-)
ifdef GNUMAJOR
Expand Down Expand Up @@ -2707,7 +2719,9 @@ ifneq ($(TARGET),LINUX)

LINK.f = $(FC) $(LDFLAGS)
FOPTIMIZE += -O3
FOPTIMIZE += -mfpmath=sse #
ifneq ($(USE_FLANG),1)
FOPTIMIZE += -mfpmath=sse #
endif

ifeq ($(GNU_GE_6),true)
FOPTIMIZE += -fno-tree-dominator-opts # solvation/hnd_cosmo_lib breaks
Expand Down Expand Up @@ -2753,7 +2767,9 @@ ifneq ($(TARGET),LINUX)

ifeq ($(GNU_GE_4_6),true)
ifeq ($(shell $(CNFDIR)/check_env.sh $(USE_HWOPT)),1)
FOPTIMIZE += -mtune=native
ifneq ($(USE_FLANG),1)
FOPTIMIZE += -mtune=native
endif
endif
ifdef GFORTRAN_MARCH
FOPTIMIZE += -march=$(GFORTRAN_MARCH)
Expand Down Expand Up @@ -3975,7 +3991,7 @@ endif
#
V = 0
ACTUAL_FC := $(FC)
NWFC_-1 = @echo "Compiling $<..."; $(ACTUAL_FC)
NWFC_-1 = @echo "Compiling $<..."; $(ACTUAL_FC) 2> >(grep -v warning|grep -v '\^\^' |grep -v previous\ ref >&2)
NWFC_0 = @echo "Compiling $<..."; $(ACTUAL_FC)
NWFC_1 = $(ACTUAL_FC)
NWFC = $(NWFC_$(V))
Expand Down
2 changes: 2 additions & 0 deletions src/config/strip_compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ elif [[ "$1" == *cc* ]] && [[ ! -z $_CC ]]; then
echo $_CC
elif [[ "$1" == *gfortran* ]] ; then
echo gfortran
elif [[ "$1" == *flang* ]] ; then
echo flang
else
echo $(basename -- $1 | cut -d \- -f 1 | sed 's/[0-9]*//g')
fi
Expand Down
3 changes: 3 additions & 0 deletions src/geom/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ include ../config/makefile.h
include ../config/makelib.h


ifeq ($(FC),flang-new-17)
FOPTIONS += -fno-automatic
endif
ifeq ($(_FC),pgf90)
FOPTIONS += -Mnorecursive
endif
Expand Down
11 changes: 8 additions & 3 deletions src/libext/openblas/build_openblas.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
#set -v
arch=`uname -m`
VERSION=0.3.23
VERSION=0.3.24
#COMMIT=974acb39ff86121a5a94be4853f58bd728b56b81
BRANCH=develop
if [ -f OpenBLAS-${VERSION}.tar.gz ]; then
Expand Down Expand Up @@ -146,9 +146,12 @@ if [[ -n ${FC} ]] && [[ ${FC} == xlf ]] || [[ ${FC} == xlf_r ]] || [[ ${FC} ==
FORCETARGET+=" CC=gcc "
_FC=xlf
LAPACK_FPFLAGS_VAL=" -qstrict=ieeefp -O2 -g"
elif [[ -n ${FC} ]] && [[ "${FC}" == "flang" ]] || [[ "${FC}" == "amdflang" ]]; then
elif [[ -n ${FC} ]] && [[ $(../../../config/strip_compiler.sh "${FC}") == "flang" ]]; then
FORCETARGET+=' F_COMPILER=FLANG '
LAPACK_FPFLAGS_VAL=" -O1 -g -Kieee"
LAPACK_FPFLAGS_VAL=" -O1 -g -fno-fast-math"
if [[ ${BLAS_SIZE} == 8 ]]; then
LAPACK_FPFLAGS_VAL+=" -fdefault-integer-8"
fi
elif [[ "${_FC}" == "crayftn" ]] ; then
# FORCETARGET+=' F_COMPILER=FLANG '
LAPACK_FPFLAGS_VAL=" -s integer64 -ef "
Expand Down Expand Up @@ -251,6 +254,8 @@ echo output redirected to libext/openblas/OpenBLAS/openblas.log
echo
if [[ ${_FC} == xlf ]]; then
$MYMAKE FC="xlf -qextname" $FORCETARGET LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=$MYNTS NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log
elif [[ ${FC} == flang-new-17 ]]; then
$MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET FCOMMON_OPT="$LAPACK_FPFLAGS_VAL" LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log
else
$MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log
fi
Expand Down
2 changes: 2 additions & 0 deletions src/libext/scalapack/build_scalapa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ fi
if [[ "$SCALAPACK_SIZE" == 8 ]] ; then
if [[ ${FC} == f95 ]] || [[ ${FC_EXTRA} == gfortran ]] ; then
Fortran_FLAGS+=" -fdefault-integer-8 -w "
elif [[ ${FC_EXTRA} == flang ]] ; then
Fortran_FLAGS+=" -fdefault-integer-8 "
elif [[ ${FC} == xlf ]] || [[ ${FC} == xlf_r ]] || [[ ${FC} == xlf90 ]]|| [[ ${FC} == xlf90_r ]]; then
Fortran_FLAGS=" -qintsize=8 -qextname "
elif [[ ${FC} == crayftn ]]; then
Expand Down
5 changes: 4 additions & 1 deletion src/nwdft/lr_tddft/tddft_analysis.F
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ subroutine tddft_analysis(rtdb,geom,ao_bas_han,nroots,nbf_ao,
double precision s2_save(nroots)
logical lstores2
double precision s2_tmp(nroots)
integer ioserr
c
c MN solvation models -->
c
Expand Down Expand Up @@ -1845,7 +1846,9 @@ subroutine tddft_analysis(rtdb,geom,ao_bas_han,nroots,nbf_ao,
write(luout,*) "fn_civecs: ",fn_civecs
call util_file_name_resolve(fn_civecs, .false.)
open(unit=69,file=fn_civecs,form='unformatted',
1 status='unknown')
1 status='unknown',
$ iostat=ioserr)
write(luout,*) ' open iostat ',ioserr
write(LuOut,2010) fn_civecs
rewind(69)
write(69) tda
Expand Down
8 changes: 4 additions & 4 deletions src/nwdft/xc/xc_att_xc.F
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Subroutine xc_att_xc_d3(rho,ipol,Ex,Amat,Cmat,Amat2,Cmat2,Cmat3,
double precision a_first,a2_first,btmp_first, btmp1
c
double precision sqrt_pi,t1,t2,t3,t4,t5,t6,t7
double precision alpha,beta, DERF
double precision alpha,beta, ERF
double precision f10, f01, b_first
double precision a2, a3, a4, a5, a6, a7, a8, a9, a10, a11
double precision ta, ta2, ta3, ta4, ta5, ta6, ta7, ta8, ta9,
Expand Down Expand Up @@ -170,7 +170,7 @@ Subroutine xc_att_xc_d3(rho,ipol,Ex,Amat,Cmat,Amat2,Cmat2,Cmat3,
erff = 1.0d0
else
expf = exp(-1d0/(4d0*a2))
erff = DERF(1d0/(2d0*a))
erff = ERF(1d0/(2d0*a))
endif
c
if (a .lt. 0.14d0) then
Expand Down Expand Up @@ -199,7 +199,7 @@ Subroutine xc_att_xc_d3(rho,ipol,Ex,Amat,Cmat,Amat2,Cmat2,Cmat3,
b = expf - 1d0
c c = 2d0*a*a*b + 0.5d0
c = 2d0*a2*b + 0.5d0
c btmp = (8d0/3d0)*a*(sqrt_pi*DERF(1/(2d0*a)) + 2d0*a*(b-c))
c btmp = (8d0/3d0)*a*(sqrt_pi*ERF(1/(2d0*a)) + 2d0*a*(b-c))
btmp = (8d0/3d0)*a*(sqrt_pi*erff + 2d0*a*(b-c))
c OLD CODE
c t1 = 1/a
Expand All @@ -211,7 +211,7 @@ Subroutine xc_att_xc_d3(rho,ipol,Ex,Amat,Cmat,Amat2,Cmat2,Cmat3,
c t6 = t4 -2d0*t2*t5 - 1.5d0
c btmp_first = -t7*a *
c & (2*a*(t4/(2*a**3) - 4d0*a*t5 - t1*t4) + 2d0*t6 -t3*t4) -
c & t7*(2*a*t6 + sqrt_pi*DERF(0.5d0*t1))
c & t7*(2*a*t6 + sqrt_pi*ERF(0.5d0*t1))
c btmp_first = -t7*a *
c & (2*a*(t4/(2*a**3) - 4d0*a*t5 - t1*t4) + 2d0*t6 -t3*t4) -
c & t7*(2*a*t6 + sqrt_pi*erff)
Expand Down
8 changes: 4 additions & 4 deletions src/nwdft/xc/xc_bnl.F
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ double precision function HqBNL(q)
implicit none
#include "xc_params.fh"

double precision q,TwoSqrtPi,OneOverQ,q2,DERF
double precision q,TwoSqrtPi,OneOverQ,q2,ERF

if (q .lt. 1D-15) then
HqBNL=1.d0
Expand All @@ -205,7 +205,7 @@ double precision function HqBNL(q)
return
end if

HqBNL=1.0d0-q*2.0d0/3.0d0*(TwoSqrtPi*DERF(OneOverQ)-q+
HqBNL=1.0d0-q*2.0d0/3.0d0*(TwoSqrtPi*ERF(OneOverQ)-q+
$ q*(q2-2.0d0)*(1.0d0-exp(-OneOverQ*OneOverQ)))

return
Expand Down Expand Up @@ -262,7 +262,7 @@ double precision function HqBNLPrime(q)
implicit none
#include "xc_params.fh"

double precision q,OneOverQ,q2,q3,DERF
double precision q,OneOverQ,q2,q3,ERF

q2 = q**2.0d0
q3 = q**3.0d0
Expand All @@ -274,7 +274,7 @@ double precision function HqBNLPrime(q)
OneOverQ = 1.0d0/q

HqBNLPrime = 4.0d0/3.0d0*(q*(exp(-OneOverQ*OneOverQ)*(2.0d0*q2
$ -1.0d0)+(3.0d0-2.0d0*q2))-dsqrt(Pi)*DERF(OneOverQ))
$ -1.0d0)+(3.0d0-2.0d0*q2))-dsqrt(Pi)*ERF(OneOverQ))

return
end
Expand Down
2 changes: 1 addition & 1 deletion src/peigs/DEFS
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ else
peigs_LIB = $(TOPDIR)/lib/$(NWCHEM_TARGET)_$(NWCHEM_TARGET_CPU)/libpeigs.a
endif

SHELL = /bin/sh
SHELL = /usr/bin/env bash

peigs_OBJDIR = $(peigs_DIR)/o
peigs_HDIR = $(peigs_DIR)/h
Expand Down
12 changes: 8 additions & 4 deletions src/property/raman.F
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ logical function raman_read_list(
integer inntsize
integer l_scr,k_scr,
& l_iscr,k_iscr
integer util_system
external util_system

inntsize=MA_sizeof(MT_INT,1,MT_BYTE)
call ga_sync()
Expand All @@ -1065,10 +1067,12 @@ logical function raman_read_list(
& .false.,.false.,fname_raman)
write(*,*) 'Searching for fname_raman=',fname_raman
c WARNING: This works only on UNIX systems
call system('ls -1 -p '//trim(fname_raman)
& //'_[0-9]*nblock > list_raman_files.txt')
call system('ls -1 -p '//trim(fname_raman)
& //'_[!0-9]*nblock >> list_raman_files.txt')
if(util_system('ls -1 -p '//trim(fname_raman)
& //'_[0-9]*nblock > list_raman_files.txt').ne.0)
& call errquit('raman: util_systemfailed',1,0)
if(util_system('ls -1 -p '//trim(fname_raman)
& //'_[!0-9]*nblock >> list_raman_files.txt').ne.0)
& call errquit('raman: util_systemfailed',2,0)
c Note.- Listing XX_[0-9]*nblock first
c Listing XX_[!0-9]*nblock below
c This is to update rminfo correctly
Expand Down
4 changes: 2 additions & 2 deletions src/solvation/grad_hnd_cos.F
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ subroutine grad_hnd_cos ( H, lbuf, scr, lscr,

logical status, pointforce, ateq

double precision derf, cosff, cosdff
double precision cosff, cosdff
external cosff, cosdff

integer nxtask, task_size
Expand Down Expand Up @@ -472,7 +472,7 @@ subroutine grad_hnd_cos ( H, lbuf, scr, lscr,
$ * dbl_mb(iefc_q+ich2-1)
$ * (2.0d0*zeta12/sqrt(pi)/(rr**2)
$ * exp(-(zeta12*rr)**2)
$ - derf(zeta12*rr)/(rr**3))
$ - erf(zeta12*rr)/(rr**3))
else
call errquit("grad_hnd_cos: panic",
$ do_cosmo_model,UERR)
Expand Down
9 changes: 3 additions & 6 deletions src/solvation/hnd_cosmo_lib.F
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,6 @@ subroutine hnd_cos_energy(nat,nefc,chgscr,efcc,efcs,efcz,efczz,
double precision zero, one, two
parameter (zero=0.0d0, one=1.0d0, two=2.0d0)
double precision pi
double precision derf
c
pi =acos(-1.0d0)
allefc=zero
Expand Down Expand Up @@ -1880,7 +1879,7 @@ subroutine hnd_cos_energy(nat,nefc,chgscr,efcc,efcs,efcz,efczz,
if (dij.lt.1.0d-8) then
aij=2.0d0*zetaij/sqrt(pi)
else
aij=derf(zetaij*dij)/dij
aij=erf(zetaij*dij)/dij
endif
efcefc=efcefc+2*qi*aij*qj
enddo
Expand Down Expand Up @@ -1920,7 +1919,6 @@ subroutine hnd_cosmata(nat,nefc,efcc,efcs,efczz,efciat,ratm,a)
parameter (one = 1.0d0)
c
c
double precision derf
double precision factor, factor2

double precision pi
Expand Down Expand Up @@ -1965,7 +1963,7 @@ subroutine hnd_cosmata(nat,nefc,efcc,efcs,efczz,efciat,ratm,a)
if (dij.lt.1.0d-5) then
a(ief,jef)=factor2*zetaij*(1d0 - (zetaij*dij)**2/3d0)
else
a(ief,jef)=derf(zetaij*dij)/dij
a(ief,jef)=erf(zetaij*dij)/dij
endif
a(jef,ief) = a(ief,jef)
enddo
Expand Down Expand Up @@ -2005,7 +2003,6 @@ subroutine hnd_cosaxd(nat,x,ax,nefc,efcc,efcs,efczz,efciat,ratm)
parameter (zero=0.0d+00, one=1.0d+00)
c
c
double precision derf
c
c Introduced a trivial replicated data parallelization of this
c matrix-vector multiplication
Expand Down Expand Up @@ -2042,7 +2039,7 @@ subroutine hnd_cosaxd(nat,x,ax,nefc,efcc,efcs,efczz,efciat,ratm)
if (dij.lt.1.0d-8) then
aij=factor2*zetaij*(1d0 - (zetaij*dij)**2/3d0)
else
aij=derf(zetaij*dij)/dij
aij=erf(zetaij*dij)/dij
endif
ax(i)=ax(i)+aij*x(j)
ax(j)=ax(j)+aij*x(i)
Expand Down
7 changes: 3 additions & 4 deletions src/util/util_erf.F
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ real*8 function util_erf(x)
util_erf = f
#else
double precision x
double precision derf
util_erf=derf(x)
util_erf=erf(x)
#endif
return
end
Expand All @@ -65,8 +64,8 @@ real*8 function util_erfc(x)
util_erfc = 1.0d0-f
#else
double precision x
double precision derfc
util_erfc=derfc(x)
double precision erfc
util_erfc=erfc(x)
#endif
return
end
Expand Down
5 changes: 4 additions & 1 deletion src/util/util_getenv.F
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ subroutine util_getenv(env_name, env_value)
character*(*) env_value ! [output] the value of the named environement variable
#if defined(CRAY)
integer*4 lname, lvalue, lerror
#else
integer len,status
#endif
*
#if defined(CRAY)
Expand All @@ -24,7 +26,8 @@ subroutine util_getenv(env_name, env_value)
* lerror, UNKNOWN_ERR)
endif
#else
call getenv(env_name, env_value)
cold call getenv(env_name, env_value)
call GET_ENVIRONMENT_VARIABLE(env_name, env_value, len, status)
#endif
*
end
Expand Down
Loading