Skip to content

Commit

Permalink
Merge pull request #108 from openmopac/flang-fix
Browse files Browse the repository at this point in the history
Flang compiler support
  • Loading branch information
godotalgorithm authored Aug 24, 2022
2 parents 0788c28 + 37baa3c commit d46ce82
Show file tree
Hide file tree
Showing 55 changed files with 230,847 additions and 230,791 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install lcov with Ubuntu package manager
run: sudo apt-get install lcov

- name: Install dependencies with PyPI
run: python -m pip install numpy
run: pip install numpy

- name: Configure MOPAC with CMake
run: |
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Test MOPAC with CTest
run: |
cd build
ctest -j $NUM_CORES
ctest -V -j $NUM_CORES
- name: Save test results as an artifact (on failure)
if: ${{ failure() }}
Expand All @@ -86,7 +86,7 @@ jobs:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
path: glibc

- name: Install dependencies with PyPI
run: python -m pip install numpy
run: pip install numpy

- name: Configure MOPAC with CMake
run: |
Expand All @@ -140,7 +140,7 @@ jobs:
run: |
source /opt/intel/oneapi/setvars.sh
cd build
ctest -j $NUM_CORES
ctest -V -j $NUM_CORES
- name: Save test results as an artifact (on failure)
if: ${{ failure() }}
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
sudo /Volumes/m_fortran-compiler*/bootstrapper.app/Contents/MacOS/install.sh --silent --eula accept
- name: Install dependencies with PyPI
run: python -m pip install numpy
run: pip3 install numpy

# AUTO_BLAS=OFF because find_package(BLAS) has a bug with static BLAS libraries on Mac
- name: Configure MOPAC with CMake
Expand Down Expand Up @@ -242,7 +242,7 @@ jobs:
run: |
source /opt/intel/oneapi/setvars.sh
cd build
ctest -j $NUM_CORES
ctest -V -j $NUM_CORES
- name: Save test results as an artifact (on failure)
if: ${{ failure() }}
Expand Down Expand Up @@ -283,7 +283,7 @@ jobs:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:
mkl_unpack\bootstrapper --silent --eula accept -p=NEED_VS2019_INTEGRATION=0
- name: Install dependencies with PyPI
run: python -m pip install numpy
run: pip3 install numpy

# The main Intel\oneAPI\setvars.bat script is not setting up the correct version of ifort, so using component-level scripts
- name: Configure MOPAC with CMake
Expand Down Expand Up @@ -341,7 +341,7 @@ jobs:
call "C:\Program Files (x86)\Intel\oneAPI\compiler\${{ env.IFORT_WINDOWS_VERSION }}\env\vars.bat"
call "C:\Program Files (x86)\Intel\oneAPI\mkl\${{ env.MKL_WINDOWS_VERSION }}\env\vars.bat"
cd build
ctest -j %NUM_CORES%
ctest -V -j %NUM_CORES%
- name: Save test results as an artifact (on failure)
if: ${{ failure() }}
Expand Down
41 changes: 40 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ elseif(UNIX)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib")
endif()


# Define a common library and executables for MOPAC & PARAM
if (STATIC_BUILD)
# Static build
Expand Down Expand Up @@ -131,6 +130,12 @@ endif()
# MOPAC shared library ABI compatibility version
set_target_properties(mopac-core PROPERTIES SOVERSION 1)

# Disable C-style backslash characters
if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI|Flang")
target_compile_options(mopac-core PUBLIC "-fno-backslash")
target_compile_options(mopac-makpol PUBLIC "-fno-backslash")
endif()

# Pass OS information to MOPAC's Fortran source
if(APPLE)
target_compile_definitions(mopac-core PRIVATE MOPAC_OS="MacOS")
Expand All @@ -140,6 +145,40 @@ elseif(UNIX)
target_compile_definitions(mopac-core PRIVATE MOPAC_OS="Linux")
endif()

# Pass compiler information to MOPAC's Fortran source
if(CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
option(F2003_INTRINSICS "Replace non-standard intrinsics w/ Fortran 2003 standards" ON)
else()
option(F2003_INTRINSICS "Replace non-standard intrinsics w/ Fortran 2003 standards" OFF)
endif()
if(F2003_INTRINSICS)
target_compile_definitions(mopac-core PRIVATE MOPAC_IARGC=command_argument_count)
target_compile_definitions(mopac-core PRIVATE MOPAC_GETARG=get_command_argument)
target_compile_definitions(mopac-core PRIVATE MOPAC_ISNAN=ieee_is_nan)
target_compile_definitions(mopac-core PRIVATE MOPAC_IEEE=1)
target_compile_definitions(mopac-makpol PRIVATE MOPAC_IARGC=command_argument_count)
target_compile_definitions(mopac-makpol PRIVATE MOPAC_GETARG=get_command_argument)
if(BUILD_WINMOPAC)
target_compile_definitions(mopac-win PRIVATE MOPAC_IARGC=command_argument_count)
target_compile_definitions(mopac-win PRIVATE MOPAC_GETARG=get_command_argument)
target_compile_definitions(mopac-bz PRIVATE MOPAC_IARGC=command_argument_count)
target_compile_definitions(mopac-bz PRIVATE MOPAC_GETARG=get_command_argument)
endif()
else()
target_compile_definitions(mopac-core PRIVATE MOPAC_IARGC=iargc)
target_compile_definitions(mopac-core PRIVATE MOPAC_GETARG=getarg)
target_compile_definitions(mopac-core PRIVATE MOPAC_ISNAN=isnan)
target_compile_definitions(mopac-core PRIVATE MOPAC_IEEE=0)
target_compile_definitions(mopac-makpol PRIVATE MOPAC_IARGC=iargc)
target_compile_definitions(mopac-makpol PRIVATE MOPAC_GETARG=getarg)
if(BUILD_WINMOPAC)
target_compile_definitions(mopac-win PRIVATE MOPAC_IARGC=iargc)
target_compile_definitions(mopac-win PRIVATE MOPAC_GETARG=getarg)
target_compile_definitions(mopac-bz PRIVATE MOPAC_IARGC=iargc)
target_compile_definitions(mopac-bz PRIVATE MOPAC_GETARG=getarg)
endif()
endif()

# Pass version & commit information to MOPAC's Fortran source
target_compile_definitions(mopac-core PRIVATE MOPAC_VERSION_FULL="${PROJECT_VERSION}")
execute_process(COMMAND git rev-parse HEAD OUTPUT_VARIABLE GIT_HASH)
Expand Down
2 changes: 1 addition & 1 deletion src/PARAM/datinp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ subroutine datinp
! The weights given to each reference datum depend on the elements present.
! Weights are assigned according to the type of element
double precision, dimension (107) :: element_weights
character, external :: get_a_name*300
character(len=300), external :: get_a_name
integer, external :: end_of_keyword
double precision, external :: seconds, reada
double precision, parameter :: &
Expand Down
2 changes: 1 addition & 1 deletion src/PARAM/parkey.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ subroutine parkey (keywrd)
character (len=*), intent (in) :: keywrd
integer :: i, j, k
character :: num*1, line*300
character, external :: get_a_name*300
character(len=300), external :: get_a_name
integer, external :: end_of_keyword
double precision, external :: reada
if (Index (keywrd, " MNDO ") /= 0) &
Expand Down
2 changes: 1 addition & 1 deletion src/PARAM/savgeo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ subroutine savgeo (loop, geo, na, nb, nc, xparam, loc)
character :: num*1
intrinsic Index
double precision, external :: reada
character, external :: get_a_name*300
character(len=300), external :: get_a_name
save :: iatm, igeo
!--------------------------------------------------------------------
!
Expand Down
8 changes: 4 additions & 4 deletions src/bz/bz.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ program BZ
character :: num
!
iw = 6
i = iargc()
i = MOPAC_IARGC()
l_read_dat = (i < 2)
if (i == 0) then
call graphics(0.0, 0.0, 1)
Expand All @@ -60,7 +60,7 @@ program BZ
call graphics(0.0, 0.0, 100)
stop
else
call getarg(1, jobnam)
call MOPAC_GETARG(1, jobnam)
j = len_trim(jobnam)
if (jobnam(j - 3:j - 3) == ".") then
suffix = .true.
Expand All @@ -71,7 +71,7 @@ program BZ
end if
if (i > 1) then
ir = 25
call getarg(2, data_set_name)
call MOPAC_GETARG(2, data_set_name)
i = len_trim(data_set_name)
if (i > 4) then
if (data_set_name(i - 3:i - 3) == ".") then
Expand Down Expand Up @@ -330,4 +330,4 @@ subroutine write_keystrokes(text, len_text)
write(16,'(a)', iostat = status) text
return
end subroutine write_keystrokes


8 changes: 4 additions & 4 deletions src/input/getdat.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ subroutine getdat(input, output)
! L o c a l V a r i a b l e s
!-----------------------------------------------
integer, parameter :: from_data_set = 7
integer :: i, j, io_stat, l, nlines, iargc
integer :: i, j, io_stat, l, nlines
logical :: exists, arc_file, comments = .true.
character :: line1*3000, num1*1, num2*1
character, allocatable :: tmp_comments(:)*120
Expand All @@ -53,9 +53,9 @@ subroutine getdat(input, output)
natoms = 1
else
if (run /= 2 .or.jobnam ==" ") then
i = iargc()
i = MOPAC_IARGC()
if (i >= run) then
call getarg (run, jobnam)
call MOPAC_GETARG (run, jobnam)
natoms = 1
do i = len_trim(jobnam), 1, -1 ! Remove any unprintable characters from the end of the file-name
if (ichar(jobnam(i:i)) > 39 .and. ichar(jobnam(i:i)) < 126 .or. jobnam(i:i) =="'") exit
Expand Down Expand Up @@ -370,7 +370,7 @@ subroutine getdat(input, output)
1000 if (nlines < 3 .and. .not. is_PARAM) then
inquire(unit=output, opened=exists)
if (.not. exists) open(unit=output, file=trim(jobnam)//'.out')
call getarg (run, jobnam)
call MOPAC_GETARG (run, jobnam)
write (0, '(A)') ' INPUT FILE "'//trim(jobnam)//'" MISSING OR EMPTY'
call mopend ( ' INPUT FILE "'//trim(jobnam)//'" MISSING OR EMPTY')
return
Expand Down
2 changes: 1 addition & 1 deletion src/input/wrtkey.F90
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ subroutine wrtcon (allkey)
integer :: i, ielec, ilevel, j, k, l
logical :: l_add_H = .false., l_temp
character :: num*1, num1*1
character, external :: get_a_name*300, get_text*300
character(len=300), external :: get_a_name, get_text
integer, external :: end_of_keyword
logical, external :: myword
double precision, external :: reada
Expand Down
10 changes: 8 additions & 2 deletions src/integrals/mndod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ subroutine printp(i, para, value, txt)
! M o d u l e s
!-----------------------------------------------
USE chanel_C, only : iw
#if MOPAC_IEEE
USE, INTRINSIC :: IEEE_ARITHMETIC
#endif
implicit none
!-----------------------------------------------
! D u m m y A r g u m e n t s
Expand All @@ -265,7 +268,7 @@ subroutine printp(i, para, value, txt)
! L o c a l V a r i a b l e s
!-----------------------------------------------
double precision :: loc_value
if (isnan(value)) then
if (MOPAC_ISNAN(value)) then
loc_value = 0.d0
else
loc_value = value
Expand All @@ -286,6 +289,9 @@ subroutine prtpar
zpn, zdn, gpp, gp2, hsp, gss, gsp, eisol, eheat, betas, betap, betad, &
po, ddp, f0dd, f2dd, f4dd, f0sd, g2sd, f0pd, f2pd, alpb, xfac, &
& g1pd, g3pd, guess1, guess2, guess3
#if MOPAC_IEEE
USE, INTRINSIC :: IEEE_ARITHMETIC
#endif
!***********************************************************************
!-----------------------------------------------
! I n t e r f a c e B l o c k s
Expand Down Expand Up @@ -399,7 +405,7 @@ subroutine prtpar
call printp(i, 'FN24 ', guess2(i,4), 'CORE-CORE VDW EXPONENT 4')
call printp(i, 'FN34 ', guess3(i,4), 'CORE-CORE VDW POSITION 4')
do j = 1, 100
if (isnan(alpb(i,j))) alpb(i,j)= 0.d0
if (MOPAC_ISNAN(alpb(i,j))) alpb(i,j)= 0.d0
if (Abs (alpb(i,j)) > 1.d-5 .and. used(j)) then
write (iw, "(I4,A6,i2,F13.8,2X,A)") i, "ALPB_", j,alpb(i,j), "ALPB factor"
write (iw, "(I4,A6,i2,F13.8,2X,A)") i, "XFAC_", j,xfac(i,j), "XFAC factor"
Expand Down
12 changes: 6 additions & 6 deletions src/makpol/standard.F90
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ subroutine getdat

ir = 25
iw = 26
i = iargc()
i = MOPAC_IARGC()
if (i == 0) then
write(*,"(a)")" Program MAKPOL"
write(*,"(a)")" "
write(*,"(a)")" "
write(*,"(a)")" MAKPOL constructs a MOPAC data set for a polymer, layer system, or solid."
write(*,"(a)")" It uses either a MOPAC-type data set that contains information about "
write(*,"(a)")" the size of the cluster to be built or a raw "".pdb"" or "".ent"" file. "
Expand All @@ -301,23 +301,23 @@ subroutine getdat
write(*,'(//10x,a,/)') "Makpol only uses one argument, more than one was supplied"
stop
end if
call getarg (1, jobnam)
call MOPAC_GETARG (1, jobnam)
write(*,*)trim(jobnam)
!
! allow for up to 3 commas in data set file name
!
if (i >= 2) then
call getarg (2, jobnam_c)
call MOPAC_GETARG (2, jobnam_c)
j = len_trim(jobnam)
if (jobnam(j:j) == ",") jobnam(j:j) = " "
jobnam=trim(jobnam)//","//jobnam_c
end if
if (i >= 3) then
call getarg (3, jobnam_c)
call MOPAC_GETARG (3, jobnam_c)
jobnam=trim(jobnam)//","//jobnam_c
end if
if (i == 4) then
call getarg (4, jobnam_c)
call MOPAC_GETARG (4, jobnam_c)
jobnam=trim(jobnam)//","//jobnam_c
end if
!
Expand Down
9 changes: 6 additions & 3 deletions src/models/calpar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ subroutine calpar
USE molkst_C, only : keywrd, method_indo
USE reimers_C, only: zetad, zetawt, nbfa
USE chanel_C, only : iw
#if MOPAC_IEEE
USE, INTRINSIC :: IEEE_ARITHMETIC
#endif
implicit none
!-----------------------------------------------
! L o c a l V a r i a b l e s
Expand All @@ -46,9 +49,9 @@ subroutine calpar
!
if (method_indo) then
do i = 1, 107
if (isnan(zs(i))) zs(i) = 0.d0
if (isnan(zp(i))) zp(i) = 0.d0
if (isnan(zd(i))) zd(i) = 1.d-6
if (MOPAC_ISNAN(zs(i))) zs(i) = 0.d0
if (MOPAC_ISNAN(zp(i))) zp(i) = 0.d0
if (MOPAC_ISNAN(zd(i))) zd(i) = 1.d-6
if(zd(i) == 0.d0) zd(i) = 1.d-6
end do
end if
Expand Down
6 changes: 5 additions & 1 deletion src/output/to_screen.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ subroutine current_version (text)
use maps_C, only : rxn_coord, rc_escf, ekin, lparam, latom
!
use drc_C, only: time
!
#if MOPAC_IEEE
USE, INTRINSIC :: IEEE_ARITHMETIC
#endif
!
implicit none
character (len=*) :: text
Expand Down Expand Up @@ -433,7 +437,7 @@ subroutine current_version (text)
write(hook,"(3f"//fmt13p5//")")(press(i),i=1,3)
end if
end if
if (.not. isnan(dip(4,3))) then
if (.not. MOPAC_ISNAN(dip(4,3))) then
if (Abs(dip(4,3)) > 1.d-20) then
write(hook,"(a,sp, d"//fmt13p6//", a)")" DIPOLE:DEBYE=",dip(4,3)
write(hook,"(a,sp, 3d"//fmt13p5//", a)")" DIP_VEC:DEBYE[3]=",(dip(i,3), i = 1, 3)
Expand Down
Loading

0 comments on commit d46ce82

Please sign in to comment.