From fdd4d332599d8ee20d8af437d808bc8e0b71aaa8 Mon Sep 17 00:00:00 2001 From: Leandro Martinez Date: Thu, 23 Nov 2023 13:48:54 -0300 Subject: [PATCH 1/4] output receives file name as parameter --- app/packmol.f90 | 14 +++++++------- src/checkpoint.f90 | 4 ++-- src/output.f90 | 11 ++++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/packmol.f90 b/app/packmol.f90 index f1d8558..2a2f56e 100644 --- a/app/packmol.f90 +++ b/app/packmol.f90 @@ -668,7 +668,7 @@ program packmol ! If there are no variables (only fixed molecules, stop) if(n.eq.0) then - call output(n,x) + call output(n,x, xyzout) write(*,dash1_line) write(*,*) ' There are only fixed molecules, therefore there is nothing to do. ' write(*,*) ' The output file contains the fixed molecules in the desired positions. ' @@ -701,7 +701,7 @@ program packmol ! Stop if only checking the initial approximation if(check) then - call output(n,x) + call output(n,x,xyzout) write(*,*) ' Wrote initial point to output file: ', trim(adjustl(xyzout)) if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile)) stop @@ -753,7 +753,7 @@ program packmol write(*,*) ' Initial approximation is a solution. Nothing to do. ' write(*,*) call swaptype(n,x,itype,3) ! Restore all-molecule vectors - call output(n,x) + call output(n,x,xyzout) if( itype == ntype + 1 ) then write(*,*) ' Solution written to file: ', trim(adjustl(xyzout)) if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile)) @@ -849,7 +849,7 @@ program packmol ! If the solution was found for this type if( fdist < precision .and. frest < precision ) then call swaptype(n,x,itype,3) ! Restore all molecule vectors - call output(n,x) + call output(n,x,xyzout) write(*,*) ' Current structure written to file: ', trim(adjustl(xyzout)) if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile)) call writesuccess(itype,fdist,frest,fx) @@ -869,7 +869,7 @@ program packmol if ( fx < bestf ) bestf = fx ! If solution was found for all system if ( fdist < precision .and. frest < precision ) then - call output(n,x) + call output(n,x,xyzout) call writesuccess(itype,fdist,frest,fx) write(*,*) ' Solution written to file: ', trim(adjustl(xyzout)) if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile)) @@ -882,7 +882,7 @@ program packmol ! If this is the best structure so far if( mod(loop+1,writeout) == 0 .and. all_type_fx < fprint ) then - call output(n,x) + call output(n,x,xyzout) write(*,*) ' Current solution written to file: ', trim(adjustl(xyzout)) if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile)) fprint = all_type_fx @@ -892,7 +892,7 @@ program packmol ! If the user required printing even bad structures else if ( mod(loop+1,writeout) == 0 .and. writebad ) then - call output(n,x) + call output(n,x,xyzout) write(*,*) ' Writing current (perhaps bad) structure to file: ', trim(adjustl(xyzout)) if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile)) end if diff --git a/src/checkpoint.f90 b/src/checkpoint.f90 index a40b625..d4dc8bf 100644 --- a/src/checkpoint.f90 +++ b/src/checkpoint.f90 @@ -59,7 +59,7 @@ subroutine checkpoint(n,x) &)") fx write(*,dash3_line) - call output(n,x) + call output(n,x,xyzout) write(*,*) ' The solution with the best function value was ' write(*,*) ' written to the output file: ', trim(adjustl(xyzout)) @@ -82,7 +82,7 @@ subroutine checkpoint(n,x) write(*,*) write(*,dash1_line) xyzout_forced = trim(adjustl(xyzout))//'_FORCED' - call output(n,x) + call output(n,x,xyzout_forced) write(*,*) ' The forced point was writen to the ' write(*,*) ' output file: ', trim(adjustl(xyzout_forced)) diff --git a/src/output.f90 b/src/output.f90 index b970748..15e1d55 100644 --- a/src/output.f90 +++ b/src/output.f90 @@ -6,7 +6,7 @@ ! Subroutine output: Subroutine that writes the output file ! -subroutine output(n,x) +subroutine output(n, x, output_file_name) use exit_codes use sizes @@ -36,6 +36,7 @@ subroutine output(n,x) character(len=strl) :: pdb_atom_line, tinker_atom_line, crd_format character(len=8) :: crdires,crdresn,crdsegi,atmname character(len=strl) :: record + character(len=strl) :: output_file_name character(len=5) :: i5hex, tmp_i5hex ! Job title @@ -96,7 +97,7 @@ subroutine output(n,x) ! Write the output (xyz file) if(xyz) then - open(30,file=xyzout,status='unknown') + open(30,file=output_file_name,status='unknown') write(30,*) ntotat write(30,*) title ilubar = 0 @@ -143,7 +144,7 @@ subroutine output(n,x) ! write the output as a MOLDY file if(moldy) then - open(30,file=xyzout,status='unknown') + open(30,file=output_file_name,status='unknown') ! For square moldy boxes, this must be the side dimensions of the box sxmin = 1.d30 symin = 1.d30 @@ -351,7 +352,7 @@ subroutine output(n,x) &f8.3,t55,a26 )" crd_format='(2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10)' - open(30,file=xyzout,status='unknown') + open(30,file=output_file_name,status='unknown') if ( crd ) then open(40,file=crdfile,status='unknown') write(40,'("* TITLE ", a64,/& @@ -696,7 +697,7 @@ subroutine output(n,x) tinker_atom_line = "( i7,tr2,a3,3(tr2,f10.6),9(tr2,i7) )" - open(30, file = xyzout,status='unknown') + open(30, file = output_file_name,status='unknown') write(30,"( i6,tr2,a64 )") ntotat, title From 32721eb90a3e168191fa84cfa9a84d6e1bd91330 Mon Sep 17 00:00:00 2001 From: Leandro Martinez Date: Thu, 23 Nov 2023 13:49:22 -0300 Subject: [PATCH 2/4] add failing forced tests, improve testing script --- .github/workflows/actions.yml | 5 +++-- .gitignore | 2 ++ testing/test.sh | 25 +++++++++++++++++++++++++ testing/water_box_failed.inp | 16 ++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 testing/test.sh create mode 100644 testing/water_box_failed.inp diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index ec05215..f0114fd 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -46,7 +46,8 @@ jobs: - name: Run run: | cd testing - ../packmol < water_box.inp - ../packmol < ieee_signaling.inp + ./test.sh "water_box.inp" "packmol.log" "Success!" + ./test.sh "ieee_signaling.inp" "packmol.log" "Success!" + ./test.sh "water_box_failed.inp" "packmol.log" "FORCED" cd .. shell: bash diff --git a/.gitignore b/.gitignore index a654385..8b45a66 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ cmake_install.cmake tmpfile.txt testing/ieee_signaling_box.pdb testing/water_box.pdb +testing/water_box.pdb_FORCED +testing/packmol.log diff --git a/testing/test.sh b/testing/test.sh new file mode 100755 index 0000000..ad9ff54 --- /dev/null +++ b/testing/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# First argument: input file name +# Second argument: log file name +# +# Third argument: string to be searched in the log file, to declare that +# the test passed +# +# Example: ./test.sh "water_box.inp" "packmol.log" "Success!" +# +if ! [ -f $1 ]; then + echo "Error: input file not found: $1" + exit 1 +fi +../packmol < $1 > $2 +if ! [ -f $2 ]; then + echo "Error: Log file not generated: $2" + exit 1 +fi +if ! grep -q $3 $2; then + echo "Error: could not find $3 in $2" + exit 1 +fi +echo "Test passed." +exit 0 diff --git a/testing/water_box_failed.inp b/testing/water_box_failed.inp new file mode 100644 index 0000000..d315e57 --- /dev/null +++ b/testing/water_box_failed.inp @@ -0,0 +1,16 @@ +# +# A box with water for which the packing will fail +# + +tolerance 2.0 +filetype pdb +output water_box.pdb + +maxit 2 +nloop 1 + +structure water.pdb + number 2 + inside box 0. 0. 0. 3.0 3.0 1.0 +end structure + From d4c9ad4da6e845c4bd91b2705fd66d548eda7990 Mon Sep 17 00:00:00 2001 From: Leandro Martinez Date: Thu, 23 Nov 2023 13:49:59 -0300 Subject: [PATCH 3/4] set version to 20.14.3 --- fpm.toml | 2 +- src/title.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fpm.toml b/fpm.toml index 8253d04..1eaeec2 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,5 +1,5 @@ name = "packmol" -version = "20.14.2" +version = "20.14.3" license = "MIT" author = "Leandro Martinez, Ernesto Birgin, Jose Mario Martinez" maintainer = "Leandro Martinez" diff --git a/src/title.f90 b/src/title.f90 index 6cd6af9..3968cac 100644 --- a/src/title.f90 +++ b/src/title.f90 @@ -13,7 +13,7 @@ subroutine title() write(*,"(' PACKMOL - Packing optimization for the automated generation of', /& &' starting configurations for molecular dynamics simulations.', /& &' ',/& - &t62,' Version 20.14.2 ')") + &t62,' Version 20.14.3 ')") write(*,hash3_line) end subroutine title From 6a50d6a5cab70a79dd0f5a8eea5a0a08b21afcfe Mon Sep 17 00:00:00 2001 From: Leandro Martinez Date: Thu, 23 Nov 2023 13:54:24 -0300 Subject: [PATCH 4/4] run CI on all push and pull requests --- .github/workflows/actions.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index f0114fd..ff165c8 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,14 +1,8 @@ name: actions on: - push: - branches: - - master - pull_request: - branches: - - master - schedule: - - cron: '0 6 * * *' + - push + - pull_request jobs: test: