From eb3d19880fd03a4deeb5cbc51b58e8b8ba4474bf Mon Sep 17 00:00:00 2001 From: zaikunzhang Date: Fri, 8 Sep 2023 10:09:59 +0800 Subject: [PATCH] 230908.100959.HKT remove unwanted writings --- fortran/lincoa/getact.f90 | 4 +-- fortran/tests/testsuite/freeform.m | 44 ------------------------------ matlab/setup_tools/freeform.m | 2 ++ 3 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 fortran/tests/testsuite/freeform.m diff --git a/fortran/lincoa/getact.f90 b/fortran/lincoa/getact.f90 index 6c4063126b..b670edee42 100644 --- a/fortran/lincoa/getact.f90 +++ b/fortran/lincoa/getact.f90 @@ -12,7 +12,7 @@ module getact_mod ! ! Started: February 2022 ! -! Last Modified: Thursday, September 07, 2023 PM12:01:27 +! Last Modified: Friday, September 08, 2023 AM10:09:46 !--------------------------------------------------------------------------------------------------! implicit none @@ -392,8 +392,6 @@ subroutine getact(amat, delta, g, iact, nact, qfac, resact, resnew, rfac, psd) call assert(all(is_finite(psd)) .or. nact == 0, 'PSD is finite unless NACT == 0', srname) ! In theory, ||PSD||^2 <= GG and -GG <= PSD^T*G <= 0. ! N.B. 1. Do not use DD, which may not be up to date. 2. PSD^T*G can be NaN if G is huge. - write (*, *) 'GG = ', GG, 'PSD*PSD = ', inprod(psd, psd), 'PSD*G = ', inprod(psd, g) - write (*, *) 'PSD = ', psd call assert(inprod(psd, psd) <= TWO * gg, '||PSD||^2 <= 2*GG', srname) call assert(.not. (inprod(psd, g) > 1.0E2_RP * EPS * gg .or. inprod(psd, g) < -TWO * gg), '-2*GG <= PSD^T*G <= 0', srname) end if diff --git a/fortran/tests/testsuite/freeform.m b/fortran/tests/testsuite/freeform.m deleted file mode 100644 index 4824be4c11..0000000000 --- a/fortran/tests/testsuite/freeform.m +++ /dev/null @@ -1,44 +0,0 @@ -function freeform(files) -%FREEFORM refactors the Fortran code in `files` from the fixed form to the free form. -% -% Coded by Zaikun ZHANG (www.zhangzk.net) in August, 2020. - -if nargin < 1 || isempty(files) || strcmpi(files, 'ALL') - listing = dir(); - files = {listing.name}; -else - files = {files}; -end - -for ifile = 1 : length(files) - filename = files{ifile}; - if endsWith(filename, '.f') || endsWith(filename, '.f90') - fid = fopen(filename, 'r'); % Open file for reading. - if fid == -1 - error('Cannot open file %s', filename); - end - data = textscan(fid, '%s', 'delimiter', '\n', 'whitespace', ''); - fclose(fid); - cstr = data{1}; - cstr(count(cstr, 'C') == strlength(cstr)) = replace(cstr(count(cstr, 'C') == strlength(cstr)), 'C', '!'); - for jc = 1 : length(cstr) - if startsWith(cstr{jc}, 'C') - strt = cstr{jc}; - strt(1) = '!'; - cstr{jc} = strt; - end - if startsWith(cstr{jc}, ' ') - strt = cstr{jc}; - strt = strt(7:end); - cstr{jc} = strt; - end - end - cstr(~startsWith(strtrim(cstr), '!') & ~contains(cstr, 'FORMAT')) = lower(cstr(~startsWith(strtrim(cstr), '!') & ~contains(cstr, 'FORMAT'))); - fid = fopen(filename, 'w'); % Open/create file for writing. Discard existing contents, if any. - if fid == -1 - error('Cannot open file %s', filename); - end - fprintf(fid, '%s\n', cstr{:}); - fclose(fid); - end -end diff --git a/matlab/setup_tools/freeform.m b/matlab/setup_tools/freeform.m index 2170a6e663..ba4de8a08d 100644 --- a/matlab/setup_tools/freeform.m +++ b/matlab/setup_tools/freeform.m @@ -8,6 +8,8 @@ function freeform(files) files = {listing.name}; elseif ischarstr(files) files = {files}; +else + error('Invalid input.') end for ifile = 1 : length(files)