Skip to content

Commit

Permalink
Switch from absolute to relative state counters
Browse files Browse the repository at this point in the history
  • Loading branch information
godotalgorithm committed Nov 11, 2024
1 parent e68b168 commit a9d865c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 43 deletions.
6 changes: 3 additions & 3 deletions src/MOZYME/iter_for_MOZYME.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
! along with this program. If not, see <https://www.gnu.org/licenses/>.

subroutine iter_for_MOZYME (ee)
use molkst_C, only: norbs, step_num, numcal, nscf, escf, &
use molkst_C, only: norbs, step_num, numcal, numcal0, nscf, escf, &
& numat, enuclr, atheat, emin, keywrd, moperr, line, use_disk
!
use chanel_C, only: iw, iend, end_fn
Expand Down Expand Up @@ -519,7 +519,7 @@ subroutine iter_for_MOZYME (ee)
goto 80
end if
end if
if (bigscf .or. numcal /= 1) then
if (bigscf .or. numcal /= 1+numcal0) then
call diagg (f, nocc1, nvir1, idiagg, partp, indi)
idiagg = idiagg + 1
else
Expand Down Expand Up @@ -610,7 +610,7 @@ subroutine iter_for_MOZYME (ee)
backspace (iw)
end if
call isitsc (escf, selcon, emin, iemin, iemax, okscf, niter, itrmax)
if ( .not. bigscf .and. numcal == 1) then
if ( .not. bigscf .and. numcal == 1+numcal0) then
exit
else if (okscf .and. niter > 1 .and. (emin /= 0.d0 .or. niter > 3)) then
exit
Expand Down
4 changes: 2 additions & 2 deletions src/MOZYME/tidy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

subroutine tidy (nmos_loc, nc, ic, n01, c, n02, nnc_loc, ncmo, ln, mn, mode)
use MOZYME_C, only: iorbs, jopt, thresh, numred
use molkst_C, only: numat, step_num, norbs, moperr, keywrd, numcal, use_disk
use molkst_C, only: numat, step_num, step_num0, norbs, moperr, keywrd, numcal, use_disk
use chanel_C, only: iw
implicit none
integer, intent (in) :: mode, n02, nmos_loc
Expand Down Expand Up @@ -115,7 +115,7 @@ subroutine tidy (nmos_loc, nc, ic, n01, c, n02, nnc_loc, ncmo, ln, mn, mode)
!
! Do the LMOs of the SCF need to be put at the start of the storage?
!
if (isnew /= 0 .or. step_num <= 1 .or. step_num == imode(mode)) exit
if (isnew /= 0 .or. step_num <= 1+step_num0 .or. step_num == imode(mode)) exit
isnew = 2
if (numred >= numat-1) then
isnew = 1
Expand Down
10 changes: 5 additions & 5 deletions src/input/getgeo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ subroutine getgeo(iread, labels, geo, xyz, lopt, na, nb, nc, int)
use parameters_C, only : ams
!
use molkst_C, only : natoms, keywrd, numat, maxtxt, line, moperr, &
numcal, id, units, Angstroms, arc_hof_1, arc_hof_2, keywrd_txt, pdb_label
numcal, numcal0, id, units, Angstroms, arc_hof_1, arc_hof_2, keywrd_txt, pdb_label
!
use chanel_C, only : iw, ir, input_fn, end_fn, iend
!
Expand Down Expand Up @@ -162,11 +162,11 @@ subroutine getgeo(iread, labels, geo, xyz, lopt, na, nb, nc, int)
if (line == '$end') go to 20
if (line(1:1) == '*') go to 20
if (line == ' ') then
if(natoms == 0 .and. numcal == 1) then
if(natoms == 0 .and. numcal == 1+numcal0) then
!
! Check: Is this an ARC file?
!
numcal = 2
numcal = 2+numcal0

Check warning on line 169 in src/input/getgeo.F90

View check run for this annotation

Codecov / codecov/patch

src/input/getgeo.F90#L169

Added line #L169 was not covered by tests
rewind (iread)
sum = 0.d0
do i = 1, 10000
Expand Down Expand Up @@ -572,7 +572,7 @@ subroutine getgeo(iread, labels, geo, xyz, lopt, na, nb, nc, int)
write(iw,'(/10x,a,i5)')"Faulty atom:", natoms
write(iw,'(/10x,a)')"Faulty line: """//trim(line)//""""
call mopend("Unless MINI is used, optimization flags must be 1, 0, or -1")
numcal = 2
numcal = 2+numcal0

Check warning on line 575 in src/input/getgeo.F90

View check run for this annotation

Codecov / codecov/patch

src/input/getgeo.F90#L575

Added line #L575 was not covered by tests
if ((lopt(1,natoms) > 10 .or. lopt(2,natoms) > 10 .or. lopt(3,natoms) > 10) .and. natoms > 1) &
write(iw,'(/10x,a)')" If the geometry is in Gaussian format, add keyword ""AIGIN"" and re-run"
return
Expand Down Expand Up @@ -626,7 +626,7 @@ subroutine getgeo(iread, labels, geo, xyz, lopt, na, nb, nc, int)
!***********************************************************************
120 continue
if (natoms == 0) then
if (numcal == 1) call mopend (' Error detected while reading geometry')
if (numcal == 1+numcal0) call mopend (' Error detected while reading geometry')
return
end if
if ( .not. Angstroms) then
Expand Down
8 changes: 4 additions & 4 deletions src/input/gettxt.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

subroutine gettxt
use chanel_C, only: ir, iw, isetup, input_fn
use molkst_C, only: keywrd, keywrd_quoted, koment, title, refkey, gui, numcal, line, &
use molkst_C, only: keywrd, keywrd_quoted, koment, title, refkey, gui, numcal, numcal0, line, &
moperr, allkey, backslash
implicit none
!-----------------------------------------------
Expand Down Expand Up @@ -107,7 +107,7 @@ subroutine gettxt
if (.not. exists) then
if (setup_present .and. .not. zero_scf) then
write (line, '(A)') "SETUP FILE """//trim(filen)//""" MISSING."
numcal = 2
numcal = 2+numcal0

Check warning on line 110 in src/input/gettxt.F90

View check run for this annotation

Codecov / codecov/patch

src/input/gettxt.F90#L110

Added line #L110 was not covered by tests
if (.not. gui )write(0,'(//30x,a)')' SETUP FILE "'//trim(filen)//'" MISSING'
call mopend (trim(line))
return
Expand Down Expand Up @@ -401,7 +401,7 @@ subroutine gettxt
go to 60
50 continue
if (zero_scf) go to 60
numcal = 2
numcal = 2+numcal0

Check warning on line 404 in src/input/gettxt.F90

View check run for this annotation

Codecov / codecov/patch

src/input/gettxt.F90#L404

Added line #L404 was not covered by tests
call mopend ('SETUP FILE "'//trim(filen)//'" MISSING')
write(iw,'(a)') " (Setup file name: '"//trim(filen)//"')"
return
Expand All @@ -411,7 +411,7 @@ subroutine gettxt
100 continue
call split_keywords(oldkey)

if (numcal > 1) then
if (numcal > 1+numcal0) then
if (index(keywrd,"OLDGEO") /= 0) return ! User forgot to add extra lines for title and comment
if (aux) keywrd = " AUX"
line = "JOB ENDED NORMALLY"
Expand Down
18 changes: 9 additions & 9 deletions src/input/readmo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ subroutine readmo
!
USE symmetry_C, ONLY: idepfn, locdep, depmul, locpar
!
use molkst_C, only : ndep, numat, numcal, natoms, nvar, keywrd, dh, &
use molkst_C, only : ndep, numat, numcal, numcal0, natoms, nvar, keywrd, dh, &
& verson, is_PARAM, line, nl_atoms, l_feather, backslash, &
& moperr, maxatoms, koment, title, method_pm6, refkey, l_feather_1, &
isok, method_pm6_dh2, caltyp, keywrd_quoted, &
Expand Down Expand Up @@ -464,13 +464,13 @@ subroutine readmo
intern = .false.
else
call getgeo (ir, labels, geo, coord, lopt, na, nb, nc, intern)
if (numcal == 1 .and. natoms == 0) then
if (numcal == 1+numcal0 .and. natoms == 0) then
i = index(keywrd, "GEO_DAT")
if (i /= 0) then
write(line,'(2a)')" GEO_DAT file """//trim(line_1)//""" exists, but does not contain any atoms."
write(0,'(//10x,a,//)')trim(line)
call mopend(trim(line))
else if (.not. gui .and. numcal < 2) then
else if (.not. gui .and. numcal < 2+numcal0) then

Check warning on line 473 in src/input/readmo.F90

View check run for this annotation

Codecov / codecov/patch

src/input/readmo.F90#L473

Added line #L473 was not covered by tests
write(line,'(2a)')" Data set '"//trim(job_fn)//" exists, but does not contain any atoms."
write(0,'(//10x,a,//)')trim(line)
call mopend(trim(line))
Expand Down Expand Up @@ -498,7 +498,7 @@ subroutine readmo
coorda(:,:numat) = geo(:,:numat)
numat_old = numat
else if (natoms /= -3) then
if (moperr .and. numcal == 1) return
if (moperr .and. numcal == 1+numcal0) return
if (maxtxt > txtmax) txtmax = maxtxt
txtatm1(:natoms) = txtatm(:natoms)
if (index(keywrd, " RESID") /= 0) txtatm1(:numat)(22:22) = " "
Expand Down Expand Up @@ -623,7 +623,7 @@ subroutine readmo
end do
end if
if (natoms < 0 ) then
if (numcal == 1) rewind ir
if (numcal == 1+numcal0) rewind ir
if (.not.isok) then
write (iw, '(A)') &
' Use AIGIN to allow more geometries to be used'
Expand All @@ -634,7 +634,7 @@ subroutine readmo
stop
end if
isok = .FALSE.
if (numcal > 2) then
if (numcal > 2+numcal0) then
naigin = naigin + 1
write (iw, '(2/,2A)') ' GAUSSIAN INPUT REQUIRES', &
' STAND-ALONE JOB'
Expand All @@ -647,15 +647,15 @@ subroutine readmo
go to 10
end if
end if
if (natoms == 0 .and. numcal == 1) then
if (natoms == 0 .and. numcal == 1+numcal0) then
call mopend ('NO ATOMS IN SYSTEM')
return
end if
else
!
! Use the old geometry, if one exists
!
if (numcal == 1) then
if (numcal == 1+numcal0) then
write(line,'(a)')" Keyword OLDGEO cannot be used in the first calculation - there is no old geometry"
write(iw,'(//10x,a)')trim(line)
call to_screen(trim(line))
Expand Down Expand Up @@ -689,7 +689,7 @@ subroutine readmo
call mopend(trim(line))
return
else
if (numcal == 1 .and. numat > 50) write(0,'(10x,a)')idate//" Job: '"//trim(jobnam)//"' started successfully"
if (numcal == 1+numcal0 .and. numat > 50) write(0,'(10x,a)')idate//" Job: '"//trim(jobnam)//"' started successfully"
end if
end if
maxci = 10000
Expand Down
1 change: 1 addition & 0 deletions src/molkst_C.F90
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ module molkst_C
! Each stage is limited to the same electronic structure. Most calculations
! will only have one stage, e.g. geometry optimization or force constants.
!
& job_no0, numcal0, step_num0, & ! Needed for repeated API calls to run_mopac
& mpack, & ! Number of elements in a lower-half-triangle = (norbs*(norbs+1))/2
& n2elec, & ! Number of two-electron integrals
& nscf, & ! Number of SCF calculations done
Expand Down
4 changes: 2 additions & 2 deletions src/mopend.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ subroutine summary(txt, ntxt)
!
!
use chanel_C, only : iw, ir
use molkst_C, only : line, job_no, natoms, dummy, errtxt
use molkst_C, only : line, job_no, job_no0, natoms, dummy, errtxt
implicit none
integer, intent (in) :: ntxt
character, intent (in) :: txt*(*)
Expand Down Expand Up @@ -83,7 +83,7 @@ subroutine summary(txt, ntxt)
end if
end if
if (ntxt == 1) then
if (natoms == 0 .and. job_no == 1) then
if (natoms == 0 .and. job_no == job_no0) then
write(iw,'(/10x, a)')"Job failed to run because no atoms were detected in the system"
write(iw,'(10x, a, /)')"The start of the data-set is as follows:"
rewind (ir)
Expand Down
4 changes: 2 additions & 2 deletions src/output/to_screen.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subroutine current_version (text)
method_am1, method_mndo, method_pm3, method_rm1, method_mndod, method_pm6, &
method_pm7, nvar, koment, keywrd, zpe, id, density, natoms, formula, press, voigt, &
uhf, nalpha, nbeta, gnorm, mozyme, mol_weight, ilim, &
line, nscf, time0, sz, ss2, no_pKa, title, jobnam, job_no, fract
line, nscf, time0, sz, ss2, no_pKa, title, jobnam, job_no, job_no0, fract
!
use MOZYME_C, only : ncf, ncocc, noccupied, icocc_dim, cocc_dim, nvirtual, icvir_dim, &
nncf, iorbs, cocc, icocc, ncvir, nnce, nce, icvir, cvir, tyres, size_mres, &
Expand Down Expand Up @@ -1340,7 +1340,7 @@ subroutine current_version (text)
!
! Don't print processor-independent CPU times for quick jobs - that would waste too much time.
!
if (time0 > 1.d0 .and. job_no < 4) then
if (time0 > 1.d0 .and. job_no < 4+job_no0) then
!
! Deliberately run a time-consuming calculation to work out CPU speed
! The "j" index is set to use up 1.0 seconds on the development computer.
Expand Down
4 changes: 2 additions & 2 deletions src/output/writmo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ subroutine writmo
use cosmo_C, only : iseps, area, fepsi, cosvol, ediel, solv_energy
!
use molkst_C, only : numat, nclose, nopen, fract, nalpha, nelecs, nbeta, &
& norbs, nvar, gnorm, iflepo, enuclr,elect, ndep, nscf, numcal, escf, &
& norbs, nvar, gnorm, iflepo, enuclr,elect, ndep, nscf, numcal, numcal0, escf, &
& keywrd, os, verson, time0, moperr, last, iscf, id, pressure, mol_weight, &
jobnam, line, mers, uhf, method_indo, &
density, formula, mozyme, mpack, stress, &
Expand Down Expand Up @@ -971,7 +971,7 @@ subroutine writmo
call pdbout(31)
close (31)
end if
if (numcal == 2) then
if (numcal == 2+numcal0) then
if (index(keywrd, "OLDGEO") /= 0) then
!
! Write a warning that OLDGEO has been used, so user is aware that multiple ARC files are present
Expand Down
30 changes: 16 additions & 14 deletions src/run_mopac.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ subroutine run_mopac
sparkle, itemp_1, maxtxt, koment, sz, ss2, keywrd_quoted, &
nl_atoms, use_ref_geo, prt_coords, pdb_label, step, &
density, norbs, method_indo, nclose, nopen, backslash, gui, os, git_hash, verson, &
use_disk, run
use_disk, run, numcal0, job_no0, step_num0
!
USE parameters_C, only : tore, ios, iop, iod, eisol, eheat, zs, eheat_sparkles, gss
!
Expand Down Expand Up @@ -69,7 +69,7 @@ subroutine run_mopac
Use settingGPUcard
#endif
implicit none
integer :: i, j, k, l, numcal0
integer :: i, j, k, l
double precision :: eat, tim, store_fepsi
logical :: exists, opend, l_OLDDEN
double precision, external :: C_triple_bond_C, reada, seconds
Expand Down Expand Up @@ -124,8 +124,10 @@ subroutine run_mopac
stop
endif
end do
! save numcal reference to use only relative numcal values in API calls
! save state reference to use only relative state values in API calls
numcal0 = numcal
job_no0 = job_no
step_num0 = step_num
!------------------------------------------------------------------------
tore = ios + iop + iod
call fbx ! Factorials and Pascal's triangle (pure constants)
Expand Down Expand Up @@ -181,7 +183,7 @@ subroutine run_mopac
10 continue
numcal = numcal + 1 ! A new calculation
job_no = job_no + 1 ! A new job
if (job_no > 1) then
if (job_no > 1+job_no0) then
backspace(ir)
read(ir,'(a)', iostat = i) line
if (i == 0) then
Expand Down Expand Up @@ -231,17 +233,17 @@ subroutine run_mopac
l_normal_html = .true.
use_disk = .true.
state_Irred_Rep = " "
if (job_no > 1) then
if (job_no > 1+job_no0) then
i = index(keywrd, " BIGCYCL")
if (i /= 0 .and. index(keywrd,' DRC') == 0) then
i = nint(reada(keywrd, i)) + 1
if (job_no < i) then
if (job_no < i+job_no0) then
fepsi = store_fepsi
goto 90
end if
end if
end if
if (numcal > numcal0 .and. numcal < numcal0+3 .and. index(keywrd_txt," GEO_DAT") /= 0) then
if (numcal > 1+numcal0 .and. numcal < 4+numcal0 .and. index(keywrd_txt," GEO_DAT") /= 0) then
!
! Quickly jump over first three lines
!
Expand All @@ -251,7 +253,7 @@ subroutine run_mopac
natoms = i
call gettxt
end if
if (numcal > numcal0) call to_screen("To_file: Leaving MOPAC")
if (numcal > 1+numcal0) call to_screen("To_file: Leaving MOPAC")
!
! Read in all the data for the current job
!
Expand All @@ -267,12 +269,12 @@ subroutine run_mopac
if (j /= 0) i = i - 6 + j
end if
inquire(file=line(:i)//".den", exist=l_OLDDEN)
90 if (moperr .and. numcal == numcal0 .and. natoms > 1) goto 101
if (moperr .and. numcal == numcal0 .and. index(keywrd_txt," GEO_DAT") == 0) goto 100
90 if (moperr .and. numcal == 1+numcal0 .and. natoms > 1) goto 101
if (moperr .and. numcal == 1+numcal0 .and. index(keywrd_txt," GEO_DAT") == 0) goto 100
if (moperr) goto 101
! Adjust maximum number of threads using the OpenMP API
#ifdef _OPENMP
if (numcal == numcal0) default_num_threads = omp_get_max_threads()
if (numcal == 1+numcal0) default_num_threads = omp_get_max_threads()
i = index(keywrd, " THREADS")
if (i > 0) then
num_threads = nint(reada(keywrd, i))
Expand All @@ -281,7 +283,7 @@ subroutine run_mopac
end if
call omp_set_num_threads(num_threads)
#endif
if (numcal == numcal0) then
if (numcal == 1+numcal0) then
#ifdef MKL
num_threads = min(mkl_get_max_threads(), 20)
i = index(keywrd, " THREADS")
Expand Down Expand Up @@ -359,7 +361,7 @@ subroutine run_mopac
lgpu = (lgpu_ref .and. natoms > 100) ! Warning - there are problems with UHF calculations on small systems
#endif
end if
if (.not. gui .and. numcal == numcal0 .and. natoms == 0) then
if (.not. gui .and. numcal == 1+numcal0 .and. natoms == 0) then
write(line,'(2a)')" Data set exists, but does not contain any atoms."
write(0,'(//10x,a,//)')trim(line)
call mopend(trim(line))
Expand All @@ -378,7 +380,7 @@ subroutine run_mopac
natoms = 0
goto 100
end if
if (numcal == numcal0 .and. moperr .or. natoms == 0) then
if (numcal == 1+numcal0 .and. moperr .or. natoms == 0) then
!
! Check for spurious "extra" data
!
Expand Down

0 comments on commit a9d865c

Please sign in to comment.