Merge pull request #1279 from edoapra/aocc60
Some checks failed
check_64_to_32 / check (push) Has been cancelled
NWChem_CI / build (ARMCI, build_openblas, true, gfortran, mpich, all, ubuntu-22.04) (push) Has been cancelled
NWChem_CI / build (GA_DEBIAN, libopenblas-pthread-dev, 4, true, gfortran, openmpi, all python, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-PR, gcc-10, true, gfortran-10, mpich, tinyqmpw python, ubuntu-22.04, 1) (push) Has been cancelled
NWChem_CI / build (MPI-PR, gcc-11, false, gfortran-11, mpich, tinyqmpw python, ubuntu-22.04) (push) Has been cancelled
NWChem_CI / build (MPI-PR, gcc-12, true, gfortran-12, openmpi, tce, macos-latest, 15.4) (push) Has been cancelled
NWChem_CI / build (MPI-PR, true, gfortran-13, openmpi, qmandpw qmd, macos-15, 15.0.1) (push) Has been cancelled
NWChem_CI / build (MPI-PR, true, ifx, intel, tinyqmpw python, ubuntu-22.04, 2) (push) Has been cancelled
NWChem_CI / build (MPI-PR, true, ifx, intel, tinyqmpw python, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-PR, true, ifx, intel, tinyqmpw python, ubuntu-latest, 2) (push) Has been cancelled
NWChem_CI / build (MPI-PT, gcc-10, true, gfortran-10, mpich, nwdft solvation driver, ubuntu-22.04, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, accelerate, 4, true, gfortran-14, openmpi, tinyqmpw, macos-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, amdclang, true, amdflang, mpich, tce, ubuntu-22.04) (push) Has been cancelled
NWChem_CI / build (MPI-TS, amdclang, true, amdflang, mpich, tinyqmpw python, ubuntu-22.04) (push) Has been cancelled
NWChem_CI / build (MPI-TS, brew_openblas, 4, gcc, true, gfortran, openmpi, nwdft driver solvation, macos-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 1, true, gfortran-9, openmpi, xtb qmd driver solvation, ubuntu-22.04, 2, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 4, gcc-11, true, gfortran-11, mpich, xtb driver solvation, ubuntu-22.04, 2, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 4, true, ifx, intel, xtb driver solvation, ubuntu-22.04, 2, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, mpich, qmandpw qmd, ubuntu-24.04-arm, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, mpich, qmandpw qmd, ubuntu-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, mpich, tce, ubuntu-24.04-arm, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, mpich, tce, ubuntu-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, mpich, tinyqmpw python, ubuntu-24.04-arm, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, mpich, tinyqmpw python, ubuntu-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, qmandpw qmd, macos-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, qmandpw qmd, ubuntu-24.04-arm, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, qmandpw qmd, ubuntu-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, tce, macos-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, tce, ubuntu-24.04-arm, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, tce, ubuntu-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, tinyqmpw python, macos-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, tinyqmpw python, ubuntu-24.04-arm, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, false, gfortran, openmpi, tinyqmpw python, ubuntu-latest, 13.2.1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, gcc-15, true, gfortran-15, openmpi, all, macos-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, 8, true, flang, mpich, all, macos-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, gcc-10, true, gfortran-10, mpich, qmandpw qmd, ubuntu-22.04, 2) (push) Has been cancelled
NWChem_CI / build (MPI-TS, build_openblas, true, gfortran-9, openmpi, xtb driver solvation, ubuntu-22.04, 2, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, gfortran, openmpi, nwdft driver solvation mp2_grad mcscf ccsd rimp2 fcidump nwc_columbus, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, gfortran, openmpi, tinyqmpw, ubuntu-22.04, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, gfortran-13, openmpi, tinyqmpw, macos-latest, 1, 15.3) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, nvfortran, build_mpich, nwdft solvation driver, ubuntu-latest, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, nvfortran, build_mpich, tinyqmpw python, ubuntu-22.04) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, nvfortran, mpich, nwdft driver solvation mp2_grad mcscf ccsd rimp2 fcidump nwc_columbus, ubuntu-22.04) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc, true, nvfortran, mpich, qmandpw qmd, ubuntu-22.04, 2) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc-11, false, gfortran-11, mpich, tce, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc-11, true, gfortran-11, mpich, qmandpw qmd, ubuntu-latest, -1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, gcc-14, true, gfortran-14, openmpi, tinyqmpw python, macos-latest, 15.4) (push) Has been cancelled
NWChem_CI / build (MPI-TS, icx, true, ifx, intel, nwdft solvation driver, ubuntu-latest, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, icx, true, ifx, intel, tinyqmpw, ubuntu-22.04, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, internal, 4, true, gfortran, mpich, all, ubuntu-22.04, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, internal, 4, true, gfortran, mpich, all, ubuntu-latest, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, internal, 8, gcc, true, gfortran, mpich, nwdft solvation driver, ubuntu-22.04, -1, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, libopenblas64-openmp-dev, 8, gcc, true, gfortran, openmpi, nwdft driver solvation, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, libopenblas64-pthread-dev, 8, gcc, true, gfortran, openmpi, nwdft driver solvation, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, flang-20, build_mpich, tinyqmpw, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, flang-new-18, mpich, tinyqmpw, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, flang-new-19, mpich, tinyqmpw, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, gfortran-14, openmpi, tinyqmpw python, macos-15, 1, 15.2) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, ifx, intel, nwdft driver solvation mp2_grad mcscf ccsd rimp2 fcidump nwc_columbus, ubuntu-latest) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, ifx, intel, qmandpw qmd, ubuntu-latest, 2) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, ifx, intel, xtb driver solvation, ubuntu-22.04, 2, 1) (push) Has been cancelled
NWChem_CI / build (MPI-TS, true, nvfortran, mpich, xtb driver solvation, ubuntu-22.04, 2, 1) (push) Has been cancelled
NWChem_CI / build (SOCKETS, true, ifx, intel, tce, ubuntu-22.04, 2) (push) Has been cancelled
NWChem_CI / build (SOCKETS, true, ifx, intel, tce, ubuntu-latest, 2) (push) Has been cancelled
lint_python / lint_python (push) Has been cancelled

updates
This commit is contained in:
Edoardo Aprà 2026-06-30 22:01:23 -07:00 committed by GitHub
commit 4185dc300e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 793 additions and 349 deletions

View file

@ -34,9 +34,9 @@ from pylab import *
def parse_nwchem_output(fname):
import re
from pprint import pprint
singlet_pat = re.compile('\s+Root\s+\d+\s+singlet')
triplet_pat = re.compile('\s+Root\s+\d+\s+triplet')
unrestricted_pat = re.compile('\s+Root\s+\d')
singlet_pat = re.compile(r'\s+Root\s+\d+\s+singlet')
triplet_pat = re.compile(r'\s+Root\s+\d+\s+triplet')
unrestricted_pat = re.compile(r'\s+Root\s+\d')
singlets = []
triplets = []
unrestricted = []
@ -59,7 +59,7 @@ def parse_nwchem_output(fname):
def parse_element(line,f):
import re
oscillator_pat = re.compile('\s+Oscillator')
oscillator_pat = re.compile(r'\s+Oscillator')
words = line.split()
try:
energy = float(words[4])

View file

@ -23,7 +23,7 @@
logical active_sp2c_lindx ! active ma array sp2c_lindx ?
logical active_invsp2c_lindx ! active ma array sp2c_lindx ?
logical active_cart_norm_scale ! active ma array cart_norm_scale ?
logical trust_dgemm ! is dgemm okay
logical trust_dgemm ! is _dgemm_ okay
*
parameter (sph_cart_init_value = 1731)
*

View file

@ -10,19 +10,8 @@ if [[ -z "${NWCHEM_TOP}" ]]; then
MYPWD=`pwd`
NWCHEM_TOP=`echo ${MYPWD}/${DIRUTIL} | sed -e 's/\/src.*//' `
fi
if [ -x /msrc/apps/bin/perl ]; then
perlexe=/msrc/apps/bin/perl
elif [ -x /usr/local/bin/perl ]; then
perlexe=/usr/local/bin/perl
elif [ -x /usr/local/gnu/bin/perl ]; then
perlexe=/usr/local/gnu/bin/perl
elif [ -x /usr/gnu/bin/perl ]; then
perlexe=/usr/gnu/bin/perl
else
# assume perl is in your path
perlexe=perl
fi
perlscript=${NWCHEM_TOP}/src/config/32_to_64.pl
pythonexe=python
pythonscript=${NWCHEM_TOP}/src/config/32_to_64.py
JOB_LIMIT=6
@ -31,16 +20,18 @@ fi
for file in "$@"
do
if [ -f "$file" ]; then
echo converting "$file" to 64-bit integers for BLAS/LAPACK
($perlexe $perlscript $file) &
($pythonexe $pythonscript $file) &
let njob++
if [ $njob -gt $JOB_LIMIT ]; then
wait
let njob=0
fi
else
echo "!!!!file missing: " "$file"
fi
done
if [ $njob -gt 0 ] ; then

218
src/config/32_to_64.py Normal file
View file

@ -0,0 +1,218 @@
#!/usr/bin/env python3
"""
Python script to do transliteration from "single" values to "double" values
Usage: python 32_to_64.py file1.f [file2.f ...]
Original Perl script:
Written: 3/14/97
By: Ricky A. Kendall
High Performance Computational Chemistry Group
Theory Modeling and Simulation Program [2]
Converted from Perl to Python using Claude (claude-4-5-opus-4-5-20251101-v1)
Optimizations applied:
- Early exits to skip unnecessary processing
- Reduced redundant regex passes
- Combined line-type checks
- Precompiled regex patterns
- Lookahead for correct underscore boundary matching
"""
import os
import sys
import re
debug = False
def copy_case(from_str, to_str):
"""Take case from 'from_str' and apply it to 'to_str' and return that new string"""
result = []
for i, char in enumerate(to_str):
if i < len(from_str):
if from_str[i].isupper():
result.append(char.upper())
elif from_str[i].islower():
result.append(char.lower())
else:
result.append(char)
else:
result.append(char)
return ''.join(result)
class ConversionPattern:
"""Holds precompiled regex patterns for a single from/to conversion pair"""
def __init__(self, from_str, to_str):
self.from_str = from_str
self.to_str = to_str
self.from_str_upper = from_str.upper()
# Precompile all regex patterns
escaped = re.escape(from_str)
# Pattern for finding the from_str (case insensitive)
self.search_pattern = re.compile(escaped, re.IGNORECASE)
# Pattern for Fortran continuation lines (5 spaces + non-space)
self.fortran_pattern = re.compile(
r'([ ]{5}.)' + escaped + r'(?=_|\W)',
re.IGNORECASE
)
# Pattern for general substitution
# Use capturing group for preceding \W (consumed, restored via group(1))
# Use lookahead (?=_|\W) so underscore after pattern is not consumed [2]
# This correctly handles: void ycopy_() -> void dcopy_()
self.general_pattern = re.compile(
r'(\W)' + escaped + r'(?=_|\W)',
re.IGNORECASE
)
def load_data_file():
"""Load the from/to conversion pairs from the data file and precompile patterns"""
patterns = []
data_path = os.path.dirname(os.path.abspath(__file__))
data_path = os.path.join(data_path, "data.64_to_32")
if debug:
print(f"Data path: {data_path}")
try:
with open(data_path, 'r') as data_file:
for line in data_file:
if line and not line.startswith('#'):
tokens = line.split()
if len(tokens) >= 2:
# For 32_to_64: tokens[1] is "from", tokens[0] is "to" [2]
patterns.append(ConversionPattern(tokens[1], tokens[0]))
except IOError:
sys.exit(f"Unable to open: {data_path}")
if debug:
print(f"Loaded {len(patterns)} conversion patterns")
return patterns
def process_line(line, patterns, line_upper):
"""
Process a single line with all conversion patterns.
Uses early exits and optimized regex passes [2]
"""
# Early exit: Skip comment lines (Fortran style) or empty lines [2]
if not line or line[0] in ('c', 'C', '*') or line.strip() == '':
return line
# Early exit: Quick check if any pattern might match using uppercase comparison
has_potential_match = any(conv.from_str_upper in line_upper for conv in patterns)
if not has_potential_match:
return line
# Determine line type once (not for each pattern) [2]
is_fortran_continuation = (
line.startswith(' ') and len(line) > 5 and not line[5].isspace()
)
# Matches lines starting with space or tab [2]
is_general_line = len(line) > 0 and line[0] in ' \t'
# Matches any line starting with space or non-whitespace char [2]
# ^[ \S] in Perl matches virtually every non-empty line
# including C declarations like "void ycopy_()"
is_declaration_line = len(line) > 0 and (line[0] == ' ' or not line[0].isspace())
# Process each conversion pattern
for conv in patterns:
# Early exit: Skip if pattern not in line (case-insensitive quick check)
if conv.from_str_upper not in line_upper:
continue
match = conv.search_pattern.search(line)
if not match:
continue
# Found a match - compute replacement
froom = match.start()
toot = copy_case(
line[froom:froom + len(conv.from_str)],
conv.to_str
)
# Apply Fortran continuation substitution [2]
if is_fortran_continuation:
line = conv.fortran_pattern.sub(
lambda m: m.group(1) + toot,
line
)
# Apply general substitution for tab/space lines [2]
if is_general_line:
line = conv.general_pattern.sub(
lambda m: m.group(1) + toot,
line
)
# Apply declaration substitution for C-style lines [2]
# Handles cases like "void ycopy_()" where line starts with non-space
if is_declaration_line:
line = conv.general_pattern.sub(
lambda m: m.group(1) + toot,
line
)
# Update line_upper after substitution for subsequent patterns
line_upper = line.upper()
return line
def process_file(file_path, patterns):
"""Process a single file and perform transliteration"""
pid = os.getpid()
orgfile = file_path
filebak = f"{file_path}.{pid}"
if debug:
print(f"Processing: {file_path}")
print(f"Backup file: {filebak}")
# Rename original to backup [2]
os.rename(file_path, filebak)
try:
with open(filebak, 'r') as fh_in:
with open(orgfile, 'w') as fh_out:
for line in fh_in:
line_upper = line.upper()
processed_line = process_line(line, patterns, line_upper)
fh_out.write(processed_line)
except IOError as e:
sys.exit(f"Can't open file: {e}")
# Remove backup [2]
os.unlink(filebak)
def main():
if debug:
print(f"Arguments: {sys.argv[1:]}")
# Load patterns once (precompiled)
patterns = load_data_file()
if len(patterns) == 0:
sys.exit("Fatal sngl2dbl error: No conversion patterns loaded")
files = sys.argv[1:]
if len(files) == 0:
print("Usage: python 32_to_64.py file1.f [file2.f ...]")
sys.exit(1)
# Process each file sequentially
for file_path in files:
process_file(file_path, patterns)
if __name__ == "__main__":
main()

View file

@ -10,39 +10,35 @@ if [[ -z "${NWCHEM_TOP}" ]]; then
MYPWD=`pwd`
NWCHEM_TOP=`echo ${MYPWD}/${DIRUTIL} | sed -e 's/\/src.*//' `
fi
if [ -x /msrc/apps/bin/perl ]; then
perlexe=/msrc/apps/bin/perl
elif [ -x /usr/local/bin/perl ]; then
perlexe=/usr/local/bin/perl
elif [ -x /usr/local/gnu/bin/perl ]; then
perlexe=/usr/local/gnu/bin/perl
elif [ -x /usr/gnu/bin/perl ]; then
perlexe=/usr/gnu/bin/perl
else
# assume perl is in your path
perlexe=perl
fi
perlscript=${NWCHEM_TOP}/src/config/64_to_32.pl
pythonexe=python
pythonscript=${NWCHEM_TOP}/src/config/64_to_32.py
filecheck="/tmp/myfail.txt"
rm -f $filecheck
JOB_LIMIT=6
njob=0
nfail=0
for file in "$@"
do
if [ -f "$file" ]; then
echo converting "$file" to 32-bit integers for BLAS/LAPACK
($perlexe $perlscript $file) &
($pythonexe $pythonscript $file ; if [ $? == 123 ]; then echo $file> $filecheck;fi ) &
let njob++
if [ $njob -gt $JOB_LIMIT ]; then
wait
let njob=0
fi
else
echo "!!!!file missing: " "$file"
fi
done
if [ $njob -gt 0 ] ; then
wait
fi
if [ -f $filecheck ]; then
echo 'Error: DOS file '$(cat $filecheck)
exit 1
fi

238
src/config/64_to_32.py Normal file
View file

@ -0,0 +1,238 @@
#!/usr/bin/env python3
"""
Python script to do transliteration from "double" values to "8wrap" values
Usage: python 64_to_32.py file1.f [file2.f ...]
Original Perl script:
Written: 3/14/97
By: Ricky A. Kendall
Converted from Perl to Python using Claude (claude-4-5-opus-4-5-20251101-v1)
Optimizations applied:
- Early exits to skip unnecessary processing
- Reduced redundant regex passes
- Combined line-type checks
- Precompiled regex patterns
- Lookahead for correct underscore boundary matching
"""
import os
import sys
import re
import subprocess # nosec B404
debug = False
def copy_case(from_str, to_str):
"""Take case from 'from_str' and apply it to 'to_str' and return that new string"""
result = []
for i, char in enumerate(to_str):
if i < len(from_str):
if from_str[i].isupper():
result.append(char.upper())
elif from_str[i].islower():
result.append(char.lower())
else:
result.append(char)
else:
result.append(char)
return ''.join(result)
class ConversionPattern:
"""Holds precompiled regex patterns for a single from/to conversion pair"""
def __init__(self, from_str, to_str):
self.from_str = from_str
self.to_str = to_str
self.from_str_upper = from_str.upper()
# Precompile all regex patterns
escaped = re.escape(from_str)
# Pattern for finding the from_str (case insensitive)
self.search_pattern = re.compile(escaped, re.IGNORECASE)
# Pattern for Fortran continuation lines (5 spaces + non-space)
self.fortran_pattern = re.compile(
r'([ ]{5}.)' + escaped + r'(?=_\(|\W)',
re.IGNORECASE
)
# Pattern for general substitution
# Use capturing group for preceding \W (consumed, restored via group(1))
# Lookahead (?=_\(|\W) matches underscore only when followed by ( [1]
# This correctly handles:
# DCOPY_() -> YCOPY_() (matches - underscore followed by paren)
# DCOPY_OMP() -> DCOPY_OMP() (no match - underscore followed by letter)
# dcopy( -> ycopy( (matches - non-word char after)
self.general_pattern = re.compile(
r'(\W)' + escaped + r'(?=_\(|\W)',
re.IGNORECASE
)
def load_data_file():
"""Load the from/to conversion pairs from the data file and precompile patterns"""
patterns = []
data_path = os.path.dirname(os.path.abspath(__file__))
data_path = os.path.join(data_path, "data.64_to_32")
if debug:
print(f"Data path: {data_path}")
try:
with open(data_path, 'r') as data_file:
for line in data_file:
if line and not line.startswith('#'):
tokens = line.split()
if len(tokens) >= 2:
# For 64_to_32: tokens[0] is "from", tokens[1] is "to" [1]
patterns.append(ConversionPattern(tokens[0], tokens[1]))
except IOError:
sys.exit(f"Unable to open: {data_path}")
if debug:
print(f"Loaded {len(patterns)} conversion patterns")
return patterns
# Precompile line-type detection patterns (used for every line)
FORTRAN_CONTINUATION = re.compile(r'^[ ]{5}[^\s]')
def process_line(line, patterns, line_upper):
"""
Process a single line with all conversion patterns.
Uses early exits and optimized regex passes.
"""
# Early exit: Skip comment lines (Fortran style) or empty lines [1]
if not line or line[0] in ('c', 'C', '*') or line.strip() == '':
return line
# Early exit: Quick check if any pattern might match using uppercase comparison
# This avoids regex overhead for lines with no potential matches
has_potential_match = False
for conv in patterns:
if conv.from_str_upper in line_upper:
has_potential_match = True
break
if not has_potential_match:
return line
# Determine line type once (not for each pattern) [1]
is_fortran_continuation = line.startswith(' ') and len(line) > 5 and not line[5].isspace()
is_general_line = len(line) > 0 and line[0] in ' \t'
# Matches any line starting with space or non-whitespace char [1]
# ^[ \S] in Perl matches virtually every non-empty line
# including C declarations like "void dcopy_()"
is_declaration_line = len(line) > 0 and (line[0] == ' ' or not line[0].isspace())
# Process each conversion pattern
for conv in patterns:
# Early exit: Skip if pattern not in line (case-insensitive quick check)
if conv.from_str_upper not in line_upper:
continue
match = conv.search_pattern.search(line)
if not match:
continue
# Found a match - compute replacement
froom = match.start()
toot = copy_case(
line[froom:froom + len(conv.from_str)],
conv.to_str
)
# Apply Fortran continuation substitution [1]
if is_fortran_continuation:
line = conv.fortran_pattern.sub(
lambda m: m.group(1) + toot,
line
)
# Apply general substitution for tab/space lines [1]
if is_general_line:
line = conv.general_pattern.sub(
lambda m: m.group(1) + toot,
line
)
# Apply declaration substitution for C-style lines [1]
# Handles cases like "void dcopy_()" where line starts with non-space
if is_declaration_line:
line = conv.general_pattern.sub(
lambda m: m.group(1) + toot,
line
)
# Update line_upper after substitution for subsequent patterns
line_upper = line.upper()
return line
def process_file(file_path, patterns):
"""Process a single file and perform transliteration"""
pid = os.getpid()
orgfile = file_path
filebak = f"{file_path}.{pid}"
if debug:
print(f"Processing: {file_path}")
print(f"Backup file: {filebak}")
# Runs the Linux 'file' command
result = subprocess.run(['file', file_path], shell=False, capture_output=True, text=True) # nosec
# DOS files output contains "with CRLF line terminators"
if "CRLF" in result.stdout:
print(f"ERROR: DOS file with CRLF {file_path}", file=sys.stderr)
sys.exit(123)
# Rename original to backup [1]
os.rename(file_path, filebak)
try:
with open(filebak, 'r') as fh_in:
with open(orgfile, 'w') as fh_out:
for line in fh_in:
line_upper = line.upper()
processed_line = process_line(line, patterns, line_upper)
fh_out.write(processed_line)
except IOError as e:
sys.exit(f"Can't open file: {e}")
# Remove backup [1]
os.unlink(filebak)
def main():
if debug:
print(f"Arguments: {sys.argv[1:]}")
# Load patterns once (precompiled)
patterns = load_data_file()
if len(patterns) == 0:
sys.exit("Fatal dbl2sngl error: No conversion patterns loaded")
files = sys.argv[1:]
if len(files) == 0:
print("Usage: python 64_to_32.py file1.f [file2.f ...]")
sys.exit(1)
# Process each file sequentially
for file_path in files:
process_file(file_path, patterns)
if __name__ == "__main__":
main()

View file

@ -264,7 +264,7 @@ endif
endif # QUICKBUILD
ifdef CONVERT_ALL
64_to_32:
$(CNFDIR)/64_to_32 *.F *.f *.c *.f90
$(CNFDIR)/64_to_32 *.F *.f *.c *.f90 *fh
ifdef SUBDIRS
$(MAKESUBDIRS)
endif

View file

@ -73,7 +73,7 @@ c
$ ostress2, ! include lattice gradients
$ ocheckgrad, ! verify the gradient
$ diagonal_hessian, ! tells the code to use a diagonal hessian
$ ofast_diag , ! use dsyev instead of jacobi eigensolver
$ ofast_diag , ! use _dsyev_ instead of jacobi eigensolver
$ oactive(max_cent) ! active atom flags
c
character*8

View file

@ -1,228 +1,228 @@
c
c this is the gradient correction term by Keal and Tozer,
c which can be used on its own (as in the KT1 functional),
c or forms part of the SSB-D functional
c
c it never includes LDA !!
c (this is taken care of somewhere else)
c
c note that even though the energy is assigned here to the
c exchange, this gradient correction is strictly speaking
c NOT an exchange functional !
c
c KT1/KT2 reference:
c T.W. Keal, D.J. Tozer, JCP 2006, 119, 3015
c SSB-D reference:
c M. Swart, M. Sola, F.M. Bickelhaupt, JCP 2009, 131, 094103
c
#ifndef SECOND_DERIV
Subroutine xc_kt1(tol_rho, fac, rho, delrho,
& Amat, Cmat, nq, ipol, Ex, qwght,ldew,func)
#else
Subroutine xc_kt1_d2(tol_rho, fac, rho, delrho,
& Amat, Amat2, Cmat, Cmat2, nq, ipol,
& Ex, qwght,ldew,func)
#endif
c
C$Id$
c
implicit none
c
#include "dft2drv.fh"
c
double precision tol_rho, fac, Ex
integer nq, ipol
logical ldew
double precision func(*) ! value of the functional [output]
c
c Charge Density
c
double precision rho(nq,ipol*(ipol+1)/2)
c
c Charge Density Gradient
c
double precision delrho(nq,3,ipol)
c
c Quadrature Weights
c
double precision qwght(nq)
c
c Sampling Matrices for the XC Potential
c
double precision Amat(nq,ipol), Cmat(nq,*)
c
#ifdef SECOND_DERIV
c
c Second Derivatives of the Exchange Energy Functional
c
double precision Amat2(nq,NCOL_AMAT2), Cmat2(nq,NCOL_CMAT2)
#endif
c
double precision DELTA, GAMKT
Parameter (DELTA = 0.1D0, GAMKT= -0.006d0)
c
c References:
c
c Keal, Tozer, JCP 119, 3015 (2003), JCP 121, 5654 (2004)
c Swart, Sola, Bickelhaupt, JCP 131, XXXX (2009)
c Johnson, Gill & Pople, J. Chem. Phys. 98, 5612 (1993)
c
c***************************************************************************
c
integer n
double precision hrho
double precision rho13, rho43, gamma, g, gdenom, gdenom2
#ifdef SECOND_DERIV
double precision rho23, rhom23, gdenom3
#endif
c
c NOTE: the gamma from the KT1 formulation is here called
c gamkt, gamma is in NWChem reserved for grad**2
c
if (ipol.eq.1) then
c
c ======> SPIN-RESTRICTED <======
c
do 10 n = 1, nq
if (rho(n,1).lt.tol_rho) goto 10
c
c Spin alpha:
c
hrho = 0.5d0*rho(n,1)
rho13 = hrho**(1.d0/3.d0)
rho43 = rho13*hrho
gamma = delrho(n,1,1)*delrho(n,1,1) +
& delrho(n,2,1)*delrho(n,2,1) +
& delrho(n,3,1)*delrho(n,3,1)
if (dsqrt(gamma).gt.tol_rho) then
gamma = 0.25d0 * gamma
else
goto 10
endif
c
gdenom = 1.d0 / (rho43 + DELTA)
gdenom2 = gdenom*gdenom
g = GAMKT * gamma * gdenom
c
Ex = Ex + 2.d0*g*qwght(n)*fac
if (ldew) func(n) = func(n) + 2.d0*g*fac
Amat(n,1) = Amat(n,1) - (4d0/3d0)*GAMKT*gamma*rho13*
& fac*gdenom2
Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + GAMKT*gdenom*fac
c
#ifdef SECOND_DERIV
rho23 = rho13*rho13
rhom23 = rho13 / (0.5d0*rho(n,1))
gdenom3 = gdenom2*gdenom
c
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) + (4d0/3d0)*GAMKT*
& gamma*(rho23*7d0/3d0 - DELTA*rhom23/3d0)*gdenom3*fac
Cmat2(n,D2_RA_GAA) = Cmat2(n,D2_RA_GAA)
& - (4d0/3d0)*GAMKT*rho13*gdenom2*fac
c
c second derivative w.r.t. gamma is zero !
c (by construction)
c therefore, nothing added to Cmat2(n,D2_GAA_GAA)
c
#endif
c
10 continue
c
else
c
c ======> SPIN-UNRESTRICTED <======
c
do 20 n = 1, nq
if (rho(n,1).lt.tol_rho) goto 20
if (rho(n,2).lt.tol_rho) goto 25
c
c Spin alpha:
c
rho13 = rho(n,2)**(1.d0/3.d0)
rho43 = rho13*rho(n,2)
gamma = delrho(n,1,1)*delrho(n,1,1) +
& delrho(n,2,1)*delrho(n,2,1) +
& delrho(n,3,1)*delrho(n,3,1)
if (dsqrt(gamma).lt.tol_rho) then
goto 25
endif
c
gdenom = 1d0 / (rho43 + DELTA)
gdenom2 = gdenom*gdenom
g = GAMKT * gamma * gdenom
c
Ex = Ex + g*qwght(n)*fac
if (ldew) func(n) = func(n) + g*fac
Amat(n,1) = Amat(n,1) - (4d0/3d0)*GAMKT*gamma*rho13*
& gdenom2*fac
Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + GAMKT*gdenom*fac
c
#ifdef SECOND_DERIV
rho23 = rho13*rho13
rhom23 = rho13 / rho(n,2)
gdenom3 = gdenom2*gdenom
c
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) + (4d0/3d0)*GAMKT*
& gamma*(rho23*7d0/3d0 - DELTA*rhom23/3d0)*gdenom3*fac
Cmat2(n,D2_RA_GAA) = Cmat2(n,D2_RA_GAA)
& - (4d0/3d0)*GAMKT*rho13*gdenom2*fac
c
c second derivative w.r.t. gamma is zero !
c (by construction)
c therefore, nothing added to Cmat2(n,D2_GAA_GAA)
#endif
c
25 continue
c
c Spin beta:
c
if (rho(n,3).lt.tol_rho) goto 20
c
rho13 = rho(n,3)**(1.d0/3.d0)
rho43 = rho13*rho(n,3)
gamma = delrho(n,1,2)*delrho(n,1,2) +
& delrho(n,2,2)*delrho(n,2,2) +
& delrho(n,3,2)*delrho(n,3,2)
if (dsqrt(gamma).lt.tol_rho) then
goto 20
endif
c
gdenom = 1d0 / (rho43 + DELTA)
gdenom2 = gdenom*gdenom
g = GAMKT * gamma * gdenom
c
Ex = Ex + g*qwght(n)*fac
if (ldew) func(n) = func(n) + g*fac
Amat(n,2) = Amat(n,2) - (4d0/3d0)*GAMKT*gamma*rho13*
& fac*gdenom2
Cmat(n,D1_GBB) = Cmat(n,D1_GBB) + GAMKT*gdenom*fac
c
#ifdef SECOND_DERIV
rho23 = rho13*rho13
rhom23 = rho13 / rho(n,3)
gdenom3 = gdenom2*gdenom
c
Amat2(n,D2_RB_RB) = Amat2(n,D2_RB_RB) + (4d0/3d0)*GAMKT*
& gamma*(rho23*7d0/3d0 - DELTA*rhom23/3d0)*gdenom3*fac
Cmat2(n,D2_RB_GBB) = Cmat2(n,D2_RB_GBB)
& - (4d0/3d0)*GAMKT*rho13*gdenom2*fac
c
c second derivative w.r.t. gamma is zero !
c (by construction)
c therefore, nothing added to Cmat2(n,D2_GAA_GAA)
c
#endif
c
20 continue
c
endif
c
return
end
#ifndef SECOND_DERIV
#define SECOND_DERIV
c
c Compile source again for the 2nd derivative case
c
#include "xc_kt1.F"
#endif
c
c this is the gradient correction term by Keal and Tozer,
c which can be used on its own (as in the KT1 functional),
c or forms part of the SSB-D functional
c
c it never includes LDA !!
c (this is taken care of somewhere else)
c
c note that even though the energy is assigned here to the
c exchange, this gradient correction is strictly speaking
c NOT an exchange functional !
c
c KT1/KT2 reference:
c T.W. Keal, D.J. Tozer, JCP 2006, 119, 3015
c SSB-D reference:
c M. Swart, M. Sola, F.M. Bickelhaupt, JCP 2009, 131, 094103
c
#ifndef SECOND_DERIV
Subroutine xc_kt1(tol_rho, fac, rho, delrho,
& Amat, Cmat, nq, ipol, Ex, qwght,ldew,func)
#else
Subroutine xc_kt1_d2(tol_rho, fac, rho, delrho,
& Amat, Amat2, Cmat, Cmat2, nq, ipol,
& Ex, qwght,ldew,func)
#endif
c
C$Id$
c
implicit none
c
#include "dft2drv.fh"
c
double precision tol_rho, fac, Ex
integer nq, ipol
logical ldew
double precision func(*) ! value of the functional [output]
c
c Charge Density
c
double precision rho(nq,ipol*(ipol+1)/2)
c
c Charge Density Gradient
c
double precision delrho(nq,3,ipol)
c
c Quadrature Weights
c
double precision qwght(nq)
c
c Sampling Matrices for the XC Potential
c
double precision Amat(nq,ipol), Cmat(nq,*)
c
#ifdef SECOND_DERIV
c
c Second Derivatives of the Exchange Energy Functional
c
double precision Amat2(nq,NCOL_AMAT2), Cmat2(nq,NCOL_CMAT2)
#endif
c
double precision DELTA, GAMKT
Parameter (DELTA = 0.1D0, GAMKT= -0.006d0)
c
c References:
c
c Keal, Tozer, JCP 119, 3015 (2003), JCP 121, 5654 (2004)
c Swart, Sola, Bickelhaupt, JCP 131, XXXX (2009)
c Johnson, Gill & Pople, J. Chem. Phys. 98, 5612 (1993)
c
c***************************************************************************
c
integer n
double precision hrho
double precision rho13, rho43, gamma, g, gdenom, gdenom2
#ifdef SECOND_DERIV
double precision rho23, rhom23, gdenom3
#endif
c
c NOTE: the gamma from the KT1 formulation is here called
c gamkt, gamma is in NWChem reserved for grad**2
c
if (ipol.eq.1) then
c
c ======> SPIN-RESTRICTED <======
c
do 10 n = 1, nq
if (rho(n,1).lt.tol_rho) goto 10
c
c Spin alpha:
c
hrho = 0.5d0*rho(n,1)
rho13 = hrho**(1.d0/3.d0)
rho43 = rho13*hrho
gamma = delrho(n,1,1)*delrho(n,1,1) +
& delrho(n,2,1)*delrho(n,2,1) +
& delrho(n,3,1)*delrho(n,3,1)
if (dsqrt(gamma).gt.tol_rho) then
gamma = 0.25d0 * gamma
else
goto 10
endif
c
gdenom = 1.d0 / (rho43 + DELTA)
gdenom2 = gdenom*gdenom
g = GAMKT * gamma * gdenom
c
Ex = Ex + 2.d0*g*qwght(n)*fac
if (ldew) func(n) = func(n) + 2.d0*g*fac
Amat(n,1) = Amat(n,1) - (4d0/3d0)*GAMKT*gamma*rho13*
& fac*gdenom2
Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + GAMKT*gdenom*fac
c
#ifdef SECOND_DERIV
rho23 = rho13*rho13
rhom23 = rho13 / (0.5d0*rho(n,1))
gdenom3 = gdenom2*gdenom
c
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) + (4d0/3d0)*GAMKT*
& gamma*(rho23*7d0/3d0 - DELTA*rhom23/3d0)*gdenom3*fac
Cmat2(n,D2_RA_GAA) = Cmat2(n,D2_RA_GAA)
& - (4d0/3d0)*GAMKT*rho13*gdenom2*fac
c
c second derivative w.r.t. gamma is zero !
c (by construction)
c therefore, nothing added to Cmat2(n,D2_GAA_GAA)
c
#endif
c
10 continue
c
else
c
c ======> SPIN-UNRESTRICTED <======
c
do 20 n = 1, nq
if (rho(n,1).lt.tol_rho) goto 20
if (rho(n,2).lt.tol_rho) goto 25
c
c Spin alpha:
c
rho13 = rho(n,2)**(1.d0/3.d0)
rho43 = rho13*rho(n,2)
gamma = delrho(n,1,1)*delrho(n,1,1) +
& delrho(n,2,1)*delrho(n,2,1) +
& delrho(n,3,1)*delrho(n,3,1)
if (dsqrt(gamma).lt.tol_rho) then
goto 25
endif
c
gdenom = 1d0 / (rho43 + DELTA)
gdenom2 = gdenom*gdenom
g = GAMKT * gamma * gdenom
c
Ex = Ex + g*qwght(n)*fac
if (ldew) func(n) = func(n) + g*fac
Amat(n,1) = Amat(n,1) - (4d0/3d0)*GAMKT*gamma*rho13*
& gdenom2*fac
Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + GAMKT*gdenom*fac
c
#ifdef SECOND_DERIV
rho23 = rho13*rho13
rhom23 = rho13 / rho(n,2)
gdenom3 = gdenom2*gdenom
c
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) + (4d0/3d0)*GAMKT*
& gamma*(rho23*7d0/3d0 - DELTA*rhom23/3d0)*gdenom3*fac
Cmat2(n,D2_RA_GAA) = Cmat2(n,D2_RA_GAA)
& - (4d0/3d0)*GAMKT*rho13*gdenom2*fac
c
c second derivative w.r.t. gamma is zero !
c (by construction)
c therefore, nothing added to Cmat2(n,D2_GAA_GAA)
#endif
c
25 continue
c
c Spin beta:
c
if (rho(n,3).lt.tol_rho) goto 20
c
rho13 = rho(n,3)**(1.d0/3.d0)
rho43 = rho13*rho(n,3)
gamma = delrho(n,1,2)*delrho(n,1,2) +
& delrho(n,2,2)*delrho(n,2,2) +
& delrho(n,3,2)*delrho(n,3,2)
if (dsqrt(gamma).lt.tol_rho) then
goto 20
endif
c
gdenom = 1d0 / (rho43 + DELTA)
gdenom2 = gdenom*gdenom
g = GAMKT * gamma * gdenom
c
Ex = Ex + g*qwght(n)*fac
if (ldew) func(n) = func(n) + g*fac
Amat(n,2) = Amat(n,2) - (4d0/3d0)*GAMKT*gamma*rho13*
& fac*gdenom2
Cmat(n,D1_GBB) = Cmat(n,D1_GBB) + GAMKT*gdenom*fac
c
#ifdef SECOND_DERIV
rho23 = rho13*rho13
rhom23 = rho13 / rho(n,3)
gdenom3 = gdenom2*gdenom
c
Amat2(n,D2_RB_RB) = Amat2(n,D2_RB_RB) + (4d0/3d0)*GAMKT*
& gamma*(rho23*7d0/3d0 - DELTA*rhom23/3d0)*gdenom3*fac
Cmat2(n,D2_RB_GBB) = Cmat2(n,D2_RB_GBB)
& - (4d0/3d0)*GAMKT*rho13*gdenom2*fac
c
c second derivative w.r.t. gamma is zero !
c (by construction)
c therefore, nothing added to Cmat2(n,D2_GAA_GAA)
c
#endif
c
20 continue
c
endif
c
return
end
#ifndef SECOND_DERIV
#define SECOND_DERIV
c
c Compile source again for the 2nd derivative case
c
#include "xc_kt1.F"
#endif

View file

@ -189,7 +189,7 @@ def find_code_skeleton_type(lines,subr_lines):
autoxc-Ds generated subroutine.
"""
(lineno_start,lineno_end) = subr_lines
pattern = re.compile("if \(taua\.gt\.tol_rho\) then")
pattern = re.compile(r"if \(taua\.gt\.tol_rho\) then")
subr_type = type_autoxc
line = lineno_start
while line <= lineno_end:
@ -210,14 +210,14 @@ def find_autoxc_code_skeleton(lines,subr_lines):
ifstart = -1
ifend = -1
#
pattern = re.compile("if \(rhoa\.gt\.tol_rho\) then")
pattern = re.compile(r"if \(rhoa\.gt\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifstart = line+1
break
line += 1
#
pattern = re.compile("endif ! rhoa\.gt\.tol_rho")
pattern = re.compile(r"endif ! rhoa\.gt\.tol_rho")
while line <= lineno_end:
if pattern.search(lines[line]):
ifend = line-1
@ -232,14 +232,14 @@ def find_autoxc_code_skeleton(lines,subr_lines):
ifendb = -1
ifstartc = -1
ifendc = -1
pattern = re.compile("if \(rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
pattern = re.compile(r"if \(rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifstarta = line+1
break
line += 1
#
pattern = re.compile("elseif \(rhoa\.gt\.tol_rho\.and\.rhob\.le\.tol_rho\) then")
pattern = re.compile(r"elseif \(rhoa\.gt\.tol_rho\.and\.rhob\.le\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifenda = line-1
@ -247,7 +247,7 @@ def find_autoxc_code_skeleton(lines,subr_lines):
break
line += 1
#
pattern = re.compile("elseif \(rhoa\.le\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
pattern = re.compile(r"elseif \(rhoa\.le\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifendb = line-1
@ -255,7 +255,7 @@ def find_autoxc_code_skeleton(lines,subr_lines):
break
line += 1
#
pattern = re.compile("endif ! rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho")
pattern = re.compile(r"endif ! rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho")
while line <= lineno_end:
if pattern.search(lines[line]):
ifendc = line-1
@ -281,14 +281,14 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
ifstartb = -1
ifendb = -1
#
pattern = re.compile("if \(taua\.gt\.tol_rho\) then")
pattern = re.compile(r"if \(taua\.gt\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifstarta = line+1
break
line += 1
#
pattern = re.compile("else")
pattern = re.compile(r"else")
while line <= lineno_end:
if pattern.search(lines[line]):
ifenda = line-1
@ -296,7 +296,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
break
line += 1
#
pattern = re.compile("endif")
pattern = re.compile(r"endif")
while line <= lineno_end:
if pattern.search(lines[line]):
ifendb = line-1
@ -315,14 +315,14 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
ifendc = -1
ifstartd = -1
ifendd = -1
pattern = re.compile("if \(taua\.gt\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
pattern = re.compile(r"if \(taua\.gt\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifstarta = line+1
break
line += 1
#
pattern = re.compile("elseif \(taua\.gt\.tol_rho\.and\.taub\.le\.tol_rho\) then")
pattern = re.compile(r"elseif \(taua\.gt\.tol_rho\.and\.taub\.le\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifenda = line-1
@ -330,7 +330,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
break
line += 1
#
pattern = re.compile("elseif \(taua\.le\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
pattern = re.compile(r"elseif \(taua\.le\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
while line <= lineno_end:
if pattern.search(lines[line]):
ifendb = line-1
@ -340,7 +340,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
#
# needed because "else" is a substring of "elseif ..."
line = ifstartc
pattern = re.compile("else")
pattern = re.compile(r"else")
while line <= lineno_end:
if pattern.search(lines[line]):
ifendc = line-1
@ -348,7 +348,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
break
line += 1
#
pattern = re.compile("endif")
pattern = re.compile(r"endif")
while line <= lineno_end:
if pattern.search(lines[line]):
ifendd = line-1
@ -368,7 +368,7 @@ def find_type_declaration_insertion_point(lines,subr_lines):
subroutine calls can be inserted.
"""
(lineno_start,lineno_end) = subr_lines
pattern = re.compile("#include \"nwxc_param.fh\"")
pattern = re.compile(r"#include \"nwxc_param.fh\"")
line_insert = -1
line = lineno_start
while line <= lineno_end:
@ -412,7 +412,7 @@ def collect_subroutine_calls(lines,ifbranch_lines):
"""
(lineno_start,lineno_end) = ifbranch_lines
dict = {}
pattern = re.compile("nwxc")
pattern = re.compile(r"nwxc")
line = lineno_start
while line <= lineno_end:
if pattern.search(lines[line]):
@ -640,8 +640,8 @@ def find_max_order_diff(lines,subr_lines):
(lineno_start,lineno_end) = subr_lines
aline = lines[lineno_start]
orderdiff = 0
pattern_d2 = re.compile("_d2\(")
pattern_d3 = re.compile("_d3\(")
pattern_d2 = re.compile(r"_d2\(")
pattern_d3 = re.compile(r"_d3\(")
if pattern_d2.search(aline):
orderdiff = 2
elif pattern_d3.search(aline):
@ -740,9 +740,9 @@ def find_varname(dict,diffstr):
#DEBUG
lengthl = len(list)
if num == lengthl:
sys.stdout.write("entity %s not found\n"%callref)
sys.stdout.write(r"entity %s not found\n"%callref)
for jj in range(0,length):
sys.stdout.write("list %d: %s\n"%(jj,list[jj]))
sys.stdout.write(r"list %d: %s\n"%(jj,list[jj]))
sys.exit(10)
# num is now the variable set number
lengthd = len(data)
@ -764,8 +764,8 @@ def find_varname(dict,diffstr):
#print "find_varname: orderdiff:",orderdiff
#DEBUG
# orderdiff is now the order of differentiation
patternc = re.compile("gamma")
patternt = re.compile("tau")
patternc = re.compile(r"gamma")
patternt = re.compile(r"tau")
var_func = func_lda
if lengthd >= 3:
if patternc.match(data[1]):
@ -909,7 +909,7 @@ def find_indent(line):
Given a line of source code work the indentation out and return a string
containing as many spaces as the indentation.
"""
pattern = re.compile("\s*")
pattern = re.compile(r"\s*")
obj = pattern.match(line)
indent = obj.group()
return indent
@ -919,13 +919,13 @@ def find_var_in_line(line,var_name):
Find all locations where the variable given by "var_name" is used.
The locations are stored in a list which is returned.
"""
patterne = re.compile(" = ")
patterne = re.compile(r" = ")
# If var_name = t2 we need to make sure we do not replace
# cmat2 as well. Patternw is needed to achieve that. So we look for
# t2 as well at2, if the end-points are equal the string found does
# not match the variable t2.
patternv = re.compile(var_name+"[^0-9]")
patternw = re.compile("a"+var_name+"[^0-9]")
patternw = re.compile(r"a"+var_name+"[^0-9]")
aline = line+" "
found = patterne.search(aline)
list = []
@ -952,7 +952,7 @@ def expand_var_in_line(line,list):
Here we expand the tuples in the list to cover these strings in full.
The list with updated tuples is returned.
"""
pattern = re.compile("\)")
pattern = re.compile(r"\)")
item = 0
length = len(list)
while item < length:
@ -1006,7 +1006,7 @@ def rewrap_line(longline):
conform the Fortran77 standard. The chunks are written to standard output.
In addition we do not want to break the line in the middle of numbers.
"""
pattern = re.compile("\S")
pattern = re.compile(r"\S")
i = (pattern.search(longline)).start()
indent = longline[:i]
indent = indent[:5]+"+"+indent[7:]+" "

View file

@ -39,18 +39,18 @@ def rewrap_line(longline):
while len(longline)-1 > 72:
i = -1
# wrap before * / ( ) + or -
i = max(i,rfind(longline,"+",0,71))
i = max(i,rfind(longline,"-",0,71))
i = max(i,rfind(longline,"/",0,71))
i = max(i,rfind(longline,"\,",0,70))
i = max(i,rfind(longline,", ",0,70))
i = max(i,rfind(longline,"\it",0,69))
i = max(i,rfind(longline,"\rho",0,68))
i = max(i,rfind(longline,"\sigma",0,66))
i = max(i,rfind(longline,"\tau",0,68))
i = max(i,rfind(longline,"\left",0,67))
i = max(i,rfind(longline,"\over",0,67))
i = max(i,rfind(longline,"\right",0,66))
i = max(i,rfind(longline,r"+",0,71))
i = max(i,rfind(longline,r"-",0,71))
i = max(i,rfind(longline,r"/",0,71))
i = max(i,rfind(longline,r"\,",0,70))
i = max(i,rfind(longline,r", ",0,70))
i = max(i,rfind(longline,r"\it",0,69))
i = max(i,rfind(longline,r"\rho",0,68))
i = max(i,rfind(longline,r"\sigma",0,66))
i = max(i,rfind(longline,r"\tau",0,68))
i = max(i,rfind(longline,r"\left",0,67))
i = max(i,rfind(longline,r"\over",0,67))
i = max(i,rfind(longline,r"\right",0,66))
if i == -1:
sys.stderr.write("No sensible break point found in:\n")
sys.stderr.write(longline)

View file

@ -1,35 +1,35 @@
c
double precision function qmd_ran1(idum)
c
implicit none
c
integer idum,IA,IM,IQ,IR,NTAB,NDIV
double precision AM,EPS,RNMX
c
parameter (IA=16807,IM=2147483647,AM=1./IM,IQ=127773,IR=2836,
& NTAB=32,NDIV=1+(IM-1)/NTAB,EPS=1.2e-7,RNMX=1.-EPS)
c
integer j,k,iv(NTAB),iy
save iv,iy
data iv /NTAB*0/, iy /0/
c
if (idum.le.0.or.iy.eq.0) then
idum=max(-idum,1)
do 11 j=NTAB+8,1,-1
k=idum/IQ
idum=IA*(idum-k*IQ)-IR*k
if (idum.lt.0) idum=idum+IM
if (j.le.NTAB) iv(j)=idum
11 continue
iy=iv(1)
endif
k=idum/IQ
idum=IA*(idum-k*IQ)-IR*k
if (idum.lt.0) idum=idum+IM
j=1+iy/NDIV
iy=iv(j)
iv(j)=idum
qmd_ran1=min(AM*iy,RNMX)
c
return
end
c
double precision function qmd_ran1(idum)
c
implicit none
c
integer idum,IA,IM,IQ,IR,NTAB,NDIV
double precision AM,EPS,RNMX
c
parameter (IA=16807,IM=2147483647,AM=1./IM,IQ=127773,IR=2836,
& NTAB=32,NDIV=1+(IM-1)/NTAB,EPS=1.2e-7,RNMX=1.-EPS)
c
integer j,k,iv(NTAB),iy
save iv,iy
data iv /NTAB*0/, iy /0/
c
if (idum.le.0.or.iy.eq.0) then
idum=max(-idum,1)
do 11 j=NTAB+8,1,-1
k=idum/IQ
idum=IA*(idum-k*IQ)-IR*k
if (idum.lt.0) idum=idum+IM
if (j.le.NTAB) iv(j)=idum
11 continue
iy=iv(1)
endif
k=idum/IQ
idum=IA*(idum-k*IQ)-IR*k
if (idum.lt.0) idum=idum+IM
j=1+iy/NDIV
iy=iv(j)
iv(j)=idum
qmd_ran1=min(AM*iy,RNMX)
c
return
end

View file

@ -33,7 +33,7 @@ static void Error(char *string, int integer)
}
static void Dscal(int n, double s, double *u, int iu)
static void selci_dscal(int n, double s, double *u, int iu)
/*
Scale double precision vector u by s
*/
@ -735,7 +735,7 @@ void FATR selci_couple_(Integer *pmulti, Integer *pns, Integer *pprint, char *pf
/* Make the matrices (-1)^p sqrt(2) U(P), P=(1...m)(1...j)
Note that in u we already have (-1)^m U(1...m) */
Dscal(nf*nf, sqrt(2.0), u, 1);
selci_dscal(nf*nf, sqrt(2.0), u, 1);
if (print) {
(void) printf("\n(-1)^p sqrt(2) U(P), P=(1...%d)(1...%d)\n",i,1);

View file

@ -286,7 +286,7 @@ class Operator:
"""Returns a LaTex form of output"""
show = string.join([self.type[0],"_{",repr(self.index),"}"], "")
if (self.dagger == "creation"):
show = string.join([show, "^{\dagger}"], "")
show = string.join([show, r"^{\dagger}"], "")
return show
def duplicate(self):
@ -507,7 +507,7 @@ class Amplitude:
show = string.join([show, index.texwithoutdagger()])
show = string.join([show,"}"])
if (self.conjugate):
show = string.join(["\\left(",show,"\\right)^{\\dagger}"],"")
show = string.join([r"\\left(",show,"\\right)^{\\dagger}"],"")
return show
def duplicate(self):
@ -845,10 +845,10 @@ class OperatorSequence:
if (self.sequence):
show = string.join([show, "\\langle 0 |"])
for sequence in self.sequence:
show = string.join([show, "\{"])
show = string.join([show, r"\{"])
for operator in sequence:
show = string.join([show, operator.tex()])
show = string.join([show, "\}"])
show = string.join([show, r"\}"])
show = string.join([show, "|0\\rangle"])
return show

View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -eo pipefail
sudo apt-get install -y mpich libmpich-dev
export NWCHEM_TOP=`pwd`
export USE_MPI=1