From davidk at ci.uchicago.edu Wed Aug 1 14:08:20 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Wed, 1 Aug 2012 14:08:20 -0500 (CDT) Subject: [Swift-commit] r5883 - SwiftApps/CMTS/rmsd Message-ID: <20120801190820.1992A9CC82@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-01 14:08:19 -0500 (Wed, 01 Aug 2012) New Revision: 5883 Modified: SwiftApps/CMTS/rmsd/plot_pd.pl SwiftApps/CMTS/rmsd/rmsd.swift Log: Fixes for post processing plot Modified: SwiftApps/CMTS/rmsd/plot_pd.pl =================================================================== --- SwiftApps/CMTS/rmsd/plot_pd.pl 2012-07-30 18:59:23 UTC (rev 5882) +++ SwiftApps/CMTS/rmsd/plot_pd.pl 2012-08-01 19:08:19 UTC (rev 5883) @@ -7,7 +7,7 @@ # sweep the nonbonded parameter space # File names -open (OFILE, ">", "rmsd_pd.dat"); +open (OFILE, ">", "output/rmsd_pd.dat"); # Bead names my $b1name = "PX"; @@ -35,9 +35,9 @@ while ($b2<=$b2max) { - if (-s "rmsd.$b1name${b1}_$b2name${b2}.dat") + if (-s "output/rmsd.$b1name${b1}_$b2name${b2}.dat") { - open(INPUT, "<", "rmsd.$b1name${b1}_$b2name${b2}.dat"); + open(INPUT, "<", "output/rmsd.$b1name${b1}_$b2name${b2}.dat"); $_ = ; my @data = split(/ +/,$_); Modified: SwiftApps/CMTS/rmsd/rmsd.swift =================================================================== --- SwiftApps/CMTS/rmsd/rmsd.swift 2012-07-30 18:59:23 UTC (rev 5882) +++ SwiftApps/CMTS/rmsd/rmsd.swift 2012-08-01 19:08:19 UTC (rev 5883) @@ -5,9 +5,9 @@ rmsd b1_val b2_val b1_name b2_name @namd_input_file @namd_params_file @vmd_script_file stdout=@o stderr=@e; } -app (file plot_pd_f) plot_pd () +app (file plot_pd_stdout, file plot_pd_output) plot_pd (file[float][float] datfs) { - plot_pd stdout=@plot_pd_f; + plot_pd stdout=@plot_pd_stdout; } # Bead names @@ -29,6 +29,7 @@ file vmd_script <"rmsd.temp.tcl">; file psf <"cg_clath_cage.psf">; file pdb <"cg_clath_cage.pdb">; +file[float][float] dats; foreach b1 in [b1min:b1max:delta] { foreach b2 in [b2min:b2max:delta] { @@ -36,10 +37,12 @@ file error ; file dcd ; file dat ; + dats[b1][b2] = dat; (output, error, dcd, dat) = rmsd(b1, b2, b1name, b2name, namd_input, namd_params, vmd_script, psf, pdb); } } # Post processing analysis -file plot_pd_file <"output/plot_pd.txt">; -plot_pd_file = plot_pd(); +file plot_pd_stdout <"output/plot_pd.txt">; +file plot_pd_output <"output/rmsd_pd.dat">; +(plot_pd_stdout, plot_pd_output) = plot_pd(dats); From davidk at ci.uchicago.edu Wed Aug 1 14:42:05 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Wed, 1 Aug 2012 14:42:05 -0500 (CDT) Subject: [Swift-commit] r5884 - trunk/bin Message-ID: <20120801194205.B7BD09CC82@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-01 14:42:05 -0500 (Wed, 01 Aug 2012) New Revision: 5884 Added: trunk/bin/slurm-qdel trunk/bin/slurm-qstat trunk/bin/slurm-qsub Log: Adding slurm scripts Added: trunk/bin/slurm-qdel =================================================================== --- trunk/bin/slurm-qdel (rev 0) +++ trunk/bin/slurm-qdel 2012-08-01 19:42:05 UTC (rev 5884) @@ -0,0 +1,8 @@ +#! /bin/sh + +now=$(date "+%Y.%m%d.%H:%M:%S") +echo $now $0: $* >> $HOME/pbslog + +qdel $* + + Property changes on: trunk/bin/slurm-qdel ___________________________________________________________________ Added: svn:executable + * Added: trunk/bin/slurm-qstat =================================================================== --- trunk/bin/slurm-qstat (rev 0) +++ trunk/bin/slurm-qstat 2012-08-01 19:42:05 UTC (rev 5884) @@ -0,0 +1,13 @@ +#! /bin/sh + +now=$(date "+%Y.%m%d.%H:%M:%S") +echo $now $0: $* >> $HOME/pbslog + +#echo 'Job id Name User Time Use S Queue' +#echo '------------------- ---------------- --------------- -------- - -----' + +#/software/slurm-2.4-el6-x86_64/bin/qstat $* | tail -n +2 +qstat $* | sed -e 's/\t/ /' -e 's/: */: /' + + + Property changes on: trunk/bin/slurm-qstat ___________________________________________________________________ Added: svn:executable + * Added: trunk/bin/slurm-qsub =================================================================== --- trunk/bin/slurm-qsub (rev 0) +++ trunk/bin/slurm-qsub 2012-08-01 19:42:05 UTC (rev 5884) @@ -0,0 +1,76 @@ +#! /bin/sh + +now=$(date "+%Y.%m%d.%H:%M:%S") +echo $now $0: $* >> $HOME/pbslog + +slurmqsub=$( which qsub ) +script=$1.slurm +echo '#! /bin/sh' >$script +# echo 'export PBS_NODELIST=SLURM_NODELIST'' >>$script # FIXME: convert SLURM_NODELIST to PBS_NODEFILE here... +cat $1 >>$script +chmod +x $script + +srunargs=$(awk <$1 ' +/#PBS -S/ { shell=$3 } +/#PBS -N/ { jobname=$3 } +/#PBS -m/ { m = $3 } +/#PBS -l nodes/ { nodes = $3; ppn=$3; + sub(/nodes=/,"",nodes); sub(/:.*/,"",nodes); + sub(/^.*ppn=/,"",ppn); } +/#PBS -l walltime/ { walltime = $3; sub(/walltime=/,"",walltime);} +/#PBS -q/ { queue = $3 } +/#PBS -o/ { sofile = $3 } +/#PBS -e/ { sefile = $3 } + +END { + #printf("shell=%s jobname=%s m=%s nodespec=%s nodes=%s ppn=%s walltime=%s queue=%s sofile=%s sefile=%s\n", + # shell, jobname, m, nodespec, nodes, ppn, walltime, queue, sofile, sefile); + #printf("-p %s -t %s -N %s -D %s -J %s -e %s -o %s", queue, walltime, nodes, "/tmp", jobname, sefile, sofile); + +# printf("-S %s -N %s -m %s -l nodes=%s:ppn=%s -l walltime=%s -q %s -o %s -e %s", +# shell, jobname, m, nodes, ppn, walltime, queue, sofile, sefile); + printf("-N %s -m %s -l nodes=%s:ppn=%s -l walltime=%s -q %s -o %s -e %s", + jobname, m, nodes, ppn, walltime, queue, sofile, sefile); + +}') + +echo " " qsub args: $slurmqsub $srunargs $script >>$HOME/pbslog +job=$($slurmqsub $srunargs $script) +echo " " qsub output: $job >>$HOME/pbslog + +jid=$(echo $job | sed -e 's/^.* //') +echo " " qsub job id: $jid >>$HOME/pbslog +echo $jid + +# srun $srunargs $script + +# cqsub -q ${QUEUE} \ +# -k zeptoos \ +# -t ${MAXTIME} \ # minutes +# -n ${NODES} \ +# --cwd ${LOGDIR} \ +# -E ${LOGDIR}/cobalt.${$}.stderr \ +# -o ${LOGDIR}/cobalt.${$}.stdout \ +# -e "WORKER_LOGGING_LEVEL=DEBUG:ZOID_ENABLE_NAT=true" \ +# $WORKER $EXECUTION_URL $ID $LOG_DIR + +# LOGDIR=/tmp/swiftlog +# +# WORKER_LOGGING_LEVEL=DEBUG srun \ +# -p ${QUEUE} \ +# -t ${MAXTIME} \ +# -N ${NODES} \ +# -D ${LOGDIR} \ +# -J swift-worker \ +# -e ${LOGDIR}/cobalt.${$}.stderr \ +# -o ${LOGDIR}/cobalt.${$}.stdout \ +# $SWIFT_BIN/$WORKER $EXECUTION_URL $ID $LOG_DIR + +#PBS -S /bin/bash +#PBS -N cog-000000 +#PBS -m n +#PBS -l nodes=1:ppn=1 +#PBS -l walltime=00:05:00 +#PBS -q sandyb +#PBS -o /home/wilde/.globus/scripts/PBS4051523028032512638.submit.stdout +#PBS -e /home/wilde/.globus/scripts/PBS4051523028032512638.submit.stderr Property changes on: trunk/bin/slurm-qsub ___________________________________________________________________ Added: svn:executable + * From swift at ci.uchicago.edu Wed Aug 1 14:45:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 1 Aug 2012 14:45:03 -0500 (CDT) Subject: [Swift-commit] cog r3435 Message-ID: <20120801194504.511938D00065@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3435 | davidkelly999 | 2012-08-01 14:41:18 -0500 (Wed, 01 Aug 2012) | 2 lines Point slurm provider to the correct shell scripts ------------------------------------------------------------------------ Index: modules/provider-localscheduler/etc/provider-slurm.properties =================================================================== --- modules/provider-localscheduler/etc/provider-slurm.properties (revision 3434) +++ modules/provider-localscheduler/etc/provider-slurm.properties (working copy) @@ -8,17 +8,17 @@ # # The path to qsub. The default assumes that qsub is in PATH # -qsub=notqsub +qsub=slurm-qsub # # The path to qstat. The default assumes that qstat is in PATH # -qstat=notqstat +qstat=slurm-qstat # # The path to qdel. The default assumes that qdel is in PATH # -qdel=notqdel +qdel=slurm-qdel # If true, use "#PBS -l mppwidth=" instead of "#PBS -l nodes=" # in PBS script From davidk at ci.uchicago.edu Wed Aug 1 15:13:28 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Wed, 1 Aug 2012 15:13:28 -0500 (CDT) Subject: [Swift-commit] r5885 - trunk Message-ID: <20120801201328.D31DE9CC97@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-01 15:13:28 -0500 (Wed, 01 Aug 2012) New Revision: 5885 Modified: trunk/build.xml Log: Include slurm stuff during build Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2012-08-01 19:42:05 UTC (rev 5884) +++ trunk/build.xml 2012-08-01 20:13:28 UTC (rev 5885) @@ -112,6 +112,9 @@ + + + From swift at ci.uchicago.edu Thu Aug 2 01:35:04 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Thu, 2 Aug 2012 01:35:04 -0500 (CDT) Subject: [Swift-commit] cog r3437 Message-ID: <20120802063505.3C4558D00DF2@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3437 | hategan | 2012-08-02 01:34:52 -0500 (Thu, 02 Aug 2012) | 1 line changed security contexts to accept a host parameter (such that: credentials can be selected based on host name AND interactive credential dialogs can display the host name requesting credentials ------------------------------------------------------------------------ Index: modules/abstraction-common/src/org/globus/cog/abstraction/tools/execution/JobSubmission.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/tools/execution/JobSubmission.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/tools/execution/JobSubmission.java (working copy) @@ -167,13 +167,11 @@ ExecutionService service = new ExecutionServiceImpl(); service.setProvider(this.provider.toLowerCase()); - SecurityContext securityContext = AbstractionFactory - .newSecurityContext(provider); - securityContext.setCredentials(null); - service.setSecurityContext(securityContext); - ServiceContact sc = new ServiceContactImpl(this.serviceContact); service.setServiceContact(sc); + + SecurityContext securityContext = AbstractionFactory.getSecurityContext(provider, sc); + service.setSecurityContext(securityContext); /* * This is an abstraction for the jobmanager. For example, the Index: modules/abstraction-common/src/org/globus/cog/abstraction/tools/transfer/FileTransfer.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/tools/transfer/FileTransfer.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/tools/transfer/FileTransfer.java (working copy) @@ -92,28 +92,23 @@ this.task.setSpecification(spec); // create te source service - SecurityContext sourceSecurityContext = AbstractionFactory - .newSecurityContext(sourceURI.getScheme()); - // selects the default credentials - sourceSecurityContext.setCredentials(null); - ServiceContact sourceServiceContact = new ServiceContactImpl(); sourceServiceContact.setHost(sourceURI.getHost()); sourceServiceContact.setPort(sourceURI.getPort()); + + SecurityContext sourceSecurityContext = + AbstractionFactory.getSecurityContext(sourceURI.getScheme(), sourceServiceContact); Service sourceService = new ServiceImpl(sourceURI.getScheme(), Service.FILE_TRANSFER, sourceServiceContact, sourceSecurityContext); - // create te destination service - SecurityContext destinationSecurityContext = AbstractionFactory - .newSecurityContext(destinationURI.getScheme()); - // selects the default credentials - destinationSecurityContext.setCredentials(null); - ServiceContact destinationServiceContact = new ServiceContactImpl(); destinationServiceContact.setHost(destinationURI.getHost()); destinationServiceContact.setPort(destinationURI.getPort()); + + SecurityContext destinationSecurityContext = + AbstractionFactory.getSecurityContext(destinationURI.getScheme(), destinationServiceContact); Service destinationService = new ServiceImpl( destinationURI.getScheme(), Service.FILE_TRANSFER, Index: modules/abstraction-common/src/org/globus/cog/abstraction/xml/TaskUnmarshaller.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/xml/TaskUnmarshaller.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/xml/TaskUnmarshaller.java (working copy) @@ -141,26 +141,27 @@ } } String provider = xmlService.getProvider(); + // set the service contact + String serviceContact = xmlService.getServiceContact(); + if (serviceContact != null && serviceContact.length() > 0) { + ServiceContact contact = new ServiceContactImpl(serviceContact + .trim()); + service.setServiceContact(contact); + } + if (provider != null && provider.length() > 0) { service.setProvider(provider.trim()); try { - service.setSecurityContext(AbstractionFactory - .newSecurityContext(provider)); + service.setSecurityContext(AbstractionFactory.newSecurityContext(provider, service.getServiceContact())); } catch (Exception e) { throw new UnmarshalException( "Cannot establish the appropriate security context", e); } } - // set the service contact - String serviceContact = xmlService.getServiceContact(); - if (serviceContact != null && serviceContact.length() > 0) { - ServiceContact contact = new ServiceContactImpl(serviceContact - .trim()); - service.setServiceContact(contact); - } + // set the service attributes AttributeList attrList = xmlService.getAttributeList(); if (attrList != null) { Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java (working copy) @@ -26,7 +26,6 @@ import org.globus.cog.abstraction.impl.common.task.InvalidProviderException; import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; import org.globus.cog.abstraction.interfaces.FileResource; -import org.globus.cog.abstraction.interfaces.SecurityContext; import org.globus.cog.abstraction.interfaces.Service; public class FileResourceCache { @@ -115,7 +114,7 @@ throw new InvalidProviderException("Provider is null"); } if (service.getSecurityContext() == null) { - service.setSecurityContext(AbstractionFactory.newSecurityContext(provider)); + service.setSecurityContext(AbstractionFactory.getSecurityContext(provider, service.getServiceContact())); } FileResource fileResource = AbstractionFactory .newFileResource(provider); Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/fileTransfer/DelegatedFileTransferHandler.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/impl/fileTransfer/DelegatedFileTransferHandler.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/fileTransfer/DelegatedFileTransferHandler.java (working copy) @@ -8,7 +8,6 @@ import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import org.apache.log4j.Logger; import org.globus.cog.abstraction.impl.common.AbstractDelegatedTaskHandler; @@ -20,7 +19,6 @@ import org.globus.cog.abstraction.impl.common.task.InvalidProviderException; import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; import org.globus.cog.abstraction.impl.common.task.InvalidServiceContactException; -import org.globus.cog.abstraction.impl.common.task.SecurityContextImpl; import org.globus.cog.abstraction.impl.common.task.ServiceContactImpl; import org.globus.cog.abstraction.impl.common.task.ServiceImpl; import org.globus.cog.abstraction.impl.common.task.TaskImpl; @@ -38,13 +36,7 @@ import org.globus.cog.abstraction.interfaces.Status; import org.globus.cog.abstraction.interfaces.Task; import org.globus.cog.abstraction.interfaces.TaskHandler; -import org.globus.gsi.gssapi.auth.Authorization; -import org.globus.gsi.gssapi.auth.HostAuthorization; -import org.globus.io.urlcopy.UrlCopy; -import org.globus.io.urlcopy.UrlCopyException; import org.globus.io.urlcopy.UrlCopyListener; -import org.globus.util.GlobusURL; -import org.ietf.jgss.GSSCredential; public class DelegatedFileTransferHandler extends AbstractDelegatedTaskHandler implements Runnable, UrlCopyListener { @@ -628,12 +620,13 @@ } } - private SecurityContext getSecurityContext(Service service) { + private SecurityContext getSecurityContext(Service service) throws InvalidProviderException, ProviderMethodException { SecurityContext securityContext = service.getSecurityContext(); if (securityContext == null) { - // create default credentials - securityContext = new SecurityContextImpl(); + return AbstractionFactory.getSecurityContext(service.getProvider(), service.getServiceContact()); } - return securityContext; + else { + return securityContext; + } } } \ No newline at end of file Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractionFactory.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractionFactory.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractionFactory.java (working copy) @@ -16,6 +16,7 @@ import org.globus.cog.abstraction.impl.common.task.InvalidProviderException; import org.globus.cog.abstraction.interfaces.FileResource; import org.globus.cog.abstraction.interfaces.SecurityContext; +import org.globus.cog.abstraction.interfaces.ServiceContact; import org.globus.cog.abstraction.interfaces.TaskHandler; /** @@ -29,11 +30,11 @@ private static final String PROVIDER_PROP = "cog-provider.properties"; private static Logger logger = Logger.getLogger(AbstractionFactory.class); - - private static Map defaultCredentials; + public static Map> cachedSecurityContexts; + static { - defaultCredentials = new HashMap(); + cachedSecurityContexts = new HashMap>(); } public static TaskHandler newExecutionTaskHandler() @@ -92,11 +93,47 @@ AbstractionProperties.TYPE_FILE_RESOURCE); } + /** + * @deprecated + */ public static SecurityContext newSecurityContext(String provider) throws InvalidProviderException, ProviderMethodException { return (SecurityContext) newObject(provider, AbstractionProperties.TYPE_SECURITY_CONTEXT); } + + public static SecurityContext newSecurityContext(String provider, ServiceContact serviceContact) + throws InvalidProviderException, ProviderMethodException { + SecurityContext sc = (SecurityContext) newObject(provider, + AbstractionProperties.TYPE_SECURITY_CONTEXT); + sc.setServiceContact(serviceContact); + return sc; + } + + /** + * Return a possibly cached security context + */ + public static SecurityContext getSecurityContext(String provider, ServiceContact serviceContact) + throws InvalidProviderException, ProviderMethodException { + Map providerContexts; + synchronized(cachedSecurityContexts) { + providerContexts = cachedSecurityContexts.get(provider); + if (providerContexts == null) { + providerContexts = new HashMap(); + cachedSecurityContexts.put(provider, providerContexts); + } + } + + synchronized(providerContexts) { + SecurityContext sc = providerContexts.get(serviceContact); + if (sc == null) { + sc = newSecurityContext(provider, serviceContact); + providerContexts.put(serviceContact, sc); + } + + return sc; + } + } public static boolean hasObject(String provider, String role) { try { @@ -134,9 +171,11 @@ boolean useSandbox) throws InvalidProviderException, InvalidClassException { provider = provider.toLowerCase(); - logger + if (logger.isDebugEnabled()) { + logger .debug("Instantiating " + className + " for provider " + provider); + } ClassLoader cl = AbstractionFactory.class.getClassLoader(); try { return cl.loadClass(className).newInstance(); @@ -145,14 +184,4 @@ throw new InvalidClassException(e); } } - - public synchronized static Object getDefaultCredentials(String provider) throws InvalidProviderException, ProviderMethodException { - SecurityContext sc = defaultCredentials.get(provider); - if (sc == null) { - sc = newSecurityContext(provider); - defaultCredentials.put(provider, sc); - } - return sc.getDefaultCredentials(); - } - } \ No newline at end of file Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/SecurityContextImpl.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/SecurityContextImpl.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/SecurityContextImpl.java (working copy) @@ -9,11 +9,13 @@ import java.util.HashMap; import org.globus.cog.abstraction.interfaces.SecurityContext; +import org.globus.cog.abstraction.interfaces.ServiceContact; public class SecurityContextImpl implements SecurityContext { private HashMap attributes; private Object credentials; private String alias; + private ServiceContact serviceContact; public SecurityContextImpl() { this.attributes = new HashMap(); @@ -88,4 +90,12 @@ public Object getDefaultCredentials() { return null; } + + public ServiceContact getServiceContact() { + return serviceContact; + } + + public void setServiceContact(ServiceContact serviceContact) { + this.serviceContact = serviceContact; + } } \ No newline at end of file Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/util/FileTransfer.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/util/FileTransfer.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/util/FileTransfer.java (working copy) @@ -122,11 +122,11 @@ else { if (protocol.equals("gsiftp")) { service.setProvider("GridFTP"); - securityContext = AbstractionFactory.newSecurityContext("GridFTP"); + securityContext = AbstractionFactory.getSecurityContext("GridFTP", service.getServiceContact()); } else if (protocol.equals("scp")) { service.setProvider("ssh"); - securityContext = AbstractionFactory.newSecurityContext("ssh"); + securityContext = AbstractionFactory.getSecurityContext("ssh", service.getServiceContact()); } else { throw new Exception("unsupported protocol: " + protocol); Index: modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/SecurityContext.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/SecurityContext.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/SecurityContext.java (working copy) @@ -6,6 +6,7 @@ package org.globus.cog.abstraction.interfaces; +import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; import org.ietf.jgss.GSSCredential; /** @@ -40,4 +41,8 @@ * else return null */ public Object getDefaultCredentials(); + + public void setServiceContact(ServiceContact serviceContact); + + public ServiceContact getServiceContact(); } \ No newline at end of file Index: modules/abstraction-common/src/org/globus/cog/abstraction/examples/invocation/ServiceInvocation.java =================================================================== --- modules/abstraction-common/src/org/globus/cog/abstraction/examples/invocation/ServiceInvocation.java (revision 3436) +++ modules/abstraction-common/src/org/globus/cog/abstraction/examples/invocation/ServiceInvocation.java (working copy) @@ -89,7 +89,7 @@ service.setProvider(this.provider.toLowerCase()); SecurityContext securityContext = AbstractionFactory - .newSecurityContext(provider); + .getSecurityContext(provider, new ServiceContactImpl(serviceContact)); securityContext.setCredentials(null); service.setSecurityContext(securityContext); From swift at ci.uchicago.edu Thu Aug 2 01:40:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Thu, 2 Aug 2012 01:40:03 -0500 (CDT) Subject: [Swift-commit] cog r3439 Message-ID: <20120802064004.EC66F8D00DF2@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3439 | hategan | 2012-08-02 01:38:52 -0500 (Thu, 02 Aug 2012) | 1 line updated gt2 provider with changes from common and added proxy mapping file ------------------------------------------------------------------------ Index: modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java =================================================================== --- modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java (revision 3438) +++ modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java (working copy) @@ -20,10 +20,8 @@ import java.util.List; import org.apache.log4j.Logger; -import org.globus.cog.abstraction.impl.common.AbstractionFactory; import org.globus.cog.abstraction.impl.common.task.IllegalSpecException; import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; -import org.globus.cog.abstraction.impl.common.task.ServiceContactImpl; import org.globus.cog.abstraction.impl.common.task.TaskSubmissionException; import org.globus.cog.abstraction.impl.file.DirectoryNotFoundException; import org.globus.cog.abstraction.impl.file.FileResourceException; @@ -92,15 +90,15 @@ private boolean bufferSizeChanged; /** throws InvalidProviderException */ - public FileResourceImpl() throws Exception { - this(null, new ServiceContactImpl(), AbstractionFactory - .newSecurityContext("GridFTP")); + public FileResourceImpl() { + this(null, null, null); } /** constructor be used normally */ public FileResourceImpl(String name, ServiceContact serviceContact, SecurityContext securityContext) { - super(name == null ? serviceContact.toString() : name, "gsiftp", serviceContact, securityContext); + super((name == null && !(serviceContact == null)) ? serviceContact.toString() : name, + "gsiftp", serviceContact, securityContext); } /** @@ -111,9 +109,11 @@ */ public void start() throws IllegalHostException, InvalidSecurityContextException, FileResourceException { + + ServiceContact serviceContact = getAndCheckServiceContact(); - String host = getServiceContact().getHost(); - int port = getServiceContact().getPort(); + String host = serviceContact.getHost(); + int port = serviceContact.getPort(); if (port == -1) { port = 2811; } @@ -123,6 +123,8 @@ } try { + SecurityContext securityContext = getOrCreateSecurityContext("gsiftp", serviceContact); + gridFTPClient = new GridFTPClient(host, port); Reply r = gridFTPClient.getLastReply(); @@ -140,11 +142,10 @@ if (logger.isDebugEnabled()) { logger.debug("Data channel reuse: " + dataChannelReuse); } - gridFTPClient.setClientWaitParams(MAX_REPLY_WAIT_TIME, - Session.DEFAULT_WAIT_DELAY); - GSSCredential proxy = (GSSCredential) getSecurityContext() - .getCredentials(); - gridFTPClient.authenticate(proxy); + gridFTPClient.setClientWaitParams(MAX_REPLY_WAIT_TIME, Session.DEFAULT_WAIT_DELAY); + + GSSCredential cred = (GSSCredential) securityContext.getCredentials(); + gridFTPClient.authenticate(cred); gridFTPClient.setType(Session.TYPE_IMAGE); if (dataChannelReuse) { gridFTPClient.setMode(GridFTPSession.MODE_EBLOCK); @@ -155,7 +156,7 @@ } catch (Exception e) { throw translateException( - "Error communicating with the GridFTP server at " + host + ":" + port, e); + "Error connecting to the GridFTP server at " + host + ":" + port, e); } } Index: modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/InteractiveFTPSecurityContextImpl.java =================================================================== --- modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/InteractiveFTPSecurityContextImpl.java (revision 3438) +++ modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/InteractiveFTPSecurityContextImpl.java (working copy) @@ -6,33 +6,7 @@ package org.globus.cog.abstraction.impl.file.ftp; -import java.net.PasswordAuthentication; +import org.globus.cog.abstraction.impl.common.InteractivePasswordSecurityContextImpl; -import org.apache.log4j.Logger; -import org.globus.cog.abstraction.impl.common.task.SecurityContextImpl; - -public class InteractiveFTPSecurityContextImpl extends SecurityContextImpl { - - private static Logger logger = Logger - .getLogger(InteractiveFTPSecurityContextImpl.class.getName()); - - public InteractiveFTPSecurityContextImpl() { - } - - public InteractiveFTPSecurityContextImpl(PasswordAuthentication credentials) { - setCredentials(credentials); - } - - public void setCredentials(Object credentials, String alias) { - setCredentials(credentials); - } - - public synchronized Object getCredentials() { - Object credentials = getCredentials(); - if (credentials == null) { - credentials = CredentialsDialog.showCredentialsDialog(); - setCredentials(credentials); - } - return credentials; - } +public class InteractiveFTPSecurityContextImpl extends InteractivePasswordSecurityContextImpl { } Index: modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/FileResourceImpl.java =================================================================== --- modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/FileResourceImpl.java (revision 3438) +++ modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/FileResourceImpl.java (working copy) @@ -19,14 +19,13 @@ import java.util.List; import org.apache.log4j.Logger; -import org.globus.cog.abstraction.impl.common.AbstractionFactory; import org.globus.cog.abstraction.impl.common.task.IllegalSpecException; import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; -import org.globus.cog.abstraction.impl.common.task.ServiceContactImpl; import org.globus.cog.abstraction.impl.common.task.TaskSubmissionException; import org.globus.cog.abstraction.impl.file.DirectoryNotFoundException; import org.globus.cog.abstraction.impl.file.FileResourceException; import org.globus.cog.abstraction.impl.file.GridFileImpl; +import org.globus.cog.abstraction.impl.file.IllegalHostException; import org.globus.cog.abstraction.interfaces.ExecutableObject; import org.globus.cog.abstraction.interfaces.FileFragment; import org.globus.cog.abstraction.interfaces.FileResource; @@ -54,14 +53,21 @@ public class FileResourceImpl extends AbstractFTPFileResource { public static final String PROTOCOL = "ftp"; + public static final String ANONYMOUS_USERNAME = "anonymous"; + public static final char[] ANONYMOUS_PASSWORD; + static { + String pwd = "none at example.com"; + ANONYMOUS_PASSWORD = new char[pwd.length()]; + pwd.getChars(0, pwd.length(), ANONYMOUS_PASSWORD, 0); + } + private FTPClient ftpClient; public static final Logger logger = Logger.getLogger(FileResource.class .getName()); /** throws invalidprovider exception */ - public FileResourceImpl() throws Exception { - this(null, new ServiceContactImpl(), AbstractionFactory - .newSecurityContext("ftp")); + public FileResourceImpl() { + this(null, null, null); } /** the constructor to be used normally */ @@ -76,18 +82,29 @@ * @throws FileResourceException * if an exception occurs during the resource start-up */ - public void start() throws InvalidSecurityContextException, + public void start() throws InvalidSecurityContextException, IllegalHostException, FileResourceException { + ServiceContact serviceContact = getAndCheckServiceContact(); + + String host = getServiceContact().getHost(); + int port = getServiceContact().getPort(); + if (port == -1) { + port = 21; + } + + if (getName() == null) { + setName(host + ":" + port); + } + + try { - String host = getServiceContact().getHost(); - int port = getServiceContact().getPort(); - if (port == -1) { - port = 21; - } + SecurityContext securityContext = getOrCreateSecurityContext("ftp", serviceContact); + + PasswordAuthentication credentials = getCredentialsAsPasswordAuthentication(securityContext); + ftpClient = new FTPClient(host, port); - PasswordAuthentication credentials = (PasswordAuthentication) getSecurityContext() - .getCredentials(); + String username = credentials.getUserName(); String password = String.valueOf(credentials.getPassword()); @@ -95,11 +112,16 @@ ftpClient.setType(Session.TYPE_IMAGE); setStarted(true); } - catch (Exception se) { + catch (Exception e) { throw translateException( - "Error while communicating with the FTP server", se); + "Error connecting to the FTP server at " + host + ":" + port, e); } } + + @Override + protected PasswordAuthentication getDefaultUsernameAndPassword() { + return new PasswordAuthentication(ANONYMOUS_USERNAME, ANONYMOUS_PASSWORD); + } /** * Stop the ftpClient from connecting to the server Index: modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/CredentialsDialog.java =================================================================== --- modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/CredentialsDialog.java (revision 3438) +++ modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/ftp/CredentialsDialog.java (working copy) @@ -1,84 +0,0 @@ -//---------------------------------------------------------------------- -//This code is developed as part of the Java CoG Kit project -//The terms of the license can be found at http://www.cogkit.org/license -//This message may not be removed or altered. -//---------------------------------------------------------------------- - -package org.globus.cog.abstraction.impl.file.ftp; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.net.PasswordAuthentication; - -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JTextField; - -public class CredentialsDialog { - private static final String NOTHING = ""; - - private JOptionPane optionPane = new JOptionPane(); - private JDialog dialog; - - private JTextField usernameField = new JTextField(); - private JPasswordField passwordField = new JPasswordField(); - - private PasswordAuthentication result = null; - - public CredentialsDialog() { - // init sizes - usernameField.setPreferredSize(new Dimension(125, 20)); - passwordField.setPreferredSize(new Dimension(125, 20)); - - // the main panel - JPanel main = new JPanel(new BorderLayout()); - - // Labels - JPanel labels = new JPanel(new GridLayout(0, 1)); - labels.add(new JLabel("Username: ")); - labels.add(new JLabel("Password: ")); - - // username and password labels/fields - JPanel fields = new JPanel(new GridLayout(0, 1)); - fields.add(usernameField); - fields.add(passwordField); - - main.add(labels, BorderLayout.WEST); - main.add(fields, BorderLayout.CENTER); - - optionPane.setMessage(main); - optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); - dialog = optionPane.createDialog(null, "Enter Your FTP Credentials"); - } - - protected synchronized void okButtonPushed() { - String uname = usernameField.getText(); - char[] passwd = passwordField.getPassword(); - if (NOTHING.equals(uname) || NOTHING.equals(passwd)) { - result = null; - } else { - result = new PasswordAuthentication(uname, passwd); - } - } - - public static PasswordAuthentication showCredentialsDialog() { - return new CredentialsDialog().getResult(); - } - - public PasswordAuthentication getResult() { - dialog.show(); - if (optionPane.getValue() != null - && ((Integer) optionPane.getValue()).equals(new Integer( - JOptionPane.OK_OPTION))) { - okButtonPushed(); - - } else { - result = null; - } - return result; - } -} \ No newline at end of file Index: modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java =================================================================== --- modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java (revision 3438) +++ modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java (working copy) @@ -6,9 +6,20 @@ package org.globus.cog.abstraction.impl.execution.gt2; -import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.log4j.Logger; import org.globus.cog.abstraction.impl.common.task.SecurityContextImpl; import org.globus.cog.abstraction.interfaces.Delegation; +import org.globus.cog.abstraction.interfaces.ServiceContact; +import org.globus.gsi.GlobusCredential; +import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; import org.globus.gsi.gssapi.auth.Authorization; import org.globus.gsi.gssapi.auth.HostAuthorization; import org.gridforum.jgss.ExtendedGSSManager; @@ -17,14 +28,32 @@ import org.ietf.jgss.GSSManager; public class GlobusSecurityContextImpl extends SecurityContextImpl implements Delegation { + public static final Logger logger = Logger.getLogger(GlobusSecurityContextImpl.class); + public static final int XML_ENCRYPTION = 1; public static final int XML_SIGNATURE = 2; + public static final String PROXY_HOST_PATH_MAPPING_FILE = System.getProperty("user.home") + + File.separator + ".globus" + File.separator + "proxy.mapping"; + public static final int DEFAULT_CREDENTIAL_REFRESH_INTERVAL = 30000; - private static GSSCredential cachedCredential; - private static long credentialTime; + private static Map cachedCredentials = new HashMap(); + private static Map credentialTimes = new HashMap(); + private static Properties proxyPaths; + + public GlobusSecurityContextImpl() { + } + public GlobusSecurityContextImpl(String proxyPath) { + if (proxyPath == null) { + setCredentials(getDefaultCredentials()); + } + else { + setCredentials(loadProxyFromFile(proxyPath)); + } + } + public void setAuthorization(Authorization authorization) { setAttribute("authorization", authorization); } @@ -61,25 +90,104 @@ return value.intValue(); } - public GSSCredential getDefaultCredential() throws InvalidSecurityContextException { - return _getDefaultCredential(); + public GSSCredential getDefaultCredentials() { + return _getDefaultCredential(getServiceContact()); } - public static GSSCredential _getDefaultCredential() throws InvalidSecurityContextException { - synchronized (GlobusSecurityContextImpl.class) { - if (cachedCredential == null - || - (System.currentTimeMillis() - credentialTime) > DEFAULT_CREDENTIAL_REFRESH_INTERVAL) { - credentialTime = System.currentTimeMillis(); - GSSManager manager = ExtendedGSSManager.getInstance(); - try { - cachedCredential = manager.createCredential(GSSCredential.INITIATE_AND_ACCEPT); + @Override + public Object getCredentials() { + Object credentials = super.getCredentials(); + if (credentials == null) { + return getDefaultCredentials(); + } + else { + return credentials; + } + } + + public static GSSCredential _getDefaultCredential(ServiceContact serviceContact) { + String host = null; + if (serviceContact != null) { + // null is OK + host = serviceContact.getHost(); + } + loadProxyPaths(); + synchronized (cachedCredentials) { + GSSCredential cachedCredential = cachedCredentials.get(host); + Long credentialTime = credentialTimes.get(host); + long now = System.currentTimeMillis(); + if (cachedCredential == null || (now - credentialTime) > DEFAULT_CREDENTIAL_REFRESH_INTERVAL) { + if (cachedCredential == null) { + if (logger.isInfoEnabled()) { + logger.info("No cached credentials for " + host + "."); + } } - catch (GSSException e) { - throw new InvalidSecurityContextException(e); + else { + if (logger.isInfoEnabled()) { + logger.info("Credentials for " + host + " need refreshing."); + } } + credentialTimes.put(host, now); + cachedCredential = loadCredential(host); + cachedCredentials.put(host, cachedCredential); } return cachedCredential; } } + + private static GSSCredential loadCredential(String host) { + String proxyPath = null; + + if (host != null) { + proxyPath = (String) proxyPaths.get(host); + } + + if (proxyPath == null) { + if (logger.isInfoEnabled()) { + logger.info("No proxy mapping found for " + host + ". Loading default."); + } + return loadDefaultProxy(); + } + else { + if (logger.isInfoEnabled()) { + logger.info("Proxy mapping found for " + host + ": " + proxyPath); + } + return loadProxyFromFile(proxyPath); + } + } + + private static GSSCredential loadProxyFromFile(String proxyPath) { + try { + GlobusCredential cred = new GlobusCredential(proxyPath); + return new GlobusGSSCredentialImpl(cred, GSSCredential.INITIATE_AND_ACCEPT); + } + catch (Exception e) { + throw new SecurityException(e); + } + } + + private static GSSCredential loadDefaultProxy() { + GSSManager manager = ExtendedGSSManager.getInstance(); + try { + return manager.createCredential(GSSCredential.INITIATE_AND_ACCEPT); + } + catch (GSSException e) { + throw new SecurityException(e); + } + } + + private static synchronized void loadProxyPaths() { + if (proxyPaths == null) { + proxyPaths = new Properties(); + try { + proxyPaths.load(new FileInputStream(PROXY_HOST_PATH_MAPPING_FILE)); + } + catch (FileNotFoundException e) { + // no mapping + } + catch (IOException e) { + logger.warn("Could not load host-proxy mapping file", e); + } + } + } } \ No newline at end of file From swift at ci.uchicago.edu Thu Aug 2 01:45:05 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Thu, 2 Aug 2012 01:45:05 -0500 (CDT) Subject: [Swift-commit] cog r3443 Message-ID: <20120802064506.6517E8D00DF2@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3443 | hategan | 2012-08-02 01:44:59 -0500 (Thu, 02 Aug 2012) | 1 line properly serialize/deserialize remote exceptions instead of faking it with strings ------------------------------------------------------------------------ Index: modules/karajan/src/org/globus/cog/karajan/workflow/service/RequestReply.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/service/RequestReply.java (revision 3442) +++ modules/karajan/src/org/globus/cog/karajan/workflow/service/RequestReply.java (working copy) @@ -13,10 +13,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -119,22 +118,30 @@ } public void sendError(String error, Throwable e) throws ProtocolException { - logger.info(this + " sending error: " + error, e); + if (logger.isInfoEnabled()) { + logger.info(this + " sending error: " + error, e); + } if (error == null) { if (e == null) { error = "No message available"; } else { - error = e.toString(); + error = (e.getMessage() == null ? e.toString() : e.getMessage()); } } this.addOutData(error.getBytes()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - if (e != null) { - PrintStream ps = new PrintStream(baos); - e.printStackTrace(ps); + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + if (e != null) { + oos.writeObject(e); + } + oos.close(); + this.addOutData(baos.toByteArray()); } - this.addOutData(baos.toByteArray()); + catch (IOException ex) { + logger.warn("Exception caught serializing exception", e); + } send(true); } @@ -289,8 +296,14 @@ if (data != null && data.size() > 0) { msg = new String(data.get(0)); if (data.size() > 1) { - String ex = new String(data.get(1)); - exception = new RemoteException(msg, ex); + try { + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data.get(1))); + exception = new RemoteException(msg, (Exception) ois.readObject()); + ois.close(); + } + catch (Exception e) { + logger.warn("Failed to de-serialize remote exception", e); + } } } errorReceived(msg, exception); Index: modules/karajan/src/org/globus/cog/karajan/workflow/service/RemoteException.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/service/RemoteException.java (revision 3442) +++ modules/karajan/src/org/globus/cog/karajan/workflow/service/RemoteException.java (working copy) @@ -9,25 +9,10 @@ */ package org.globus.cog.karajan.workflow.service; -import java.io.PrintStream; -import java.io.PrintWriter; public class RemoteException extends Exception { - private String remote; - public RemoteException(String msg, String remote) { - super(msg); - this.remote = remote; + + public RemoteException(String msg, Exception remote) { + super(msg, remote); } - - public void printStackTrace(PrintStream s) { - super.printStackTrace(s); - s.println("Remote exception:"); - s.println(remote); - } - - public void printStackTrace(PrintWriter s) { - super.printStackTrace(s); - s.println("Remote exception:"); - s.println(remote); - } } From swift at ci.uchicago.edu Thu Aug 2 01:50:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Thu, 2 Aug 2012 01:50:03 -0500 (CDT) Subject: [Swift-commit] cog r3444 Message-ID: <20120802065004.C4BA68D00DF2@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3444 | hategan | 2012-08-02 01:46:31 -0500 (Thu, 02 Aug 2012) | 1 line new security context stuff ------------------------------------------------------------------------ Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/ServiceNode.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/ServiceNode.java (revision 3443) +++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/ServiceNode.java (working copy) @@ -12,6 +12,7 @@ import org.apache.log4j.Logger; import org.globus.cog.abstraction.impl.common.AbstractionFactory; import org.globus.cog.abstraction.impl.common.AbstractionProperties; +import org.globus.cog.abstraction.impl.common.InteractivePasswordSecurityContextImpl; import org.globus.cog.abstraction.impl.common.task.ExecutionServiceImpl; import org.globus.cog.abstraction.impl.common.task.ServiceContactImpl; import org.globus.cog.abstraction.impl.common.task.ServiceImpl; @@ -88,6 +89,15 @@ if (A_PROJECT.isPresent(stack)) { service.setAttribute("project", TypeUtil.toString(A_PROJECT.getValue(stack))); } + + String uri = null; + uri = TypeUtil.toString(A_URI.getValue(stack)); + if (uri == null) { + uri = TypeUtil.toString(A_URL.getValue(stack)); + } + if (uri != null) { + service.setServiceContact(new ServiceContactImpl(uri)); + } SecurityContext sc = (SecurityContext) A_SECURITY_CONTEXT.getValue(stack); if (sc == null) { @@ -101,7 +111,7 @@ } if (sc == null) { try { - sc = AbstractionFactory.newSecurityContext(provider); + sc = AbstractionFactory.getSecurityContext(provider, service.getServiceContact()); stack.setGlobal(scName, sc); } catch (Exception e1) { @@ -112,16 +122,13 @@ } } } + else { + if (sc instanceof InteractivePasswordSecurityContextImpl) { + ((InteractivePasswordSecurityContextImpl) sc).setHostName(uri); + } + } service.setSecurityContext(sc); service.setType(itype); - String uri = null; - uri = TypeUtil.toString(A_URI.getValue(stack)); - if (uri == null) { - uri = TypeUtil.toString(A_URL.getValue(stack)); - } - if (uri != null) { - service.setServiceContact(new ServiceContactImpl(uri)); - } return service; } } \ No newline at end of file Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java (revision 3443) +++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java (working copy) @@ -25,6 +25,7 @@ import org.globus.cog.abstraction.impl.common.task.ServiceImpl; import org.globus.cog.abstraction.interfaces.SecurityContext; import org.globus.cog.abstraction.interfaces.Service; +import org.globus.cog.abstraction.interfaces.ServiceContact; import org.globus.cog.abstraction.interfaces.Status; import org.globus.cog.abstraction.interfaces.StatusListener; import org.globus.cog.abstraction.interfaces.Task; @@ -118,22 +119,21 @@ private void addDefaultServices(BoundContact bc, String contact, String provider) throws ExecutionException { + + ServiceContact serviceContact = new ServiceContactImpl(contact); SecurityContext sc = null; if (provider != null) { try { - sc = AbstractionFactory.newSecurityContext(provider); + sc = AbstractionFactory.getSecurityContext(provider, serviceContact); } catch (Exception e) { throw new ExecutionException("Could not get default security context for provider " + provider, e); } } - bc.addService(new ServiceImpl(provider, Service.EXECUTION, new ServiceContactImpl(contact), - sc)); - bc.addService(new ServiceImpl(provider, Service.FILE_OPERATION, new ServiceContactImpl( - contact), sc)); - bc.addService(new ServiceImpl(provider, Service.FILE_TRANSFER, new ServiceContactImpl( - contact), sc)); + bc.addService(new ServiceImpl(provider, Service.EXECUTION, serviceContact, sc)); + bc.addService(new ServiceImpl(provider, Service.FILE_OPERATION, serviceContact, sc)); + bc.addService(new ServiceImpl(provider, Service.FILE_TRANSFER, serviceContact, sc)); } public static final Arg A_SECURITY_CONTEXT = new Arg.TypedPositional("securityContext", @@ -334,7 +334,7 @@ } } - protected SecurityContext getSecurityContext(VariableStack stack, String provider) + protected SecurityContext getSecurityContext(VariableStack stack, String provider, ServiceContact serviceContact) throws InvalidProviderException, ProviderMethodException, ExecutionException { if (A_SECURITY_CONTEXT.isPresent(stack)) { return (SecurityContext) A_SECURITY_CONTEXT.getValue(stack); @@ -344,7 +344,7 @@ SecurityContext.class, "Security Context"); } else { - return AbstractionFactory.newSecurityContext(provider); + return AbstractionFactory.getSecurityContext(provider, serviceContact); } } } \ No newline at end of file Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/SecurityContextNode.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/SecurityContextNode.java (revision 3443) +++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/SecurityContextNode.java (working copy) @@ -32,7 +32,7 @@ if (context == null) { String provider = TypeUtil.toString(A_PROVIDER.getValue(stack)); try { - context = AbstractionFactory.newSecurityContext(provider); + context = AbstractionFactory.getSecurityContext(provider, null); } catch (Exception e) { throw new ExecutionException("Unsupported security context type: " + provider, e); Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractFileOperation.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractFileOperation.java (revision 3443) +++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractFileOperation.java (working copy) @@ -56,8 +56,9 @@ } if (scheduler == null) { - task.setService(0, getService((BoundContact) host, provider)); - SecurityContext sc = getSecurityContext(stack, provider); + Service service = getService((BoundContact) host, provider); + task.setService(0, service); + SecurityContext sc = getSecurityContext(stack, provider, service.getServiceContact()); setSecurityContextIfNotLocal(task.getService(0), sc); synchronized (this.getClass()) { if (handler == null) { Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/GridTransfer.java =================================================================== --- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/GridTransfer.java (revision 3443) +++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/GridTransfer.java (working copy) @@ -164,8 +164,8 @@ + destinationContact); } - setSecurityContextIfNotLocal(s, getSecurityContext(stack, s.getProvider())); - setSecurityContextIfNotLocal(d, getSecurityContext(stack, d.getProvider())); + setSecurityContextIfNotLocal(s, getSecurityContext(stack, s.getProvider(), s.getServiceContact())); + setSecurityContextIfNotLocal(d, getSecurityContext(stack, d.getProvider(), d.getServiceContact())); task.setService(Service.FILE_TRANSFER_SOURCE_SERVICE, s); task.setService(Service.FILE_TRANSFER_DESTINATION_SERVICE, d); From hategan at ci.uchicago.edu Thu Aug 2 17:47:22 2012 From: hategan at ci.uchicago.edu (hategan at ci.uchicago.edu) Date: Thu, 2 Aug 2012 17:47:22 -0500 (CDT) Subject: [Swift-commit] r5886 - branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript Message-ID: <20120802224722.BFE239CC82@svn.ci.uchicago.edu> Author: hategan Date: 2012-08-02 17:47:22 -0500 (Thu, 02 Aug 2012) New Revision: 5886 Modified: branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java Log: fixed @length Modified: branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java =================================================================== --- branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2012-08-01 20:13:28 UTC (rev 5885) +++ branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2012-08-02 22:47:22 UTC (rev 5886) @@ -396,7 +396,9 @@ */ public DSHandle swiftscript_length(VariableStack stack) throws ExecutionException { - Map n = (Map) PA_ARRAY.getValue(stack); + AbstractDataNode array = (AbstractDataNode) PA_ARRAY.getValue(stack); + array.waitFor(); + Map n = array.getArrayValue(); return RootDataNode.newNode(Types.INT, Integer.valueOf(n.size())); } From hategan at ci.uchicago.edu Thu Aug 2 17:47:42 2012 From: hategan at ci.uchicago.edu (hategan at ci.uchicago.edu) Date: Thu, 2 Aug 2012 17:47:42 -0500 (CDT) Subject: [Swift-commit] r5887 - branches/release-0.93.1/src/org/griphyn/vdl/karajan/lib/swiftscript Message-ID: <20120802224742.9C1A69CC82@svn.ci.uchicago.edu> Author: hategan Date: 2012-08-02 17:47:42 -0500 (Thu, 02 Aug 2012) New Revision: 5887 Modified: branches/release-0.93.1/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java Log: fixed @length Modified: branches/release-0.93.1/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java =================================================================== --- branches/release-0.93.1/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2012-08-02 22:47:22 UTC (rev 5886) +++ branches/release-0.93.1/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2012-08-02 22:47:42 UTC (rev 5887) @@ -396,7 +396,9 @@ */ public DSHandle swiftscript_length(VariableStack stack) throws ExecutionException { - Map n = (Map) PA_ARRAY.getValue(stack); + AbstractDataNode array = (AbstractDataNode) PA_ARRAY.getValue(stack); + array.waitFor(); + Map n = array.getArrayValue(); return RootDataNode.newNode(Types.INT, Integer.valueOf(n.size())); } From hategan at ci.uchicago.edu Thu Aug 2 17:48:48 2012 From: hategan at ci.uchicago.edu (hategan at ci.uchicago.edu) Date: Thu, 2 Aug 2012 17:48:48 -0500 (CDT) Subject: [Swift-commit] r5888 - branches/release-0.93/tests/language-behaviour/arrays Message-ID: <20120802224848.BB15C9CC82@svn.ci.uchicago.edu> Author: hategan Date: 2012-08-02 17:48:48 -0500 (Thu, 02 Aug 2012) New Revision: 5888 Added: branches/release-0.93/tests/language-behaviour/arrays/030-array-length.check.sh branches/release-0.93/tests/language-behaviour/arrays/030-array-length.swift Log: added @length test Added: branches/release-0.93/tests/language-behaviour/arrays/030-array-length.check.sh =================================================================== --- branches/release-0.93/tests/language-behaviour/arrays/030-array-length.check.sh (rev 0) +++ branches/release-0.93/tests/language-behaviour/arrays/030-array-length.check.sh 2012-08-02 22:48:48 UTC (rev 5888) @@ -0,0 +1,4 @@ +#!/bin/bash +set -x +cat 030-array-length.out | grep "SwiftScript trace: 3" || exit 1 +exit 0 Property changes on: branches/release-0.93/tests/language-behaviour/arrays/030-array-length.check.sh ___________________________________________________________________ Added: svn:executable + * Added: branches/release-0.93/tests/language-behaviour/arrays/030-array-length.swift =================================================================== --- branches/release-0.93/tests/language-behaviour/arrays/030-array-length.swift (rev 0) +++ branches/release-0.93/tests/language-behaviour/arrays/030-array-length.swift 2012-08-02 22:48:48 UTC (rev 5888) @@ -0,0 +1,3 @@ +int a[] = [1, 2, 3]; + +trace(@length(a)); \ No newline at end of file From hategan at ci.uchicago.edu Thu Aug 2 17:49:31 2012 From: hategan at ci.uchicago.edu (hategan at ci.uchicago.edu) Date: Thu, 2 Aug 2012 17:49:31 -0500 (CDT) Subject: [Swift-commit] r5889 - branches/release-0.93.1/tests/language-behaviour/arrays Message-ID: <20120802224931.B327C9CC82@svn.ci.uchicago.edu> Author: hategan Date: 2012-08-02 17:49:31 -0500 (Thu, 02 Aug 2012) New Revision: 5889 Added: branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.check.sh branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.swift Log: added @length test Added: branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.check.sh =================================================================== --- branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.check.sh (rev 0) +++ branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.check.sh 2012-08-02 22:49:31 UTC (rev 5889) @@ -0,0 +1,4 @@ +#!/bin/bash +set -x +cat 030-array-length.out | grep "SwiftScript trace: 3" || exit 1 +exit 0 Property changes on: branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.check.sh ___________________________________________________________________ Added: svn:executable + * Added: branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.swift =================================================================== --- branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.swift (rev 0) +++ branches/release-0.93.1/tests/language-behaviour/arrays/030-array-length.swift 2012-08-02 22:49:31 UTC (rev 5889) @@ -0,0 +1,3 @@ +int a[] = [1, 2, 3]; + +trace(@length(a)); \ No newline at end of file From davidk at ci.uchicago.edu Fri Aug 3 15:26:46 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 3 Aug 2012 15:26:46 -0500 (CDT) Subject: [Swift-commit] r5890 - in SwiftApps/CMTS/rmsd: . docs/figures Message-ID: <20120803202646.706509CC9C@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-03 15:26:46 -0500 (Fri, 03 Aug 2012) New Revision: 5890 Added: SwiftApps/CMTS/rmsd/docs/figures/fig-distrib.png SwiftApps/CMTS/rmsd/docs/figures/fig-local.png SwiftApps/CMTS/rmsd/docs/figures/fig-multilocal.png Removed: SwiftApps/CMTS/rmsd/docs/figures/fig.distrib.png SwiftApps/CMTS/rmsd/docs/figures/fig.local.png SwiftApps/CMTS/rmsd/docs/figures/fig.multilocal.png Modified: SwiftApps/CMTS/rmsd/README Log: Some updates to README for running across multiple sites PDF generation was choking on image names in the format of first.second.png - renamed figures Modified: SwiftApps/CMTS/rmsd/README =================================================================== --- SwiftApps/CMTS/rmsd/README 2012-08-02 22:49:31 UTC (rev 5889) +++ SwiftApps/CMTS/rmsd/README 2012-08-03 20:26:46 UTC (rev 5890) @@ -4,12 +4,11 @@ Prerequisites ------------- This README will assume that runs will be started from -makena.uchicago.edu. +makena.uchicago.edu or grotthuss.uchicago.edu Please ensure that namd2, vmd, and Swift are in your $PATH. These applications must be available from the Makena worker -nodes (applications kept in /state do not seem to be -available by the worker nodes). +nodes. Add the following line to $HOME/.bashrc to set the PATH: ----- @@ -41,15 +40,20 @@ svn update ----- -How to Run ----------- +Running Single Site Jobs +------------------------ +For single site jobs, it is assumed that you are connected to the head node +where you will be doing the run. + +image:figures/fig-local.png["Local", height=390, width=664] + The runrmsd.sh script is used to start a run. The options you pass to this script will determine how the rmsd script runs. Usage: runrmsd.sh [-s sitename] -The sitename option determines where a run will take place. Currently, the -only tested option is "makena". +The sitename option determines where a run will take place. Currently, +there are valid options here are "makena" and "grotthuss". Example: @@ -72,3 +76,39 @@ Within each run directory is a subdirectory called logs. This directory contains the standard output and standard error logs from each namd task. If you notice a job is failing, reference these files for more detail about what went wrong. + +Running Remote and Multisite Jobs +--------------------------------- +It is possible to run this script remotely across multiple sites at once. For example, a test +configuration exists called "makgroth" which runs jobs on both Makena and Grotthuss at the same time. + +Here is an example of what a configuration might look like. + +image:figures/fig-distrib.png["Distributed Configuration", width=700] + +There are two requirements for this: SSH agent forwarding must be used, and a grid certificate +must be in place on each of the machines involved. + +The easiest way to set up SSH agent forwarding is to use the "-A" option to ssh. In this +example, let us assume that we will be running Swift on a machine called +bridled.ci.uchicago.edu, and sending work to grotthuss and makena. + +My laptop is the machine that has the my SSH key. When I connect to bridled, I run this command: + +----- +ssh -A bridled.ci.uchicago.edu +----- + +This will enable me to bring my SSH key to the makena and grotthuss head nodes easily. You must also +have $HOME/.ssh/authorized_keys setup correctly on makena/grotthuss to avoid getting prompted for a +password. + +The second thing that will be needed is a grid certificate. You have have the environment variables +X509_CERT_DIR and X509_USER_PROXY set up to point to your certificates directory and proxy. + +Once this is all set up, performing the run is very similar to how you run single site jobs. + +----- +./runrmsd.sh -s makgroth +----- + Copied: SwiftApps/CMTS/rmsd/docs/figures/fig-distrib.png (from rev 5889, SwiftApps/CMTS/rmsd/docs/figures/fig.distrib.png) =================================================================== (Binary files differ) Copied: SwiftApps/CMTS/rmsd/docs/figures/fig-local.png (from rev 5889, SwiftApps/CMTS/rmsd/docs/figures/fig.local.png) =================================================================== (Binary files differ) Copied: SwiftApps/CMTS/rmsd/docs/figures/fig-multilocal.png (from rev 5889, SwiftApps/CMTS/rmsd/docs/figures/fig.multilocal.png) =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/rmsd/docs/figures/fig.distrib.png =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/rmsd/docs/figures/fig.local.png =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/rmsd/docs/figures/fig.multilocal.png =================================================================== (Binary files differ) From davidk at ci.uchicago.edu Mon Aug 6 10:56:44 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 6 Aug 2012 10:56:44 -0500 (CDT) Subject: [Swift-commit] r5891 - trunk/bin Message-ID: <20120806155644.7259C9CC9C@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-06 10:56:43 -0500 (Mon, 06 Aug 2012) New Revision: 5891 Modified: trunk/bin/start-coaster-service Log: Add condor accounting groups for UC3 Modified: trunk/bin/start-coaster-service =================================================================== --- trunk/bin/start-coaster-service 2012-08-03 20:26:46 UTC (rev 5890) +++ trunk/bin/start-coaster-service 2012-08-06 15:56:43 UTC (rev 5891) @@ -283,6 +283,7 @@ notification = Never leave_in_queue = FALSE machine_count = $CONDOR_MACHINE_COUNT ++AccountingGroup="group_friends.$USER" queue $CONDOR_WORKERS EOF From swift at ci.uchicago.edu Mon Aug 6 23:35:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Mon, 6 Aug 2012 23:35:03 -0500 (CDT) Subject: [Swift-commit] cog r3445 Message-ID: <20120807043504.167918D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3445 | hategan | 2012-08-06 23:33:58 -0500 (Mon, 06 Aug 2012) | 1 line added a file locking class based on the bakery algorithm (so it doesn't need support from the FS -- in theory) ------------------------------------------------------------------------ Index: modules/util/src/org/globus/cog/util/concurrent/FileLock.java =================================================================== --- modules/util/src/org/globus/cog/util/concurrent/FileLock.java (revision 0) +++ modules/util/src/org/globus/cog/util/concurrent/FileLock.java (revision 3445) @@ -0,0 +1,190 @@ +//---------------------------------------------------------------------- +//This code is developed as part of the Java CoG Kit project +//The terms of the license can be found at http://www.cogkit.org/license +//This message may not be removed or altered. +//---------------------------------------------------------------------- + +/* + * Created on Aug 5, 2012 + */ +package org.globus.cog.util.concurrent; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileFilter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.security.SecureRandom; +import java.util.Random; + +import org.apache.log4j.Logger; + +/** + * An implementation of file locks using Lamport's Bakery algorithm. + * It tries to use the PID as thread identifier with fallback to random numbers. + * + * The Entering and Number arrays are implemented as sparse arrays of + * files in some directory. + */ +public class FileLock { + public static final Logger logger = Logger.getLogger(FileLock.class); + + public static final String NUMBER = "locking.number"; + public static final String ENTERING = "locking.entering"; + + private int myId, myN; + private File dir; + + public FileLock(String dir) { + this(new File(dir)); + } + + public FileLock(File dir) { + this.dir = dir; + dir.mkdirs(); + this.myId = getId(); + } + + private int getId() { + try { + return Integer.parseInt(new File("/proc/self").getCanonicalFile().getName()); + } + catch (Exception e) { + logger.warn("Failed to get PID of current process", e); + try { + SecureRandom rnd = SecureRandom.getInstance("SHA1PRNG"); + return rnd.nextInt() & 0x7fffffff; + } + catch (Exception ee) { + logger.warn("Failed to get instance of SHA1PRNG", ee); + return new Random().nextInt() & 0x7fffffff; + } + } + } + + public void lock() throws IOException, InterruptedException { + write(ENTERING, myId, 1); + write(NUMBER, myId, myN = 1 + maxNumber()); + write(ENTERING, myId, 0); + waitOther(); + } + + private void waitOther() throws InterruptedException { + int last = -1; + while (true) { + int minIndex = getMinIndex(last); + + if (minIndex == Integer.MAX_VALUE) { + // all remaining NUMBER[j] and ENTERING[j] are 0 + break; + } + File e = makeFile(ENTERING, minIndex); + + while (e.exists()) { + Thread.sleep(100); + } + + File n = makeFile(NUMBER, minIndex); + + while (n.exists()) { + int nj = read(n); + if (nj > myN || ((nj == myN) && (minIndex >= myId))) { + break; + } + Thread.sleep(100); + } + last = minIndex; + } + } + + private File makeFile(String prefix, int index) { + return new File(dir, prefix + "." + index); + } + + private int getMinIndex(final int greaterThan) { + File[] numbers = dir.listFiles(new FileFilter() { + @Override + public boolean accept(File f) { + String name = f.getName(); + return f.isFile() && (name.startsWith(NUMBER) || name.startsWith(ENTERING)) && (getIndex(f) > greaterThan); + } + }); + int min = Integer.MAX_VALUE; + for (File n : numbers) { + int in = getIndex(n); + if (in < min) { + min = in; + } + } + return min; + } + + private int getIndex(File n) { + try { + return Integer.parseInt(n.getName().substring(n.getName().lastIndexOf('.') + 1)); + } + catch (Exception e) { + throw new IllegalArgumentException("A file is conflicting with directory locking: " + n, e); + } + } + + private int maxNumber() { + File[] numbers = dir.listFiles(new FileFilter() { + @Override + public boolean accept(File f) { + return f.isFile() && f.getName().startsWith(NUMBER); + } + }); + + int max = 0; + for (File n : numbers) { + int in = read(n); + if (in > max) { + max = in; + } + } + return max; + } + + private int read(File n) { + try { + BufferedReader br = new BufferedReader(new FileReader(n)); + try { + return Integer.parseInt(br.readLine()); + } + finally { + br.close(); + } + } + catch (Exception e) { + // nothing. The algorithm tolerates incorrect reads + } + return 0; + } + + private void write(String prefix, int id, int value) throws IOException { + File f = new File(dir, prefix + "." + id); + if (value == 0) { + if (!f.delete()) { + f.deleteOnExit(); + throw new IOException("Failed to delete " + f); + } + } + else { + BufferedWriter br = new BufferedWriter(new FileWriter(f)); + try { + br.write(String.valueOf(value)); + } + finally { + br.close(); + } + f.deleteOnExit(); + } + } + + public void unlock() throws IOException { + write("locking.number", myId, 0); + } +} From swift at ci.uchicago.edu Mon Aug 6 23:40:04 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Mon, 6 Aug 2012 23:40:04 -0500 (CDT) Subject: [Swift-commit] cog r3447 Message-ID: <20120807044005.CBEB98D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3447 | hategan | 2012-08-06 23:37:37 -0500 (Mon, 06 Aug 2012) | 1 line added an automatic CA/user cert/proxy generator which gets used when SSH is the boot handler ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/AutoCA.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/AutoCA.java (revision 0) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/AutoCA.java (revision 3447) @@ -0,0 +1,354 @@ +//---------------------------------------------------------------------- +//This code is developed as part of the Java CoG Kit project +//The terms of the license can be found at http://www.cogkit.org/license +//This message may not be removed or altered. +//---------------------------------------------------------------------- + +/* + * Created on Aug 5, 2012 + */ +package org.globus.cog.abstraction.impl.execution.coaster; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.math.BigInteger; +import java.security.GeneralSecurityException; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.bouncycastle.asn1.ASN1InputStream; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.DEREncodable; +import org.bouncycastle.asn1.DERObject; +import org.bouncycastle.asn1.DERObjectIdentifier; +import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; +import org.bouncycastle.asn1.x509.BasicConstraints; +import org.bouncycastle.asn1.x509.KeyUsage; +import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; +import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; +import org.bouncycastle.asn1.x509.X509Extensions; +import org.bouncycastle.asn1.x509.X509Name; +import org.bouncycastle.x509.X509V3CertificateGenerator; +import org.globus.cog.util.concurrent.FileLock; +import org.globus.gsi.CertUtil; +import org.globus.gsi.GSIConstants; +import org.globus.gsi.GlobusCredential; +import org.globus.gsi.OpenSSLKey; +import org.globus.gsi.X509ExtensionSet; +import org.globus.gsi.bc.BouncyCastleCertProcessingFactory; +import org.globus.gsi.bc.BouncyCastleOpenSSLKey; +import org.globus.util.Util; + +/** + * A class to automatically generate: + * - a CA key/cert pair + * - a user key/cert pair signed by the above CA + * - a proxy certificate signed by the above user key + * + * This is heavily inspired by http://code.google.com/p/java-simple-ca/ + * + */ +public class AutoCA { + public static final Logger logger = Logger.getLogger(AutoCA.class); + + public static final String CA_DIR = System.getProperty("user.home") + File.separator + + ".globus" + File.separator + "coasters"; + public static final String CA_CRT_NAME_PREFIX = "CAcert"; + public static final String CA_KEY_NAME_PREFIX = "CAkey"; + public static final String USER_CRT_NAME_PREFIX = "usercert"; + public static final String USER_KEY_NAME_PREFIX = "userkey"; + public static final String PROXY_NAME_PREFIX = "proxy"; + + public static final String CA_CERT_ALGORITHM = "RSA"; + public static final int CA_CERT_BITS = 1024; + public static final String CA_CERT_DN = "C=US,O=JavaCoG,OU=AutoCA,CN=Certificate Authority"; + public static final String USER_CERT_DN = "C=US,O=JavaCoG,OU=AutoCA,CN=User"; + public static final String CA_CERT_SIGNATURE_ALGORITHM = "SHA1WithRSAEncryption"; + + public static final long WEEK_IN_MS = 1000 * 3600 * 24 * 7; + public static final long CA_CERT_LIFETIME = 2 * WEEK_IN_MS; + public static final long MIN_CA_CERT_LIFETIME_LEFT = WEEK_IN_MS; + + public static final int ID_BYTES = 4; + + private static AutoCA instance; + private Info info; + private X509Certificate cert; + private X509V3CertificateGenerator gen; + + public synchronized static AutoCA getInstance() { + if (instance == null) { + instance = new AutoCA(); + } + return instance; + } + + public AutoCA() { + gen = new X509V3CertificateGenerator(); + } + + public static class Info { + public final String proxyPath, caCertPath; + + public Info(File proxyFile, File caCertFile) { + this(proxyFile.getAbsolutePath(), caCertFile.getAbsolutePath()); + } + + public Info(String proxyPath, String caCertPath) { + this.proxyPath = proxyPath; + this.caCertPath = caCertPath; + } + } + + public Info createProxy() throws IOException, GeneralSecurityException { + ensureCACertsExist(); + return info; + } + + private void ensureCACertsExist() throws IOException, GeneralSecurityException { + // delete expired CAs, make a new one if the existing ones don't have + // at least MIN_CA_LIFETIME_LEFT + FileLock fl = new FileLock(CA_DIR); + try { + fl.lock(); + } + catch (Exception e) { + logger.warn("Failed to lock CA dir", e); + } + try { + File[] certs = discoverProxies(); + long now = System.currentTimeMillis(); + long maxExpirationTime = 0; + + for (File c : certs) { + if (logger.isInfoEnabled()) { + logger.info("Checking certificate " + c); + } + X509Certificate cert = CertUtil.loadCertificate(c.getAbsolutePath()); + long certExpirationTime = cert.getNotAfter().getTime(); + if (certExpirationTime < now) { + // delete cert and key + if (logger.isInfoEnabled()) { + logger.info("Certificate expired. Deleting."); + } + deleteAll(getIndex(c)); + } + if (certExpirationTime > maxExpirationTime) { + maxExpirationTime = certExpirationTime; + int index = getIndex(c); + this.info = new Info(makeFile(PROXY_NAME_PREFIX, index), makeFile(CA_CRT_NAME_PREFIX, index)); + this.cert = cert; + } + } + + if (now + MIN_CA_CERT_LIFETIME_LEFT > maxExpirationTime) { + int index = discoverNextIndex(); + this.info = new Info(makeFile(PROXY_NAME_PREFIX, index), makeFile(CA_CRT_NAME_PREFIX, index)); + if (logger.isInfoEnabled()) { + logger.info("No certificates with enough lifetime. Creating new certificate: " + info.proxyPath); + } + this.cert = createAll(index); + } + else { + if (logger.isInfoEnabled()) { + logger.info("Using certificate " + info.proxyPath + " with expiration date " + this.cert.getNotAfter()); + } + } + } + finally { + fl.unlock(); + } + } + + private File makeFile(String prefix, int index) { + return new File(CA_DIR + File.separator + prefix + ".pem." + index); + } + + private static final String[] ALL_NAMES = new String[] {CA_CRT_NAME_PREFIX, + CA_KEY_NAME_PREFIX, USER_CRT_NAME_PREFIX, USER_KEY_NAME_PREFIX, PROXY_NAME_PREFIX}; + private void deleteAll(int index) { + for (String name : ALL_NAMES) { + new File(CA_DIR + File.separator + name + ".pem." + index).delete(); + } + } + + private int getIndex(File c) { + return Integer.parseInt(c.getName().substring(c.getName().lastIndexOf('.') + 1)); + } + + private int discoverNextIndex() throws GeneralSecurityException { + for (int i = 0; i < 10; i++) { + File f = new File(CA_DIR + File.separator + PROXY_NAME_PREFIX + ".pem." + i); + if (!f.exists()) { + return i; + } + } + throw new GeneralSecurityException("No slots found to save CA certificate"); + } + + private File[] discoverProxies() { + return new File(CA_DIR).listFiles(new FileFilter() { + public boolean accept(File f) { + return f.isFile() && f.getName().matches(PROXY_NAME_PREFIX + "\\.pem\\.[0-9]"); + } + }); + } + + private X509Certificate createAll(int index) throws GeneralSecurityException, IOException { + logger.info("Generating CA key pair"); + KeyPair ca = CertUtil.generateKeyPair(CA_CERT_ALGORITHM, CA_CERT_BITS); + OpenSSLKey caKey = new BouncyCastleOpenSSLKey(ca.getPrivate()); + logger.info("Self-signing CA certificate"); + X509Certificate caCert = genCert(ca.getPrivate(), ca.getPublic(), CA_CERT_DN, CA_CERT_DN, null); + + logger.info("Generating user key pair"); + KeyPair user = CertUtil.generateKeyPair(CA_CERT_ALGORITHM, CA_CERT_BITS); + OpenSSLKey userKey = new BouncyCastleOpenSSLKey(user.getPrivate()); + logger.info("Signing user certificate"); + X509Certificate userCert = genCert(ca.getPrivate(), user.getPublic(), USER_CERT_DN, CA_CERT_DN, + createExtensions(ca.getPublic(), user.getPublic())); + logger.info("Generating proxy certificate"); + GlobusCredential proxy = makeProxy(user, userCert); + + try { + logger.info("Writing keys, certificates, and proxy"); + writeKey(caKey, makeFile(CA_KEY_NAME_PREFIX, index)); + writeCert(caCert, makeFile(CA_CRT_NAME_PREFIX, index)); + writeKey(userKey, makeFile(USER_KEY_NAME_PREFIX, index)); + writeCert(userCert, makeFile(USER_CRT_NAME_PREFIX, index)); + writeProxy(proxy, makeFile(PROXY_NAME_PREFIX, index)); + } + catch (GeneralSecurityException e) { + deleteAll(index); + throw e; + } + return cert; + } + + private Map createExtensions(PublicKey caPub, PublicKey userPub) throws IOException { + Map ext = new HashMap(); + + // not a CA + ext.put(X509Extensions.BasicConstraints, new BasicConstraints(false)); + // obvious + ext.put(X509Extensions.KeyUsage, new KeyUsage(KeyUsage.dataEncipherment | KeyUsage.digitalSignature)); + ext.put(X509Extensions.SubjectKeyIdentifier, getSubjectKeyInfo(userPub)); + ext.put(X509Extensions.AuthorityKeyIdentifier, getAuthorityKeyIdentifier(caPub)); + + return ext; + } + + + + private DEREncodable getAuthorityKeyIdentifier(PublicKey caPub) throws IOException { + DERObject derKey = new ASN1InputStream(caPub.getEncoded()).readObject(); + return new AuthorityKeyIdentifier(new SubjectPublicKeyInfo((ASN1Sequence) derKey)); + } + + private DEREncodable getSubjectKeyInfo(PublicKey userPub) throws IOException { + // convert key to bouncy castle format and get subject key identifier + DERObject derKey = new ASN1InputStream(userPub.getEncoded()).readObject(); + return new SubjectKeyIdentifier(new SubjectPublicKeyInfo((ASN1Sequence) derKey)); + } + + private void signCert(X509Certificate userCert, OpenSSLKey caKey, X509Certificate caCert) { + gen.reset(); + } + + private GlobusCredential makeProxy(KeyPair kp, X509Certificate issuerCert) throws GeneralSecurityException { + BouncyCastleCertProcessingFactory factory = BouncyCastleCertProcessingFactory.getDefault(); + KeyPair newKeyPair = CertUtil.generateKeyPair(CA_CERT_ALGORITHM, CA_CERT_BITS); + + return factory.createCredential(new X509Certificate[] { issuerCert }, + kp.getPrivate(), CA_CERT_BITS, (int) (CA_CERT_LIFETIME / 1000), GSIConstants.DELEGATION_FULL, + (X509ExtensionSet) null); + } + + private void writeProxy(GlobusCredential proxy, File f) throws GeneralSecurityException { + try { + OutputStream fw = openStream(f); + try { + proxy.save(fw); + } + finally { + fw.close(); + } + } + catch (Exception e) { + throw new GeneralSecurityException("Failed to save proxy certificate", e); + } + } + + private OutputStream openStream(File f) throws SecurityException, IOException { + String path = f.getAbsolutePath(); + File file = Util.createFile(path); + // set read only permissions + if (!Util.setOwnerAccessOnly(path)) { + logger.warn("Failed to set permissions on " + path); + } + return new FileOutputStream(file); + } + + private void writeCert(X509Certificate cert, File f) throws GeneralSecurityException { + try { + OutputStream fw = openStream(f); + CertUtil.writeCertificate(fw, cert); + } + catch (Exception e) { + throw new GeneralSecurityException("Failed to save X509 certificate", e); + } + } + + private X509Certificate genCert(PrivateKey signKey, PublicKey pubKey, String subjectDN, String issuerDN, + Map ext) throws GeneralSecurityException { + gen.reset(); + Date now = new Date(); + + gen.setSerialNumber(BigInteger.valueOf(0)); + gen.setNotBefore(now); + gen.setNotAfter(new Date(now.getTime() + CA_CERT_LIFETIME)); + gen.setIssuerDN(new X509Name(issuerDN)); + gen.setSubjectDN(new X509Name(subjectDN)); + gen.setPublicKey(pubKey); + gen.setSignatureAlgorithm(CA_CERT_SIGNATURE_ALGORITHM); + + if (ext != null) { + for (Map.Entry e : ext.entrySet()) { + gen.addExtension(e.getKey(), false, e.getValue()); + } + } + + try { + X509Certificate cert = gen.generateX509Certificate(signKey, "BC", new SecureRandom()); + return cert; + } + catch (Exception e) { + throw new GeneralSecurityException("Failed to create X509 certificate", e); + } + } + + private void writeKey(OpenSSLKey key, File f) throws GeneralSecurityException { + try { + OutputStream keyStream = openStream(f); + try { + key.writeTo(keyStream); + } + finally { + keyStream.close(); + } + } + catch (Exception e) { + throw new GeneralSecurityException("Failed to save CA private key", e); + } + } +} Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/JobSubmissionTaskHandler.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/JobSubmissionTaskHandler.java (revision 3446) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/JobSubmissionTaskHandler.java (working copy) @@ -19,7 +19,6 @@ import org.globus.cog.abstraction.coaster.service.local.LocalRequestManager; import org.globus.cog.abstraction.coaster.service.local.LocalService; import org.globus.cog.abstraction.impl.common.AbstractDelegatedTaskHandler; -import org.globus.cog.abstraction.impl.common.AbstractionFactory; import org.globus.cog.abstraction.impl.common.StatusImpl; import org.globus.cog.abstraction.impl.common.task.ExecutionServiceImpl; import org.globus.cog.abstraction.impl.common.task.IllegalSpecException; @@ -32,7 +31,6 @@ import org.globus.cog.abstraction.impl.common.task.TaskSubmissionException; import org.globus.cog.abstraction.interfaces.ExecutionService; import org.globus.cog.abstraction.interfaces.JobSpecification; -import org.globus.cog.abstraction.interfaces.SecurityContext; import org.globus.cog.abstraction.interfaces.Service; import org.globus.cog.abstraction.interfaces.Status; import org.globus.cog.abstraction.interfaces.Task; @@ -117,7 +115,6 @@ ChannelException { if (autostart) { String provider = getBootHandlerProvider(task); - cred = getCredentials(task); url = ServiceManager.getDefault().reserveService(task, provider); task.getService(0).setAttribute("coaster-url", url); } @@ -217,20 +214,6 @@ return js.getEnvironmentVariable("JAVA_HOME"); } - private GSSCredential getCredentials(Task task) throws InvalidSecurityContextException { - SecurityContext sc = task.getService(0).getSecurityContext(); - if (sc == null || sc.getCredentials() == null) { - try { - sc = AbstractionFactory.getSecurityContext("gt2", task.getService(0).getServiceContact()); - task.getService(0).setSecurityContext(sc); - } - catch (Exception e) { - throw new InvalidSecurityContextException(e); - } - } - return (GSSCredential) sc.getCredentials(); - } - public void errorReceived(Command cmd, String msg, Exception t) { Status s = new StatusImpl(Status.FAILED, msg, t); getTask().setStatus(s); Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java (revision 3446) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java (working copy) @@ -14,6 +14,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.security.GeneralSecurityException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.HashMap; @@ -53,6 +54,7 @@ import org.globus.cog.karajan.workflow.service.channels.KarajanChannel; import org.globus.cog.karajan.workflow.service.commands.Command; import org.globus.cog.karajan.workflow.service.commands.Command.Callback; +import org.globus.common.CoGProperties; import org.ietf.jgss.GSSCredential; public class ServiceManager implements StatusListener { @@ -164,11 +166,20 @@ try { startLocalService(); final Task t = buildTask(service); - setSecurityContext(t, sc, bootHandlerProvider); + t.addStatusListener(this); if (logger.isDebugEnabled()) { logger.debug("Starting coaster service on " + contact + ". Task is " + t); } + + boolean ssh = "ssh".equalsIgnoreCase(bootHandlerProvider); + + if (ssh) { + setupGSIProxy(); + } + + setSecurityContext(t, sc, bootHandlerProvider); + boolean local = "local".equals(bootHandlerProvider); if (LOCALJVM || (LOCALJVM_WHEN_LOCAL && local)) { final String ls = getLocalServiceURL(); @@ -200,6 +211,12 @@ } } + private void setupGSIProxy() throws IOException, GeneralSecurityException { + AutoCA.Info result = AutoCA.getInstance().createProxy(); + CoGProperties.getDefault().setProxyFile(result.proxyPath); + CoGProperties.getDefault().setCaCertLocations(result.caCertPath); + } + private void setSecurityContext(Task t, SecurityContext sc, String provider) throws InvalidProviderException, ProviderMethodException { t.getService(0).setSecurityContext(AbstractionFactory.getSecurityContext(provider, t.getService(0).getServiceContact())); From davidk at ci.uchicago.edu Wed Aug 8 10:11:32 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Wed, 8 Aug 2012 10:11:32 -0500 (CDT) Subject: [Swift-commit] r5892 - SwiftApps/CMTS Message-ID: <20120808151133.00AEC9CCBB@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-08 10:11:32 -0500 (Wed, 08 Aug 2012) New Revision: 5892 Added: SwiftApps/CMTS/dimers/ Log: Creating SVN location for John's LAMMPS script - an example showing serial dependencies From swift at ci.uchicago.edu Wed Aug 8 20:35:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 8 Aug 2012 20:35:03 -0500 (CDT) Subject: [Swift-commit] cog r3448 Message-ID: <20120809013504.18FA78D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3448 | hategan | 2012-08-08 20:34:37 -0500 (Wed, 08 Aug 2012) | 1 line fixed issue where gsi cert would be required in local mode ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/local/LocalService.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/local/LocalService.java (revision 3447) +++ modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/local/LocalService.java (working copy) @@ -158,9 +158,6 @@ } try { GSSCredential cred = channel.getUserContext().getCredential(); - if (cred == null) { - cred = (GSSCredential) AbstractionFactory.getSecurityContext("gt2", new ServiceContactImpl(url)).getCredentials(); - } ChannelManager.getManager().registerChannel(url, cred, channel); } catch (Exception e) { From swift at ci.uchicago.edu Wed Aug 8 20:40:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 8 Aug 2012 20:40:03 -0500 (CDT) Subject: [Swift-commit] cog r3449 Message-ID: <20120809014004.86B7F8D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3449 | hategan | 2012-08-08 20:37:44 -0500 (Wed, 08 Aug 2012) | 1 line if no relevant trusted CA can be found for forwarding, log a list of the ones that are known ------------------------------------------------------------------------ Index: modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java =================================================================== --- modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java (revision 3448) +++ modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java (working copy) @@ -22,6 +22,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.log4j.Logger; import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException; import org.globus.cog.abstraction.impl.ssh.ConnectionID; import org.globus.cog.abstraction.impl.ssh.SSHChannel; @@ -48,6 +49,8 @@ * */ public class ProxyForwardingManager { + public static final Logger logger = Logger.getLogger(ProxyForwardingManager.class); + public static final long TIME_MARGIN = 10000; public static final String PROXY_PREFIX = "sshproxy"; public static final String CA_PREFIX = "sshCAcert"; @@ -164,6 +167,12 @@ X509Certificate caCert = tc.getCertificate(userCert.getIssuerDN().getName()); if (caCert == null) { + logger.info("Cannot find root CA certificate for proxy"); + logger.info("DNs of trusted certificates:"); + X509Certificate[] roots = tc.getCertificates(); + for (X509Certificate root : roots) { + logger.info("\t" + root.getSubjectDN()); + } throw new InvalidSecurityContextException("Failed to find root CA certificate (" + userCert.getIssuerDN().getName() + ")"); } From swift at ci.uchicago.edu Wed Aug 8 20:45:04 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 8 Aug 2012 20:45:04 -0500 (CDT) Subject: [Swift-commit] cog r3450 Message-ID: <20120809014505.281648D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3450 | hategan | 2012-08-08 20:40:42 -0500 (Wed, 08 Aug 2012) | 1 line changed info to warn; you shouldn't get this far with an untrusted CA ------------------------------------------------------------------------ Index: modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java =================================================================== --- modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java (revision 3449) +++ modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java (working copy) @@ -167,11 +167,11 @@ X509Certificate caCert = tc.getCertificate(userCert.getIssuerDN().getName()); if (caCert == null) { - logger.info("Cannot find root CA certificate for proxy"); - logger.info("DNs of trusted certificates:"); + logger.warn("Cannot find root CA certificate for proxy"); + logger.warn("DNs of trusted certificates:"); X509Certificate[] roots = tc.getCertificates(); for (X509Certificate root : roots) { - logger.info("\t" + root.getSubjectDN()); + logger.warn("\t" + root.getSubjectDN()); } throw new InvalidSecurityContextException("Failed to find root CA certificate (" + userCert.getIssuerDN().getName() + ")"); } From swift at ci.uchicago.edu Thu Aug 9 03:30:03 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Thu, 9 Aug 2012 03:30:03 -0500 (CDT) Subject: [Swift-commit] cog r3451 Message-ID: <20120809083004.000EC8D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3451 | hategan | 2012-08-09 03:27:36 -0500 (Thu, 09 Aug 2012) | 1 line use system properties to set proxy and ca locations since CoGProperties gives precedence to those over its own set methods ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java (revision 3450) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java (working copy) @@ -213,8 +213,8 @@ private void setupGSIProxy() throws IOException, GeneralSecurityException { AutoCA.Info result = AutoCA.getInstance().createProxy(); - CoGProperties.getDefault().setProxyFile(result.proxyPath); - CoGProperties.getDefault().setCaCertLocations(result.caCertPath); + System.setProperty("X509_USER_PROXY", result.proxyPath); + System.setProperty("X509_CERT_DIR", result.caCertPath); } private void setSecurityContext(Task t, SecurityContext sc, String provider) From davidk at ci.uchicago.edu Thu Aug 9 17:32:54 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Thu, 9 Aug 2012 17:32:54 -0500 (CDT) Subject: [Swift-commit] r5894 - in SwiftApps/CMTS/dimers: . bin conf input_files Message-ID: <20120809223254.763AC9CC9E@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-09 17:32:54 -0500 (Thu, 09 Aug 2012) New Revision: 5894 Added: SwiftApps/CMTS/dimers/bin/restart2data.sh Removed: SwiftApps/CMTS/dimers/input_files/end_20.restart SwiftApps/CMTS/dimers/input_files/end_25.restart SwiftApps/CMTS/dimers/input_files/end_30.restart SwiftApps/CMTS/dimers/input_files/end_35.restart SwiftApps/CMTS/dimers/input_files/end_40.restart SwiftApps/CMTS/dimers/input_files/end_45.restart SwiftApps/CMTS/dimers/input_files/end_50.restart SwiftApps/CMTS/dimers/input_files/end_55.restart SwiftApps/CMTS/dimers/input_files/end_60.restart SwiftApps/CMTS/dimers/input_files/end_65.restart SwiftApps/CMTS/dimers/input_files/end_70.restart Modified: SwiftApps/CMTS/dimers/conf/local.cf SwiftApps/CMTS/dimers/dimers.swift SwiftApps/CMTS/dimers/rundimers.sh Log: Various updates to input files, swift script, and wrapper shell script Added: SwiftApps/CMTS/dimers/bin/restart2data.sh =================================================================== --- SwiftApps/CMTS/dimers/bin/restart2data.sh (rev 0) +++ SwiftApps/CMTS/dimers/bin/restart2data.sh 2012-08-09 22:32:54 UTC (rev 5894) @@ -0,0 +1,7 @@ +#!/bin/bash + +./restart2data $@ +for file in $( ls *.swift ) +do + mv $file $( basename $file .swift ) +done Property changes on: SwiftApps/CMTS/dimers/bin/restart2data.sh ___________________________________________________________________ Added: svn:executable + * Modified: SwiftApps/CMTS/dimers/conf/local.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/local.cf 2012-08-08 15:12:55 UTC (rev 5893) +++ SwiftApps/CMTS/dimers/conf/local.cf 2012-08-09 22:32:54 UTC (rev 5894) @@ -7,4 +7,5 @@ provider.staging.pin.swiftfiles=false use.wrapper.staging=false -#app rmsd=$PWD/../rmsd.sh +#app insert_molecules=$PWD/../bin/insert_molecules +#app restart2data=$PWD/../bin/restart2data.sh Modified: SwiftApps/CMTS/dimers/dimers.swift =================================================================== --- SwiftApps/CMTS/dimers/dimers.swift 2012-08-08 15:12:55 UTC (rev 5893) +++ SwiftApps/CMTS/dimers/dimers.swift 2012-08-09 22:32:54 UTC (rev 5894) @@ -1,13 +1,33 @@ type file; -app insert_molecules +app (file lamps_config_output) insert_molecules (file lamps_config, file dimer, int delta, int v_radius) +{ + insert_molecules @lamps_config @dimer delta v_radius 0 25.0 @lamps_config_output; +} -app restart2data +app (file output_file) restart2data (file restart_file, file config_file) +{ + restart2data @restart_file @config_file; +} -app lmp_john - int start_ndimers=20; -int max_ndimers=75; +int max_ndimers=70; int delta_ndimers=5; int virion_radius=300; +file dimer_file <"dimer_1232.lammps_config">; +file initial_output <"empty.lammps_config">; +file outputs[]; +outputs[start_ndimers-delta_ndimers] = initial_output; + +foreach i in [start_ndimers:max_ndimers:delta_ndimers] { + + file molecule_output ; + molecule_output = insert_molecules(outputs[i-delta_ndimers], dimer_file, delta_ndimers, virion_radius); + + file restart_input ; + file restart_output ; + restart_output = restart2data(restart_input, molecule_output); + + outputs[i] = restart_output; +} Deleted: SwiftApps/CMTS/dimers/input_files/end_20.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_25.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_30.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_35.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_40.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_45.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_50.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_55.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_60.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_65.restart =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_70.restart =================================================================== (Binary files differ) Modified: SwiftApps/CMTS/dimers/rundimers.sh =================================================================== --- SwiftApps/CMTS/dimers/rundimers.sh 2012-08-08 15:12:55 UTC (rev 5893) +++ SwiftApps/CMTS/dimers/rundimers.sh 2012-08-09 22:32:54 UTC (rev 5894) @@ -58,7 +58,7 @@ # Do the run cd $rundir -cp ../rmsd.swift . +cp ../dimers.swift . export WORK=$PWD/swiftwork mkdir -p $PWD/swiftwork/workers From davidk at ci.uchicago.edu Fri Aug 10 11:04:31 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 11:04:31 -0500 (CDT) Subject: [Swift-commit] r5895 - SwiftApps/CMTS/dimers/src Message-ID: <20120810160431.3B4459CCA5@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 11:04:31 -0500 (Fri, 10 Aug 2012) New Revision: 5895 Removed: SwiftApps/CMTS/dimers/src/insert_molecules SwiftApps/CMTS/dimers/src/restart2data Log: Remove binaries Deleted: SwiftApps/CMTS/dimers/src/insert_molecules =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/src/restart2data =================================================================== (Binary files differ) From davidk at ci.uchicago.edu Fri Aug 10 11:05:38 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 11:05:38 -0500 (CDT) Subject: [Swift-commit] r5896 - SwiftApps/CMTS/dimers/bin Message-ID: <20120810160538.2E6609CCA5@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 11:05:38 -0500 (Fri, 10 Aug 2012) New Revision: 5896 Removed: SwiftApps/CMTS/dimers/bin/insert_molecules SwiftApps/CMTS/dimers/bin/restart2data Log: Remove binaries from bin - run make in src/ Deleted: SwiftApps/CMTS/dimers/bin/insert_molecules =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/bin/restart2data =================================================================== (Binary files differ) From davidk at ci.uchicago.edu Fri Aug 10 11:24:38 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 11:24:38 -0500 (CDT) Subject: [Swift-commit] r5897 - SwiftApps/CMTS/dimers/input_files Message-ID: <20120810162438.390F59CCA5@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 11:24:38 -0500 (Fri, 10 Aug 2012) New Revision: 5897 Added: SwiftApps/CMTS/dimers/input_files/dimer_1232.lammps_config SwiftApps/CMTS/dimers/input_files/empty.lammps_config SwiftApps/CMTS/dimers/input_files/end_20.restart.swift SwiftApps/CMTS/dimers/input_files/end_25.restart.swift SwiftApps/CMTS/dimers/input_files/end_30.restart.swift SwiftApps/CMTS/dimers/input_files/end_35.restart.swift SwiftApps/CMTS/dimers/input_files/end_40.restart.swift SwiftApps/CMTS/dimers/input_files/end_45.restart.swift SwiftApps/CMTS/dimers/input_files/end_50.restart.swift SwiftApps/CMTS/dimers/input_files/end_55.restart.swift SwiftApps/CMTS/dimers/input_files/end_60.restart.swift SwiftApps/CMTS/dimers/input_files/end_65.restart.swift SwiftApps/CMTS/dimers/input_files/end_70.restart.swift Log: Input config files and example lampps outputs Added: SwiftApps/CMTS/dimers/input_files/dimer_1232.lammps_config =================================================================== --- SwiftApps/CMTS/dimers/input_files/dimer_1232.lammps_config (rev 0) +++ SwiftApps/CMTS/dimers/input_files/dimer_1232.lammps_config 2012-08-10 16:24:38 UTC (rev 5897) @@ -0,0 +1,161 @@ +Single dimer, as 1232 format + +86 atoms +5 bonds +2 impropers + +43 atom types +3 bond types +2 improper types + + -756.560 +785.152 xlo xhi + -792.835 +795.239 ylo yhi + -715.562 +702.503 zlo zhi + +Masses + + 1 1.000 # 1_1 + 2 1.000 # 1_2 + 3 1.000 # 1_3 + 4 1.000 # 1_4 + 5 1.000 # 2_1 + 6 1.000 # 2_2 + 7 1.000 # 3_1 + 8 1.000 # 3_2 + 9 1.000 # 3_3 + 10 1.000 # 4_1 + 11 1.000 # 4_2 + 12 1.000 # 4_3 + 13 1.000 # 4_4 + 14 1.000 # 4_5 + 15 1.000 # 4_6 + 16 1.000 # 5_1 + 17 1.000 # 6_1 + 18 1.000 # 6_2 + 19 1.000 # 6_3 + 20 1.000 # 7_1 + 21 1.000 # 7_2 + 22 1.000 # 7_3 + 23 1.000 # 7_4 + 24 1.000 # 7_5 + 25 1.000 # 7_6 + 26 1.000 # AN1 + 27 1.000 # AN2 + 28 1.000 # AC1 + 29 1.000 # AC2 + 30 1.000 # 8_1 + 31 1.000 # 8_2 + 32 1.000 # 8_3 + 33 1.000 # 8_4 + 34 1.000 # 9_1 + 35 1.000 # 9_2 + 36 1.000 # 9_3 + 37 1.000 # 9_4 + 38 1.000 # 10_1 + 39 1.000 # 10_2 + 40 1.000 # 10_3 + 41 1.000 # 11_1 + 42 1.000 # 11_2 + 43 1.000 # 12 + +Atoms + + 1 1 1 +226.922 -126.238 +12.619 + 2 1 2 +224.009 -124.025 +9.839 + 3 1 3 +221.082 -122.564 +6.574 + 4 1 4 +218.557 -121.306 +2.898 + 5 1 5 +214.572 -115.267 +11.126 + 6 1 6 +219.039 -117.163 +14.819 + 7 1 7 +231.591 -113.864 +15.743 + 8 1 8 +230.273 -115.423 +11.608 + 9 1 9 +229.516 -116.359 +7.193 + 10 1 10 +224.393 -109.574 -1.334 + 11 1 11 +225.128 -106.326 +1.727 + 12 1 12 +226.938 -102.700 +6.299 + 13 1 13 +227.650 -99.606 +9.640 + 14 1 14 +229.470 -96.512 +14.475 + 15 1 15 +230.559 -93.572 +17.766 + 16 1 16 +235.225 -102.180 +16.805 + 17 1 17 +239.745 -111.924 +20.986 + 18 1 18 +237.403 -110.785 +24.664 + 19 1 19 +234.974 -110.629 +28.372 + 20 1 20 +228.012 -107.919 +21.779 + 21 1 21 +225.202 -107.090 +18.297 + 22 1 22 +221.939 -105.556 +13.325 + 23 1 23 +219.184 -105.702 +9.666 + 24 1 24 +215.241 -105.432 +5.008 + 25 1 25 +212.592 -106.240 +1.329 + 26 1 26 +199.194 -107.488 +4.286 + 27 1 27 +206.737 -112.435 +8.607 + 28 2 28 +199.194 -107.488 +4.286 + 29 2 29 +206.737 -112.435 +8.607 + 30 2 30 +190.775 -115.480 +3.527 + 31 2 31 +194.919 -113.877 +4.223 + 32 2 32 +199.878 -111.026 +4.469 + 33 2 33 +203.866 -109.208 +5.251 + 34 2 34 +200.291 -99.839 +12.535 + 35 2 35 +196.603 -100.915 +10.492 + 36 2 36 +193.408 -101.313 +7.671 + 37 2 37 +190.553 -102.513 +4.748 + 38 2 38 +183.062 -108.578 +0.748 + 39 2 39 +181.304 -108.080 +5.233 + 40 2 40 +179.848 -107.264 +9.507 + 41 2 41 +188.331 -111.694 +14.227 + 42 2 42 +185.947 -114.438 +11.847 + 43 2 43 +197.466 -100.342 +7.203 + 44 3 1 +183.923 -60.433 +24.939 + 45 3 2 +183.348 -63.836 +21.906 + 46 3 3 +182.231 -66.678 +18.437 + 47 3 4 +180.530 -69.380 +15.078 + 48 3 5 +190.586 -73.326 +16.909 + 49 3 6 +191.247 -69.684 +21.753 + 50 3 7 +186.548 -70.335 +33.869 + 51 3 8 +183.367 -70.315 +30.532 + 52 3 9 +179.785 -70.866 +27.737 + 53 3 10 +176.176 -80.640 +21.701 + 54 3 11 +179.022 -82.664 +24.575 + 55 3 12 +182.709 -84.414 +29.122 + 56 3 13 +185.778 -86.215 +32.051 + 57 3 14 +189.591 -87.384 +36.563 + 58 3 15 +192.407 -88.991 +39.748 + 59 3 16 +187.786 -80.373 +40.836 + 60 3 17 +187.436 -69.202 +43.651 + 61 3 18 +191.923 -69.597 +43.535 + 62 3 19 +196.304 -69.074 +43.069 + 63 3 20 +194.513 -74.768 +35.091 + 64 3 21 +193.040 -77.058 +31.447 + 65 3 22 +190.638 -80.529 +26.986 + 66 3 23 +188.812 -81.945 +23.028 + 67 3 24 +186.781 -84.254 +17.749 + 68 3 25 +184.768 -85.036 +13.682 + 69 3 26 +193.567 -85.316 +3.085 + 70 3 27 +192.731 -78.087 +9.945 + 71 2 28 +193.567 -85.316 +3.085 + 72 2 29 +192.731 -78.087 +9.945 + 73 2 30 +195.567 -79.488 -6.783 + 74 2 31 +194.442 -80.071 -2.467 + 75 2 32 +192.760 -81.818 +2.718 + 76 2 33 +191.823 -82.605 +6.998 + 77 2 34 +201.468 -89.889 +9.750 + 78 2 35 +201.311 -90.117 +5.407 + 79 2 36 +200.371 -91.127 +1.356 + 80 2 37 +199.037 -91.355 -2.682 + 81 2 38 +198.155 -88.130 -12.567 + 82 2 39 +202.937 -87.584 -12.027 + 83 2 40 +207.449 -87.346 -11.226 + 84 2 41 +206.590 -80.322 -3.238 + 85 2 42 +205.216 -78.857 -7.091 + 86 2 43 +198.179 -91.474 +4.920 + +Bonds + + 1 1 43 86 + 2 2 26 28 + 3 3 27 29 + 4 2 69 71 + 5 3 70 72 + +Impropers + + 1 1 25 27 26 30 + 2 2 68 70 69 73 Added: SwiftApps/CMTS/dimers/input_files/empty.lammps_config =================================================================== --- SwiftApps/CMTS/dimers/input_files/empty.lammps_config (rev 0) +++ SwiftApps/CMTS/dimers/input_files/empty.lammps_config 2012-08-10 16:24:38 UTC (rev 5897) @@ -0,0 +1,66 @@ +Empty system! + +0 atoms +0 bonds +0 impropers + +44 atom types +3 bond types +2 improper types + + -800 +800 xlo xhi + -800 +800 ylo yhi + -800 +800 zlo zhi + +Masses + + 1 1.000 # 1_1 + 2 1.000 # 1_2 + 3 1.000 # 1_3 + 4 1.000 # 1_4 + 5 1.000 # 2_1 + 6 1.000 # 2_2 + 7 1.000 # 3_1 + 8 1.000 # 3_2 + 9 1.000 # 3_3 + 10 1.000 # 4_1 + 11 1.000 # 4_2 + 12 1.000 # 4_3 + 13 1.000 # 4_4 + 14 1.000 # 4_5 + 15 1.000 # 4_6 + 16 1.000 # 5_1 + 17 1.000 # 6_1 + 18 1.000 # 6_2 + 19 1.000 # 6_3 + 20 1.000 # 7_1 + 21 1.000 # 7_2 + 22 1.000 # 7_3 + 23 1.000 # 7_4 + 24 1.000 # 7_5 + 25 1.000 # 7_6 + 26 1.000 # AN1 + 27 1.000 # AN2 + 28 1.000 # AC1 + 29 1.000 # AC2 + 30 1.000 # 8_1 + 31 1.000 # 8_2 + 32 1.000 # 8_3 + 33 1.000 # 8_4 + 34 1.000 # 9_1 + 35 1.000 # 9_2 + 36 1.000 # 9_3 + 37 1.000 # 9_4 + 38 1.000 # 10_1 + 39 1.000 # 10_2 + 40 1.000 # 10_3 + 41 1.000 # 11_1 + 42 1.000 # 11_2 + 43 1.000 # 12 + 44 1.000 # ? + +Atoms + +Bonds + +Impropers Added: SwiftApps/CMTS/dimers/input_files/end_20.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_20.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_25.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_25.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_30.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_30.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_35.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_35.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_40.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_40.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_45.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_45.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_50.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_50.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_55.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_55.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_60.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_60.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_65.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_65.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_70.restart.swift =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_70.restart.swift ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From davidk at ci.uchicago.edu Fri Aug 10 11:44:54 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 11:44:54 -0500 (CDT) Subject: [Swift-commit] r5898 - SwiftApps/CMTS/dimers/conf Message-ID: <20120810164454.62DBC9CCA5@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 11:44:54 -0500 (Fri, 10 Aug 2012) New Revision: 5898 Modified: SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf SwiftApps/CMTS/dimers/conf/grotthuss.cf SwiftApps/CMTS/dimers/conf/makena-ssh.cf SwiftApps/CMTS/dimers/conf/makena.cf SwiftApps/CMTS/dimers/conf/makgroth.cf Log: Updated config files for makena/grotthuss Modified: SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf 2012-08-10 16:24:38 UTC (rev 5897) +++ SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf 2012-08-10 16:44:54 UTC (rev 5898) @@ -7,5 +7,6 @@ use.wrapper.staging=false tcp.port.range=5000,51000 -#app rmsd=$PWD/../rmsd.sh -#app plot_pd=$PWD/../plot_pd.pl +#app insert_molecules=$PWD/../bin/insert_molecules +#app restart2data=$PWD/../bin/restart2data.sh + Modified: SwiftApps/CMTS/dimers/conf/grotthuss.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss.cf 2012-08-10 16:24:38 UTC (rev 5897) +++ SwiftApps/CMTS/dimers/conf/grotthuss.cf 2012-08-10 16:44:54 UTC (rev 5898) @@ -7,5 +7,6 @@ provider.staging.pin.swiftfiles=false use.wrapper.staging=false -#app rmsd=$PWD/../rmsd.sh -#app plot_pd=$PWD/../plot_pd.pl +#app insert_molecules=$PWD/../bin/insert_molecules +#app restart2data=$PWD/../bin/restart2data.sh + Modified: SwiftApps/CMTS/dimers/conf/makena-ssh.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makena-ssh.cf 2012-08-10 16:24:38 UTC (rev 5897) +++ SwiftApps/CMTS/dimers/conf/makena-ssh.cf 2012-08-10 16:44:54 UTC (rev 5898) @@ -7,5 +7,6 @@ use.wrapper.staging=false tcp.port.range=5000,51000 -#app rmsd=$PWD/../rmsd.sh -#app plot_pd=$PWD/../plot_pd.pl +#app insert_molecules=$PWD/../bin/insert_molecules +#app restart2data=$PWD/../bin/restart2data.sh + Modified: SwiftApps/CMTS/dimers/conf/makena.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makena.cf 2012-08-10 16:24:38 UTC (rev 5897) +++ SwiftApps/CMTS/dimers/conf/makena.cf 2012-08-10 16:44:54 UTC (rev 5898) @@ -7,5 +7,6 @@ provider.staging.pin.swiftfiles=false use.wrapper.staging=false -#app rmsd=$PWD/../rmsd.sh -#app plot_pd=$PWD/../plot_pd.pl +#app insert_molecules=$PWD/../bin/insert_molecules +#app restart2data=$PWD/../bin/restart2data.sh + Modified: SwiftApps/CMTS/dimers/conf/makgroth.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makgroth.cf 2012-08-10 16:24:38 UTC (rev 5897) +++ SwiftApps/CMTS/dimers/conf/makgroth.cf 2012-08-10 16:44:54 UTC (rev 5898) @@ -7,5 +7,6 @@ use.wrapper.staging=false tcp.port.range=5000,51000 -#app rmsd=$PWD/../rmsd.sh -#app plot_pd=$PWD/../plot_pd.pl +#app insert_molecules=$PWD/../bin/insert_molecules +#app restart2data=$PWD/../bin/restart2data.sh + From davidk at ci.uchicago.edu Fri Aug 10 12:22:52 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 12:22:52 -0500 (CDT) Subject: [Swift-commit] r5899 - SwiftApps/CMTS/dimers Message-ID: <20120810172252.578E79CCAF@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 12:22:52 -0500 (Fri, 10 Aug 2012) New Revision: 5899 Modified: SwiftApps/CMTS/dimers/README Log: Added readme Modified: SwiftApps/CMTS/dimers/README =================================================================== --- SwiftApps/CMTS/dimers/README 2012-08-10 16:44:54 UTC (rev 5898) +++ SwiftApps/CMTS/dimers/README 2012-08-10 17:22:52 UTC (rev 5899) @@ -0,0 +1,70 @@ +Dimers Swift Scripts +==================== + +Prerequisites +------------- +This README will assume that runs will be started from +makena.uchicago.edu. + +Please ensure that Swift is in your $PATH. + +Add the following line to $HOME/.bashrc to set the PATH: +----- +export PATH=/scratch/davidk/swift-trunk/cog/modules/swift/dist/swift-svn/bin:/opt/torque/bin:$PATH +----- + +You will need to create a directory called /scratch/: +----- +mkdir /scratch/yourusername +cd /scratch/yourusername +----- + +IMPORTANT: Please note that runs may fail if started from /home due to some +potential NFS issues, so please make sure to always use /scratch. + + +Checking out scripts from SVN +----------------------------- +From within your scratch directory, run the following command to get the +dimers scripts: + +----- +svn checkout https://svn.ci.uchicago.edu/svn/vdl2/SwiftApps/CMTS/dimers +----- + +These scripts can periodically be updated by running an SVN update within +the dimers directory: +----- +svn update +----- + +How to Run +---------- +The rundimers.sh script is used to start a run. The options you pass to +this script will determine how the dimers script runs. + +Usage: rundimers.sh [-s sitename] + +The sitename option determines where a run will take place. Currently, the +only tested options are "makena" and "grotthuss". + +Example: + +----- +./rundimers.sh -s makena +----- + +When your job has finished running for the first time, you will see that a directory +has been created called run001. A new directory will be created each time you run +the rundimers.sh script. + +Outputs +------- +Within each run directory is a subdirectory called output. This directory will +contain all relevent outputs created during the run. + +Logs +---- +Within each run directory is a subdirectory called logs. This directory contains +the standard output and standard error logs from each namd task. If you notice a job +is failing, reference these files for more detail about what went wrong. From davidk at ci.uchicago.edu Fri Aug 10 12:36:34 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 12:36:34 -0500 (CDT) Subject: [Swift-commit] r5900 - SwiftApps/CMTS/dimers Message-ID: <20120810173634.EFBF19CCAF@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 12:36:34 -0500 (Fri, 10 Aug 2012) New Revision: 5900 Modified: SwiftApps/CMTS/dimers/rundimers.sh Log: Build packages as needed Modified: SwiftApps/CMTS/dimers/rundimers.sh =================================================================== --- SwiftApps/CMTS/dimers/rundimers.sh 2012-08-10 17:22:52 UTC (rev 5899) +++ SwiftApps/CMTS/dimers/rundimers.sh 2012-08-10 17:36:34 UTC (rev 5900) @@ -36,6 +36,15 @@ mkdir $rundir fi +# Ensure binaries are build +if [ ! -x "bin/restart2data" ] || [ ! -x "bin/insert_molecules" ]; then + echo Building packages + cd src + make + cd .. + echo +fi + # Copy input files cp input_files/* $rundir echo Run directory $rundir: site=$execsite paramfile=$paramfile From davidk at ci.uchicago.edu Fri Aug 10 16:12:09 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Fri, 10 Aug 2012 16:12:09 -0500 (CDT) Subject: [Swift-commit] r5901 - trunk/bin Message-ID: <20120810211209.33BAE9CCAF@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-10 16:12:09 -0500 (Fri, 10 Aug 2012) New Revision: 5901 Modified: trunk/bin/swift Log: Ignore ifconfig obsolete messages on midway Modified: trunk/bin/swift =================================================================== --- trunk/bin/swift 2012-08-10 17:36:34 UTC (rev 5900) +++ trunk/bin/swift 2012-08-10 21:12:09 UTC (rev 5901) @@ -122,7 +122,7 @@ PATH=$PATH:/sbin IFCONFIG=`which ifconfig 2>&1` if [ -x "$IFCONFIG" ]; then - MAC=`$IFCONFIG |grep HWaddr` + MAC=`$IFCONFIG 2>/dev/null |grep HWaddr` fi # Check if we are running on a mac, if so look for md5 and not md5sum From swift at ci.uchicago.edu Sat Aug 11 11:05:05 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Sat, 11 Aug 2012 11:05:05 -0500 (CDT) Subject: [Swift-commit] cog r3453 Message-ID: <20120811160505.A6D628D00DF3@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3453 | hategan | 2012-08-11 11:02:05 -0500 (Sat, 11 Aug 2012) | 1 line also forward signing policy ------------------------------------------------------------------------ Index: modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java =================================================================== --- modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java (revision 3452) +++ modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/ProxyForwardingManager.java (working copy) @@ -10,7 +10,10 @@ package org.globus.cog.abstraction.impl.ssh.execution; import java.io.BufferedOutputStream; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.SecureRandom; @@ -31,6 +34,7 @@ import org.globus.gsi.GSIConstants; import org.globus.gsi.GlobusCredential; import org.globus.gsi.GlobusCredentialException; +import org.globus.gsi.SigningPolicy; import org.globus.gsi.TrustedCertificates; import org.globus.gsi.X509ExtensionSet; import org.globus.gsi.bc.BouncyCastleCertProcessingFactory; @@ -152,10 +156,13 @@ SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN"); long now = System.currentTimeMillis(); int id = Math.abs(random.nextInt()); - String proxyFileName = PROXY_PREFIX + "-" + id + "-" + (cred.getTimeLeft() + now / 1000); - String caCertFileName = CA_PREFIX + "-" + id + "-" + (cred.getTimeLeft() + now / 1000); + long suffix = cred.getTimeLeft() + now / 1000; + String proxyFileName = PROXY_PREFIX + "-" + id + "-" + suffix; + String caCertFileName = CA_PREFIX + "-" + id + "-" + suffix + ".pem"; + String signingPolicyFileName = CA_PREFIX + "-" + id + "-" + suffix + ".signing_policy"; + SftpFile fp = createFile(sftp, globusDir, proxyFileName); BufferedOutputStream pout = new BufferedOutputStream(new SftpFileOutputStream(fp)); cred.save(pout); @@ -182,6 +189,14 @@ CertUtil.writeCertificate(cout, caCert); cout.close(); + SigningPolicy sp = tc.getSigningPolicy('/' + userCert.getIssuerDN().getName().replace(',', '/')); + if (sp != null) { + SftpFile spf = createFile(sftp, globusDir, signingPolicyFileName); + BufferedOutputStream spout = new BufferedOutputStream(new SftpFileOutputStream(spf)); + writeFile(spout, new FileInputStream(sp.getFileName())); + } + + return new Info(globusDir + "/" + proxyFileName, globusDir + "/" + caCertFileName, cred.getTimeLeft() * 1000 + System.currentTimeMillis()); } @@ -198,6 +213,17 @@ } } + private void writeFile(OutputStream out, InputStream in) throws IOException { + byte[] buf = new byte[1024]; + int len = in.read(buf); + while (len != -1) { + out.write(buf, 0, len); + len = in.read(buf); + } + out.close(); + in.close(); + } + private SftpFile createFile(SftpSubsystemClient sftp, String dir, String name) throws IOException { FileAttributes fa = new FileAttributes(); fa.setPermissions(new UnsignedInteger32(FileAttributes.S_IRUSR From wilde at ci.uchicago.edu Mon Aug 13 11:47:42 2012 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Mon, 13 Aug 2012 11:47:42 -0500 (CDT) Subject: [Swift-commit] r5902 - SwiftApps/CMTS/dimers Message-ID: <20120813164742.9BEA39CCB4@svn.ci.uchicago.edu> Author: wilde Date: 2012-08-13 11:47:42 -0500 (Mon, 13 Aug 2012) New Revision: 5902 Added: SwiftApps/CMTS/dimers/README_USE_CASE Log: Add description of this use case from Johns email Added: SwiftApps/CMTS/dimers/README_USE_CASE =================================================================== --- SwiftApps/CMTS/dimers/README_USE_CASE (rev 0) +++ SwiftApps/CMTS/dimers/README_USE_CASE 2012-08-13 16:47:42 UTC (rev 5902) @@ -0,0 +1,103 @@ +From John Grime, 7 Aug 2012: + +--- + +Chaps, + +Please find attached a compressed directory with an example of the +sort of thing I sometimes need to do which may benefit from +SWIFTification. + +--------------- +Brief overview: +--------------- + +I have some molecular simulations where I try to get a set of proteins +to self-assemble into a larger structure inside a spherical region of +space. + +I know what the "target" concentration of protein is for the +biological system I'm trying to model, but I found that when I add all +the proteins at once I get multiple "nucleation sites" - instead of a +single structure forming, I instead got multiple incomplete +structures. + +To get around this I instead tried to add the proteins gradually, a +few at a time. The general workflow is therefore something like this: + +1. Add a few proteins to the simulation data. + +2. Run the molecular dynamics simulation for a while, save a snapshot +of the simulation at the end of the run. + +3. Take the snapshot written at the end of step 2, and use as the +input for step 1. + +----------------------- +What I need to do this: +----------------------- + +1. The molecular dynamics program itself; I use a modified version of + LAMMPS, but in principle I could probably use other codes. + +2. A little program to insert a specified number of molecules into an + existing simulation, given a well-defined molecule description. + +3. The ability to convert a binary LAMMPS snapshot into something more + convenient for the previous program to deal with. + +-------------------------------------- +Description of files in the directory: +-------------------------------------- + +lammps_new_spherical.in : + +A LAMMPS control file, containing miscellaneous information +(temperature, interaction parameters etc) to describe how to run the +simulation. + +dimer_1232.lammps_config : + +A LAMMPS format molecular description of the protein we're adding to +the simulation (atom types and coordinates, what's bonded to what etc) + +empty.lammps_config : + +The initially empty simulation that we start to add proteins into. + +GeometryUtil.*, Ran1.*, StringUtil.*, definitions.* : + +Utility code! + +insert_molecules.cpp : + +The program to insert molecules into an existing simulation +definition. Assumes LAMMPS config format, such as found in +empty.lammps_config and dimer_1232.lammps_config. + +restart2data.cpp : + +A program to convert the binary LAMMPS snapshot format into something +suitable for use with the "insert_molecules" program. + +--------------- +Notes +--------------- + +Rather than include the source code for the modified LAMMPS MD +program, and leave you guys to it, I've instead included the script +which runs the little protein insertion loop and commented out the +line which runs LAMMPS. I have, however, included some example binary +output files from LAMMPS which should allow the loop to work as if we +actually were running LAMMPS in the loop. + +Hopefully, all should be pretty straightforward if you look at the +"looped_run.sh" script. The "insert_molecules" and "restart2data" +programs are compiled when you run the script if the binaries don't +exist. + +The version of this script I actually use has some PBS stuff in there +to generate a set of submission scripts which wait on previous job +completion, but I thought I'd keep it simple in this case! + +J. From davidk at ci.uchicago.edu Mon Aug 13 15:25:26 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 13 Aug 2012 15:25:26 -0500 (CDT) Subject: [Swift-commit] r5903 - SwiftApps/CMTS Message-ID: <20120813202526.725F69CCB4@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-13 15:25:26 -0500 (Mon, 13 Aug 2012) New Revision: 5903 Added: SwiftApps/CMTS/userguide/ Log: Creating a place for the CMTS swift userguide From hategan at ci.uchicago.edu Tue Aug 14 20:10:31 2012 From: hategan at ci.uchicago.edu (hategan at ci.uchicago.edu) Date: Tue, 14 Aug 2012 20:10:31 -0500 (CDT) Subject: [Swift-commit] r5904 - trunk/src/org/griphyn/vdl/karajan Message-ID: <20120815011031.65E569CCE6@svn.ci.uchicago.edu> Author: hategan Date: 2012-08-14 20:10:31 -0500 (Tue, 14 Aug 2012) New Revision: 5904 Modified: trunk/src/org/griphyn/vdl/karajan/WaitingThreadsMonitor.java Log: fixed sync issue which, besides causing the tracking of outputs to be inconsistent, may lead to deadlocks Modified: trunk/src/org/griphyn/vdl/karajan/WaitingThreadsMonitor.java =================================================================== --- trunk/src/org/griphyn/vdl/karajan/WaitingThreadsMonitor.java 2012-08-13 20:25:26 UTC (rev 5903) +++ trunk/src/org/griphyn/vdl/karajan/WaitingThreadsMonitor.java 2012-08-15 01:10:31 UTC (rev 5904) @@ -52,7 +52,7 @@ } public static void addOutput(VariableStack stack, List outputs) { - synchronized(outputs) { + synchronized(WaitingThreadsMonitor.outputs) { WaitingThreadsMonitor.outputs.put(stack, outputs); } } From swift at ci.uchicago.edu Wed Aug 15 18:35:53 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 15 Aug 2012 18:35:53 -0500 (CDT) Subject: [Swift-commit] cog r3454 Message-ID: <20120815233553.502AD8D0801C@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3454 | hategan | 2012-08-15 18:34:35 -0500 (Wed, 15 Aug 2012) | 1 line log file name for GETs ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/GetFileHandler.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/GetFileHandler.java (revision 3453) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/GetFileHandler.java (working copy) @@ -42,7 +42,7 @@ String src = getInDataAsString(0); try { if (logger.isInfoEnabled()) { - logger.info(this + " request complete"); + logger.info(this + " request complete; src=" + src); } provider = IOProviderFactory.getDefault().instance(getProtocol(src)); sendReply(); From swift at ci.uchicago.edu Wed Aug 15 23:40:49 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 15 Aug 2012 23:40:49 -0500 (CDT) Subject: [Swift-commit] cog r3455 Message-ID: <20120816044049.BCB6E6160001@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3455 | hategan | 2012-08-15 23:35:07 -0500 (Wed, 15 Aug 2012) | 1 line improved logging of buffers/IO providers ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/GetFileHandler.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/GetFileHandler.java (revision 3454) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/GetFileHandler.java (working copy) @@ -66,6 +66,9 @@ } try { reader = provider.pull(src, dst, this); + if (logger.isInfoEnabled()) { + logger.info(this + " reader: " + reader); + } reader.start(); } catch (IOException e) { Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/providers/LocalIOProvider.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/providers/LocalIOProvider.java (revision 3454) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/providers/LocalIOProvider.java (working copy) @@ -150,7 +150,9 @@ private FileChannel fc; public Reader(String src, ReadIOCallback cb) throws IOException { - logger.debug("LocalIOProvider.Reader " + src); + if (logger.isDebugEnabled()) { + logger.debug("LocalIOProvider.Reader " + src); + } URI srcURI = newURI(src); f = CoasterFileRequestHandler.normalize(srcURI.getPath().substring(1)); this.cb = cb; @@ -158,7 +160,7 @@ } public String toString() { - return "LR " + f; + return "LR-" + System.identityHashCode(this); } public void start() throws IOException { @@ -167,6 +169,9 @@ synchronized(this) { rbuf = Buffers.newReadBuffer(Buffers.getBuffers(Direction.IN), fc, f.length(), this); } + if (logger.isInfoEnabled()) { + logger.info(this + " rbuf: " + rbuf); + } } catch (InterruptedException e) { throw new IOException(e.toString()); Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (revision 3454) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (working copy) @@ -48,7 +48,7 @@ int nbuf = Math.min((int) (size / Buffers.ENTRY_SIZE) + 1, Buffers.ENTRIES_PER_STREAM); if (logger.isInfoEnabled()) { - logger.info("Will ask for " + nbuf + " buffers for a size of " + size); + logger.info(this + " will ask for " + nbuf + " buffers for a size of " + size); } for (int i = 0; i < nbuf; i++) { @@ -58,7 +58,7 @@ } int queuedBuffers = requestFill(); if (logger.isInfoEnabled()) { - logger.info("Actual allocated buffers " + (nbuf - queuedBuffers)); + logger.info(this + " actual allocated buffers " + (nbuf - queuedBuffers)); } if (queuedBuffers == nbuf) { // all buffers are queued @@ -112,14 +112,14 @@ protected synchronized void bufferCreated(Buffers.Allocation a) { if (logger.isDebugEnabled()) { - logger.debug("buffer created"); + logger.debug(this + " buffer created"); } allocs.add(a); } protected synchronized void deallocateBuffers() { if (logger.isInfoEnabled()) { - logger.info("De-allocating " + allocs.size() + " buffers"); + logger.info(this + " de-allocating " + allocs.size() + " buffers"); } for (Buffers.Allocation a : allocs) { buffers.free(a); @@ -133,7 +133,7 @@ } public String getName() { - return "RB-" + cb; + return "RB-" + System.identityHashCode(this); } public boolean isAlive() { @@ -148,4 +148,9 @@ public void suspend() { suspended = true; } + + @Override + public String toString() { + return getName(); + } } From swift at ci.uchicago.edu Fri Aug 17 14:55:45 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Fri, 17 Aug 2012 14:55:45 -0500 (CDT) Subject: [Swift-commit] cog r3456 Message-ID: <20120817195545.8D8E86160001@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3456 | hategan | 2012-08-17 14:49:16 -0500 (Fri, 17 Aug 2012) | 1 line make sure queued data is sent on shutdown (otherwise shutdown acknowledgements never make it to the service) ------------------------------------------------------------------------ Index: modules/provider-coaster/resources/worker.pl =================================================================== --- modules/provider-coaster/resources/worker.pl (revision 3455) +++ modules/provider-coaster/resources/worker.pl (working copy) @@ -966,27 +966,32 @@ if ($wset && @$wset) { # can write wlog(DEBUG, "Can write\n"); - my $wouldBlock; - # if last write didn't finish, try to finish it now - $wouldBlock = resumeSend(); - - if (!$wouldBlock) { - my $cmd; - # send whatever is now queued; don't clear the queue, since - # things may be added to it while stuff is being sent - my $sz = scalar(@SENDQ); - wlog(DEBUG, "SENDQ size: $sz\n"); - for (my $i = 0; $i < $sz; $i++) { - $cmd = shift(@SENDQ); - $wouldBlock = sendInternal(@$cmd); - if ($wouldBlock) { - last; - } + sendQueued(); + } +} + +sub sendQueued { + my $wouldBlock; + # if last write didn't finish, try to finish it now + $wouldBlock = resumeSend(); + + if (!$wouldBlock) { + my $cmd; + # send whatever is now queued; don't clear the queue, since + # things may be added to it while stuff is being sent + my $sz = scalar(@SENDQ); + wlog(DEBUG, "SENDQ size: $sz\n"); + for (my $i = 0; $i < $sz; $i++) { + $cmd = shift(@SENDQ); + $wouldBlock = sendInternal(@$cmd); + if ($wouldBlock) { + last; } } } } + sub printreply { my ($tag, $timeout, $err, $fin, $reply) = @_; if ($timeout) { @@ -1072,15 +1077,17 @@ my ($tag, $timeout, $msgs) = @_; wlog DEBUG, "Shutdown command received\n"; queueReply($tag, ("OK")); + sendQueued(); wlog INFO, "Acknowledged shutdown.\n"; wlog INFO, "Ran a total of $JOB_COUNT jobs\n"; if ($PROFILE) { push(@PROFILE_EVENTS, "STOP", "N/A", time()); } writeprofile(); + select(undef, undef, undef, 1); wlog INFO, "Exiting\n"; - + exit 0; } From swift at ci.uchicago.edu Fri Aug 17 20:15:37 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Fri, 17 Aug 2012 20:15:37 -0500 (CDT) Subject: [Swift-commit] cog r3457 Message-ID: <20120818011537.9CB3A6160001@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3457 | hategan | 2012-08-17 20:11:15 -0500 (Fri, 17 Aug 2012) | 1 line log reason for failures with pinning ------------------------------------------------------------------------ Index: modules/provider-coaster/resources/worker.pl =================================================================== --- modules/provider-coaster/resources/worker.pl (revision 3456) +++ modules/provider-coaster/resources/worker.pl (working copy) @@ -1394,7 +1394,7 @@ wlog DEBUG, "mkpath: $pinned_dir\n"; mkpath($pinned_dir) || die "mkPinnedDirectory(): " . - "Could not mkdir: $pinned_dir\n"; + "Could not mkdir: $pinned_dir ($!)\n"; } $PINNED_READY = 1; } @@ -1407,7 +1407,7 @@ wlog DEBUG, "link: $dst -> $pinned_dir$rdst\n"; if (! -f "$pinned_dir$rdst") { link($dst, "$pinned_dir$rdst") || - die "getPinnedFile(): Could not link: $pinned_dir$rdst\n"; + die "getPinnedFile(): Could not link: $pinned_dir$rdst ($!)\n"; } } @@ -1418,10 +1418,10 @@ if (! -d $dir) { wlog DEBUG, "mkpath: $dir\n"; mkpath($dir) || - die "getPinnedFile(): Could not mkdir: $dir\n"; + die "getPinnedFile(): Could not mkdir: $dir ($!)\n"; } link("$pinned_dir$rdst", $dst) || - die "getPinnedFile(): Could not link!\n"; + die "getPinnedFile(): Could not link: $!\n"; if ($PINNED{$rdst} == INFLIGHT) { waitForPinnedFile($rdst, $jobid); } From swift at ci.uchicago.edu Sat Aug 18 01:45:12 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Sat, 18 Aug 2012 01:45:12 -0500 (CDT) Subject: [Swift-commit] cog r3458 Message-ID: <20120818064512.DD771400001@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3458 | hategan | 2012-08-18 01:43:13 -0500 (Sat, 18 Aug 2012) | 1 line use actual get command for names of buffers instead of the previous random id ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/providers/LocalIOProvider.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/providers/LocalIOProvider.java (revision 3457) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/handlers/providers/LocalIOProvider.java (working copy) @@ -160,7 +160,7 @@ } public String toString() { - return "LR-" + System.identityHashCode(this); + return "LR-" + cb; } public void start() throws IOException { Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (revision 3457) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (working copy) @@ -133,7 +133,7 @@ } public String getName() { - return "RB-" + System.identityHashCode(this); + return "RB-" + cb; } public boolean isAlive() { From swift at ci.uchicago.edu Tue Aug 21 02:15:11 2012 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Tue, 21 Aug 2012 02:15:11 -0500 (CDT) Subject: [Swift-commit] cog r3459 Message-ID: <20120821071511.80B478D00068@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r3459 | hategan | 2012-08-21 02:13:46 -0500 (Tue, 21 Aug 2012) | 1 line fixed race condition in stagein buffer (de)allocation ------------------------------------------------------------------------ Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/NIOChannelReadBuffer.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/NIOChannelReadBuffer.java (revision 3458) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/NIOChannelReadBuffer.java (working copy) @@ -33,18 +33,15 @@ public void doStuff(boolean last, ByteBuffer b, Buffers.Allocation alloc) { synchronized(this) { if (closed) { + if (logger.isInfoEnabled()) { + logger.info("Transfer done. De-allocating one unused buffer"); + } + if (alloc != null) { + buffers.free(alloc); + } return; } } - if (read >= size) { - if (logger.isDebugEnabled()) { - logger.debug("Transfer done. De-allocating one unused buffer"); - } - if (alloc != null) { - buffers.free(alloc); - } - return; - } if (alloc != null) { bufferCreated(alloc); } Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java =================================================================== --- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (revision 3458) +++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (working copy) @@ -58,7 +58,7 @@ } int queuedBuffers = requestFill(); if (logger.isInfoEnabled()) { - logger.info(this + " actual allocated buffers " + (nbuf - queuedBuffers)); + logger.info(this + " actual allocated buffers " + (nbuf - queuedBuffers) + "(" + queuedBuffers + " queued)"); } if (queuedBuffers == nbuf) { // all buffers are queued @@ -71,9 +71,9 @@ synchronized (this) { b = full.removeFirst(); b.clear(); + empty.addLast(b); + requestFill(); } - buffers.queueRequest(false, b, this, this); - requestFill(); } protected int requestFill() { @@ -81,25 +81,20 @@ return 0; } int queued = 0; - synchronized (empty) { - while (!empty.isEmpty() && read < size) { - ByteBuffer buf = empty.removeFirst(); - if (buf != null) { - buf.clear(); - } - if (buffers.queueRequest(false, buf, this, this)) { - queued++; - } + while (!empty.isEmpty() && read < size) { + ByteBuffer buf = empty.removeFirst(); + if (buf != null) { + buf.clear(); } + if (buffers.queueRequest(false, buf, this, this)) { + queued++; + } } return queued; } public void error(ByteBuffer buf, Exception e) { - synchronized (empty) { - empty.addLast(buf); - getCallback().error(false, e); - } + getCallback().error(false, e); } public void bufferRead(ByteBuffer buf) { From davidk at ci.uchicago.edu Wed Aug 22 11:08:39 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Wed, 22 Aug 2012 11:08:39 -0500 (CDT) Subject: [Swift-commit] r5905 - trunk/bin Message-ID: <20120822160839.6D2C99CC92@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-22 11:08:39 -0500 (Wed, 22 Aug 2012) New Revision: 5905 Modified: trunk/bin/start-coaster-service Log: Remove initialization script Modified: trunk/bin/start-coaster-service =================================================================== --- trunk/bin/start-coaster-service 2012-08-15 01:10:31 UTC (rev 5904) +++ trunk/bin/start-coaster-service 2012-08-22 16:08:39 UTC (rev 5905) @@ -486,11 +486,11 @@ fi # For evil bug #467 -echo "app echo (string i) { echo i; }" > hi.swift -echo "echo(\"hi\");" >> hi.swift -swift -sites.file sites.xml -tc.file tc.data -config cf hi.swift > /dev/null 2>&1 & -DUMMYPID=$! -sleep 15 +#echo "app echo (string i) { echo i; }" > hi.swift +#echo "echo(\"hi\");" >> hi.swift +#swift -sites.file sites.xml -tc.file tc.data -config cf hi.swift > /dev/null 2>&1 & +#DUMMYPID=$! +#sleep 15 # Start workers case $WORKER_MODE in @@ -524,7 +524,7 @@ esac # Wait for dummy script to finish -wait $DUMMYPID +#wait $DUMMYPID # Generate config file if [ "$SHARED_FILESYSTEM" == "no" ]; then From davidk at ci.uchicago.edu Thu Aug 23 13:51:16 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Thu, 23 Aug 2012 13:51:16 -0500 (CDT) Subject: [Swift-commit] r5906 - trunk/bin Message-ID: <20120823185116.62C989CC9E@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-23 13:51:16 -0500 (Thu, 23 Aug 2012) New Revision: 5906 Modified: trunk/bin/start-coaster-service Log: Use unique condor submit file names Modified: trunk/bin/start-coaster-service =================================================================== --- trunk/bin/start-coaster-service 2012-08-22 16:08:39 UTC (rev 5905) +++ trunk/bin/start-coaster-service 2012-08-23 18:51:16 UTC (rev 5906) @@ -275,7 +275,8 @@ export CONDOR_MACHINE_COUNT=1 fi -cat < start_workers.submit +export MYPID=$$ +cat < start_workers.$MYPID.submit output = workers.stdout error = workers.stderr executable = $SWIFT_BIN/$WORKER @@ -288,10 +289,10 @@ EOF if [ -n "$WORKER_RELAY_HOST" ]; then - scp start_workers.submit $WORKER_USERNAME@$WORKER_RELAY_HOST: - ssh $WORKER_USERNAME@$WORKER_RELAY_HOST "condor_submit start_workers.submit" + scp start_workers.$MYPID.submit $WORKER_USERNAME@$WORKER_RELAY_HOST: + ssh $WORKER_USERNAME@$WORKER_RELAY_HOST "condor_submit start_workers.$MYPID.submit" else - condor_submit start_workers.submit + condor_submit start_workers.$MYPID.submit fi } From davidk at ci.uchicago.edu Mon Aug 27 02:14:43 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 27 Aug 2012 02:14:43 -0500 (CDT) Subject: [Swift-commit] r5907 - in SwiftApps/CMTS/dimers: . bin conf input_files Message-ID: <20120827071443.D05529CC9E@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-27 02:14:42 -0500 (Mon, 27 Aug 2012) New Revision: 5907 Added: SwiftApps/CMTS/dimers/bin/dimers.sh SwiftApps/CMTS/dimers/input_files/lammps_new_spherical.in Removed: SwiftApps/CMTS/dimers/input_files/end_20.restart.swift SwiftApps/CMTS/dimers/input_files/end_25.restart.swift SwiftApps/CMTS/dimers/input_files/end_30.restart.swift SwiftApps/CMTS/dimers/input_files/end_35.restart.swift SwiftApps/CMTS/dimers/input_files/end_40.restart.swift SwiftApps/CMTS/dimers/input_files/end_45.restart.swift SwiftApps/CMTS/dimers/input_files/end_50.restart.swift SwiftApps/CMTS/dimers/input_files/end_55.restart.swift SwiftApps/CMTS/dimers/input_files/end_60.restart.swift SwiftApps/CMTS/dimers/input_files/end_65.restart.swift SwiftApps/CMTS/dimers/input_files/end_70.restart.swift Modified: SwiftApps/CMTS/dimers/README SwiftApps/CMTS/dimers/conf/grotthuss.cf SwiftApps/CMTS/dimers/conf/makena.cf SwiftApps/CMTS/dimers/dimers.swift Log: Use real lammps Use wrapper script to simplify the example Modified: SwiftApps/CMTS/dimers/README =================================================================== --- SwiftApps/CMTS/dimers/README 2012-08-23 18:51:16 UTC (rev 5906) +++ SwiftApps/CMTS/dimers/README 2012-08-27 07:14:42 UTC (rev 5907) @@ -10,7 +10,7 @@ Add the following line to $HOME/.bashrc to set the PATH: ----- -export PATH=/scratch/davidk/swift-trunk/cog/modules/swift/dist/swift-svn/bin:/opt/torque/bin:$PATH +export PATH=/scratch/davidk/swift-trunk/cog/modules/swift/dist/swift-svn/bin:/scratch/davidk/lammps-12Oct11_spherical_modified/src:/opt/torque/bin:$PATH ----- You will need to create a directory called /scratch/: Added: SwiftApps/CMTS/dimers/bin/dimers.sh =================================================================== --- SwiftApps/CMTS/dimers/bin/dimers.sh (rev 0) +++ SwiftApps/CMTS/dimers/bin/dimers.sh 2012-08-27 07:14:42 UTC (rev 5907) @@ -0,0 +1,14 @@ +#!/bin/bash + +prev_ndimers_file=$1 +dimer_file=$2 +n_dimers_to_add=$3 +virion_radius=$4 +ndimers=$5 + +insert_molecules ${prev_ndimers_file} ${dimer_file} ${n_dimers_to_add} ${virion_radius} 0 25.0 start_${ndimers}.lammps_config + +lmp_john -in lammps_new_spherical.in -var CONFIG start_${ndimers}.lammps_config -var NTDNTD_LJEPS 5.0 -var NTDCTD_LJEPS 5.0 -var RANDOMSEED 666 -var SPHERE_RADIUS ${virion_radius} -var NDIMERS ${ndimers} + +restart2data end_${ndimers}.restart end_${ndimers}.lammps_config + Property changes on: SwiftApps/CMTS/dimers/bin/dimers.sh ___________________________________________________________________ Added: svn:executable + * Modified: SwiftApps/CMTS/dimers/conf/grotthuss.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss.cf 2012-08-23 18:51:16 UTC (rev 5906) +++ SwiftApps/CMTS/dimers/conf/grotthuss.cf 2012-08-27 07:14:42 UTC (rev 5907) @@ -7,6 +7,5 @@ provider.staging.pin.swiftfiles=false use.wrapper.staging=false -#app insert_molecules=$PWD/../bin/insert_molecules -#app restart2data=$PWD/../bin/restart2data.sh +#app dimers=$PWD/../bin/dimers.sh Modified: SwiftApps/CMTS/dimers/conf/makena.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makena.cf 2012-08-23 18:51:16 UTC (rev 5906) +++ SwiftApps/CMTS/dimers/conf/makena.cf 2012-08-27 07:14:42 UTC (rev 5907) @@ -7,6 +7,4 @@ provider.staging.pin.swiftfiles=false use.wrapper.staging=false -#app insert_molecules=$PWD/../bin/insert_molecules -#app restart2data=$PWD/../bin/restart2data.sh - +#app dimers=$PWD/../bin/dimers.sh Modified: SwiftApps/CMTS/dimers/dimers.swift =================================================================== --- SwiftApps/CMTS/dimers/dimers.swift 2012-08-23 18:51:16 UTC (rev 5906) +++ SwiftApps/CMTS/dimers/dimers.swift 2012-08-27 07:14:42 UTC (rev 5907) @@ -1,33 +1,30 @@ type file; -app (file lamps_config_output) insert_molecules (file lamps_config, file dimer, int delta, int v_radius) +# Dimers wrapper script +app (file config_out, file restart_out, file trajectory_out) dimers (file previous_file, file lampps_input_file, file dimer, int dimers_to_add, int v_radius, int step) { - insert_molecules @lamps_config @dimer delta v_radius 0 25.0 @lamps_config_output; + dimers @previous_file @dimer dimers_to_add v_radius step; } -app (file output_file) restart2data (file restart_file, file config_file) -{ - restart2data @restart_file @config_file; -} - -int start_ndimers=20; -int max_ndimers=70; +# Parameters +int start_ndimers=5; +int max_ndimers=30; int delta_ndimers=5; int virion_radius=300; +# Files file dimer_file <"dimer_1232.lammps_config">; file initial_output <"empty.lammps_config">; -file outputs[]; -outputs[start_ndimers-delta_ndimers] = initial_output; +file lampps_input <"lammps_new_spherical.in">; +file lampps_configs[]; -foreach i in [start_ndimers:max_ndimers:delta_ndimers] { +lampps_configs[start_ndimers-delta_ndimers] = initial_output; - file molecule_output ; - molecule_output = insert_molecules(outputs[i-delta_ndimers], dimer_file, delta_ndimers, virion_radius); - - file restart_input ; - file restart_output ; - restart_output = restart2data(restart_input, molecule_output); - - outputs[i] = restart_output; +# Main loop - example of a serial dependency +foreach i in [start_ndimers:max_ndimers:delta_ndimers] { + file config ; + file restart ; + file trajectory ; + (config, restart, trajectory) = dimers(lampps_configs[i-delta_ndimers], lampps_input, dimer_file, delta_ndimers, virion_radius, i); + lampps_configs[i] = config; } Deleted: SwiftApps/CMTS/dimers/input_files/end_20.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_25.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_30.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_35.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_40.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_45.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_50.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_55.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_60.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_65.restart.swift =================================================================== (Binary files differ) Deleted: SwiftApps/CMTS/dimers/input_files/end_70.restart.swift =================================================================== (Binary files differ) Added: SwiftApps/CMTS/dimers/input_files/lammps_new_spherical.in =================================================================== --- SwiftApps/CMTS/dimers/input_files/lammps_new_spherical.in (rev 0) +++ SwiftApps/CMTS/dimers/input_files/lammps_new_spherical.in 2012-08-27 07:14:42 UTC (rev 5907) @@ -0,0 +1,382 @@ +# +# You need to pass the following variables via the command line: +# +# "CONFIG", "NTDNTD_LJEPS", "NTDCTD_LJEPS", "RANDOMSEED", "SPHERE_RADIUS", "NDIMERS" +# +# Example: +# +# lammps -in -var CONFIG 1232.lammps_config -var NTDNTD_LJEPS 5.0 -var NTDCTD_LJEPS 5.0 -var RANDOMSEED 666 -var SPHERE_RADIUS x -var NDIMERS y +# + +variable LOGFILE string log.${NDIMERS} +log ${LOGFILE} + +print "Defined variables:" +print "CONFIG: ${CONFIG}" +print "RANDOMSEED: ${RANDOMSEED}" +print "NTDNTD_LJEPS: ${NTDNTD_LJEPS}" +print "NTDCTD_LJEPS: ${NTDCTD_LJEPS}" +print "SPHERE_RADIUS: ${SPHERE_RADIUS}" +print "NDIMERS: ${NDIMERS}" + +variable DUMPFILE string traj_${NDIMERS}.lammpstrj +variable RESTARTFILE string end_${NDIMERS}.restart + +variable TSTART equal 310.0 +variable TEND equal 310.0 +variable TDAMP equal 100.0 + +variable TIMESTEP equal 5.0 +#variable NSTEPS equal 20000000 +#variable DUMPEVERY equal 100000 +variable NSTEPS equal 10000 +variable DUMPEVERY equal 1000 + + +units real +atom_style molecular +boundary f f f + +print "Reading data from ${CONFIG}..." +read_data ${CONFIG} + +# 1 1.000 # 1_1 +# 2 1.000 # 1_2 +# 3 1.000 # 1_3 +# 4 1.000 # 1_4 +# 5 1.000 # 2_1 +# 6 1.000 # 2_2 +# 7 1.000 # 3_1 +# 8 1.000 # 3_2 +# 9 1.000 # 3_3 +# 10 1.000 # 4_1 +# 11 1.000 # 4_2 +# 12 1.000 # 4_3 +# 13 1.000 # 4_4 +# 14 1.000 # 4_5 +# 15 1.000 # 4_6 +# 16 1.000 # 5_1 +# 17 1.000 # 6_1 +# 18 1.000 # 6_2 +# 19 1.000 # 6_3 +# 20 1.000 # 7_1 +# 21 1.000 # 7_2 +# 22 1.000 # 7_3 +# 23 1.000 # 7_4 +# 24 1.000 # 7_5 +# 25 1.000 # 7_6 +# 26 1.000 # AN1 +# 27 1.000 # AN2 +# 28 1.000 # AC1 +# 29 1.000 # AC2 +# 30 1.000 # 8_1 +# 31 1.000 # 8_2 +# 32 1.000 # 8_3 +# 33 1.000 # 8_4 +# 34 1.000 # 9_1 +# 35 1.000 # 9_2 +# 36 1.000 # 9_3 +# 37 1.000 # 9_4 +# 38 1.000 # 10_1 +# 39 1.000 # 10_2 +# 40 1.000 # 10_3 +# 41 1.000 # 11_1 +# 42 1.000 # 11_2 +# 43 1.000 # 12 + + +################################################### +# Bond parameters etc +################################################### +bond_style harmonic +bond_coeff 1 0.1 9.17 # dimer, where necessary +# NTD-CTD linker constraints; there seem to be relatively insensitive. +bond_coeff 2 10.0 0.0 # Pivot 1 +bond_coeff 3 10.0 0.0 # Pivot 2 + +# +# Improper - parameterized from the CG capsid structure. ~132 degrees +# reproduces the angle distribution from the CG capsid in simulation pretty well! +# +improper_style harmonic +improper_coeff 1 100.0 132.0 +improper_coeff 2 100.0 132.0 + +################################################### +# Ignore forces for beads in the same rigid body +################################################### +neigh_modify exclude molecule all + + +################################################### +# Let's look at what energy we get out of the +# NTDNTD and NTDCTD interactions during the scale-in, +# as well as the ghost bonds for the CTD pivot and +# thw CTD dimer interface bond. +################################################### + +# +# pairwise interacting types: +# +# Although 2_1 -> 3_3 is a smaller distance, 2_2 -> 3_3 is *slightly* more conserved (ie smaller +# standard deviation / standard error, and smaller absolute gap between lowest and largest distances +# measured from capsid). It also works *much* better than 2_1 -> 3_3! +# +# 4_1 -> 8_3 has a *slightly* smaller average distance and *slightly* smaller spread of values from +# smallest to largest vs 4_1 -> 8_2 (albeit the standard deviation and standard error are a little +# larger). I'm not sure there's much of a difference, here; if you plot the distributions using +# the structural_analysis program, they're basically the same! +# +variable tNN1 equal 6 # 2_2 +variable tNN2 equal 9 # 3_3 +variable tNC1 equal 10 # 4_1 +variable tNC2 equal 32 # 8_3 + +# sites involved in the rotation axis, NTD and CTD +variable tAN1 equal 26 +variable tAN2 equal 27 +variable tAC1 equal 28 +variable tAC2 equal 29 + +# dimer bond +variable tDIM equal 43 + +# +# NTD-NTD interaction: 2_1 and 3_3 +# +group gNN1 type ${tNN1} +compute NN_pe_v1 gNN1 pe/atom +compute NN_pe_1 all reduce sum c_NN_pe_v1 + +group gNN2 type ${tNN2} +compute NN_pe_v2 gNN2 pe/atom +compute NN_pe_2 all reduce sum c_NN_pe_v2 + +group gNN1_NN2 type ${tNN1} ${tNN2} +compute NN_pe_v gNN1_NN2 pe/atom +compute NN_pe all reduce sum c_NN_pe_v + +# +# NTD-CTD interaction: 4_1 and 8_2 (or ghost bead!) +# +group gNC1 type ${tNC1} +compute NC_pe_v1 gNC1 pe/atom +compute NC_pe_1 all reduce sum c_NC_pe_v1 + +group gNC2 type ${tNC2} +compute NC_pe_v2 gNC2 pe/atom +compute NC_pe_2 all reduce sum c_NC_pe_v2 + +group gNC1_NC2 type ${tNC1} ${tNC2} +compute NC_pe_v gNC1_NC2 pe/atom +compute NC_pe all reduce sum c_NC_pe_v + +group gNN_NC type ${tNN1} ${tNN2} ${tNC1} ${tNC2} +compute NN_NC_pe_v gNN_NC pe/atom +compute NN_NC_pe all reduce sum c_NN_NC_pe_v + +# +# Ghost bond interactions - DI is dimer interface! +# +group gAN1_AC1 type ${tAN1} ${tAC1} +group gAN2_AC2 type ${tAN2} ${tAC2} +group gPivot type ${tAN1} ${tAC1} ${tAN2} ${tAC2} +group gDI type ${tDIM} + +compute A1_be_v gAN1_AC1 pe/atom bond +compute A1_be all reduce sum c_A1_be_v + +compute A2_be_v gAN2_AC2 pe/atom bond +compute A2_be all reduce sum c_A2_be_v + +compute Pivot_be_v gPivot pe/atom bond +compute Pivot_be all reduce sum c_Pivot_be_v + +compute DI_be_v gDI pe/atom bond +compute DI_be all reduce sum c_DI_be_v + +# +# check what weird-ass method lammps uses for the improper dihedral calculation +# +#group gimp1 id 25 27 26 30 +group gimp1 type 25 27 26 30 +compute imp1 gimp1 improper/local chi +compute imp1_min all reduce min c_imp1 +compute imp1_ave all reduce ave c_imp1 +compute imp1_max all reduce max c_imp1 + + +# special thermo output for scale-in; list temperature, bond energy, nonbonded energy, then specific NTD-NTD, NTD-CTD and NTDNTD+NTDCTD energy +thermo_style custom step cpu temp evdwl c_NN_pe c_NC_pe c_NN_NC_pe ebond c_A1_be c_A2_be c_Pivot_be c_DI_be c_imp1_min c_imp1_ave c_imp1_max + + +################################################### +# some system info +################################################### +thermo ${DUMPEVERY} +dump 1 all custom ${DUMPEVERY} ${DUMPFILE} id mol type x y z +dump_modify 1 sort id +timestep ${TIMESTEP} + + +################################################### +# Fixes, initial velocity distribution +################################################### +# Nose-Hoover +fix 1 all rigid/nvt molecule temp ${TSTART} ${TEND} ${TDAMP} tparam 10 6 3 + +# sphere constraint +fix 2 all wall/harmonicsphericaljohn xhi ${SPHERE_RADIUS} 0.05 1.0 ${SPHERE_RADIUS} units box + +# Langevin +#fix 1 all rigid/nve molecule +#fix 2 all langevin ${TSTART} ${TEND} ${TDAMP} ${RANDOMSEED} + +velocity all create ${TSTART} ${RANDOMSEED} mom yes rot yes dist gaussian + + +############################################################# +# Nonbonded: Morse (pure exclusion) & LJ (attractive wells) # +############################################################# +# Notes: +# 1. Lammps uses the star notation for "all types", but it's +# implicit that the second type in the pair_coeff line is +# larger than the first; we therefore have to use the star +# both "before" and "after" the global type interaction. +# This is why eg the ghost types have both "x *" and +# "* x" when we set them to have no excluded volume effect +# with any other type in the system. +############################################################# +#pair_style hybrid lj/cut 25.0 lj/john 12.0 morse 12.0 +pair_style hybrid lj/cut 25.0 morse 12.0 +# -- Morse params ------------------------------------------- +variable MORSE_D0 equal 0.0001 +variable MORSE_ALPHA equal 4.5 + +# -- default size excluded radius ---- +pair_coeff * * morse ${MORSE_D0} ${MORSE_ALPHA} 12.0 12.0 + +# -- raw output from capsid analysis, independent NTD and CTD superpositions ---- +pair_coeff 1 1 morse ${MORSE_D0} ${MORSE_ALPHA} 9.891 9.891 # 1_1 1_1: 9.891 10.705 10.755 +pair_coeff 1 2 morse ${MORSE_D0} ${MORSE_ALPHA} 9.565 9.565 # 1_1 1_2: 9.565 10.301 10.347 +pair_coeff 1 3 morse ${MORSE_D0} ${MORSE_ALPHA} 11.366 11.366 # 1_1 1_3: 11.366 11.935 11.971 +pair_coeff 1 6 morse ${MORSE_D0} ${MORSE_ALPHA} 10.178 10.178 # 1_1 2_2: 10.178 10.187 10.188 +pair_coeff 2 2 morse ${MORSE_D0} ${MORSE_ALPHA} 11.196 11.196 # 1_2 1_2: 11.196 11.197 11.198 +pair_coeff 2 3 morse ${MORSE_D0} ${MORSE_ALPHA} 11.207 11.207 # 1_2 1_3: 11.207 11.207 11.209 +pair_coeff 2 6 morse ${MORSE_D0} ${MORSE_ALPHA} 11.657 11.657 # 1_2 2_2: 11.657 11.883 11.897 +pair_coeff 3 29 morse ${MORSE_D0} ${MORSE_ALPHA} 11.247 11.247 # 1_3 AC2: 11.247 11.247 11.247 +pair_coeff 4 29 morse ${MORSE_D0} ${MORSE_ALPHA} 10.586 10.586 # 1_4 AC2: 10.586 11.428 11.796 +pair_coeff 5 8 morse ${MORSE_D0} ${MORSE_ALPHA} 10.814 10.814 # 2_1 3_2: 10.814 10.862 11.644 +pair_coeff 5 9 morse ${MORSE_D0} ${MORSE_ALPHA} 7.744 7.744 # 2_1 3_3: 7.744 7.773 8.243 +pair_coeff 5 29 morse ${MORSE_D0} ${MORSE_ALPHA} 7.128 7.128 # 2_1 AC2: 7.128 8.862 11.920 +pair_coeff 5 33 morse ${MORSE_D0} ${MORSE_ALPHA} 10.876 10.876 # 2_1 8_4: 10.876 11.619 11.997 +pair_coeff 6 8 morse ${MORSE_D0} ${MORSE_ALPHA} 10.393 10.393 # 2_2 3_2: 10.393 10.456 11.492 +pair_coeff 6 9 morse ${MORSE_D0} ${MORSE_ALPHA} 9.675 9.675 # 2_2 3_3: 9.675 9.704 10.159 +pair_coeff 8 29 morse ${MORSE_D0} ${MORSE_ALPHA} 9.672 9.672 # 3_2 AC2: 9.672 11.430 11.997 +pair_coeff 9 27 morse ${MORSE_D0} ${MORSE_ALPHA} 9.945 9.945 # 3_3 AN2: 9.945 9.967 10.322 +pair_coeff 9 29 morse ${MORSE_D0} ${MORSE_ALPHA} 6.143 6.143 # 3_3 AC2: 6.143 8.920 11.839 +pair_coeff 9 33 morse ${MORSE_D0} ${MORSE_ALPHA} 10.806 10.806 # 3_3 8_4: 10.806 11.524 11.972 +pair_coeff 10 26 morse ${MORSE_D0} ${MORSE_ALPHA} 11.109 11.109 # 4_1 AN1: 11.109 11.128 11.431 +pair_coeff 10 27 morse ${MORSE_D0} ${MORSE_ALPHA} 9.080 9.080 # 4_1 AN2: 9.080 9.083 9.117 +pair_coeff 10 28 morse ${MORSE_D0} ${MORSE_ALPHA} 7.985 7.985 # 4_1 AC1: 7.985 10.524 11.996 +pair_coeff 10 29 morse ${MORSE_D0} ${MORSE_ALPHA} 2.501 2.501 # 4_1 AC2: 2.501 8.595 10.808 +pair_coeff 10 30 morse ${MORSE_D0} ${MORSE_ALPHA} 8.581 8.581 # 4_1 8_1: 8.581 10.780 11.991 +pair_coeff 10 31 morse ${MORSE_D0} ${MORSE_ALPHA} 5.397 5.397 # 4_1 8_2: 5.397 7.996 10.379 +pair_coeff 10 32 morse ${MORSE_D0} ${MORSE_ALPHA} 5.100 5.100 # 4_1 8_3: 5.100 7.925 9.861 +pair_coeff 10 33 morse ${MORSE_D0} ${MORSE_ALPHA} 5.196 5.196 # 4_1 8_4: 5.196 9.826 11.658 +pair_coeff 10 41 morse ${MORSE_D0} ${MORSE_ALPHA} 10.110 10.110 # 4_1 11_1: 10.110 11.413 11.999 +pair_coeff 10 42 morse ${MORSE_D0} ${MORSE_ALPHA} 11.606 11.606 # 4_1 11_2: 11.606 11.835 11.995 +pair_coeff 11 27 morse ${MORSE_D0} ${MORSE_ALPHA} 11.301 11.301 # 4_2 AN2: 11.301 11.308 11.409 +pair_coeff 11 28 morse ${MORSE_D0} ${MORSE_ALPHA} 10.782 10.782 # 4_2 AC1: 10.782 11.744 12.000 +pair_coeff 11 29 morse ${MORSE_D0} ${MORSE_ALPHA} 4.749 4.749 # 4_2 AC2: 4.749 10.138 11.996 +pair_coeff 11 30 morse ${MORSE_D0} ${MORSE_ALPHA} 11.415 11.415 # 4_2 8_1: 11.415 11.719 11.973 +pair_coeff 11 31 morse ${MORSE_D0} ${MORSE_ALPHA} 8.439 8.439 # 4_2 8_2: 8.439 11.119 11.999 +pair_coeff 11 32 morse ${MORSE_D0} ${MORSE_ALPHA} 8.333 8.333 # 4_2 8_3: 8.333 11.011 11.999 +pair_coeff 11 33 morse ${MORSE_D0} ${MORSE_ALPHA} 8.698 8.698 # 4_2 8_4: 8.698 11.123 11.998 +pair_coeff 11 41 morse ${MORSE_D0} ${MORSE_ALPHA} 8.066 8.066 # 4_2 11_1: 8.066 10.726 12.000 +pair_coeff 11 42 morse ${MORSE_D0} ${MORSE_ALPHA} 11.011 11.011 # 4_2 11_2: 11.011 11.622 11.998 +pair_coeff 12 29 morse ${MORSE_D0} ${MORSE_ALPHA} 9.835 9.835 # 4_3 AC2: 9.835 11.080 11.989 +pair_coeff 12 41 morse ${MORSE_D0} ${MORSE_ALPHA} 9.931 9.931 # 4_3 11_1: 9.931 11.300 11.999 +pair_coeff 24 29 morse ${MORSE_D0} ${MORSE_ALPHA} 10.115 10.115 # 7_5 AC2: 10.115 11.358 12.000 +pair_coeff 24 33 morse ${MORSE_D0} ${MORSE_ALPHA} 10.974 10.974 # 7_5 8_4: 10.974 11.572 11.997 +pair_coeff 24 41 morse ${MORSE_D0} ${MORSE_ALPHA} 10.207 10.207 # 7_5 11_1: 10.207 11.419 11.992 +pair_coeff 24 42 morse ${MORSE_D0} ${MORSE_ALPHA} 9.468 9.468 # 7_5 11_2: 9.468 11.169 11.998 +pair_coeff 25 28 morse ${MORSE_D0} ${MORSE_ALPHA} 11.525 11.525 # 7_6 AC1: 11.525 11.777 11.982 +pair_coeff 25 29 morse ${MORSE_D0} ${MORSE_ALPHA} 9.917 9.917 # 7_6 AC2: 9.917 11.265 11.994 +pair_coeff 25 30 morse ${MORSE_D0} ${MORSE_ALPHA} 10.548 10.548 # 7_6 8_1: 10.548 11.533 11.977 +pair_coeff 25 33 morse ${MORSE_D0} ${MORSE_ALPHA} 9.307 9.307 # 7_6 8_4: 9.307 10.121 11.997 +pair_coeff 25 41 morse ${MORSE_D0} ${MORSE_ALPHA} 10.508 10.508 # 7_6 11_1: 10.508 11.500 11.989 +pair_coeff 25 42 morse ${MORSE_D0} ${MORSE_ALPHA} 8.144 8.144 # 7_6 11_2: 8.144 10.663 11.985 +pair_coeff 26 28 morse ${MORSE_D0} ${MORSE_ALPHA} 0.277 0.277 # AN1 AC1: 0.277 1.693 4.228 +pair_coeff 26 29 morse ${MORSE_D0} ${MORSE_ALPHA} 8.840 8.840 # AN1 AC2: 8.840 10.660 11.997 +pair_coeff 26 30 morse ${MORSE_D0} ${MORSE_ALPHA} 9.190 9.190 # AN1 8_1: 9.190 11.163 11.999 +pair_coeff 26 31 morse ${MORSE_D0} ${MORSE_ALPHA} 5.725 5.725 # AN1 8_2: 5.725 8.001 10.884 +pair_coeff 26 32 morse ${MORSE_D0} ${MORSE_ALPHA} 2.296 2.296 # AN1 8_3: 2.296 4.609 7.720 +pair_coeff 26 33 morse ${MORSE_D0} ${MORSE_ALPHA} 4.298 4.298 # AN1 8_4: 4.298 6.119 8.959 +pair_coeff 26 34 morse ${MORSE_D0} ${MORSE_ALPHA} 7.771 7.771 # AN1 9_1: 7.771 10.421 11.992 +pair_coeff 26 35 morse ${MORSE_D0} ${MORSE_ALPHA} 5.446 5.446 # AN1 9_2: 5.446 8.505 11.909 +pair_coeff 26 36 morse ${MORSE_D0} ${MORSE_ALPHA} 5.025 5.025 # AN1 9_3: 5.025 8.167 11.994 +pair_coeff 26 37 morse ${MORSE_D0} ${MORSE_ALPHA} 5.987 5.987 # AN1 9_4: 5.987 9.062 11.969 +pair_coeff 26 43 morse ${MORSE_D0} ${MORSE_ALPHA} 3.816 3.816 # AN1 12: 3.816 7.256 11.981 +pair_coeff 27 28 morse ${MORSE_D0} ${MORSE_ALPHA} 6.778 6.778 # AN2 AC1: 6.778 9.066 10.948 +pair_coeff 27 29 morse ${MORSE_D0} ${MORSE_ALPHA} 0.422 0.422 # AN2 AC2: 0.422 2.216 7.719 +pair_coeff 27 31 morse ${MORSE_D0} ${MORSE_ALPHA} 11.120 11.120 # AN2 8_2: 11.120 11.821 11.999 +pair_coeff 27 32 morse ${MORSE_D0} ${MORSE_ALPHA} 6.050 6.050 # AN2 8_3: 6.050 7.306 9.818 +pair_coeff 27 33 morse ${MORSE_D0} ${MORSE_ALPHA} 2.330 2.330 # AN2 8_4: 2.330 4.398 7.000 +pair_coeff 27 34 morse ${MORSE_D0} ${MORSE_ALPHA} 10.795 10.795 # AN2 9_1: 10.795 11.697 11.975 +pair_coeff 27 35 morse ${MORSE_D0} ${MORSE_ALPHA} 11.673 11.673 # AN2 9_2: 11.673 11.673 11.673 +pair_coeff 27 43 morse ${MORSE_D0} ${MORSE_ALPHA} 10.447 10.447 # AN2 12: 10.447 11.613 11.965 +pair_coeff 30 40 morse ${MORSE_D0} ${MORSE_ALPHA} 9.753 9.753 # 8_1 10_3: 9.753 11.067 11.975 +pair_coeff 34 34 morse ${MORSE_D0} ${MORSE_ALPHA} 4.337 4.337 # 9_1 9_1: 4.337 9.883 10.595 +pair_coeff 34 35 morse ${MORSE_D0} ${MORSE_ALPHA} 6.685 6.685 # 9_1 9_2: 6.685 6.686 6.687 +pair_coeff 34 36 morse ${MORSE_D0} ${MORSE_ALPHA} 9.967 9.967 # 9_1 9_3: 9.967 9.968 9.969 +pair_coeff 34 43 morse ${MORSE_D0} ${MORSE_ALPHA} 7.367 7.367 # 9_1 12: 7.367 11.092 11.571 +pair_coeff 35 35 morse ${MORSE_D0} ${MORSE_ALPHA} 6.424 6.424 # 9_2 9_2: 6.424 6.425 6.426 +pair_coeff 35 36 morse ${MORSE_D0} ${MORSE_ALPHA} 7.873 7.873 # 9_2 9_3: 7.873 7.874 7.875 +pair_coeff 35 37 morse ${MORSE_D0} ${MORSE_ALPHA} 11.212 11.212 # 9_2 9_4: 11.212 11.213 11.214 +pair_coeff 35 43 morse ${MORSE_D0} ${MORSE_ALPHA} 5.309 5.309 # 9_2 12: 5.309 10.529 11.200 +pair_coeff 36 36 morse ${MORSE_D0} ${MORSE_ALPHA} 6.831 6.831 # 9_3 9_3: 6.831 6.832 6.833 +pair_coeff 36 37 morse ${MORSE_D0} ${MORSE_ALPHA} 8.652 8.652 # 9_3 9_4: 8.652 8.653 8.654 +pair_coeff 36 43 morse ${MORSE_D0} ${MORSE_ALPHA} 5.640 5.640 # 9_3 12: 5.640 10.765 11.424 +pair_coeff 37 37 morse ${MORSE_D0} ${MORSE_ALPHA} 8.340 8.340 # 9_4 9_4: 8.340 8.341 8.342 +pair_coeff 37 43 morse ${MORSE_D0} ${MORSE_ALPHA} 8.910 8.910 # 9_4 12: 8.910 8.911 8.912 +pair_coeff 38 40 morse ${MORSE_D0} ${MORSE_ALPHA} 9.360 9.360 # 10_1 10_3: 9.360 10.984 11.983 +pair_coeff 39 39 morse ${MORSE_D0} ${MORSE_ALPHA} 9.299 9.299 # 10_2 10_2: 9.299 11.228 12.000 +pair_coeff 39 40 morse ${MORSE_D0} ${MORSE_ALPHA} 6.916 6.916 # 10_2 10_3: 6.916 10.645 11.995 +pair_coeff 39 42 morse ${MORSE_D0} ${MORSE_ALPHA} 9.311 9.311 # 10_2 11_2: 9.311 11.030 11.989 +pair_coeff 40 40 morse ${MORSE_D0} ${MORSE_ALPHA} 4.327 4.327 # 10_3 10_3: 4.327 9.538 11.995 +pair_coeff 40 41 morse ${MORSE_D0} ${MORSE_ALPHA} 8.798 8.798 # 10_3 11_1: 8.798 10.732 12.000 +pair_coeff 40 42 morse ${MORSE_D0} ${MORSE_ALPHA} 5.234 5.234 # 10_3 11_2: 5.234 9.733 11.998 +pair_coeff 41 41 morse ${MORSE_D0} ${MORSE_ALPHA} 8.882 8.882 # 11_1 11_1: 8.882 10.866 11.874 +pair_coeff 41 42 morse ${MORSE_D0} ${MORSE_ALPHA} 8.214 8.214 # 11_1 11_2: 8.214 10.925 11.993 +pair_coeff 42 42 morse ${MORSE_D0} ${MORSE_ALPHA} 8.702 8.702 # 11_2 11_2: 8.702 10.987 11.983 +pair_coeff 43 43 morse ${MORSE_D0} ${MORSE_ALPHA} 5.173 5.173 # 12 12: 5.173 8.727 9.183 + +# -- ghost sites have no morse interaction with anything ---- +pair_coeff 26 * morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff * 26 morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff 27 * morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff * 27 morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff 28 * morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff * 28 morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff 29 * morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff * 29 morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff 43 * morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 +pair_coeff * 43 morse ${MORSE_D0} ${MORSE_ALPHA} 0.0 0.0 + +# from independent NTD and CTD superpositions onto hexs and pents +#pair_coeff ${tNN1} ${tNN2} lj/cut ${NTDNTD_LJEPS} 6.925 +#pair_coeff ${tNC1} ${tNC2} lj/cut ${NTDCTD_LJEPS} 7.39 + +# from superposition onto capsid +#pair_coeff ${tNN1} ${tNN2} lj/cut ${NTDNTD_LJEPS} 7.27 +#pair_coeff ${tNC1} ${tNC2} lj/cut ${NTDCTD_LJEPS} 8.3 + +pair_coeff ${tNN1} ${tNN2} lj/cut ${NTDNTD_LJEPS} 8.65 # for 2_2, 3_3 - most conserved NTD-NTD distance from capsid! +pair_coeff ${tNC1} ${tNC2} lj/cut ${NTDCTD_LJEPS} 7.39 # for 4_1, 8_3 - most conserved NTD-CTD distance from capsid! + +pair_modify shift yes + +run ${NSTEPS} + +write_restart ${RESTARTFILE} \ No newline at end of file From davidk at ci.uchicago.edu Mon Aug 27 11:36:20 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 27 Aug 2012 11:36:20 -0500 (CDT) Subject: [Swift-commit] r5908 - in SwiftApps/CMTS/dimers: . bin Message-ID: <20120827163620.C831B9CC9C@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-27 11:36:20 -0500 (Mon, 27 Aug 2012) New Revision: 5908 Modified: SwiftApps/CMTS/dimers/README SwiftApps/CMTS/dimers/bin/dimers.sh Log: Use MPI Modified: SwiftApps/CMTS/dimers/README =================================================================== --- SwiftApps/CMTS/dimers/README 2012-08-27 07:14:42 UTC (rev 5907) +++ SwiftApps/CMTS/dimers/README 2012-08-27 16:36:20 UTC (rev 5908) @@ -46,7 +46,7 @@ Usage: rundimers.sh [-s sitename] The sitename option determines where a run will take place. Currently, the -only tested options are "makena" and "grotthuss". +only tested option is "makena". Example: Modified: SwiftApps/CMTS/dimers/bin/dimers.sh =================================================================== --- SwiftApps/CMTS/dimers/bin/dimers.sh 2012-08-27 07:14:42 UTC (rev 5907) +++ SwiftApps/CMTS/dimers/bin/dimers.sh 2012-08-27 16:36:20 UTC (rev 5908) @@ -6,9 +6,11 @@ virion_radius=$4 ndimers=$5 +lmp_john=`which lmp_john` + insert_molecules ${prev_ndimers_file} ${dimer_file} ${n_dimers_to_add} ${virion_radius} 0 25.0 start_${ndimers}.lammps_config -lmp_john -in lammps_new_spherical.in -var CONFIG start_${ndimers}.lammps_config -var NTDNTD_LJEPS 5.0 -var NTDCTD_LJEPS 5.0 -var RANDOMSEED 666 -var SPHERE_RADIUS ${virion_radius} -var NDIMERS ${ndimers} +mpiexec -machinefile $PBS_NODEFILE ${lmp_john} -in lammps_new_spherical.in -var CONFIG start_${ndimers}.lammps_config -var NTDNTD_LJEPS 5.0 -var NTDCTD_LJEPS 5.0 -var RANDOMSEED 666 -var SPHERE_RADIUS ${virion_radius} -var NDIMERS ${ndimers} restart2data end_${ndimers}.restart end_${ndimers}.lammps_config From davidk at ci.uchicago.edu Mon Aug 27 12:18:15 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 27 Aug 2012 12:18:15 -0500 (CDT) Subject: [Swift-commit] r5909 - in SwiftApps/CMTS/dimers: . docs docs/images docs/images/icons docs/stylesheets Message-ID: <20120827171815.5ADA29CC9E@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-27 12:18:15 -0500 (Mon, 27 Aug 2012) New Revision: 5909 Added: SwiftApps/CMTS/dimers/docs/ SwiftApps/CMTS/dimers/docs/README SwiftApps/CMTS/dimers/docs/images/ SwiftApps/CMTS/dimers/docs/images/icons/ SwiftApps/CMTS/dimers/docs/images/icons/caution.png SwiftApps/CMTS/dimers/docs/images/icons/example.png SwiftApps/CMTS/dimers/docs/images/icons/home.png SwiftApps/CMTS/dimers/docs/images/icons/important.png SwiftApps/CMTS/dimers/docs/images/icons/next.png SwiftApps/CMTS/dimers/docs/images/icons/note.png SwiftApps/CMTS/dimers/docs/images/icons/prev.png SwiftApps/CMTS/dimers/docs/images/icons/tip.png SwiftApps/CMTS/dimers/docs/images/icons/up.png SwiftApps/CMTS/dimers/docs/images/icons/warning.png SwiftApps/CMTS/dimers/docs/stylesheets/ SwiftApps/CMTS/dimers/docs/stylesheets/asciidoc.css Log: Document generation scripts Added: SwiftApps/CMTS/dimers/docs/README =================================================================== --- SwiftApps/CMTS/dimers/docs/README (rev 0) +++ SwiftApps/CMTS/dimers/docs/README 2012-08-27 17:18:15 UTC (rev 5909) @@ -0,0 +1 @@ +link ../README \ No newline at end of file Property changes on: SwiftApps/CMTS/dimers/docs/README ___________________________________________________________________ Added: svn:special + * Added: SwiftApps/CMTS/dimers/docs/images/icons/caution.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/caution.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/example.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/example.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/home.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/home.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/important.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/important.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/next.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/next.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/note.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/note.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/prev.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/prev.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/tip.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/tip.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/up.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/up.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/images/icons/warning.png =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/docs/images/icons/warning.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/docs/stylesheets/asciidoc.css =================================================================== --- SwiftApps/CMTS/dimers/docs/stylesheets/asciidoc.css (rev 0) +++ SwiftApps/CMTS/dimers/docs/stylesheets/asciidoc.css 2012-08-27 17:18:15 UTC (rev 5909) @@ -0,0 +1,2 @@ +a:link { color:navy; } +a:visited { color:navy; } From davidk at ci.uchicago.edu Mon Aug 27 12:21:52 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 27 Aug 2012 12:21:52 -0500 (CDT) Subject: [Swift-commit] r5910 - SwiftApps/CMTS/dimers/docs Message-ID: <20120827172152.537E39CC9E@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-27 12:21:52 -0500 (Mon, 27 Aug 2012) New Revision: 5910 Added: SwiftApps/CMTS/dimers/docs/build_docs.sh Log: build_docs.sh Added: SwiftApps/CMTS/dimers/docs/build_docs.sh =================================================================== --- SwiftApps/CMTS/dimers/docs/build_docs.sh (rev 0) +++ SwiftApps/CMTS/dimers/docs/build_docs.sh 2012-08-27 17:21:52 UTC (rev 5910) @@ -0,0 +1,11 @@ +#!/bin/bash + +echo Converting README to HTML + asciidoc -a toc -a toclevels=2 \ + -a max-width=750px \ + -a textwidth=80 \ + -a stylesheet=$PWD/stylesheets/asciidoc.css \ + README + +echo Converting README to PDF + a2x --format=pdf --no-xmllint README Property changes on: SwiftApps/CMTS/dimers/docs/build_docs.sh ___________________________________________________________________ Added: svn:executable + * From davidk at ci.uchicago.edu Mon Aug 27 16:58:26 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Mon, 27 Aug 2012 16:58:26 -0500 (CDT) Subject: [Swift-commit] r5911 - in SwiftApps/CMTS/rmsd: . conf Message-ID: <20120827215826.BF8C09CC9E@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-27 16:58:26 -0500 (Mon, 27 Aug 2012) New Revision: 5911 Modified: SwiftApps/CMTS/rmsd/conf/grotthuss.cf SwiftApps/CMTS/rmsd/conf/makena.cf SwiftApps/CMTS/rmsd/rmsd.sh Log: Execution retries should be enabled Put a delay after renaming files for possible NFS issues Modified: SwiftApps/CMTS/rmsd/conf/grotthuss.cf =================================================================== --- SwiftApps/CMTS/rmsd/conf/grotthuss.cf 2012-08-27 17:21:52 UTC (rev 5910) +++ SwiftApps/CMTS/rmsd/conf/grotthuss.cf 2012-08-27 21:58:26 UTC (rev 5911) @@ -1,6 +1,6 @@ wrapperlog.always.transfer=true sitedir.keep=true -execution.retries=0 +execution.retries=10 lazy.errors=true status.mode=provider use.provider.staging=false Modified: SwiftApps/CMTS/rmsd/conf/makena.cf =================================================================== --- SwiftApps/CMTS/rmsd/conf/makena.cf 2012-08-27 17:21:52 UTC (rev 5910) +++ SwiftApps/CMTS/rmsd/conf/makena.cf 2012-08-27 21:58:26 UTC (rev 5911) @@ -1,6 +1,6 @@ wrapperlog.always.transfer=true sitedir.keep=true -execution.retries=0 +execution.retries=10 lazy.errors=true status.mode=provider use.provider.staging=false Modified: SwiftApps/CMTS/rmsd/rmsd.sh =================================================================== --- SwiftApps/CMTS/rmsd/rmsd.sh 2012-08-27 17:21:52 UTC (rev 5910) +++ SwiftApps/CMTS/rmsd/rmsd.sh 2012-08-27 21:58:26 UTC (rev 5911) @@ -18,3 +18,4 @@ mv output/cg_clath_cage.dcd output/cg_clath_cage-$b1-$b2.dcd mv rmsd.dat output/rmsd.$b1name${b1}_$b2name${b2}.dat +sleep 5 From davidk at ci.uchicago.edu Tue Aug 28 14:47:25 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Tue, 28 Aug 2012 14:47:25 -0500 (CDT) Subject: [Swift-commit] r5912 - SwiftApps/CMTS/rmsd Message-ID: <20120828194725.9FF499CC9C@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-28 14:47:25 -0500 (Tue, 28 Aug 2012) New Revision: 5912 Modified: SwiftApps/CMTS/rmsd/rmsd.sh SwiftApps/CMTS/rmsd/rmsd.swift Log: Add more debugging info Modified: SwiftApps/CMTS/rmsd/rmsd.sh =================================================================== --- SwiftApps/CMTS/rmsd/rmsd.sh 2012-08-27 21:58:26 UTC (rev 5911) +++ SwiftApps/CMTS/rmsd/rmsd.sh 2012-08-28 19:47:25 UTC (rev 5912) @@ -8,14 +8,36 @@ namd_parameters=$6 vmd_script=$7 -sed -i -e s/BLAB1/$b1name$b1/ -e s/BLAB2/$b2name$b2/ -e s at __DIR__@$PWD@ $namd_input +echo Command line arguments: $@ +echo +echo File listing +echo ------------ +find +echo + +echo Running the following sed commands +echo sed -i -e s/BLAB1/$b1name$b1/ -e s/BLAB2/$b2name$b2/ -e s at __DIR__@$PWD@ $namd_input +echo sed -i -e s/BLAB1/$b1name$b1/ -e s/BLAB2/$b2name$b2/ -e s at __DIR__@$PWD@ $namd_input +echo sed -i -e s/HBEPS/-0.01/g -e s/PXEPS/-$b1/g -e s/DTEPS/-$b2/g -e s/AKEPS/-0.01/g -e s/LTEPS/-0.01/g $namd_parameters +sed -i -e s/BLAB1/$b1name$b1/g -e s/BLAB2/$b2name$b2/g -e s/B1/$b1/ -e s/B2/$b2/ $vmd_script sed -i -e s/HBEPS/-0.01/g -e s/PXEPS/-$b1/g -e s/DTEPS/-$b2/g -e s/AKEPS/-0.01/g -e s/LTEPS/-0.01/g $namd_parameters sed -i -e s/BLAB1/$b1name$b1/g -e s/BLAB2/$b2name$b2/g -e s/B1/$b1/ -e s/B2/$b2/ $vmd_script +echo Done with sed +echo namd2=$( which namd2 ) +echo Found namd2 at $namd2 +echo About to run mpiexec -machinefile $PBS_NODEFILE $namd2 $namd_input mpiexec -machinefile $PBS_NODEFILE $namd2 $namd_input + +echo +echo About to run vmd -dispdev text -e $vmd_script vmd -dispdev text -e $vmd_script mv output/cg_clath_cage.dcd output/cg_clath_cage-$b1-$b2.dcd mv rmsd.dat output/rmsd.$b1name${b1}_$b2name${b2}.dat -sleep 5 + +echo +echo Files at end of run +find +echo Modified: SwiftApps/CMTS/rmsd/rmsd.swift =================================================================== --- SwiftApps/CMTS/rmsd/rmsd.swift 2012-08-27 21:58:26 UTC (rev 5911) +++ SwiftApps/CMTS/rmsd/rmsd.swift 2012-08-28 19:47:25 UTC (rev 5912) @@ -33,8 +33,8 @@ foreach b1 in [b1min:b1max:delta] { foreach b2 in [b2min:b2max:delta] { - file output ; - file error ; + file output ; + file error ; file dcd ; file dat ; dats[b1][b2] = dat; From davidk at ci.uchicago.edu Tue Aug 28 16:42:21 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Tue, 28 Aug 2012 16:42:21 -0500 (CDT) Subject: [Swift-commit] r5913 - SwiftApps/CMTS/rmsd Message-ID: <20120828214221.8E8BD9CCA2@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-28 16:42:21 -0500 (Tue, 28 Aug 2012) New Revision: 5913 Modified: SwiftApps/CMTS/rmsd/rmsd.sh Log: Add hostname of node to logs Modified: SwiftApps/CMTS/rmsd/rmsd.sh =================================================================== --- SwiftApps/CMTS/rmsd/rmsd.sh 2012-08-28 19:47:25 UTC (rev 5912) +++ SwiftApps/CMTS/rmsd/rmsd.sh 2012-08-28 21:42:21 UTC (rev 5913) @@ -10,6 +10,10 @@ echo Command line arguments: $@ echo + +echo Hostname: $( hostname ) +echo + echo File listing echo ------------ find From hategan at ci.uchicago.edu Fri Aug 31 19:47:24 2012 From: hategan at ci.uchicago.edu (hategan at ci.uchicago.edu) Date: Fri, 31 Aug 2012 19:47:24 -0500 (CDT) Subject: [Swift-commit] r5914 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript Message-ID: <20120901004724.DE2989CCE6@svn.ci.uchicago.edu> Author: hategan Date: 2012-08-31 19:47:24 -0500 (Fri, 31 Aug 2012) New Revision: 5914 Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java Log: fixed readData and readStructured with field arguments (or any non-root arguments) Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java =================================================================== --- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2012-08-28 21:42:21 UTC (rev 5913) +++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2012-09-01 00:47:24 UTC (rev 5914) @@ -36,7 +36,6 @@ import org.griphyn.vdl.mapping.AbsFile; import org.griphyn.vdl.mapping.AbstractDataNode; import org.griphyn.vdl.mapping.DSHandle; -import org.griphyn.vdl.mapping.HandleOpenException; import org.griphyn.vdl.mapping.InvalidPathException; import org.griphyn.vdl.mapping.Path; import org.griphyn.vdl.mapping.PhysicalFormat; @@ -62,7 +61,7 @@ readData(dest, (String) src.getValue()); } else { - PhysicalFormat pf = src.getMapper().map(Path.EMPTY_PATH); + PhysicalFormat pf = src.getMapper().map(src.getPathFromRoot()); if (pf instanceof AbsFile) { AbsFile af = (AbsFile) pf; if (!af.getProtocol().equalsIgnoreCase("file")) { Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java =================================================================== --- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2012-08-28 21:42:21 UTC (rev 5913) +++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2012-09-01 00:47:24 UTC (rev 5914) @@ -57,7 +57,7 @@ readData(dest, (String) src.getValue()); } else { - PhysicalFormat pf = src.getMapper().map(Path.EMPTY_PATH); + PhysicalFormat pf = src.getMapper().map(src.getPathFromRoot()); if (pf instanceof AbsFile) { AbsFile af = (AbsFile) pf; if (!af.getProtocol().equalsIgnoreCase("file")) { From davidk at ci.uchicago.edu Wed Aug 8 10:13:06 2012 From: davidk at ci.uchicago.edu (davidk at ci.uchicago.edu) Date: Wed, 08 Aug 2012 15:13:06 -0000 Subject: [Swift-commit] r5893 - in SwiftApps/CMTS/dimers: . bin conf input_files src Message-ID: <20120808151256.044159CCBB@svn.ci.uchicago.edu> Author: davidk Date: 2012-08-08 10:12:55 -0500 (Wed, 08 Aug 2012) New Revision: 5893 Added: SwiftApps/CMTS/dimers/README SwiftApps/CMTS/dimers/TODO SwiftApps/CMTS/dimers/bin/ SwiftApps/CMTS/dimers/bin/insert_molecules SwiftApps/CMTS/dimers/bin/restart2data SwiftApps/CMTS/dimers/conf/ SwiftApps/CMTS/dimers/conf/beagle.cf SwiftApps/CMTS/dimers/conf/beagle.xml SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf SwiftApps/CMTS/dimers/conf/grotthuss-ssh.xml SwiftApps/CMTS/dimers/conf/grotthuss.cf SwiftApps/CMTS/dimers/conf/grotthuss.xml SwiftApps/CMTS/dimers/conf/local.cf SwiftApps/CMTS/dimers/conf/local.xml SwiftApps/CMTS/dimers/conf/makena-ssh.cf SwiftApps/CMTS/dimers/conf/makena-ssh.xml SwiftApps/CMTS/dimers/conf/makena.cf SwiftApps/CMTS/dimers/conf/makena.xml SwiftApps/CMTS/dimers/conf/makgroth.cf SwiftApps/CMTS/dimers/conf/makgroth.xml SwiftApps/CMTS/dimers/conf/mcs.cf SwiftApps/CMTS/dimers/conf/mcs.conf SwiftApps/CMTS/dimers/conf/pads-ssh.cf SwiftApps/CMTS/dimers/conf/pads-ssh.xml SwiftApps/CMTS/dimers/conf/pads.cf SwiftApps/CMTS/dimers/conf/pads.xml SwiftApps/CMTS/dimers/dimers.swift SwiftApps/CMTS/dimers/input_files/ SwiftApps/CMTS/dimers/input_files/end_20.restart SwiftApps/CMTS/dimers/input_files/end_25.restart SwiftApps/CMTS/dimers/input_files/end_30.restart SwiftApps/CMTS/dimers/input_files/end_35.restart SwiftApps/CMTS/dimers/input_files/end_40.restart SwiftApps/CMTS/dimers/input_files/end_45.restart SwiftApps/CMTS/dimers/input_files/end_50.restart SwiftApps/CMTS/dimers/input_files/end_55.restart SwiftApps/CMTS/dimers/input_files/end_60.restart SwiftApps/CMTS/dimers/input_files/end_65.restart SwiftApps/CMTS/dimers/input_files/end_70.restart SwiftApps/CMTS/dimers/rundimers.sh SwiftApps/CMTS/dimers/src/ SwiftApps/CMTS/dimers/src/GeometryUtil.cpp SwiftApps/CMTS/dimers/src/GeometryUtil.h SwiftApps/CMTS/dimers/src/Makefile SwiftApps/CMTS/dimers/src/Ran1.cpp SwiftApps/CMTS/dimers/src/Ran1.h SwiftApps/CMTS/dimers/src/StringUtil.cpp SwiftApps/CMTS/dimers/src/StringUtil.h SwiftApps/CMTS/dimers/src/definitions.h SwiftApps/CMTS/dimers/src/insert_molecules SwiftApps/CMTS/dimers/src/insert_molecules.cpp SwiftApps/CMTS/dimers/src/restart2data SwiftApps/CMTS/dimers/src/restart2data.cpp Log: Initial commit of general directory layouts, source files, and config files Added: SwiftApps/CMTS/dimers/README =================================================================== Added: SwiftApps/CMTS/dimers/TODO =================================================================== Added: SwiftApps/CMTS/dimers/bin/insert_molecules =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/bin/insert_molecules ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/bin/restart2data =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/bin/restart2data ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/conf/beagle.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/beagle.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/beagle.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,10 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=3 +lazy.errors=true +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false + +#app sumloss=$PWD/../sumloss.sh +#app evolve=$PWD/../evolve.sh Added: SwiftApps/CMTS/dimers/conf/beagle.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/beagle.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/beagle.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,23 @@ + + + + + KEEP + + 1 + 100 + 100 + pbs.aprun;pbs.mpp;depth=24 + 10000 + 01:30:00 + 50 + 2 + 2 + route + 9.59 + 10000 + + _WORK_/beagle + + + Added: SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/grotthuss-ssh.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=false +use.provider.staging=true +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false +tcp.port.range=5000,51000 + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/grotthuss-ssh.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss-ssh.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/grotthuss-ssh.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,20 @@ + + + + + 100 + 100 + 00:50:00 + 3600 + 1 + 1 + 2 + devel + 1.01 + 10000 + 1 + single + 8 + _WORK_ + + Added: SwiftApps/CMTS/dimers/conf/grotthuss.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/grotthuss.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=true +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/grotthuss.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/grotthuss.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/grotthuss.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,19 @@ + + + + + 01:00:00 + 3600 + 8 + 1 + 1 + devel + 5.99 + 10000 + 1 + single + 8 + _WORK_ + + + Added: SwiftApps/CMTS/dimers/conf/local.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/local.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/local.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,10 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=true +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false + +#app rmsd=$PWD/../rmsd.sh Added: SwiftApps/CMTS/dimers/conf/local.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/local.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/local.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,14 @@ + + + + + 2.55 + 10000 + 4 + 8 + 1000 + 1 + 4 + /tmp + + Added: SwiftApps/CMTS/dimers/conf/makena-ssh.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makena-ssh.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/makena-ssh.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=false +use.provider.staging=true +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false +tcp.port.range=5000,51000 + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/makena-ssh.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/makena-ssh.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/makena-ssh.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,21 @@ + + + + + 100 + 100 + 00:50:00 + 3600 + 1 + 1 + 2 + devel + 1.01 + 10000 + 2 + single + 8 + _WORK_ + + + Added: SwiftApps/CMTS/dimers/conf/makena.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makena.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/makena.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=true +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/makena.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/makena.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/makena.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,20 @@ + + + + + 01:00:00 + 3600 + 8 + 1 + 2 + 2 + devel + 5.99 + 10000 + 2 + single + 8 + _WORK_ + + + Added: SwiftApps/CMTS/dimers/conf/makgroth.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/makgroth.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/makgroth.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=false +use.provider.staging=true +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false +tcp.port.range=5000,51000 + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/makgroth.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/makgroth.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/makgroth.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,41 @@ + + + + + + 100 + 100 + 00:50:00 + 3600 + 1 + 1 + 2 + devel + 1.01 + 10000 + 2 + single + 8 + _WORK_ + + + + + + 100 + 100 + 00:50:00 + 3600 + 1 + 1 + 2 + devel + 1.01 + 10000 + 1 + single + 8 + _WORK_ + + + Added: SwiftApps/CMTS/dimers/conf/mcs.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/mcs.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/mcs.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,7 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=3 +lazy.errors=true +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false Added: SwiftApps/CMTS/dimers/conf/mcs.conf =================================================================== --- SwiftApps/CMTS/dimers/conf/mcs.conf (rev 0) +++ SwiftApps/CMTS/dimers/conf/mcs.conf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,45 @@ +# Keep all interesting settings in one place +# User should modify this to fit environment + +# Location of SWIFT. If empty, PATH is referenced +export SWIFT= + +# Where to place/launch worker.pl on the remote machine for sites.xml +export WORKER_LOCATION=_RUNDIR_ + +# How to launch workers: local, ssh, or cobalt +export WORKER_MODE=ssh + +# Worker logging setting passed to worker.pl for sites.xml +export WORKER_LOGGING_LEVEL=INFO + +# User name to use for all systems +export WORKER_USERNAME=$USER + +# Worker host names for ssh +export WORKER_HOSTS="crush thwomp stomp crank steamroller grind churn trounce thrash vanquish" + +# Directory to keep log files, relative to working directory when launching start-coaster-service +export LOG_DIR=logs +export WORKER_LOG_DIR=_RUNDIR_ + +# Manually define ports. If not specified, ports will be automatically generated +export LOCAL_PORT= +export SERVICE_PORT= + +# Set shared filesystem to no since work will be done in local /sandbox directory +export SHARED_FILESYSTEM=yes + +# start-coaster-service tries to automatically detect IP address. +# Specify here if auto detection is not working correctly +export IPADDR= + +# Below are various settings to give information about how to create sites.xml +#export WORK=_RUNDIR_ +export JOBS_PER_NODE=1 +# export JOB_THROTTLE=$( echo "scale=5; $( echo $WORKER_HOSTS | wc -w )/100 - 0.00001"|bc ) + +# Swift applications +#app sumloss=$PWD/../sumloss.sh +#app evolve=$PWD/../evolve.sh + Added: SwiftApps/CMTS/dimers/conf/pads-ssh.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/pads-ssh.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/pads-ssh.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=10 +lazy.errors=false +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/pads-ssh.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/pads-ssh.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/pads-ssh.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,21 @@ + + + + + 100 + 100 + 00:50:00 + 3600 + 1 + 1 + 2 + fast + 1.01 + 10000 + 2 + single + 8 + _WORK_ + + + Added: SwiftApps/CMTS/dimers/conf/pads.cf =================================================================== --- SwiftApps/CMTS/dimers/conf/pads.cf (rev 0) +++ SwiftApps/CMTS/dimers/conf/pads.cf 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,11 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=10 +lazy.errors=false +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false +use.wrapper.staging=false + +#app rmsd=$PWD/../rmsd.sh +#app plot_pd=$PWD/../plot_pd.pl Added: SwiftApps/CMTS/dimers/conf/pads.xml =================================================================== --- SwiftApps/CMTS/dimers/conf/pads.xml (rev 0) +++ SwiftApps/CMTS/dimers/conf/pads.xml 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,20 @@ + + + + + 01:00:00 + 3600 + 8 + 1 + 2 + 1 + fast + 5.99 + 10000 + 1 + single + 8 + _WORK_ + + + Added: SwiftApps/CMTS/dimers/dimers.swift =================================================================== --- SwiftApps/CMTS/dimers/dimers.swift (rev 0) +++ SwiftApps/CMTS/dimers/dimers.swift 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,13 @@ +type file; + +app insert_molecules + +app restart2data + +app lmp_john + +int start_ndimers=20; +int max_ndimers=75; +int delta_ndimers=5; +int virion_radius=300; + Added: SwiftApps/CMTS/dimers/input_files/end_20.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_20.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_25.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_25.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_30.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_30.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_35.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_35.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_40.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_40.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_45.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_45.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_50.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_50.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_55.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_55.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_60.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_60.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_65.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_65.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/input_files/end_70.restart =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/input_files/end_70.restart ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/rundimers.sh =================================================================== --- SwiftApps/CMTS/dimers/rundimers.sh (rev 0) +++ SwiftApps/CMTS/dimers/rundimers.sh 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,90 @@ +#!/bin/bash + +# Usage: swiftopt.sh [-s sitename] [-w] +# + +usage="$0 [-s sitename] [-p paramfile]" + +# Function to run Swift +runswift() { + swift -tc.file tc.data -sites.file $1 -config cf dimers.swift 2>&1 | tee swift.out +} + +# Default settings +execsite=local +paramfile=local +ram=2048M + +# Process command line arguments +while [ $# -gt 0 ]; do + case $1 in + -s) execsite=$2; shift 2;; + *) echo $usage 1>&2 + exit 1;; + esac +done + +# Create next unique run id and run directory +rundir=$( echo run??? | sed -e 's/^.*run//' | awk '{ printf("run%03d\n", $1+1)}' ) + +# Exit if rundir already exits. Something is funky +if [ -d $rundir ]; +then + echo "$rundir already exists! exiting." >&2 + exit 2 +else + mkdir $rundir +fi + +# Copy input files +cp input_files/* $rundir +echo Run directory $rundir: site=$execsite paramfile=$paramfile + +# Report an error if configuration files are missing +if [ ! -f "conf/$execsite.xml" ] && [ ! -f "conf/$execsite.conf" ]; then + echo Unable to find requested configuration file for site $execsite + exit 1 +fi + +# Use start-coaster-service if site is a .conf file +if [ -f "conf/$execsite.conf" ]; then + USE_SCS=1 +fi + +# Check for missing .cf files +if [ -f "conf/$execsite.xml" ] && [ ! -f "conf/$execsite.cf" ]; then + echo Missing configuration file $execsite.cf +fi + +# Do the run +cd $rundir +cp ../rmsd.swift . +export WORK=$PWD/swiftwork +mkdir -p $PWD/swiftwork/workers + +# Use start-coaster-service if the site uses a .conf file +if [ "$USE_SCS" == "1" ]; then + cp ../conf/$execsite.conf coaster-service.conf + cp ../conf/$execsite.cf cf + sed -i -e "s at _RUNDIR_@$rundir@" coaster-service.conf + start-coaster-service +fi + +# Run gensites +if [ ! "$USE_SCS" == 1 ]; then + cp ../conf/$execsite.cf cf + gensites -p ../conf/$execsite.cf ../conf/$execsite.xml > $execsite.xml +fi + +echo "Run dir=$rundir" >> ABOUT +echo "Work dir=$WORK" >> ABOUT +echo "Total jobs=$total_jobs" >> ABOUT + +if [ "$USE_SCS" == "1" ]; then + runswift "sites.xml" + stop-coaster-service +else + runswift "$execsite.xml" +fi + +exit Property changes on: SwiftApps/CMTS/dimers/rundimers.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/GeometryUtil.cpp =================================================================== --- SwiftApps/CMTS/dimers/src/GeometryUtil.cpp (rev 0) +++ SwiftApps/CMTS/dimers/src/GeometryUtil.cpp 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,721 @@ +#include "GeometryUtil.h" + +/* + Here theta is the "horizontal" resolution, and phi is the "vertical resolution" + We add single point "caps" on the north and south poles of the sphere - these are included + in the phi resolution, so the number of vertical circles which for the sphere is phi_res-2. +*/ +FLOAT_TYPE * GenerateSphere( int theta_res, int phi_res, FLOAT_TYPE sphere_radius, int *npoints ) +{ + double theta, phi, delta_phi; + double circle_radius, pi, twopi, x, y, z; + FLOAT_TYPE *points; // FLOAT_TYPE, as we pass it back. + int i, j, k; + + assert( phi_res > 2 ); // ensure we have at least one genuine circle on the vertical axis! + + pi = M_PI; + twopi = 2.0*M_PI; + + phi_res -= 2; + + *npoints = 2 + (phi_res*theta_res); + points = (FLOAT_TYPE *) malloc( sizeof(FLOAT_TYPE)*(*npoints)*3 ); + + k = 0; + + // add north pole - single point + points[k*3 +0] = 0.0; + points[k*3 +1] = 0.0; + points[k*3 +2] = sphere_radius; + k++; + + // add list of circles on vertical axis + delta_phi = pi/(phi_res+1); + for( i=0; i 0 ); + assert( xyz != NULL ); + assert( COM != NULL ); + + COM[0] = 0.0; + COM[1] = 0.0; + COM[2] = 0.0; + total_mass = 0.0; + + if( mass == NULL ) + { + // assume mass of 1.0 + m = 1.0; + for( i=0; ipi, ie the minimum angle. For the case of theta, this gives us a circle around the zenith axis + but to properly define the phi we need the full range of 0->2pi so we don't have uncertainty as to which "side" of the circle + phi actually lies on. + + This is an issue, as which "side" of the circle phi is on dependes on whether we're looking from above or below the origin of + the coordinate system, as that reflects phi! Therefore, we make an assumption here; specifically, that the zenith axis defines + a normal to the plane formed by the remaining two cartesian axes, and we use this as "up". If we then project the 3D vector + onto a 2D plane defined by the two potential azimuthal axes (by killing the zenith axis component), we can actually get the + full range of 0->2pi given that "up" is the zenith axis, and IT IS SIGNED! + + Here we use zenith axis = z and azimuthal axis = x for convenience and easy interpretation. + + "Conventional" method (phi only on [0,pi]): + + x,y,z = v2-v1 + r = sqrt( dot(v1,v2) ) + theta = acos( z / r ) + phi = atan( y, x ) +*/ +void CartesianToSpherical( FLOAT_TYPE *p1, FLOAT_TYPE *p2, FLOAT_TYPE *r, FLOAT_TYPE *theta, FLOAT_TYPE *phi ) +{ + double vec[3], axis[3], r2, x, y; + double min_r = 1e-20; + + assert( p1 != NULL ); + assert( p2 != NULL ); + assert( r != NULL ); + assert( theta != NULL ); + assert( phi != NULL ); + + vec[0] = p2[0] - p1[0]; + vec[1] = p2[1] - p1[1]; + vec[2] = p2[2] - p1[2]; + + *r = sqrt( DOT_PRODUCT(vec,vec) ); + // is the 3D point too close to the origin? + if( *r < min_r ) + { + *theta = 0.0; + *phi = 0.0; + } + else + { + vec[0] /= *r; + vec[1] /= *r; + vec[2] /= *r; + + // theta is the angle between the vector and the zenith axis - this is easy. + axis[0] = axis[1] = axis[2] = 0.0; + axis[2] = 1.0; // zenith axis is z + *theta = acos( DOT_PRODUCT(axis,vec) ); + + // now we get clever; we project the vector onto the 2D plane by killing the zenith component. Obviously, + // this vector may no longer be a unit vector, so we renormalise. We can then use the atan2 function to get + // the angle in the range -pi->pi (atan2 is also more accurate than other methods) + axis[0] = axis[1] = axis[2] = 0.0; + axis[0] = 1.0; // azimuthal axis is x + + vec[2] = 0.0; // kill the zenith component of the vector to project onto azimuthal plane + r2 = sqrt( DOT_PRODUCT(vec,vec) ); // renomalise value + // is the projected point too close to the 2D origin? + if( r2 < min_r ) *phi = 0.0; + else + { + // use the atan2 function, with x and y components! + vec[0] /= r2; + vec[1] /= r2; + vec[2] /= r2; + // + x = vec[0]; + y = vec[1]; + *phi = atan2( x, y ); + //*phi = acos( axis[0]*vec[0] + axis[1]*vec[1] + axis[2]*vec[2] ); // old version; only 0 -> pi, so merges data symmetrically. + } + } +} +void SphericalToCartesian( FLOAT_TYPE r, FLOAT_TYPE theta, FLOAT_TYPE phi, FLOAT_TYPE *x, FLOAT_TYPE *y, FLOAT_TYPE *z ) +{ + assert( x != NULL ); + assert( y != NULL ); + assert( z != NULL ); + + // deffo right! unaffected by phi calculations. + *z = r * cos(theta); + + // but it fucking beats me why the x and y components have switched here vs "standard" spherical. :/ + *x = r * sin(theta)*sin( phi ); + *y = r * sin(theta)*cos( phi ); + + // the above actually avoids singularities that catch out the standard spherical coords method, + // so we don't need to check for any weirdness as we have phi defined with no weirdness. + + // alternatively ... + //FLOAT_TYPE u; + //u = sqrt( r*r - (*z)*(*z) ); + //*x = u * sin( phi ); + //*y = u * cos( phi ); +} + +/* +// conventional Cartesian => spherical coords conversion +void _CartesianToSpherical( FLOAT_TYPE *p1, FLOAT_TYPE *p2, FLOAT_TYPE *r, FLOAT_TYPE *theta, FLOAT_TYPE *phi ) +{ + double x, y, z; + + x = p2[0] - p1[0]; + y = p2[1] - p1[1]; + z = p2[2] - p1[2]; + + *r = sqrt( x*x + y*y + z*z ); + *theta = acos( z / *r ); + *phi = atan( y/x ); +} +// conventional spherical coords => Cartesian conversion +void _SphericalToCartesian( FLOAT_TYPE r, FLOAT_TYPE theta, FLOAT_TYPE phi, FLOAT_TYPE *x, FLOAT_TYPE *y, FLOAT_TYPE *z ) +{ + *x = r * sin(theta)*cos(phi); + *y = r * sin(theta)*sin(phi); + *z = r * cos(theta); +} +// check we recover correct coordinates vs original, and against standard spherical methods marked with underscore. +// note the problems in the original method that we avoid around the origin! +void test_spherical( int dim ) +{ + int x, y, z; + FLOAT_TYPE s_r, s_t, s_p; // need to be FLOAT_TYPE, as we're passing into and out of the FLOAT_TYPE routines. + FLOAT_TYPE v1[3], v2[3]; // as above. + + v1[0] = v1[1] = v1[2] = 0.0; + + for( x=-dim; x<=dim; x++ ) + for( y=-dim; y<=dim; y++ ) + for( z=-dim; z<=dim; z++ ) + { + v2[0] = x; + v2[1] = y; + v2[2] = z; + printf( "%+.12f %+.12f %+.12f\n", v2[0], v2[1], v2[2] ); + + _CartesianToSpherical( v1, v2, &s_r, &s_t, &s_p ); + printf( "\t %+.6f %+.6f %+.6f => ", s_r, s_t, s_p ); + _SphericalToCartesian( s_r, s_t, s_p, &v2[0], &v2[1], &v2[2] ); + printf( "%+.12f %+.12f %+.12f\n", v2[0], v2[1], v2[2] ); + + v2[0] = x; + v2[1] = y; + v2[2] = z; + CartesianToSpherical( v1, v2, &s_r, &s_t, &s_p ); + printf( "\t %+.6f %+.6f %+.6f => ", s_r, s_t, s_p ); + SphericalToCartesian( s_r, s_t, s_p, &v2[0], &v2[1], &v2[2] ); + printf( "%+.12f %+.12f %+.12f\n", v2[0], v2[1], v2[2] ); + } +} +*/ + +void Translate( int N, FLOAT_TYPE *xyz, FLOAT_TYPE *offset ) +{ + int i; + + assert( N > 0 ); + assert( xyz != NULL ); + assert( offset != NULL ); + + for( i=0; i 0 ); + assert( xyz != NULL ); + assert( axis != NULL ); + + a = 0.0; + b = 0.0; + c = 0.0; + + if( point != NULL ) + { + a = point[0]; + b = point[1]; + c = point[2]; + } + + ct = cos( theta ); + st = sin( theta ); + + u = axis[0]; + v = axis[1]; + w = axis[2]; + u2 = u*u; + v2 = v*v; + w2 = w*w; + K = u2 + v2 + w2; + L = sqrt( K ); + + for( i=0; i x, y, z; + + // build a list of "good" vertices in the shell + for( i=0; i 1! +void UniformSpherePoint( FLOAT_TYPE random_number1, FLOAT_TYPE random_number2, FLOAT_TYPE *vec ) +{ + /* + // original version; this had issues + + double u, theta; + + assert( vec != NULL ); + + u = (random_number1-0.5) * 2.0; // u \elem [-1,1] + u = sqrt( 1 - u*u ); + theta = random_number2 * 2.0*M_PI; // theta \elem [0,2pi) + vec[0] = u * cos( theta ); + vec[1] = u * sin( theta ); + vec[2] = u; + */ + + // new; tested ok! previous version was wrong. + double z, phi, theta, ctheta; + + assert( vec != NULL ); + + z = (random_number1 - 0.5) * 2.0; + phi = random_number2 * 2.0*M_PI; + theta = asin( z ); + ctheta = cos( theta ); + + vec[0] = ctheta * cos(phi); + vec[1] = ctheta * sin(phi); + vec[2] = z; + +} Property changes on: SwiftApps/CMTS/dimers/src/GeometryUtil.cpp ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/GeometryUtil.h =================================================================== --- SwiftApps/CMTS/dimers/src/GeometryUtil.h (rev 0) +++ SwiftApps/CMTS/dimers/src/GeometryUtil.h 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,65 @@ +#ifndef GEOMETRYUTIL_INCLUDED + +#include "definitions.h" + +#include +#include + +/* + Where we recieve or pass back data, data type is FLOAT_TYPE. However, function-local variables are double precision. +*/ + +#define DOT_PRODUCT( v1, v2 ) ( v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2] ) + +FLOAT_TYPE * GenerateSphere( int theta_res, int phi_res, FLOAT_TYPE sphere_radius, int *npoints ); + +void CartesianToSpherical( FLOAT_TYPE *p1, FLOAT_TYPE *p2, FLOAT_TYPE *r, FLOAT_TYPE *theta, FLOAT_TYPE *phi ); +void SphericalToCartesian( FLOAT_TYPE r, FLOAT_TYPE theta, FLOAT_TYPE phi, FLOAT_TYPE *x, FLOAT_TYPE *y, FLOAT_TYPE *z ); + +void CentreOfMass( int N, FLOAT_TYPE *coords, FLOAT_TYPE *mass, FLOAT_TYPE *COM ); + +// rotate on point rotates ... about the specified point! Can pass COM for molecular rotations etc. +// point = NULL rotates about point (0.0, 0.0, 0.0) +void RotateAboutPoint( int N, FLOAT_TYPE *xyz, FLOAT_TYPE *point, FLOAT_TYPE *axis, FLOAT_TYPE theta ); + +// pass 2 random numbers on the range 0 -> 1! +void UniformSpherePoint( FLOAT_TYPE random_number1, FLOAT_TYPE random_number2, FLOAT_TYPE *vec ); + + +FLOAT_TYPE l2_norm_difference( int len, FLOAT_TYPE *v1, FLOAT_TYPE *v2 ); + +#define INIT_TETRAHEDRON 0 +#define INIT_OCTAHEDRON 1 +#define INIT_ICOSAHEDRON 2 + +#include + +class Subdivider +{ + public: + + int n_vertices, n_faces, n_edges; + float *vertices; + int *faces; + + int edge_walk; + int *start, *end, *midpoint; + + // initial generation stuff + void InitTetrahedron(); + void InitOctahedron(); + void InitIcosahedron(); + // refinement of structures + int SearchMidpoint( int index_start, int index_end ); + void Subdivide(); + + // enclosing mesh production for a set of atoms, where r is the mesh distance from the atoms + FLOAT_TYPE * BuildShell( int n_atoms, FLOAT_TYPE *atom_pos, FLOAT_TYPE r, int *n_shell_points ); + + Subdivider( int init_as, int n_subdivisions ); + ~Subdivider(); +}; + + +#define GEOMETRYUTIL_INCLUDED +#endif Property changes on: SwiftApps/CMTS/dimers/src/GeometryUtil.h ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/Makefile =================================================================== --- SwiftApps/CMTS/dimers/src/Makefile (rev 0) +++ SwiftApps/CMTS/dimers/src/Makefile 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,14 @@ +CC=g++ + +all: insert_molecules restart2data + +insert_molecules: + $(CC) -Wall -Wextra -pedantic -O3 insert_molecules.cpp StringUtil.cpp GeometryUtil.cpp Ran1.cpp -o insert_molecules + cp insert_molecules ../bin + +restart2data: + $(CC) -O3 restart2data.cpp -o restart2data + cp restart2data ../bin + +clean: + rm -f restart2data insert_molecules Added: SwiftApps/CMTS/dimers/src/Ran1.cpp =================================================================== --- SwiftApps/CMTS/dimers/src/Ran1.cpp (rev 0) +++ SwiftApps/CMTS/dimers/src/Ran1.cpp 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,58 @@ +#include "Ran1.h" + +/* + The ran1() function from Numerical Recipes in C: The Art of Scientific Computing ( ISBN: 0-521-43108-5 ). + Call with idum as negative number to start, then do not alter idum between calls! +*/ +#define IA 16807 +#define IM 2147483647 +#define AM (1.0/IM) +#define IQ 127773 +#define IR 2836 +#define NTAB 32 +#define NDIV (1+(IM-1)/NTAB) +#define EPS 1.2e-7 +#define RNMX (1.0-EPS) +float ran1( long * idum ) +{ + int j; + long k; + static long iy = 0; + static long iv[NTAB]; + float temp; + + if( *idum <= 0 || !iy ) + { + /* initialize */ + if (-(*idum) < 1) *idum=1; /* prevent idum == 0 */ + else *idum =-(*idum); + + for( j = NTAB+7; j >= 0; j--) + { + /* Load the shuffle table ( after 8 warm-ups ) */ + k = (*idum) / IQ; + *idum = IA*(*idum-k*IQ)-IR*k; + if( *idum < 0 ) *idum += IM; + if( j < NTAB ) iv[j] = *idum; + } + iy = iv[0]; + } + + k = (*idum) / IQ; /* Start here when not initializing */ + *idum=IA*(*idum-k*IQ)-IR*k; /* Compute idum = (IA*idum) % IM without overflows by Schrage's method */ + if( *idum < 0 ) *idum += IM; + j = iy / NDIV; /* Will be in the range 0..NTAB-1. */ + iy = iv[j]; /* Output previously stored value and refill the shuffle table */ + iv[j] = *idum; + if( (temp = AM*iy) > RNMX ) return RNMX; /* Because users don?t expect end point values. */ + else return temp; +} +#undef IA +#undef IM +#undef AM +#undef IQ +#undef IR +#undef NTAB +#undef NDIV +#undef EPS +#undef RNMX Property changes on: SwiftApps/CMTS/dimers/src/Ran1.cpp ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/Ran1.h =================================================================== --- SwiftApps/CMTS/dimers/src/Ran1.h (rev 0) +++ SwiftApps/CMTS/dimers/src/Ran1.h 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,6 @@ +#ifndef RAN1_DEFINED + +float ran1( long * idum ); + +#define RAN1_DEFINED +#endif Property changes on: SwiftApps/CMTS/dimers/src/Ran1.h ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/StringUtil.cpp =================================================================== --- SwiftApps/CMTS/dimers/src/StringUtil.cpp (rev 0) +++ SwiftApps/CMTS/dimers/src/StringUtil.cpp 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,191 @@ +#include "StringUtil.h" + +#define STRINGERROR( msg ) { printf( "ERROR: %s(): %s line %d: \"%s\"\n", __func__, __FILE__, __LINE__, msg ); exit(-1); } + +/* + Convert null terminated character array into an integer. Checks for bad input string, and produces error where failed. +*/ +int StringToInt( const char * str, int base, const char * file, int lineno ) +{ + char *endptr; + char message[1024]; + int returned; + + #ifdef DEBUG + if( str == NULL ) STRINGERROR( "NULL string passed as input" ); + if( file == NULL ) STRINGERROR( "NULL file name passed as input" ); + #endif + + returned = strtol( str, &endptr, 10 ); + if( *endptr != '\0' ) + { + sprintf( message, "Unable to convert '%s' (%s, line %d) into an integer of base %d", str, file, lineno, base ); + STRINGERROR( message ); + } + return returned; +} +/* + Convert null terminated character array into a double precision floating point. Checks for bad input string, and produces error where failed. +*/ +double StringToDouble( const char * str, const char * file, int lineno ) +{ + char *endptr; + char message[1024]; + double returned; + + #ifdef DEBUG + if( str == NULL ) STRINGERROR( "NULL string passed" ); + if( file == NULL ) STRINGERROR( "NULL file name passed" ); + #endif + + returned = strtod( str, &endptr ); + if( *endptr != '\0' ) + { + sprintf( message, "Unable to convert '%s' (%s, line %d) into a double", str, file, lineno ); + STRINGERROR( message ); + } + return returned; +} +/* + Check if character 'test' is a member of "delimiters" +*/ +int IsDelim( char test, const char * delimiters, int ndelim ) +{ + int i; + + #ifdef DEBUG + if( delimiters == NULL ) STRINGERROR( "NULL delimiter string passed" ); + #endif + + for( i=0; i=0 && end == -1; i-- ) + { + if( IsDelim( str[i], whitespace_ptr, whitespace_length ) == 0 ) end = i; + } + + /* note that we could have an empty string, so check for that. */ + j = 0; + if( start == -1 || end == -1 || end < start ) + { + } + else + { + for( i=start; i<=end; i++ ) + { + str[j] = str[i]; + j++; + } + } + str[j] = '\0'; + + return strlen( str ); +} +/* + Chops up "str", and stores the substrings in the array "pointers". If too many substrings are present to store in + the "pointers" array, this routine will just do as many as possible. +*/ +int TokenizeString( char * str, const char * delimiters, char ** pointers, int maxptrs ) +{ + int ntoks, len, ndelim, i, j; + + #ifdef DEBUG + if( str == NULL ) STRINGERROR( "NULL string passed" ); + if( delimiters == NULL ) STRINGERROR( "NULL delimiters string passed" ); + if( pointers == NULL ) STRINGERROR( "NULL pointers array passed" ); + if( maxptrs < 1 ) STRINGERROR( "maxptrs < 1" ); + #endif + + len = strlen( str ); + ndelim = strlen( delimiters ); + ntoks = 0; + + j = 0; /* index into current token. */ + for( i=0; i 0 ) ntoks++; + j = 0; + if( ntoks >= maxptrs ) break; + } + else + { + pointers[ntoks][j] = str[i]; + pointers[ntoks][j+1] = '\0'; + j++; + } + } + /* We may have a trailing token at the end of the string */ + if( j > 0 ) ntoks++; + return ntoks; +} + +int TokenizeString( const char * source, const char * delimiters, std::vector< std::string > &results ) +{ + int ntoks; + char buffer[1024], tokens[100][1024], *token_ptrs[100]; + std::string str; + + for( int i=0; i<100; i++ ) token_ptrs[i] = tokens[i]; + + strcpy( buffer, source ); + + results.clear(); + + ntoks = TokenizeString( buffer, delimiters, token_ptrs, 100 ); + for( int i=0; i &results ) +{ + #ifdef DEBUG + if( f == NULL ) STRINGERROR( "NULL FILE* passed" ); + if( delimiters == NULL ) STRINGERROR( "NULL delimiters string passed" ); + if( line_buffer == NULL ) STRINGERROR( "NULL line_buffer pointer passed" ); + #endif + + line_buffer[0] = '\0'; + if( fgets( line_buffer, 1024, f) == NULL ) return -1; + return TokenizeString( line_buffer, delimiters, results ); +} + + +#undef STRINGERROR + Property changes on: SwiftApps/CMTS/dimers/src/StringUtil.cpp ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/StringUtil.h =================================================================== --- SwiftApps/CMTS/dimers/src/StringUtil.h (rev 0) +++ SwiftApps/CMTS/dimers/src/StringUtil.h 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,19 @@ +#ifndef STRING_UTIL_DEFINED + +#include +#include + +#include +#include +#include + +int StringToInt( const char * str, int base, const char * file, int lineno ); +double StringToDouble( const char * str, const char * file, int lineno ); +int IsDelim( char test, const char * delimiters, int ndelim ); +int StripString( char * str, const char *whitespace ); +int TokenizeString( char * str, const char * delimiters, char ** pointers, int maxptrs ); +int TokenizeString( const char * source, const char * delimiters, std::vector< std::string > &results ); +int TokenizeLine( FILE * f, const char *delimiters, char *line_buffer, std::vector &results ); + +#define STRING_UTIL_DEFINED +#endif Property changes on: SwiftApps/CMTS/dimers/src/StringUtil.h ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/definitions.h =================================================================== --- SwiftApps/CMTS/dimers/src/definitions.h (rev 0) +++ SwiftApps/CMTS/dimers/src/definitions.h 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1 @@ +#define FLOAT_TYPE float Property changes on: SwiftApps/CMTS/dimers/src/definitions.h ___________________________________________________________________ Added: svn:executable + * Added: SwiftApps/CMTS/dimers/src/insert_molecules =================================================================== (Binary files differ) Property changes on: SwiftApps/CMTS/dimers/src/insert_molecules ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: SwiftApps/CMTS/dimers/src/insert_molecules.cpp =================================================================== --- SwiftApps/CMTS/dimers/src/insert_molecules.cpp (rev 0) +++ SwiftApps/CMTS/dimers/src/insert_molecules.cpp 2012-08-08 15:12:55 UTC (rev 5893) @@ -0,0 +1,700 @@ +#include +#include + +#include +#include +#include + +#include "StringUtil.h" +#include "GeometryUtil.h" +#include "Ran1.h" + +/* + This inserts one or more copies of a lammps config file into another lammps config file. + Bonding info and molecular assignments etc are preserved, and incremented as appropriate. + + The program assumes you're inserting into a sphere, and will insert in the whole sphere + volume or onto the surface as specified. Also specified is a cutoff distance to any existing + site in the simulation to avoid steric clashes. + + g++ -Wall -Wextra -pedantic -O3 config_insert.cpp StringUtil.cpp GeometryUtil.cpp Ran1.cpp -o config_insert +*/ + +struct atom_data +{ + int serial, mol, type; + double x, y, z; + double vx, vy, vz; +}; +struct bond_data +{ + int serial, type, i, j; +}; +struct improper_data +{ + int serial, type, i, j, k, l; +}; +struct sim_data +{ + double minx,maxx; + double miny,maxy; + double minz,maxz; + + int n_atoms, n_bonds, n_impropers; + int n_atom_types, n_bond_types, n_improper_types; + + std::map masses; + std::map atoms; + std::map bonds; + std::map impropers; +}; +void add_atom( struct sim_data &sd, int type, int mol, double x, double y, double z, double vx, double vy, double vz ) +{ + struct atom_data ad; + + if( sd.masses.find( type ) == sd.masses.end() ) + { + printf( "%s(): unable to find atom type %d in defined masses.\n", __func__, type ); + return; + } + + sd.n_atoms++; + + ad.serial = sd.n_atoms; + ad.mol = mol; + ad.type = type; + ad.x = x; + ad.y = y; + ad.z = z; + ad.vx = vx; + ad.vy = vy; + ad.vz = vz; + + sd.atoms[ ad.serial ] = ad; +} +void add_bond( struct sim_data &sd, int type, int i, int j ) +{ + struct bond_data bd; + + if( sd.atoms.find( i ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom index %d in defined atoms.\n", __func__, i ); + return; + } + if( sd.atoms.find( j ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom index %d in defined atoms.\n", __func__, j ); + return; + } + + sd.n_bonds++; + + bd.serial = sd.n_bonds; + bd.type = type; + bd.i = i; + bd.j = j; + + sd.bonds[ bd.serial ] = bd; +} +void add_improper( struct sim_data &sd, int type, int i, int j, int k, int l ) +{ + struct improper_data id; + + sd.n_impropers++; + + id.serial = sd.n_impropers; + id.type = type; + id.i = i; + id.j = j; + id.k = k; + id.l = l; + + sd.impropers[ id.serial ] = id; +} +int get_largest_molecule_id( struct sim_data &sd ) +{ + std::map::iterator it; + int largest; + + largest = 0; + + for( it = sd.atoms.begin(); it != sd.atoms.end(); it++ ) + { + if( it->second.mol > largest ) largest = it->second.mol; + } + return largest; +} + +void load_data( + FILE * f, + struct sim_data &sd + ) +{ + char line_buffer[1024]; + const char *delimiters = " \t\n"; + int line_no; + + std::string state; + std::vector tokens; + std::map states; + + std::map::iterator a_it; + std::map::iterator b_it; + std::map::iterator i_it; + std::map int_map; + + states["Masses"] = 1; + states["Atoms"] = 1; + states["Velocities"] = 1; + states["Bonds"] = 1; + states["Impropers"] = 1; + // following are in case the coeffs are included in the file, so we don't get confused, eg "Bond Coeffs" + states["Bond"] = 1; + states["Improper"] = 1; + + state = ""; + + sd.minx = sd.maxx = 0.0; + sd.miny = sd.maxy = 0.0; + sd.minz = sd.maxz = 0.0; + sd.n_atoms = sd.n_atom_types = 0; + sd.n_bonds = sd.n_bond_types = 0; + sd.n_impropers = sd.n_improper_types = 0; + sd.masses.clear(); + sd.atoms.clear(); + sd.bonds.clear(); + sd.impropers.clear(); + + TokenizeLine( f, delimiters, line_buffer, tokens ); // skip leading line. + + while( TokenizeLine( f, delimiters, line_buffer, tokens ) != -1 ) + { + line_no++; + + if( tokens.size() < 1 ) continue; + + if( states.find( tokens[0] ) != states.end() ) + { + //printf( "State switch: '%s' => '%s'\n", state.c_str(), tokens[0].c_str() ); + state = tokens[0]; + continue; + } + + if( state == "" ) + { + // load cell etc, put into metadata + if( tokens.size() > 3 ) + { + if( tokens[2] == "xlo" && tokens[3] == "xhi" ) + { + sd.minx = atof( tokens[0].c_str() ); + sd.maxx = atof( tokens[1].c_str() ); + } + if( tokens[2] == "ylo" && tokens[3] == "yhi" ) + { + sd.miny = atof( tokens[0].c_str() ); + sd.maxy = atof( tokens[1].c_str() ); + } + if( tokens[2] == "zlo" && tokens[3] == "zhi" ) + { + sd.minz = atof( tokens[0].c_str() ); + sd.maxz = atof( tokens[1].c_str() ); + } + } + else if( tokens.size() == 2 && tokens[1] == "atoms" ) { sd.n_atoms = atoi( tokens[0].c_str() ); } + else if( tokens.size() == 2 && tokens[1] == "bonds" ) { sd.n_bonds = atoi( tokens[0].c_str() ); } + else if( tokens.size() == 2 && tokens[1] == "impropers" ) { sd.n_impropers = atoi( tokens[0].c_str() ); } + else if( tokens.size() == 3 && tokens[1] == "atom" ) { sd.n_atom_types = atoi( tokens[0].c_str() ); } + else if( tokens.size() == 3 && tokens[1] == "bond" ) { sd.n_bond_types = atoi( tokens[0].c_str() ); } + else if( tokens.size() == 3 && tokens[1] == "improper" ) { sd.n_improper_types = atoi( tokens[0].c_str() ); } + } + else if( state == "Masses" ) + { + sd.masses[ atoi( tokens[0].c_str() ) ] = atof( tokens[1].c_str() ); + } + else if( state == "Atoms" ) + { + struct atom_data ad; + + ad.serial = atoi( tokens[0].c_str() ); + ad.mol = atoi( tokens[1].c_str() ); + ad.type = atoi( tokens[2].c_str() ); + + ad.x = atof( tokens[3].c_str() ); + ad.y = atof( tokens[4].c_str() ); + ad.z = atof( tokens[5].c_str() ); + + ad.vx = 0.0; + ad.vy = 0.0; + ad.vz = 0.0; + + // assume zero velocoties by default ; will be overwritten in Velocities section, where exists + + sd.atoms[ ad.serial ] = ad; + } + else if( state == "Velocities" ) + { + int serial; + + serial = atoi( tokens[0].c_str() ); + if( sd.atoms.find( serial ) == sd.atoms.end() ) + { + printf( "%s(): '%s' : unable to find atom with serial %d\n", __func__, state.c_str(), serial ); + exit( -1 ); + } + + sd.atoms[serial].vx = atof( tokens[1].c_str() ); + sd.atoms[serial].vy = atof( tokens[2].c_str() ); + sd.atoms[serial].vz = atof( tokens[3].c_str() ); + } + else if( state == "Bonds" ) + { + struct bond_data bd; + + bd.serial = atoi( tokens[0].c_str() ); + bd.type = atoi( tokens[1].c_str() ); + bd.i = atoi( tokens[2].c_str() ); + bd.j = atoi( tokens[3].c_str() ); + + sd.bonds[ bd.serial ] = bd; + + //printf( "[%d] Bond: %d, %d, %d, %d\n", (int)sd.bonds.size(), bd.serial, bd.type, bd.i, bd.j ); + } + else if( state == "Impropers" ) + { + struct improper_data id; + + id.serial = atoi( tokens[0].c_str() ); + id.type = atoi( tokens[1].c_str() ); + id.i = atoi( tokens[2].c_str() ); + id.j = atoi( tokens[3].c_str() ); + id.k = atoi( tokens[4].c_str() ); + id.l = atoi( tokens[5].c_str() ); + + sd.impropers[ id.serial ] = id; + //printf( "[%d] Improper: %d, %d, %d, %d, %d, %d\n", (int)sd.impropers.size(), id.serial, id.type, id.i, id.j, id.k, id.l ); + } + } + + // error tests, and build system info. + + for( a_it = sd.atoms.begin(); a_it != sd.atoms.end(); a_it++ ) + { + if( sd.masses.find( a_it->second.type ) == sd.masses.end() ) + { + printf( "%s(): unable to find atom mass for type %d\n", __func__, a_it->second.type ); + exit( -1 ); + } + } + if( sd.n_atoms != (int)sd.atoms.size() ) + { + printf( "%s(): system declares %d atoms, but only have data for %d\n", __func__, sd.n_atoms, (int)sd.atoms.size() ); + exit( -1 ); + } + + for( b_it = sd.bonds.begin(); b_it != sd.bonds.end(); b_it++ ) + { + if( sd.atoms.find( b_it->second.i ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom serial %d in bond definition\n", __func__, b_it->second.i ); + exit( -1 ); + } + if( sd.atoms.find( b_it->second.j ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom serial %d in bond definition\n", __func__, b_it->second.j ); + exit( -1 ); + } + if( b_it->second.type > sd.n_bond_types ) + { + printf( "%s(): bond type %d is larger than declared number of types %d\n", __func__, b_it->second.type, sd.n_bond_types ); + exit( -1 ); + } + //printf( "Bond: %d %d %d %d\n", b_it->second.serial, b_it->second.type, b_it->second.i, b_it->second.j ); + } + if( sd.n_bonds != (int)sd.bonds.size() ) + { + printf( "%s(): system declares %d bonds, but only have data for %d\n", __func__, sd.n_bonds, (int)sd.bonds.size() ); + exit( -1 ); + } + + for( i_it = sd.impropers.begin(); i_it != sd.impropers.end(); i_it++ ) + { + if( sd.atoms.find( i_it->second.i ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom serial %d in improper definition\n", __func__, i_it->second.i ); + exit( -1 ); + } + if( sd.atoms.find( i_it->second.j ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom serial %d in improper definition\n", __func__, i_it->second.j ); + exit( -1 ); + } + if( sd.atoms.find( i_it->second.k ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom serial %d in improper definition\n", __func__, i_it->second.k ); + exit( -1 ); + } + if( sd.atoms.find( i_it->second.l ) == sd.atoms.end() ) + { + printf( "%s(): unable to find atom serial %d in improper definition\n", __func__, i_it->second.l ); + exit( -1 ); + } + if( i_it->second.type > sd.n_improper_types ) + { + printf( "%s(): improper type %d is larger than declared number of types %d\n", __func__, i_it->second.type, sd.n_improper_types ); + exit( -1 ); + } + } + if( sd.n_impropers != (int)sd.impropers.size() ) + { + printf( "%s(): system declares %d impropers, but only have data for %d\n", __func__, sd.n_impropers, (int)sd.impropers.size() ); + exit( -1 ); + } + +} + +void save_data( + FILE * f, + struct sim_data &sd + ) +{ + std::map::iterator m_it; + std::map::iterator a_it; + std::map::iterator b_it; + std::map::iterator i_it; + + fprintf( f, "Autogenerated!\n" ); + fprintf( f, "\n" ); + fprintf( f, "%d atoms\n", sd.n_atoms ); + fprintf( f, "%d bonds\n", sd.n_bonds ); + fprintf( f, "%d impropers\n", sd.n_impropers ); + fprintf( f, "\n" ); + fprintf( f, "%d atom types\n", sd.n_atom_types ); + fprintf( f, "%d bond types\n", sd.n_bond_types ); + fprintf( f, "%d improper types\n", sd.n_improper_types ); + fprintf( f, "\n" ); + fprintf( f, "%+g %+g xlo xhi\n", sd.minx, sd.maxx ); + fprintf( f, "%+g %+g ylo yhi\n", sd.miny, sd.maxy ); + fprintf( f, "%+g %+g zlo zhi\n", sd.minz, sd.maxz ); + fprintf( f, "\n" ); + fprintf( f, "Masses\n" ); + fprintf( f, "\n" ); + for( m_it = sd.masses.begin(); m_it != sd.masses.end(); m_it++ ) fprintf( f, "%d %g\n", m_it->first, m_it->second ); + fprintf( f, "\n" ); + fprintf( f, "Atoms\n" ); + fprintf( f, "\n" ); + for( a_it = sd.atoms.begin(); a_it != sd.atoms.end(); a_it++ ) fprintf( f, "%d %d %d %g %g %g\n", a_it->first, a_it->second.mol, a_it->second.type, a_it->second.x, a_it->second.y, a_it->second.z ); + fprintf( f, "\n" ); + fprintf( f, "Velocities\n" ); + fprintf( f, "\n" ); + for( a_it = sd.atoms.begin(); a_it != sd.atoms.end(); a_it++ ) fprintf( f, "%d %g %g %g\n", a_it->first, a_it->second.vx, a_it->second.vy, a_it->second.vz ); + fprintf( f, "\n" ); + fprintf( f, "Bonds\n" ); + fprintf( f, "\n" ); + for( b_it = sd.bonds.begin(); b_it != sd.bonds.end(); b_it++ ) fprintf( f, "%d %d %d %d\n", b_it->first, b_it->second.type, b_it->second.i, b_it->second.j ); + fprintf( f, "\n" ); + fprintf( f, "Impropers\n" ); + fprintf( f, "\n" ); + for( i_it = sd.impropers.begin(); i_it != sd.impropers.end(); i_it++ ) fprintf( f, "%d %d %d %d %d %d\n", i_it->first, i_it->second.type, i_it->second.i, i_it->second.j, i_it->second.k, i_it->second.l ); + fprintf( f, "\n" ); +} + +double reset_cog( struct sim_data &sd ) +{ + std::map::iterator it; + double max_extent_from_cog_sq; + double COG[3], COG2[3]; + + COG[0] = COG[1] = COG[2] = 0.0; + COG2[0] = COG2[1] = COG2[2] = 0.0; + + for( it = sd.atoms.begin(); it != sd.atoms.end(); it++ ) + { + COG[0] += it->second.x; + COG[1] += it->second.y; + COG[2] += it->second.z; + } + COG[0] /= sd.n_atoms; + COG[1] /= sd.n_atoms; + COG[2] /= sd.n_atoms; + printf( "COM was: %g, %g, %g\n", COG[0], COG[1], COG[2] ); + max_extent_from_cog_sq = -1.0; + for( it = sd.atoms.begin(); it != sd.atoms.end(); it++ ) + { + double dr[3], extent_sq; + + it->second.x -= COG[0]; + it->second.y -= COG[1]; + it->second.z -= COG[2]; + + COG2[0] += it->second.x; + COG2[1] += it->second.y; + COG2[2] += it->second.z; + + // COG now at origin, or should be, so just use the coords. + dr[0] = it->second.x; + dr[1] = it->second.y; + dr[2] = it->second.z; + extent_sq = dr[0]*dr[0] + dr[1]*dr[1] + dr[2]*dr[2]; + if( extent_sq > max_extent_from_cog_sq ) + { + max_extent_from_cog_sq = extent_sq; + } + } + COG2[0] /= sd.n_atoms; + COG2[1] /= sd.n_atoms; + COG2[2] /= sd.n_atoms; + printf( "COM now: %g, %g, %g\n", COG2[0], COG2[1], COG2[2] ); + + return sqrt( max_extent_from_cog_sq ); +} + +void add_fragment( struct sim_data &sd, struct sim_data &frag ) +{ + int start_mol_id, start_atom_serial; + + std::map::iterator a_it; + std::map::iterator b_it; + std::map::iterator i_it; + + start_mol_id = get_largest_molecule_id( sd ); + start_atom_serial = sd.n_atoms; + + for( a_it = frag.atoms.begin(); a_it != frag.atoms.end(); a_it++ ) + { + add_atom( sd, + a_it->second.type, + a_it->second.mol+start_mol_id, + a_it->second.x, + a_it->second.y, + a_it->second.z, + a_it->second.vx, + a_it->second.vy, + a_it->second.vz ); + } + for( b_it = frag.bonds.begin(); b_it != frag.bonds.end(); b_it++ ) + { + add_bond( sd, b_it->second.type, b_it->second.i+start_atom_serial, b_it->second.j+start_atom_serial ); + } + for( i_it = frag.impropers.begin(); i_it != frag.impropers.end(); i_it++ ) + { + add_improper( sd, i_it->second.type, i_it->second.i+start_atom_serial, i_it->second.j+start_atom_serial, i_it->second.k+start_atom_serial, i_it->second.l+start_atom_serial ); + } +} + +int check_collisions( struct sim_data &sd, struct sim_data &frag, float min_separation ) +{ + std::map::iterator i_it; + std::map::iterator j_it; + + for( i_it = frag.atoms.begin(); i_it != frag.atoms.end(); i_it++ ) + { + for( j_it = sd.atoms.begin(); j_it != sd.atoms.end(); j_it++ ) + { + double dr[3], r_sq; + + dr[0] = i_it->second.x - j_it->second.x; + dr[1] = i_it->second.y - j_it->second.y; + dr[2] = i_it->second.z - j_it->second.z; + r_sq = dr[0]*dr[0] + dr[1]*dr[1] + dr[2]*dr[2]; + + if( r_sq < min_separation*min_separation ) return 1; + } + } + + return 0; +} + +void sim_coords_to_xyz( struct sim_data &sd, FLOAT_TYPE *xyz ) +{ + std::map::iterator it; + int i; + + i = 0; + for( it = sd.atoms.begin(); it != sd.atoms.end(); it++ ) + { + xyz[i*3 +0] = it->second.x; + xyz[i*3 +1] = it->second.y; + xyz[i*3 +2] = it->second.z; + i++; + } +} +void xyz_to_sim_coords( FLOAT_TYPE *xyz, struct sim_data &sd ) +{ + std::map::iterator it; + int i; + + i = 0; + for( it = sd.atoms.begin(); it != sd.atoms.end(); it++ ) + { + it->second.x = xyz[i*3+0]; + it->second.y = xyz[i*3+1]; + it->second.z = xyz[i*3+2]; + i++; + } +} +void save_xyz( const char *fpath, int N, FLOAT_TYPE *xyz ) +{ + FILE * f; + + f = fopen( fpath, "w" ); + fprintf( f, "%d\n", N ); + fprintf( f, "Comment line\n" ); + for( int i=0; i::iterator it; + FILE * f; + + f = fopen( fpath, "w" ); + fprintf( f, "%d\n", (int)sd.atoms.size() ); + fprintf( f, "Comment line\n" ); + + for( it = sd.atoms.begin(); it != sd.atoms.end(); it++ ) + { + fprintf( f, "P %g %g %g\n", it->second.x, it->second.y, it->second.z ); + } + + fclose( f ); +} + +int main( int argc, char **argv ) +{ + struct sim_data sim, fragment, frag; + int ncopies, insert_on_surface; + double radius, min_sep, max_extent_from_cog; + long ran1_seed; + FLOAT_TYPE *original_xyz, *xyz; + + FILE *f; + const char *sim_fpath, *fragment_fpath, *output_fpath; + + if( argc < 8 ) + { + printf( "Usage: %s \n", argv[0] ); + exit( -1 ); + } + + sim_fpath = argv[1]; + fragment_fpath = argv[2]; + ncopies = atoi( argv[3] ); + radius = atof( argv[4] ); + insert_on_surface = atoi( argv[5] ); + min_sep = atof( argv[6] ); + output_fpath = argv[7]; + + // load target sim + if( (f = fopen( sim_fpath, "r" )) == NULL ) + { + printf( "Unable to open file '%s'\n", sim_fpath ); + exit( EXIT_FAILURE ); + } + load_data( f, sim ); + fclose( f ); + + // load fragment to add to target sim + if( (f = fopen( fragment_fpath, "r" )) == NULL ) + { + printf( "Unable to open file '%s'\n", fragment_fpath ); + exit( -1 ); + } + load_data( f, fragment ); + fclose( f ); + + max_extent_from_cog = reset_cog( fragment ); + + printf( "Target sim has %d atoms (%d molecules)\n", sim.n_atoms, get_largest_molecule_id( sim ) ); + printf( "Fragment sim has %d atoms (%d molecules), max extent from COG is %g\n", fragment.n_atoms, get_largest_molecule_id( fragment ), max_extent_from_cog ); + printf( "%d copies of fragment data to insert.\n", ncopies ); + printf( "sphere radius is %g.\n", radius ); + + original_xyz = new FLOAT_TYPE[ fragment.atoms.size()*3 ]; + xyz = new FLOAT_TYPE[ fragment.atoms.size()*3 ]; + + sim_coords_to_xyz( fragment, original_xyz ); + frag = fragment; + + for( int i=0; i= 10 && i % (ncopies/10) == 0 ) { printf( "Adding %d...\n", i+1 ); save_sim_as_xyz( "temp.xyz", sim ); } + + collided = 1; + for( int j=0; j<1e6; j++ ) + { + FLOAT_TYPE origin[3], COG[3], axis[3], theta; + FLOAT_TYPE r1, r2, distance_from_origin; + + memcpy( xyz, original_xyz, sizeof(FLOAT_TYPE)*frag.atoms.size()*3 ); + + // generate random axis of rotation + r1 = ran1( &ran1_seed ); + r2 = ran1( &ran1_seed ); + UniformSpherePoint( r1, r2, axis ); + + // generate random rotation about this axis + theta = (ran1( &ran1_seed )-0.5) * 2.0*M_PI; + + // generate random COG offset onto surface of sphere + r1 = ran1( &ran1_seed ); + r2 = ran1( &ran1_seed ); + UniformSpherePoint( r1, r2, COG ); + if( insert_on_surface == 1 ) + { + distance_from_origin = radius - max_extent_from_cog; + } + else + { + distance_from_origin = ran1( &ran1_seed ) * (radius - max_extent_from_cog); + } + COG[0] *= distance_from_origin; + COG[1] *= distance_from_origin; + COG[2] *= distance_from_origin; + + origin[0] = origin[1] = origin[2] = 0.0; + + RotateAboutPoint( (int)frag.atoms.size(), xyz, origin, axis, theta ); + for( size_t i=0; i (b) ? (a) : (b)) + +#define MAX_GROUP 32 +#define PI (4.0*atan(1.0)) + +// these should match settings in src/lmptype.h + +#include "stdint.h" +#define __STDC_FORMAT_MACROS +#include "inttypes.h" + +typedef int tagint; +typedef int64_t bigint; +#define BIGINT_FORMAT "%" PRId64 + +// same as write_restart.cpp + +enum{VERSION,SMALLINT,TAGINT,BIGINT, + UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2, + NEWTON_PAIR,NEWTON_BOND,XPERIODIC,YPERIODIC,ZPERIODIC, + BOUNDARY_00,BOUNDARY_01,BOUNDARY_10,BOUNDARY_11,BOUNDARY_20,BOUNDARY_21, + ATOM_STYLE,NATOMS,NTYPES, + NBONDS,NBONDTYPES,BOND_PER_ATOM, + NANGLES,NANGLETYPES,ANGLE_PER_ATOM, + NDIHEDRALS,NDIHEDRALTYPES,DIHEDRAL_PER_ATOM, + NIMPROPERS,NIMPROPERTYPES,IMPROPER_PER_ATOM, + BOXLO_0,BOXHI_0,BOXLO_1,BOXHI_1,BOXLO_2,BOXHI_2, + SPECIAL_LJ_1,SPECIAL_LJ_2,SPECIAL_LJ_3, + SPECIAL_COUL_1,SPECIAL_COUL_2,SPECIAL_COUL_3, + XY,XZ,YZ}; +enum{MASS}; +enum{PAIR,BOND,ANGLE,DIHEDRAL,IMPROPER}; + +static const char * const cg_type_list[] = + {"none", "lj9_6", "lj12_4", "lj12_6"}; + +// --------------------------------------------------------------------- +// Data class to hold problem +// --------------------------------------------------------------------- + +class Data { + public: + + // global settings + + char *version; + int size_smallint,size_tagint,size_bigint; + bigint ntimestep; + int nprocs; + char *unit_style; + int dimension; + int px,py,pz; + int newton_pair,newton_bond; + int xperiodic,yperiodic,zperiodic; + int boundary[3][2]; + + char *atom_style; + int style_angle,style_atomic,style_bond,style_charge,style_dipole; + int style_ellipsoid,style_full; + int style_hybrid,style_molecular,style_peri,style_sphere; + + bigint natoms; + bigint nellipsoids; + bigint nbonds,nangles,ndihedrals,nimpropers; + int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; + int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; + int triclinic; + + double xlo,xhi,ylo,yhi,zlo,zhi,xy,xz,yz; + double special_lj[4],special_coul[4]; + + double cut_lj_global,cut_coul_global,kappa; + int offset_flag,mix_flag; + + // force fields + + char *pair_style,*bond_style,*angle_style,*dihedral_style,*improper_style; + + double *pair_born_A,*pair_born_rho,*pair_born_sigma; + double *pair_born_C,*pair_born_D; + double *pair_buck_A,*pair_buck_rho,*pair_buck_C; + double *pair_colloid_A12,*pair_colloid_sigma; + double *pair_colloid_d1,*pair_colloid_d2; + double *pair_dipole_epsilon,*pair_dipole_sigma; + double *pair_dpd_a0,*pair_dpd_gamma; + double *pair_charmm_epsilon,*pair_charmm_sigma; + double *pair_charmm_eps14,*pair_charmm_sigma14; + double *pair_class2_epsilon,*pair_class2_sigma; + double *pair_gb_epsilon,*pair_gb_sigma; + double *pair_gb_epsa,*pair_gb_epsb,*pair_gb_epsc; + double *pair_lj_epsilon,*pair_lj_sigma; + double **pair_cg_epsilon,**pair_cg_sigma; + int **pair_cg_cmm_type, **pair_setflag; + double **pair_cut_coul, **pair_cut_lj; + double *pair_ljexpand_epsilon,*pair_ljexpand_sigma,*pair_ljexpand_shift; + double *pair_ljgromacs_epsilon,*pair_ljgromacs_sigma; + double *pair_ljsmooth_epsilon,*pair_ljsmooth_sigma; + double *pair_morse_d0,*pair_morse_alpha,*pair_morse_r0; + double *pair_soft_A; + double *pair_yukawa_A; + + double *bond_class2_r0,*bond_class2_k2,*bond_class2_k3,*bond_class2_k4; + double *bond_fene_k,*bond_fene_r0,*bond_fene_epsilon,*bond_fene_sigma; + double *bond_feneexpand_k,*bond_feneexpand_r0; + double *bond_feneexpand_epsilon,*bond_feneexpand_sigma; + double *bond_feneexpand_shift; + double *bond_harmonic_k,*bond_harmonic_r0; + double *bond_harmonicshift_umin,*bond_harmonicshift_r0, + *bond_harmonicshift_rc; + double *bond_harmonicshiftcut_umin,*bond_harmonicshiftcut_r0, + *bond_harmonicshiftcut_rc; + double *bond_morse_d0,*bond_morse_alpha,*bond_morse_r0; + double *bond_nonlinear_epsilon,*bond_nonlinear_r0,*bond_nonlinear_lamda; + double *bond_quartic_k,*bond_quartic_b1,*bond_quartic_b2; + double *bond_quartic_rc,*bond_quartic_u0; + + double *angle_charmm_k,*angle_charmm_theta0; + double *angle_charmm_k_ub,*angle_charmm_r_ub; + double *angle_class2_theta0; + double *angle_class2_k2,*angle_class2_k3,*angle_class2_k4; + double *angle_class2_bb_k,*angle_class2_bb_r1,*angle_class2_bb_r2; + double *angle_class2_ba_k1,*angle_class2_ba_k2; + double *angle_class2_ba_r1,*angle_class2_ba_r2; + double *angle_cosine_k; + double *angle_cosine_squared_k,*angle_cosine_squared_theta0; + double *angle_harmonic_k,*angle_harmonic_theta0; + double *angle_cg_cmm_epsilon,*angle_cg_cmm_sigma; + double *angle_cosineshift_umin,*angle_cosineshift_sint, + *angle_cosineshift_cost,*angle_cosineshift_theta0; + double *angle_cosineshiftexp_umin,*angle_cosineshiftexp_a, + *angle_cosineshiftexp_sint,*angle_cosineshiftexp_cost, + *angle_cosineshiftexp_theta0; + int *angle_cg_cmm_type; + + double *dihedral_charmm_k,*dihedral_charmm_weight; + int *dihedral_charmm_multiplicity,*dihedral_charmm_sign; + double *dihedral_class2_k1,*dihedral_class2_k2,*dihedral_class2_k3; + double *dihedral_class2_phi1,*dihedral_class2_phi2,*dihedral_class2_phi3; + double *dihedral_class2_mbt_f1,*dihedral_class2_mbt_f2; + double *dihedral_class2_mbt_f3,*dihedral_class2_mbt_r0; + double *dihedral_class2_ebt_f1_1,*dihedral_class2_ebt_f2_1; + double *dihedral_class2_ebt_f3_1,*dihedral_class2_ebt_r0_1; + double *dihedral_class2_ebt_f1_2,*dihedral_class2_ebt_f2_2; + double *dihedral_class2_ebt_f3_2,*dihedral_class2_ebt_r0_2; + double *dihedral_class2_at_f1_1,*dihedral_class2_at_f2_1; + double *dihedral_class2_at_f3_1,*dihedral_class2_at_theta0_1; + double *dihedral_class2_at_f1_2,*dihedral_class2_at_f2_2; + double *dihedral_class2_at_f3_2,*dihedral_class2_at_theta0_2; + double *dihedral_class2_aat_k; + double *dihedral_class2_aat_theta0_1,*dihedral_class2_aat_theta0_2; + double *dihedral_class2_bb13_k; + double *dihedral_class2_bb13_r10,*dihedral_class2_bb13_r30; + double *dihedral_harmonic_k; + int *dihedral_harmonic_multiplicity,*dihedral_harmonic_sign; + double *dihedral_helix_aphi,*dihedral_helix_bphi,*dihedral_helix_cphi; + double *dihedral_multi_a1,*dihedral_multi_a2,*dihedral_multi_a3; + double *dihedral_multi_a4,*dihedral_multi_a5; + double *dihedral_opls_k1,*dihedral_opls_k2; + double *dihedral_opls_k3,*dihedral_opls_k4; + double *dihedral_cosineshiftexp_umin, *dihedral_cosineshiftexp_a, + *dihedral_cosineshiftexp_sint,*dihedral_cosineshiftexp_cost, + *dihedral_cosineshiftexp_theta; + + double *improper_class2_k0,*improper_class2_chi0; + double *improper_class2_aa_k1,*improper_class2_aa_k2,*improper_class2_aa_k3; + double *improper_class2_aa_theta0_1,*improper_class2_aa_theta0_2; + double *improper_class2_aa_theta0_3; + double *improper_cvff_k; + int *improper_cvff_sign,*improper_cvff_multiplicity; + double *improper_harmonic_k,*improper_harmonic_chi; + + // atom quantities + + int iatoms,ibonds,iangles,idihedrals,iimpropers; + + double *mass; + double *x,*y,*z,*vx,*vy,*vz; + double *omegax,*omegay,*omegaz; + tagint *tag; + int *type,*mask,*image; + int *molecule; + double *q,*mux,*muy,*muz,*radius,*density,*vfrac,*rmass; + double *s0,*x0x,*x0y,*x0z; + double *shapex,*shapey,*shapez; + double *quatw,*quati,*quatj,*quatk,*angmomx,*angmomy,*angmomz; + int *ellipsoid; + int *bond_type,*angle_type,*dihedral_type,*improper_type; + int *bond_atom1,*bond_atom2; + int *angle_atom1,*angle_atom2,*angle_atom3; + int *dihedral_atom1,*dihedral_atom2,*dihedral_atom3,*dihedral_atom4; + int *improper_atom1,*improper_atom2,*improper_atom3,*improper_atom4; + + // functions + + Data(); + void stats(); + void write(FILE *fp, FILE *fp2=NULL); + + void write_atom_angle(FILE *, int, int, int, int); + void write_atom_atomic(FILE *, int, int, int, int); + void write_atom_bond(FILE *, int, int, int, int); + void write_atom_charge(FILE *, int, int, int, int); + void write_atom_dipole(FILE *, int, int, int, int); + void write_atom_ellipsoid(FILE *, int, int, int, int); + void write_atom_full(FILE *, int, int, int, int); + void write_atom_molecular(FILE *, int, int, int, int); + void write_atom_peri(FILE *, int, int, int, int); + void write_atom_sphere(FILE *, int, int, int, int); + + void write_atom_angle_extra(FILE *, int); + void write_atom_atomic_extra(FILE *, int); + void write_atom_bond_extra(FILE *, int); + void write_atom_charge_extra(FILE *, int); + void write_atom_dipole_extra(FILE *, int); + void write_atom_ellipsoid_extra(FILE *, int); + void write_atom_full_extra(FILE *, int); + void write_atom_molecular_extra(FILE *, int); + void write_atom_peri_extra(FILE *, int); + void write_atom_sphere_extra(FILE *, int); + + void write_vel_angle(FILE *, int); + void write_vel_atomic(FILE *, int); + void write_vel_bond(FILE *, int); + void write_vel_charge(FILE *, int); + void write_vel_dipole(FILE *, int); + void write_vel_ellipsoid(FILE *, int); + void write_vel_full(FILE *, int); + void write_vel_molecular(FILE *, int); + void write_vel_peri(FILE *, int); + void write_vel_sphere(FILE *, int); + + void write_vel_angle_extra(FILE *, int); + void write_vel_atomic_extra(FILE *, int); + void write_vel_bond_extra(FILE *, int); + void write_vel_charge_extra(FILE *, int); + void write_vel_dipole_extra(FILE *, int); + void write_vel_ellipsoid_extra(FILE *, int); + void write_vel_full_extra(FILE *, int); + void write_vel_molecular_extra(FILE *, int); + void write_vel_peri_extra(FILE *, int); + void write_vel_sphere_extra(FILE *, int); +}; + +// --------------------------------------------------------------------- +// function prototypes +// --------------------------------------------------------------------- + +void header(FILE *, Data &); +void set_style(char *, Data &, int); +void groups(FILE *); +void type_arrays(FILE *, Data &); +void force_fields(FILE *, Data &); +void modify(FILE *); +void pair(FILE *fp, Data &data, char *style, int flag); +void bond(FILE *fp, Data &data); +void angle(FILE *fp, Data &data); +void dihedral(FILE *fp, Data &data); +void improper(FILE *fp, Data &data); +int atom(double *, Data &data); + +void allocate_angle(Data &data); +void allocate_atomic(Data &data); +void allocate_bond(Data &data); +void allocate_charge(Data &data); +void allocate_dipole(Data &data); +void allocate_ellipsoid(Data &data); +void allocate_full(Data &data); +void allocate_molecular(Data &data); +void allocate_peri(Data &data); +void allocate_sphere(Data &data); + +int atom_angle(double *, Data &, int); +int atom_atomic(double *, Data &, int); +int atom_bond(double *, Data &, int); +int atom_charge(double *, Data &, int); +int atom_dipole(double *, Data &, int); +int atom_ellipsoid(double *, Data &, int); +int atom_full(double *, Data &, int); +int atom_molecular(double *, Data &, int); +int atom_peri(double *, Data &, int); +int atom_sphere(double *, Data &, int); + +void strip_suffix(char *); + +int read_int(FILE *fp); +double read_double(FILE *fp); +char *read_char(FILE *fp); +bigint read_bigint(FILE *fp); + +// --------------------------------------------------------------------- +// main program +// --------------------------------------------------------------------- + +int main (int narg, char **arg) +{ + // process command-line args + + int iarg = 1; + if (strcmp(arg[iarg],"-h") == 0) { + printf("Syntax: restart2data switch arg ... " + "restart-file data-file (input-file)\n"); + printf(" restart-file and data-file are mandatory"); + printf(" input-file is optional"); + printf(" if specified it will contain LAMMPS input script commands"); + printf(" for mass and force field info"); + printf(" only a few force field styles support this option"); + return 0; + } + + if ((narg-iarg != 2) && (narg-iarg != 3)) { + printf("Syntax: restart2data switch arg ... " + "restart-file data-file (input-file)\n"); + return 1; + } + + char *restartfile = arg[iarg]; + char *datafile = arg[iarg+1]; + char *inputfile = NULL; + if (narg-iarg == 3) inputfile = arg[iarg+2]; + + // if restart file contains '%', file = filename with % replaced by "base" + // else file = single file + // open single restart file or base file for multiproc case + + printf("Reading restart file ...\n"); + + char *ptr; + FILE *fp; + + int multiproc = 0; + if ( (ptr = strchr(restartfile,'%')) ) { + multiproc = 1; + char *basefile = new char[strlen(restartfile) + 16]; + *ptr = '\0'; + sprintf(basefile,"%s%s%s",restartfile,"base",ptr+1); + fp = fopen(basefile,"rb"); + if (fp == NULL) { + printf("ERROR: Cannot open restart file %s\n",basefile); + return 1; + } + } else { + fp = fopen(restartfile,"rb"); + if (fp == NULL) { + printf("ERROR: Cannot open restart file %s\n",restartfile); + return 1; + } + } + + // read beginning of restart file + + Data data; + + header(fp,data); + if (data.size_smallint != sizeof(int) || + data.size_tagint != sizeof(tagint) || + data.size_bigint != sizeof(bigint)) { + printf("ERROR: Data type sizes in restart file " + "are incompatible with restart2data.cpp\n"); + return 1; + } + + groups(fp); + type_arrays(fp,data); + force_fields(fp,data); + modify(fp); + + // read atoms from single or multiple restart files + + double *buf = NULL; + int n,m; + int maxbuf = 0; + data.iatoms = data.ibonds = data.iangles = + data.idihedrals = data.iimpropers = 0; + + for (int iproc = 0; iproc < data.nprocs; iproc++) { + if (multiproc) { + fclose(fp); + char *procfile; + sprintf(procfile,"%s%d%s",restartfile,iproc,ptr+1); + fp = fopen(procfile,"rb"); + if (fp == NULL) { + printf("ERROR: Cannot open restart file %s\n",procfile); + return 1; + } + } + n = read_int(fp); + + if (n > maxbuf) { + maxbuf = n; + delete [] buf; + buf = new double[maxbuf]; + } + + fread(buf,sizeof(double),n,fp); + + m = 0; + while (m < n) m += atom(&buf[m],data); + } + + fclose(fp); + + // print out stats + + data.stats(); + + // write out data file and no input file + + if (!inputfile) { + printf("Writing data file ...\n"); + fp = fopen(datafile,"w"); + if (fp == NULL) { + printf("ERROR: Cannot open data file %s\n",datafile); + return 1; + } + data.write(fp); + fclose(fp); + + // write out data file and input file + + } else { + printf("Writing data file ...\n"); + fp = fopen(datafile,"w"); + if (fp == NULL) { + printf("ERROR: Cannot open data file %s\n",datafile); + return 1; + } + printf("Writing input file ...\n"); + FILE *fp2 = fopen(inputfile,"w"); + if (fp2 == NULL) { + printf("ERROR: Cannot open input file %s\n",inputfile); + return 1; + } + + data.write(fp,fp2); + fclose(fp); + fclose(fp2); + } + + return 0; +} + +// --------------------------------------------------------------------- +// read header of restart file +// --------------------------------------------------------------------- + +void header(FILE *fp, Data &data) +{ + char *version = "19 Aug 2011"; + + data.triclinic = 0; + + int flag; + flag = read_int(fp); + + while (flag >= 0) { + + if (flag == VERSION) { + data.version = read_char(fp); + if (strcmp(version,data.version) != 0) { + char *str = "Restart file version does not match restart2data version"; + printf("WARNING %s\n",str); + printf(" restart2data version = %s\n",version); + } + } + else if (flag == SMALLINT) data.size_smallint = read_int(fp); + else if (flag == TAGINT) data.size_tagint = read_int(fp); + else if (flag == BIGINT) data.size_bigint = read_int(fp); + else if (flag == UNITS) data.unit_style = read_char(fp); + else if (flag == NTIMESTEP) data.ntimestep = read_bigint(fp); + else if (flag == DIMENSION) data.dimension = read_int(fp); + else if (flag == NPROCS) data.nprocs = read_int(fp); + else if (flag == PROCGRID_0) data.px = read_int(fp); + else if (flag == PROCGRID_1) data.py = read_int(fp); + else if (flag == PROCGRID_2) data.pz = read_int(fp); + else if (flag == NEWTON_PAIR) data.newton_pair = read_int(fp); + else if (flag == NEWTON_BOND) data.newton_bond = read_int(fp); + else if (flag == XPERIODIC) data.xperiodic = read_int(fp); + else if (flag == YPERIODIC) data.yperiodic = read_int(fp); + else if (flag == ZPERIODIC) data.zperiodic = read_int(fp); + else if (flag == BOUNDARY_00) data.boundary[0][0] = read_int(fp); + else if (flag == BOUNDARY_01) data.boundary[0][1] = read_int(fp); + else if (flag == BOUNDARY_10) data.boundary[1][0] = read_int(fp); + else if (flag == BOUNDARY_11) data.boundary[1][1] = read_int(fp); + else if (flag == BOUNDARY_20) data.boundary[2][0] = read_int(fp); + else if (flag == BOUNDARY_21) data.boundary[2][1] = read_int(fp); + + // if atom_style = hybrid: + // set data_style_hybrid to # of sub-styles + // read additional sub-class arguments + // set sub-styles to 1 to N + + else if (flag == ATOM_STYLE) { + data.style_angle = data.style_atomic = data.style_bond = + data.style_charge = data.style_dipole = + data.style_ellipsoid = data.style_full = data.style_hybrid = + data.style_molecular = data.style_peri = data.style_sphere = 0; + + data.atom_style = read_char(fp); + strip_suffix(data.atom_style); + set_style(data.atom_style,data,1); + + if (strcmp(data.atom_style,"hybrid") == 0) { + int nwords = read_int(fp); + set_style(data.atom_style,data,nwords); + char *substyle; + for (int i = 1; i <= nwords; i++) { + substyle = read_char(fp); + set_style(substyle,data,i); + } + } + } + + else if (flag == NATOMS) data.natoms = read_bigint(fp); + else if (flag == NTYPES) data.ntypes = read_int(fp); + else if (flag == NBONDS) data.nbonds = read_bigint(fp); + else if (flag == NBONDTYPES) data.nbondtypes = read_int(fp); + else if (flag == BOND_PER_ATOM) data.bond_per_atom = read_int(fp); + else if (flag == NANGLES) data.nangles = read_bigint(fp); + else if (flag == NANGLETYPES) data.nangletypes = read_int(fp); + else if (flag == ANGLE_PER_ATOM) data.angle_per_atom = read_int(fp); + else if (flag == NDIHEDRALS) data.ndihedrals = read_bigint(fp); + else if (flag == NDIHEDRALTYPES) data.ndihedraltypes = read_int(fp); + else if (flag == DIHEDRAL_PER_ATOM) data.dihedral_per_atom = read_int(fp); + else if (flag == NIMPROPERS) data.nimpropers = read_bigint(fp); + else if (flag == NIMPROPERTYPES) data.nimpropertypes = read_int(fp); + else if (flag == IMPROPER_PER_ATOM) data.improper_per_atom = read_int(fp); + else if (flag == BOXLO_0) data.xlo = read_double(fp); + else if (flag == BOXHI_0) data.xhi = read_double(fp); + else if (flag == BOXLO_1) data.ylo = read_double(fp); + else if (flag == BOXHI_1) data.yhi = read_double(fp); + else if (flag == BOXLO_2) data.zlo = read_double(fp); + else if (flag == BOXHI_2) data.zhi = read_double(fp); + else if (flag == SPECIAL_LJ_1) data.special_lj[1] = read_double(fp); + else if (flag == SPECIAL_LJ_2) data.special_lj[2] = read_double(fp); + else if (flag == SPECIAL_LJ_3) data.special_lj[3] = read_double(fp); + else if (flag == SPECIAL_COUL_1) data.special_coul[1] = read_double(fp); + else if (flag == SPECIAL_COUL_2) data.special_coul[2] = read_double(fp); + else if (flag == SPECIAL_COUL_3) data.special_coul[3] = read_double(fp); + else if (flag == XY) { + data.triclinic = 1; + data.xy = read_double(fp); + } else if (flag == XZ) { + data.triclinic = 1; + data.xz = read_double(fp); + } else if (flag == YZ) { + data.triclinic = 1; + data.yz = read_double(fp); + } else { + printf("ERROR: Invalid flag in header section of restart file %d\n", + flag); + exit(1); + } + + flag = read_int(fp); + } +} + +// --------------------------------------------------------------------- +// set atom style to flag +// --------------------------------------------------------------------- + +void set_style(char *name, Data &data, int flag) +{ + if (strcmp(name,"angle") == 0) data.style_angle = flag; + else if (strcmp(name,"atomic") == 0) data.style_atomic = flag; + else if (strcmp(name,"bond") == 0) data.style_bond = flag; + else if (strcmp(name,"charge") == 0) data.style_charge = flag; + else if (strcmp(name,"dipole") == 0) data.style_dipole = flag; + else if (strcmp(name,"ellipsoid") == 0) data.style_ellipsoid = flag; + else if (strcmp(name,"full") == 0) data.style_full = flag; + else if (strcmp(name,"hybrid") == 0) data.style_hybrid = flag; + else if (strcmp(name,"molecular") == 0) data.style_molecular = flag; + else if (strcmp(name,"peri") == 0) data.style_peri = flag; + else if (strcmp(name,"sphere") == 0) data.style_sphere = flag; + else { + printf("ERROR: Unknown atom style %s\n",name); + exit(1); + } +} + +// --------------------------------------------------------------------- +// read group info from restart file, just ignore it +// --------------------------------------------------------------------- + +void groups(FILE *fp) +{ + int ngroup = read_int(fp); + + char *name; + + // use count to not change restart format with deleted groups + // remove this on next major release + + int count = 0; + for (int i = 0; i < MAX_GROUP; i++) { + name = read_char(fp); + delete [] name; + count++; + if (count == ngroup) break; + } +} + +// --------------------------------------------------------------------- +// read type arrays from restart file +// --------------------------------------------------------------------- + +void type_arrays(FILE *fp, Data &data) +{ + data.mass = NULL; + + int flag; + flag = read_int(fp); + + while (flag >= 0) { + + if (flag == MASS) { + data.mass = new double[data.ntypes+1]; + fread(&data.mass[1],sizeof(double),data.ntypes,fp); + } else { + printf("ERROR: Invalid flag in type arrays section of restart file %d\n", + flag); + exit(1); + } + + flag = read_int(fp); + } +} + +// --------------------------------------------------------------------- +// read force-field info from restart file +// --------------------------------------------------------------------- + +void force_fields(FILE *fp, Data &data) +{ + data.pair_style = data.bond_style = data.angle_style = + data.dihedral_style = data.improper_style = NULL; + + int flag; + flag = read_int(fp); + + while (flag >= 0) { + + if (flag == PAIR) { + data.pair_style = read_char(fp); + strip_suffix(data.pair_style); + pair(fp,data,data.pair_style,1); + } else if (flag == BOND) { + data.bond_style = read_char(fp); + strip_suffix(data.bond_style); + bond(fp,data); + } else if (flag == ANGLE) { + data.angle_style = read_char(fp); + strip_suffix(data.angle_style); + angle(fp,data); + } else if (flag == DIHEDRAL) { + data.dihedral_style = read_char(fp); + strip_suffix(data.dihedral_style); + dihedral(fp,data); + } else if (flag == IMPROPER) { + data.improper_style = read_char(fp); + strip_suffix(data.improper_style); + improper(fp,data); + } else { + printf("ERROR: Invalid flag in force fields section of restart file %d\n", + flag); + exit(1); + } + + flag = read_int(fp); + } +} + +// --------------------------------------------------------------------- +// read fix info from restart file, just ignore it +// --------------------------------------------------------------------- + +void modify(FILE *fp) +{ + char *buf; + int n; + + // nfix = # of fix entries with state + + int nfix = read_int(fp); + + // read each entry with id string, style string, chunk of data + + for (int i = 0; i < nfix; i++) { + buf = read_char(fp); delete [] buf; + buf = read_char(fp); delete [] buf; + buf = read_char(fp); delete [] buf; + } + + // nfix = # of fix entries with peratom info + + int nfix_peratom = read_int(fp); + + // read each entry with id string, style string, maxsize of one atom data + + for (int i = 0; i < nfix_peratom; i++) { + buf = read_char(fp); delete [] buf; + buf = read_char(fp); delete [] buf; + n = read_int(fp); + } +} + +// --------------------------------------------------------------------- +// read atom info from restart file and store in data struct +// --------------------------------------------------------------------- + +int atom(double *buf, Data &data) +{ + // allocate per-atom arrays + + if (data.iatoms == 0) { + + // common to all atom styles + + data.x = new double[data.natoms]; + data.y = new double[data.natoms]; + data.z = new double[data.natoms]; + data.tag = new int[data.natoms]; + data.type = new int[data.natoms]; + data.mask = new int[data.natoms]; + data.image = new int[data.natoms]; + data.vx = new double[data.natoms]; + data.vy = new double[data.natoms]; + data.vz = new double[data.natoms]; + + // style-specific arrays + // don't worry about re-allocating if style = hybrid + + if (data.style_angle) allocate_angle(data); + if (data.style_atomic) allocate_atomic(data); + if (data.style_bond) allocate_bond(data); + if (data.style_charge) allocate_charge(data); + if (data.style_dipole) allocate_dipole(data); + if (data.style_ellipsoid) allocate_ellipsoid(data); + if (data.style_full) allocate_full(data); + if (data.style_molecular) allocate_molecular(data); + if (data.style_peri) allocate_peri(data); + if (data.style_sphere) allocate_sphere(data); + } + + // read atom quantities from buf + // if hybrid, loop over all sub-styles in order listed + // if hybrid, loop index k will match style setting to insure correct order + + int nloop = 1; + if (data.style_hybrid) nloop = data.style_hybrid; + + int iatoms = data.iatoms; + int m = 0; + for (int k = 1; k <= nloop; k++) { + if (k == data.style_angle) m += atom_angle(&buf[m],data,iatoms); + if (k == data.style_atomic) m += atom_atomic(&buf[m],data,iatoms); + if (k == data.style_bond) m += atom_bond(&buf[m],data,iatoms); + if (k == data.style_charge) m += atom_charge(&buf[m],data,iatoms); + if (k == data.style_dipole) m += atom_dipole(&buf[m],data,iatoms); + if (k == data.style_ellipsoid) m += atom_ellipsoid(&buf[m],data,iatoms); + if (k == data.style_full) m += atom_full(&buf[m],data,iatoms); + if (k == data.style_molecular) m += atom_molecular(&buf[m],data,iatoms); + if (k == data.style_peri) m += atom_peri(&buf[m],data,iatoms); + if (k == data.style_sphere) m += atom_sphere(&buf[m],data,iatoms); + } + + data.iatoms++; + m = static_cast (buf[0]); + return m; +} + +// --------------------------------------------------------------------- +// read one atom's info from buffer +// one routine per atom style +// --------------------------------------------------------------------- + +int atom_angle(double *buf, Data &data, int iatoms) +{ + int type,atom1,atom2,atom3; + + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.molecule[iatoms] = static_cast (buf[m++]); + + int n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] < atom1 ) { + data.bond_type[data.ibonds] = type; + data.bond_atom1[data.ibonds] = data.tag[iatoms]; + data.bond_atom2[data.ibonds] = atom1; + data.ibonds++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.angle_type[data.iangles] = type; + data.angle_atom1[data.iangles] = atom1; + data.angle_atom2[data.iangles] = atom2; + data.angle_atom3[data.iangles] = atom3; + data.iangles++; + } + } + + return m; +} + +int atom_atomic(double *buf, Data &data, int iatoms) +{ + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + return m; +} + +int atom_bond(double *buf, Data &data, int iatoms) +{ + int type,atom1; + + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.molecule[iatoms] = static_cast (buf[m++]); + + int n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] < atom1) { + data.bond_type[data.ibonds] = type; + data.bond_atom1[data.ibonds] = data.tag[iatoms]; + data.bond_atom2[data.ibonds] = atom1; + data.ibonds++; + } + } + + return m; +} + +int atom_charge(double *buf, Data &data, int iatoms) +{ + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.q[iatoms] = buf[m++]; + + return m; +} + +int atom_dipole(double *buf, Data &data, int iatoms) +{ + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.q[iatoms] = buf[m++]; + data.mux[iatoms] = buf[m++]; + data.muy[iatoms] = buf[m++]; + data.muz[iatoms] = buf[m++]; + + return m; +} + +int atom_ellipsoid(double *buf, Data &data, int iatoms) +{ + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.rmass[iatoms] = buf[m++]; + data.angmomx[iatoms] = buf[m++]; + data.angmomy[iatoms] = buf[m++]; + data.angmomz[iatoms] = buf[m++]; + data.ellipsoid[iatoms] = static_cast (buf[m++]); + + if (data.ellipsoid[iatoms]) { + data.nellipsoids++; + data.shapex[iatoms] = buf[m++]; + data.shapey[iatoms] = buf[m++]; + data.shapez[iatoms] = buf[m++]; + data.quatw[iatoms] = buf[m++]; + data.quati[iatoms] = buf[m++]; + data.quatj[iatoms] = buf[m++]; + data.quatk[iatoms] = buf[m++]; + data.density[iatoms] = data.rmass[iatoms] / + (4.0*PI/3.0 * + data.shapex[iatoms]*data.shapey[iatoms]*data.shapez[iatoms]); + } else data.density[iatoms] = data.rmass[iatoms]; + + return m; +} + +int atom_sphere(double *buf, Data &data, int iatoms) +{ + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.radius[iatoms] = buf[m++]; + data.rmass[iatoms] = buf[m++]; + if (data.radius[iatoms] == 0.0) data.density[iatoms] = data.rmass[iatoms]; + else + data.density[iatoms] = data.rmass[iatoms] / + (4.0*PI/3.0 * + data.radius[iatoms]*data.radius[iatoms]*data.radius[iatoms]); + data.omegax[iatoms] = buf[m++]; + data.omegay[iatoms] = buf[m++]; + data.omegaz[iatoms] = buf[m++]; + + return m; +} + +int atom_full(double *buf, Data &data, int iatoms) +{ + int type,atom1,atom2,atom3,atom4; + + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.q[iatoms] = buf[m++]; + data.molecule[iatoms] = static_cast (buf[m++]); + + int n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] < atom1) { + data.bond_type[data.ibonds] = type; + data.bond_atom1[data.ibonds] = data.tag[iatoms]; + data.bond_atom2[data.ibonds] = atom1; + data.ibonds++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.angle_type[data.iangles] = type; + data.angle_atom1[data.iangles] = atom1; + data.angle_atom2[data.iangles] = atom2; + data.angle_atom3[data.iangles] = atom3; + data.iangles++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + atom4 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.dihedral_type[data.idihedrals] = type; + data.dihedral_atom1[data.idihedrals] = atom1; + data.dihedral_atom2[data.idihedrals] = atom2; + data.dihedral_atom3[data.idihedrals] = atom3; + data.dihedral_atom4[data.idihedrals] = atom4; + data.idihedrals++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + atom4 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.improper_type[data.iimpropers] = type; + data.improper_atom1[data.iimpropers] = atom1; + data.improper_atom2[data.iimpropers] = atom2; + data.improper_atom3[data.iimpropers] = atom3; + data.improper_atom4[data.iimpropers] = atom4; + data.iimpropers++; + } + } + + return m; +} + +int atom_molecular(double *buf, Data &data, int iatoms) +{ + int type,atom1,atom2,atom3,atom4; + + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.molecule[iatoms] = static_cast (buf[m++]); + + int n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] < atom1) { + data.bond_type[data.ibonds] = type; + data.bond_atom1[data.ibonds] = data.tag[iatoms]; + data.bond_atom2[data.ibonds] = atom1; + data.ibonds++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.angle_type[data.iangles] = type; + data.angle_atom1[data.iangles] = atom1; + data.angle_atom2[data.iangles] = atom2; + data.angle_atom3[data.iangles] = atom3; + data.iangles++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + atom4 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.dihedral_type[data.idihedrals] = type; + data.dihedral_atom1[data.idihedrals] = atom1; + data.dihedral_atom2[data.idihedrals] = atom2; + data.dihedral_atom3[data.idihedrals] = atom3; + data.dihedral_atom4[data.idihedrals] = atom4; + data.idihedrals++; + } + } + + n = static_cast (buf[m++]); + for (int k = 0; k < n; k++) { + type = static_cast (buf[m++]); + atom1 = static_cast (buf[m++]); + atom2 = static_cast (buf[m++]); + atom3 = static_cast (buf[m++]); + atom4 = static_cast (buf[m++]); + if (data.newton_bond || data.tag[iatoms] == atom2) { + data.improper_type[data.iimpropers] = type; + data.improper_atom1[data.iimpropers] = atom1; + data.improper_atom2[data.iimpropers] = atom2; + data.improper_atom3[data.iimpropers] = atom3; + data.improper_atom4[data.iimpropers] = atom4; + data.iimpropers++; + } + } + + return m; +} + +int atom_peri(double *buf, Data &data, int iatoms) +{ + int m = 1; + data.x[iatoms] = buf[m++]; + data.y[iatoms] = buf[m++]; + data.z[iatoms] = buf[m++]; + data.tag[iatoms] = static_cast (buf[m++]); + data.type[iatoms] = static_cast (buf[m++]); + data.mask[iatoms] = static_cast (buf[m++]); + data.image[iatoms] = static_cast (buf[m++]); + data.vx[iatoms] = buf[m++]; + data.vy[iatoms] = buf[m++]; + data.vz[iatoms] = buf[m++]; + + data.vfrac[iatoms] = buf[m++]; + data.rmass[iatoms] = buf[m++]; + data.s0[iatoms] = buf[m++]; + data.x0x[iatoms] = buf[m++]; + data.x0y[iatoms] = buf[m++]; + data.x0z[iatoms] = buf[m++]; + + return m; +} + +// --------------------------------------------------------------------- +// per-atom memory allocation routines +// one routine per atom style +// --------------------------------------------------------------------- + +void allocate_angle(Data &data) +{ + data.molecule = new int[data.natoms]; + data.bond_type = new int[data.nbonds]; + data.bond_atom1 = new int[data.nbonds]; + data.bond_atom2 = new int[data.nbonds]; + data.angle_type = new int[data.nangles]; + data.angle_atom1 = new int[data.nangles]; + data.angle_atom2 = new int[data.nangles]; + data.angle_atom3 = new int[data.nangles]; +} + +void allocate_atomic(Data &data) {} + +void allocate_bond(Data &data) +{ + data.molecule = new int[data.natoms]; + data.bond_type = new int[data.nbonds]; + data.bond_atom1 = new int[data.nbonds]; + data.bond_atom2 = new int[data.nbonds]; +} + +void allocate_charge(Data &data) +{ + data.q = new double[data.natoms]; +} + +void allocate_dipole(Data &data) +{ + data.q = new double[data.natoms]; + data.mux = new double[data.natoms]; + data.muy = new double[data.natoms]; + data.muz = new double[data.natoms]; +} + +void allocate_full(Data &data) +{ + data.q = new double[data.natoms]; + data.molecule = new int[data.natoms]; + data.bond_type = new int[data.nbonds]; + data.bond_atom1 = new int[data.nbonds]; + data.bond_atom2 = new int[data.nbonds]; + data.angle_type = new int[data.nangles]; + data.angle_atom1 = new int[data.nangles]; + data.angle_atom2 = new int[data.nangles]; + data.angle_atom3 = new int[data.nangles]; + data.dihedral_type = new int[data.ndihedrals]; + data.dihedral_atom1 = new int[data.ndihedrals]; + data.dihedral_atom2 = new int[data.ndihedrals]; + data.dihedral_atom3 = new int[data.ndihedrals]; + data.dihedral_atom4 = new int[data.ndihedrals]; + data.improper_type = new int[data.nimpropers]; + data.improper_atom1 = new int[data.nimpropers]; + data.improper_atom2 = new int[data.nimpropers]; + data.improper_atom3 = new int[data.nimpropers]; + data.improper_atom4 = new int[data.nimpropers]; +} + +void allocate_ellipsoid(Data &data) +{ + data.rmass = new double[data.natoms]; + data.density = new double[data.natoms]; + data.angmomx = new double[data.natoms]; + data.angmomy = new double[data.natoms]; + data.angmomz = new double[data.natoms]; + data.ellipsoid = new int[data.natoms]; + data.quatw = new double[data.natoms]; + data.shapex = new double[data.natoms]; + data.shapey = new double[data.natoms]; + data.shapez = new double[data.natoms]; + data.quati = new double[data.natoms]; + data.quatj = new double[data.natoms]; + data.quatk = new double[data.natoms]; +} + +void allocate_sphere(Data &data) +{ + data.radius = new double[data.natoms]; + data.rmass = new double[data.natoms]; + data.density = new double[data.natoms]; + data.omegax = new double[data.natoms]; + data.omegay = new double[data.natoms]; + data.omegaz = new double[data.natoms]; +} + +void allocate_molecular(Data &data) +{ + data.molecule = new int[data.natoms]; + data.bond_type = new int[data.nbonds]; + data.bond_atom1 = new int[data.nbonds]; + data.bond_atom2 = new int[data.nbonds]; + data.angle_type = new int[data.nangles]; + data.angle_atom1 = new int[data.nangles]; + data.angle_atom2 = new int[data.nangles]; + data.angle_atom3 = new int[data.nangles]; + data.dihedral_type = new int[data.ndihedrals]; + data.dihedral_atom1 = new int[data.ndihedrals]; + data.dihedral_atom2 = new int[data.ndihedrals]; + data.dihedral_atom3 = new int[data.ndihedrals]; + data.dihedral_atom4 = new int[data.ndihedrals]; + data.improper_type = new int[data.nimpropers]; + data.improper_atom1 = new int[data.nimpropers]; + data.improper_atom2 = new int[data.nimpropers]; + data.improper_atom3 = new int[data.nimpropers]; + data.improper_atom4 = new int[data.nimpropers]; +} + +void allocate_peri(Data &data) +{ + data.vfrac = new double[data.natoms]; + data.rmass = new double[data.natoms]; + data.s0 = new double[data.natoms]; + data.x0x = new double[data.natoms]; + data.x0y = new double[data.natoms]; + data.x0z = new double[data.natoms]; +} + +// --------------------------------------------------------------------- +// pair coeffs +// one section for each pair style +// flag = 1, read all coeff info and allocation arrays +// flag = 0, just read global settings (when called recursively by hybrid) +// --------------------------------------------------------------------- + +void pair(FILE *fp, Data &data, char *style, int flag) +{ + int i,j,m; + int itmp; + double rtmp; + + if (strcmp(style,"none") == 0) { + + } else if (strcmp(style,"adp") == 0) { + } else if (strcmp(style,"airebo") == 0) { + + } else if (strcmp(style,"born/coul/long") == 0) { + double cut_lj_global = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_born_A = new double[data.ntypes+1]; + data.pair_born_rho = new double[data.ntypes+1]; + data.pair_born_sigma = new double[data.ntypes+1]; + data.pair_born_C = new double[data.ntypes+1]; + data.pair_born_D = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_born_A[i] = read_double(fp); + data.pair_born_rho[i] = read_double(fp); + data.pair_born_sigma[i] = read_double(fp); + data.pair_born_C[i] = read_double(fp); + data.pair_born_D[i] = read_double(fp); + double cut_lj = read_double(fp); + } else { + double born_A = read_double(fp); + double born_rho = read_double(fp); + double born_sigma = read_double(fp); + double born_C = read_double(fp); + double born_D = read_double(fp); + double cut_lj = read_double(fp); + } + } + } + + } else if ((strcmp(style,"buck") == 0) || + (strcmp(style,"buck/coul/cut") == 0) || + (strcmp(style,"buck/coul/long") == 0) || + (strcmp(style,"buck/coul") == 0)) { + + if (strcmp(style,"buck") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"buck/coul/cut") == 0) { + m = 1; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"buck/coul/long") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"buck/coul") == 0) { + m = 0; + double cut_buck_global = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + int ewald_order = read_int(fp); + } + + if (!flag) return; + + data.pair_buck_A = new double[data.ntypes+1]; + data.pair_buck_rho = new double[data.ntypes+1]; + data.pair_buck_C = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_buck_A[i] = read_double(fp); + data.pair_buck_rho[i] = read_double(fp); + data.pair_buck_C[i] = read_double(fp); + double cut_lj = read_double(fp); + if (m) double cut_coul = read_double(fp); + } else { + double buck_A = read_double(fp); + double buck_rho = read_double(fp); + double buck_C = read_double(fp); + double cut_lj = read_double(fp); + if (m) double cut_coul = read_double(fp); + } + } + } + + } else if (strcmp(style,"colloid") == 0) { + + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_colloid_A12 = new double[data.ntypes+1]; + data.pair_colloid_sigma = new double[data.ntypes+1]; + data.pair_colloid_d1 = new double[data.ntypes+1]; + data.pair_colloid_d2 = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_colloid_A12[i] = read_double(fp); + data.pair_colloid_sigma[i] = read_double(fp); + data.pair_colloid_d1[i] = read_double(fp); + data.pair_colloid_d2[i] = read_double(fp); + double cut_lj = read_double(fp); + } else { + double colloid_A12 = read_double(fp); + double colloid_sigma = read_double(fp); + double colloid_d1 = read_double(fp); + double colloid_d2 = read_double(fp); + double cut_lj = read_double(fp); + } + } + } + + } else if ((strcmp(style,"coul/cut") == 0) || + (strcmp(style,"coul/debye") == 0) || + (strcmp(style,"coul/long") == 0)) { + + if (strcmp(style,"coul/cut") == 0) { + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"coul/debye") == 0) { + m = 1; + double cut_coul = read_double(fp); + double kappa = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"coul/long") == 0) { + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } + + if (!flag) return; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + double cut_coul = read_double(fp); + } else { + double cut_coul = read_double(fp); + } + } + } + + } else if (strcmp(style,"dipole/cut") == 0) { + + double cut_lj_global = read_double(fp); + double cut_coul_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_dipole_epsilon = new double[data.ntypes+1]; + data.pair_dipole_sigma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_dipole_epsilon[i] = read_double(fp); + data.pair_dipole_sigma[i] = read_double(fp); + double cut_lj = read_double(fp); + double cut_coul = read_double(fp); + } else { + double dipole_epsilon = read_double(fp); + double dipole_sigma = read_double(fp); + double cut_lj = read_double(fp); + double cut_coul = read_double(fp); + } + } + } + + } else if (strcmp(style,"dpd") == 0) { + + double temperature = read_double(fp); + double cut_global = read_double(fp); + int seed = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_dpd_a0 = new double[data.ntypes+1]; + data.pair_dpd_gamma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_dpd_a0[i] = read_double(fp); + data.pair_dpd_gamma[i] = read_double(fp); + double cut = read_double(fp); + } else { + double dpd_a0 = read_double(fp); + double dpd_gamma = read_double(fp); + double cut = read_double(fp); + } + } + } + + } else if (strcmp(style,"dpd/tstat") == 0) { + + double tstart = read_double(fp); + double tstop = read_double(fp); + double cut_global = read_double(fp); + int seed = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_dpd_a0 = new double[data.ntypes+1]; + data.pair_dpd_gamma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_dpd_a0[i] = read_double(fp); + data.pair_dpd_gamma[i] = read_double(fp); + double cut = read_double(fp); + } else { + double dpd_a0 = read_double(fp); + double dpd_gamma = read_double(fp); + double cut = read_double(fp); + } + } + } + + } else if (strcmp(style,"eam") == 0) { + } else if (strcmp(style,"eam/alloy") == 0) { + } else if (strcmp(style,"eam/fs") == 0) { + } else if (strcmp(style,"eim") == 0) { + + } else if (strcmp(style,"eff/cut") == 0) { + + double cut_coul = read_double(fp); + int limit_size_flag = read_int(fp); + int flexible_pressure_flag = read_int(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + double cut = read_double(fp); + } else { + double cut = read_double(fp); + } + } + } + + } else if (strcmp(style,"gayberne") == 0) { + + double gamma = read_double(fp); + double upsilon = read_double(fp); + double mu = read_double(fp); + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_gb_epsilon = new double[data.ntypes+1]; + data.pair_gb_sigma = new double[data.ntypes+1]; + data.pair_gb_epsa = new double[data.ntypes+1]; + data.pair_gb_epsb = new double[data.ntypes+1]; + data.pair_gb_epsc = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) { + itmp = read_int(fp); + if (itmp) { + data.pair_gb_epsa[i] = read_double(fp); + data.pair_gb_epsb[i] = read_double(fp); + data.pair_gb_epsc[i] = read_double(fp); + data.pair_gb_epsa[i] = pow(data.pair_gb_epsa[i],-mu); + data.pair_gb_epsb[i] = pow(data.pair_gb_epsb[i],-mu); + data.pair_gb_epsc[i] = pow(data.pair_gb_epsc[i],-mu); + } + + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_gb_epsilon[i] = read_double(fp); + data.pair_gb_sigma[i] = read_double(fp); + double cut = read_double(fp); + } else { + double gb_epsilon = read_double(fp); + double gb_sigma = read_double(fp); + double cut = read_double(fp); + } + } + } + } + + } else if ((strcmp(style,"gran/hooke") == 0) || + (strcmp(style,"gran/hooke/history") == 0) || + (strcmp(style,"gran/hertz/history") == 0)) { + + double kn = read_double(fp); + double kt = read_double(fp); + double gamman = read_double(fp); + double gammat = read_double(fp); + double xmu = read_double(fp); + int dampflag = read_int(fp); + + if (!flag) return; + + for (i = 1; i <= data.ntypes; i++) { + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + } + } + + } else if ((strcmp(style,"lj/charmm/coul/charmm") == 0) || + (strcmp(style,"lj/charmm/coul/charmm/implicit") == 0) || + (strcmp(style,"lj/charmm/coul/long") == 0)) { + + if (strcmp(style,"lj/charmm/coul/charmm") == 0) { + double cut_lj_inner = read_double(fp); + double cut_lj = read_double(fp); + double cut_coul_inner = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/charmm/coul/charmm/implicit") == 0) { + double cut_lj_inner = read_double(fp); + double cut_lj = read_double(fp); + double cut_coul_inner = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/charmm/coul/long") == 0) { + double cut_lj_inner = read_double(fp); + double cut_lj = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } + + if (!flag) return; + + data.pair_charmm_epsilon = new double[data.ntypes+1]; + data.pair_charmm_sigma = new double[data.ntypes+1]; + data.pair_charmm_eps14 = new double[data.ntypes+1]; + data.pair_charmm_sigma14 = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_charmm_epsilon[i] = read_double(fp); + data.pair_charmm_sigma[i] = read_double(fp); + data.pair_charmm_eps14[i] = read_double(fp); + data.pair_charmm_sigma14[i] = read_double(fp); + } else { + double charmm_epsilon = read_double(fp); + double charmm_sigma = read_double(fp); + double charmm_eps14 = read_double(fp); + double charmm_sigma14 = read_double(fp); + } + } + } + + } else if ((strcmp(style,"lj/class2") == 0) || + (strcmp(style,"lj/class2/coul/cut") == 0) || + (strcmp(style,"lj/class2/coul/long") == 0)) { + + if (strcmp(style,"lj/class2") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/class2/coul/cut") == 0) { + m = 1; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/class2/coul/long") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } + + if (!flag) return; + + data.pair_class2_epsilon = new double[data.ntypes+1]; + data.pair_class2_sigma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_class2_epsilon[i] = read_double(fp); + data.pair_class2_sigma[i] = read_double(fp); + double cut_lj = read_double(fp); + if (m) double cut_coul = read_double(fp); + } else { + double class2_epsilon = read_double(fp); + double class2_sigma = read_double(fp); + double cut_lj = read_double(fp); + if (m) double cut_coul = read_double(fp); + } + } + } + + } else if ((strcmp(style,"lj/cut") == 0) || + (strcmp(style,"lj96/cut") == 0) || + (strcmp(style,"lj/cut/coul/cut") == 0) || + (strcmp(style,"lj/cut/coul/debye") == 0) || + (strcmp(style,"lj/cut/coul/long") == 0) || + (strcmp(style,"lj/cut/coul/long/tip4p") == 0) || + (strcmp(style,"lj/coul") == 0)) { + + if (strcmp(style,"lj/cut") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj96/cut") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/cut/coul/cut") == 0) { + m = 1; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/cut/coul/debye") == 0) { + m = 1; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + double kappa = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/cut/coul/long") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/cut/coul/long/tip4p") == 0) { + m = 0; + int typeO = read_int(fp); + int typeH = read_int(fp); + int typeB = read_int(fp); + int typeA = read_int(fp); + double qdist = read_double(fp); + double cut_lj_global = read_double(fp); + double cut_lj_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/coul") == 0) { + m = 0; + double cut_lj_global = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + int ewald_order = read_int(fp); + } + + if (!flag) return; + + data.pair_lj_epsilon = new double[data.ntypes+1]; + data.pair_lj_sigma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_lj_epsilon[i] = read_double(fp); + data.pair_lj_sigma[i] = read_double(fp); + double cut_lj = read_double(fp); + if (m) double cut_coul = read_double(fp); + } else { + double lj_epsilon = read_double(fp); + double lj_sigma = read_double(fp); + double cut_lj = read_double(fp); + if (m) double cut_coul = read_double(fp); + } + } + } + + } else if (strcmp(style,"lj/expand") == 0) { + + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_ljexpand_epsilon = new double[data.ntypes+1]; + data.pair_ljexpand_sigma = new double[data.ntypes+1]; + data.pair_ljexpand_shift = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_ljexpand_epsilon[i] = read_double(fp); + data.pair_ljexpand_sigma[i] = read_double(fp); + data.pair_ljexpand_shift[i] = read_double(fp); + double cut_lj = read_double(fp); + } else { + double ljexpand_epsilon = read_double(fp); + double ljexpand_sigma = read_double(fp); + double ljexpand_shift = read_double(fp); + double cut_lj = read_double(fp); + } + } + } + + } else if ((strcmp(style,"lj/gromacs") == 0) || + (strcmp(style,"lj/gromacs/coul/gromacs") == 0)) { + + if (strcmp(style,"lj/gromacs") == 0) { + m = 1; + double cut_inner_global = read_double(fp); + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } else if (strcmp(style,"lj/gromacs/coul/gromacs") == 0) { + m = 0; + double cut_lj_inner_global = read_double(fp); + double cut_lj = read_double(fp); + double cut_coul_inner_global = read_double(fp); + double cut_coul = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + } + + if (!flag) return; + + data.pair_ljgromacs_epsilon = new double[data.ntypes+1]; + data.pair_ljgromacs_sigma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_ljgromacs_epsilon[i] = read_double(fp); + data.pair_ljgromacs_sigma[i] = read_double(fp); + if (m) { + double cut_inner = read_double(fp); + double cut = read_double(fp); + } + } else { + double ljgromacs_epsilon = read_double(fp); + double ljgromacs_sigma = read_double(fp); + if (m) { + double cut_inner = read_double(fp); + double cut = read_double(fp); + } + } + } + } + + } else if (strcmp(style,"lj/smooth") == 0) { + + double cut_inner_global = read_double(fp); + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_ljsmooth_epsilon = new double[data.ntypes+1]; + data.pair_ljsmooth_sigma = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_ljsmooth_epsilon[i] = read_double(fp); + data.pair_ljsmooth_sigma[i] = read_double(fp); + double cut_inner = read_double(fp); + double cut = read_double(fp); + } else { + double ljsmooth_epsilon = read_double(fp); + double ljsmooth_sigma = read_double(fp); + double cut_inner = read_double(fp); + double cut = read_double(fp); + } + } + } + + } else if (strcmp(style,"meam") == 0) { + + } else if (strcmp(style,"morse") == 0) { + + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_morse_d0 = new double[data.ntypes+1]; + data.pair_morse_alpha = new double[data.ntypes+1]; + data.pair_morse_r0 = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_morse_d0[i] = read_double(fp); + data.pair_morse_alpha[i] = read_double(fp); + data.pair_morse_r0[i] = read_double(fp); + double cut = read_double(fp); + } else { + double morse_d0 = read_double(fp); + double morse_alpha = read_double(fp); + double morse_r0 = read_double(fp); + double cut = read_double(fp); + } + } + } + + } else if (strcmp(style,"reax") == 0) { + } else if (strcmp(style,"reax/c") == 0) { + + } else if (strcmp(style,"soft") == 0) { + + double cut_global = read_double(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_soft_A = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_soft_A[i] = read_double(fp); + double cut = read_double(fp); + } else { + double soft_A = read_double(fp); + double cut = read_double(fp); + } + } + } + + } else if (strcmp(style,"sw") == 0) { + + } else if (strcmp(style,"table") == 0) { + + int tabstyle = read_int(fp); + int n = read_int(fp); + + } else if (strcmp(style,"tersoff") == 0) { + } else if (strcmp(style,"tersoff/zbl") == 0) { + + } else if (strcmp(style,"yukawa") == 0) { + + double kappa = read_double(fp); + double cut_global = read_double(fp); + int offset_flag = read_int(fp); + int mix_flag = read_int(fp); + + if (!flag) return; + + data.pair_yukawa_A = new double[data.ntypes+1]; + + for (i = 1; i <= data.ntypes; i++) + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + if (i == j) { + data.pair_yukawa_A[i] = read_double(fp); + double cut = read_double(fp); + } else { + double yukawa_A = read_double(fp); + double cut = read_double(fp); + } + } + } + + } else if ((strcmp(style,"cg/cmm") == 0) || + (strcmp(style,"cg/cmm/coul/cut") == 0) || + (strcmp(style,"cg/cmm/coul/long") == 0)) { + m = 0; + data.cut_lj_global = read_double(fp); + data.cut_coul_global = read_double(fp); + data.kappa = read_double(fp); + data.offset_flag = read_int(fp); + data.mix_flag = read_int(fp); + + if (!flag) return; + + const int numtyp=data.ntypes+1; + data.pair_cg_cmm_type = new int*[numtyp]; + data.pair_setflag = new int*[numtyp]; + data.pair_cg_epsilon = new double*[numtyp]; + data.pair_cg_sigma = new double*[numtyp]; + data.pair_cut_lj = new double*[numtyp]; + if ((strcmp(style,"cg/cmm/coul/cut") == 0) || + (strcmp(style,"cg/cmm/coul/long") == 0)) { + data.pair_cut_coul = new double*[numtyp]; + m=1; + } else { + data.pair_cut_coul = NULL; + m=0; + } + + for (i = 1; i <= data.ntypes; i++) { + data.pair_cg_cmm_type[i] = new int[numtyp]; + data.pair_setflag[i] = new int[numtyp]; + data.pair_cg_epsilon[i] = new double[numtyp]; + data.pair_cg_sigma[i] = new double[numtyp]; + data.pair_cut_lj[i] = new double[numtyp]; + if ((strcmp(style,"cg/cmm/coul/cut") == 0) || + (strcmp(style,"cg/cmm/coul/long") == 0)) { + data.pair_cut_coul[i] = new double[numtyp]; + } + + for (j = i; j <= data.ntypes; j++) { + itmp = read_int(fp); + data.pair_setflag[i][j] = itmp; + if (i == j && itmp == 0) { + printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j); + exit(1); + } + if (itmp) { + data.pair_cg_cmm_type[i][j] = read_int(fp); + data.pair_cg_epsilon[i][j] = read_double(fp); + data.pair_cg_sigma[i][j] = read_double(fp); + data.pair_cut_lj[i][j] = read_double(fp); + if (m) { + data.pair_cut_lj[i][j] = read_double(fp); + data.pair_cut_coul[i][j] = read_double(fp); + } + } + } + } + + } else if ((strcmp(style,"hybrid") == 0) || + (strcmp(style,"hybrid/overlay") == 0)) { + + // for each substyle of hybrid, + // read its settings by calling pair() recursively with flag = 0 + // so that coeff array allocation is skipped + + int nstyles = read_int(fp); + for (int i = 0; i < nstyles; i++) { + char *substyle = read_char(fp); + pair(fp,data,substyle,0); + } + + } else { + printf("ERROR: Unknown pair style %s\n",style); + exit(1); + } +} + +// --------------------------------------------------------------------- +// bond coeffs +// one section for each bond style +// --------------------------------------------------------------------- + +void bond(FILE *fp, Data &data) +{ + if (strcmp(data.bond_style,"none") == 0) { + + } else if (strcmp(data.bond_style,"class2") == 0) { + + data.bond_class2_r0 = new double[data.nbondtypes+1]; + data.bond_class2_k2 = new double[data.nbondtypes+1]; + data.bond_class2_k3 = new double[data.nbondtypes+1]; + data.bond_class2_k4 = new double[data.nbondtypes+1]; + fread(&data.bond_class2_r0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_class2_k2[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_class2_k3[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_class2_k4[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"fene") == 0) { + + data.bond_fene_k = new double[data.nbondtypes+1]; + data.bond_fene_r0 = new double[data.nbondtypes+1]; + data.bond_fene_epsilon = new double[data.nbondtypes+1]; + data.bond_fene_sigma = new double[data.nbondtypes+1]; + fread(&data.bond_fene_k[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_fene_r0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_fene_epsilon[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_fene_sigma[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"fene/expand") == 0) { + + data.bond_feneexpand_k = new double[data.nbondtypes+1]; + data.bond_feneexpand_r0 = new double[data.nbondtypes+1]; + data.bond_feneexpand_epsilon = new double[data.nbondtypes+1]; + data.bond_feneexpand_sigma = new double[data.nbondtypes+1]; + data.bond_feneexpand_shift = new double[data.nbondtypes+1]; + fread(&data.bond_feneexpand_k[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_feneexpand_r0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_feneexpand_epsilon[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_feneexpand_sigma[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_feneexpand_shift[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"harmonic") == 0) { + + data.bond_harmonic_k = new double[data.nbondtypes+1]; + data.bond_harmonic_r0 = new double[data.nbondtypes+1]; + fread(&data.bond_harmonic_k[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_harmonic_r0[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"harmonicshift") == 0) { + + data.bond_harmonicshift_umin = new double[data.nbondtypes+1]; + data.bond_harmonicshift_r0 = new double[data.nbondtypes+1]; + data.bond_harmonicshift_rc = new double[data.nbondtypes+1]; + fread(&data.bond_harmonicshift_umin[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_harmonicshift_r0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_harmonicshift_rc[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"harmonicshiftcut") == 0) { + + data.bond_harmonicshiftcut_umin = new double[data.nbondtypes+1]; + data.bond_harmonicshiftcut_r0 = new double[data.nbondtypes+1]; + data.bond_harmonicshiftcut_rc = new double[data.nbondtypes+1]; + fread(&data.bond_harmonicshiftcut_umin[1],sizeof(double), + data.nbondtypes,fp); + fread(&data.bond_harmonicshiftcut_r0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_harmonicshiftcut_rc[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"morse") == 0) { + + data.bond_morse_d0 = new double[data.nbondtypes+1]; + data.bond_morse_alpha = new double[data.nbondtypes+1]; + data.bond_morse_r0 = new double[data.nbondtypes+1]; + fread(&data.bond_morse_d0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_morse_alpha[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_morse_r0[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"nonlinear") == 0) { + + data.bond_nonlinear_epsilon = new double[data.nbondtypes+1]; + data.bond_nonlinear_r0 = new double[data.nbondtypes+1]; + data.bond_nonlinear_lamda = new double[data.nbondtypes+1]; + fread(&data.bond_nonlinear_epsilon[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_nonlinear_r0[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_nonlinear_lamda[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"quartic") == 0) { + + data.bond_quartic_k = new double[data.nbondtypes+1]; + data.bond_quartic_b1 = new double[data.nbondtypes+1]; + data.bond_quartic_b2 = new double[data.nbondtypes+1]; + data.bond_quartic_rc = new double[data.nbondtypes+1]; + data.bond_quartic_u0 = new double[data.nbondtypes+1]; + fread(&data.bond_quartic_k[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_quartic_b1[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_quartic_b2[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_quartic_rc[1],sizeof(double),data.nbondtypes,fp); + fread(&data.bond_quartic_u0[1],sizeof(double),data.nbondtypes,fp); + + } else if (strcmp(data.bond_style,"table") == 0) { + + int tabstyle = read_int(fp); + int n = read_int(fp); + + } else if (strcmp(data.bond_style,"hybrid") == 0) { + + int nstyles = read_int(fp); + for (int i = 0; i < nstyles; i++) + char *substyle = read_char(fp); + + } else { + printf("ERROR: Unknown bond style %s\n",data.bond_style); + exit(1); + } +} + +// --------------------------------------------------------------------- +// angle coeffs +// one section for each angle style +// --------------------------------------------------------------------- + +void angle(FILE *fp, Data &data) +{ + if (strcmp(data.angle_style,"none") == 0) { + + } else if (strcmp(data.angle_style,"cg/cmm") == 0) { + + data.angle_harmonic_k = new double[data.nangletypes+1]; + data.angle_harmonic_theta0 = new double[data.nangletypes+1]; + data.angle_cg_cmm_epsilon = new double[data.nangletypes+1]; + data.angle_cg_cmm_sigma = new double[data.nangletypes+1]; + double *angle_cg_cmm_rcut = new double[data.nangletypes+1]; + data.angle_cg_cmm_type = new int[data.nangletypes+1]; + + fread(&data.angle_harmonic_k[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_harmonic_theta0[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_cg_cmm_epsilon[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_cg_cmm_sigma[1],sizeof(double),data.nangletypes,fp); + fread(angle_cg_cmm_rcut,sizeof(double),data.nangletypes,fp); + fread(&data.angle_cg_cmm_type[1],sizeof(int),data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"charmm") == 0) { + + data.angle_charmm_k = new double[data.nangletypes+1]; + data.angle_charmm_theta0 = new double[data.nangletypes+1]; + data.angle_charmm_k_ub = new double[data.nangletypes+1]; + data.angle_charmm_r_ub = new double[data.nangletypes+1]; + fread(&data.angle_charmm_k[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_charmm_theta0[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_charmm_k_ub[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_charmm_r_ub[1],sizeof(double),data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"class2") == 0) { + + data.angle_class2_theta0 = new double[data.nangletypes+1]; + data.angle_class2_k2 = new double[data.nangletypes+1]; + data.angle_class2_k3 = new double[data.nangletypes+1]; + data.angle_class2_k4 = new double[data.nangletypes+1]; + + data.angle_class2_bb_k = new double[data.nangletypes+1]; + data.angle_class2_bb_r1 = new double[data.nangletypes+1]; + data.angle_class2_bb_r2 = new double[data.nangletypes+1]; + + data.angle_class2_ba_k1 = new double[data.nangletypes+1]; + data.angle_class2_ba_k2 = new double[data.nangletypes+1]; + data.angle_class2_ba_r1 = new double[data.nangletypes+1]; + data.angle_class2_ba_r2 = new double[data.nangletypes+1]; + + fread(&data.angle_class2_theta0[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_k2[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_k3[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_k4[1],sizeof(double),data.nangletypes,fp); + + fread(&data.angle_class2_bb_k[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_bb_r1[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_bb_r2[1],sizeof(double),data.nangletypes,fp); + + fread(&data.angle_class2_ba_k1[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_ba_k2[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_ba_r1[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_class2_ba_r2[1],sizeof(double),data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"cosineshift") == 0) { + + data.angle_cosineshift_umin = new double[data.nangletypes+1]; + fread(&data.angle_cosineshift_umin[1],sizeof(double),data.nangletypes,fp); + data.angle_cosineshift_cost = new double[data.nangletypes+1]; + fread(&data.angle_cosineshift_cost[1],sizeof(double),data.nangletypes,fp); + data.angle_cosineshift_sint = new double[data.nangletypes+1]; + fread(&data.angle_cosineshift_sint[1],sizeof(double),data.nangletypes,fp); + data.angle_cosineshift_theta0 = new double[data.nangletypes+1]; + fread(&data.angle_cosineshift_theta0[1],sizeof(double),data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"cosineshiftexp") == 0) { + + data.angle_cosineshiftexp_umin = new double[data.nangletypes+1]; + fread(&data.angle_cosineshiftexp_umin[1],sizeof(double), + data.nangletypes,fp); + data.angle_cosineshiftexp_a = new double[data.nangletypes+1]; + fread(&data.angle_cosineshiftexp_a[1],sizeof(double),data.nangletypes,fp); + data.angle_cosineshiftexp_cost = new double[data.nangletypes+1]; + fread(&data.angle_cosineshiftexp_cost[1],sizeof(double), + data.nangletypes,fp); + data.angle_cosineshiftexp_sint = new double[data.nangletypes+1]; + fread(&data.angle_cosineshiftexp_sint[1],sizeof(double), + data.nangletypes,fp); + data.angle_cosineshiftexp_theta0 = new double[data.nangletypes+1]; + fread(&data.angle_cosineshiftexp_theta0[1],sizeof(double), + data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"cosine") == 0) { + + data.angle_cosine_k = new double[data.nangletypes+1]; + fread(&data.angle_cosine_k[1],sizeof(double),data.nangletypes,fp); + + } else if ((strcmp(data.angle_style,"cosine/squared") == 0) || + (strcmp(data.angle_style,"cosine/delta") == 0)) { + + data.angle_cosine_squared_k = new double[data.nangletypes+1]; + data.angle_cosine_squared_theta0 = new double[data.nangletypes+1]; + fread(&data.angle_cosine_squared_k[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_cosine_squared_theta0[1], + sizeof(double),data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"harmonic") == 0) { + + data.angle_harmonic_k = new double[data.nangletypes+1]; + data.angle_harmonic_theta0 = new double[data.nangletypes+1]; + fread(&data.angle_harmonic_k[1],sizeof(double),data.nangletypes,fp); + fread(&data.angle_harmonic_theta0[1],sizeof(double),data.nangletypes,fp); + + } else if (strcmp(data.angle_style,"table") == 0) { + + int tabstyle = read_int(fp); + int n = read_int(fp); + + } else if (strcmp(data.angle_style,"hybrid") == 0) { + + int nstyles = read_int(fp); + for (int i = 0; i < nstyles; i++) + char *substyle = read_char(fp); + + } else { + printf("ERROR: Unknown angle style %s\n",data.angle_style); + exit(1); + } +} + +// --------------------------------------------------------------------- +// dihedral coeffs +// one section for each dihedral style +// --------------------------------------------------------------------- + +void dihedral(FILE *fp, Data &data) +{ + if (strcmp(data.dihedral_style,"none") == 0) { + + } else if (strcmp(data.dihedral_style,"charmm") == 0) { + + data.dihedral_charmm_k = new double[data.ndihedraltypes+1]; + data.dihedral_charmm_multiplicity = new int[data.ndihedraltypes+1]; + data.dihedral_charmm_sign = new int[data.ndihedraltypes+1]; + data.dihedral_charmm_weight = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_charmm_k[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_charmm_multiplicity[1],sizeof(int), + data.ndihedraltypes,fp); + fread(&data.dihedral_charmm_sign[1],sizeof(int),data.ndihedraltypes,fp); + fread(&data.dihedral_charmm_weight[1],sizeof(double), + data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"class2") == 0) { + + data.dihedral_class2_k1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_k2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_k3 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_phi1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_phi2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_phi3 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_mbt_f1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_mbt_f2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_mbt_f3 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_mbt_r0 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_ebt_f1_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_ebt_f2_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_ebt_f3_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_ebt_r0_1 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_ebt_f1_2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_ebt_f2_2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_ebt_f3_2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_ebt_r0_2 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_at_f1_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_at_f2_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_at_f3_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_at_theta0_1 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_at_f1_2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_at_f2_2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_at_f3_2 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_at_theta0_2 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_aat_k = new double[data.ndihedraltypes+1]; + data.dihedral_class2_aat_theta0_1 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_aat_theta0_2 = new double[data.ndihedraltypes+1]; + + data.dihedral_class2_bb13_k = new double[data.ndihedraltypes+1]; + data.dihedral_class2_bb13_r10 = new double[data.ndihedraltypes+1]; + data.dihedral_class2_bb13_r30 = new double[data.ndihedraltypes+1]; + + fread(&data.dihedral_class2_k1[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_class2_k2[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_class2_k3[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_class2_phi1[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_class2_phi2[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_class2_phi3[1],sizeof(double),data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_mbt_f1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_mbt_f2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_mbt_f3[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_mbt_r0[1],sizeof(double), + data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_ebt_f1_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_ebt_f2_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_ebt_f3_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_ebt_r0_1[1],sizeof(double), + data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_ebt_f1_2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_ebt_f2_2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_ebt_f3_2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_ebt_r0_2[1],sizeof(double), + data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_at_f1_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_at_f2_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_at_f3_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_at_theta0_1[1],sizeof(double), + data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_at_f1_2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_at_f2_2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_at_f3_2[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_at_theta0_2[1],sizeof(double), + data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_aat_k[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_aat_theta0_1[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_aat_theta0_2[1],sizeof(double), + data.ndihedraltypes,fp); + + fread(&data.dihedral_class2_bb13_k[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_bb13_r10[1],sizeof(double), + data.ndihedraltypes,fp); + fread(&data.dihedral_class2_bb13_r30[1],sizeof(double), + data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"harmonic") == 0) { + + data.dihedral_harmonic_k = new double[data.ndihedraltypes+1]; + data.dihedral_harmonic_multiplicity = new int[data.ndihedraltypes+1]; + data.dihedral_harmonic_sign = new int[data.ndihedraltypes+1]; + fread(&data.dihedral_harmonic_k[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_harmonic_multiplicity[1],sizeof(int), + data.ndihedraltypes,fp); + fread(&data.dihedral_harmonic_sign[1],sizeof(int),data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"helix") == 0) { + + data.dihedral_helix_aphi = new double[data.ndihedraltypes+1]; + data.dihedral_helix_bphi = new double[data.ndihedraltypes+1]; + data.dihedral_helix_cphi = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_helix_aphi[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_helix_bphi[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_helix_cphi[1],sizeof(double),data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"multi/harmonic") == 0) { + + data.dihedral_multi_a1 = new double[data.ndihedraltypes+1]; + data.dihedral_multi_a2 = new double[data.ndihedraltypes+1]; + data.dihedral_multi_a3 = new double[data.ndihedraltypes+1]; + data.dihedral_multi_a4 = new double[data.ndihedraltypes+1]; + data.dihedral_multi_a5 = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_multi_a1[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_multi_a2[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_multi_a3[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_multi_a4[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_multi_a5[1],sizeof(double),data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"opls") == 0) { + + data.dihedral_opls_k1 = new double[data.ndihedraltypes+1]; + data.dihedral_opls_k2 = new double[data.ndihedraltypes+1]; + data.dihedral_opls_k3 = new double[data.ndihedraltypes+1]; + data.dihedral_opls_k4 = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_opls_k1[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_opls_k2[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_opls_k3[1],sizeof(double),data.ndihedraltypes,fp); + fread(&data.dihedral_opls_k4[1],sizeof(double),data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"cosineshiftexp") == 0) { + + data.dihedral_cosineshiftexp_umin = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_cosineshiftexp_umin[1],sizeof(double), + data.ndihedraltypes,fp); + data.dihedral_cosineshiftexp_a = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_cosineshiftexp_a[1],sizeof(double), + data.ndihedraltypes,fp); + data.dihedral_cosineshiftexp_cost = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_cosineshiftexp_cost[1],sizeof(double), + data.ndihedraltypes,fp); + data.dihedral_cosineshiftexp_sint = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_cosineshiftexp_sint[1],sizeof(double), + data.ndihedraltypes,fp); + data.dihedral_cosineshiftexp_theta = new double[data.ndihedraltypes+1]; + fread(&data.dihedral_cosineshiftexp_theta[1],sizeof(double), + data.ndihedraltypes,fp); + + } else if (strcmp(data.dihedral_style,"table") == 0) { + + int tabstyle = read_int(fp); + int n = read_int(fp); + + } else if (strcmp(data.dihedral_style,"hybrid") == 0) { + + int nstyles = read_int(fp); + for (int i = 0; i < nstyles; i++) + char *substyle = read_char(fp); + + } else { + printf("ERROR: Unknown dihedral style %s\n",data.dihedral_style); + exit(1); + } +} + +// --------------------------------------------------------------------- +// improper coeffs +// one section for each improper style +// --------------------------------------------------------------------- + +void improper(FILE *fp, Data &data) +{ + if (strcmp(data.improper_style,"none") == 0) { + + } else if (strcmp(data.improper_style,"class2") == 0) { + + data.improper_class2_k0 = new double[data.nimpropertypes+1]; + data.improper_class2_chi0 = new double[data.nimpropertypes+1]; + + data.improper_class2_aa_k1 = new double[data.nimpropertypes+1]; + data.improper_class2_aa_k2 = new double[data.nimpropertypes+1]; + data.improper_class2_aa_k3 = new double[data.nimpropertypes+1]; + data.improper_class2_aa_theta0_1 = new double[data.nimpropertypes+1]; + data.improper_class2_aa_theta0_2 = new double[data.nimpropertypes+1]; + data.improper_class2_aa_theta0_3 = new double[data.nimpropertypes+1]; + + fread(&data.improper_class2_k0[1],sizeof(double), + data.nimpropertypes,fp); + fread(&data.improper_class2_chi0[1],sizeof(double), + data.nimpropertypes,fp); + + fread(&data.improper_class2_aa_k1[1],sizeof(double), + data.nimpropertypes,fp); + fread(&data.improper_class2_aa_k2[1],sizeof(double), + data.nimpropertypes,fp); + fread(&data.improper_class2_aa_k3[1],sizeof(double), + data.nimpropertypes,fp); + fread(&data.improper_class2_aa_theta0_1[1],sizeof(double), + data.nimpropertypes,fp); + fread(&data.improper_class2_aa_theta0_2[1],sizeof(double), + data.nimpropertypes,fp); + fread(&data.improper_class2_aa_theta0_3[1],sizeof(double), + data.nimpropertypes,fp); + + } else if (strcmp(data.improper_style,"cvff") == 0) { + + data.improper_cvff_k = new double[data.nimpropertypes+1]; + data.improper_cvff_sign = new int[data.nimpropertypes+1]; + data.improper_cvff_multiplicity = new int[data.nimpropertypes+1]; + fread(&data.improper_cvff_k[1],sizeof(double),data.nimpropertypes,fp); + fread(&data.improper_cvff_sign[1],sizeof(int),data.nimpropertypes,fp); + fread(&data.improper_cvff_multiplicity[1],sizeof(int), + data.nimpropertypes,fp); + + } else if (strcmp(data.improper_style,"harmonic") == 0) { + + data.improper_harmonic_k = new double[data.nimpropertypes+1]; + data.improper_harmonic_chi = new double[data.nimpropertypes+1]; + fread(&data.improper_harmonic_k[1],sizeof(double),data.nimpropertypes,fp); + fread(&data.improper_harmonic_chi[1],sizeof(double), + data.nimpropertypes,fp); + + } else if (strcmp(data.improper_style,"hybrid") == 0) { + + int nstyles = read_int(fp); + for (int i = 0; i < nstyles; i++) + char *substyle = read_char(fp); + + } else { + printf("ERROR: Unknown improper style %s\n",data.improper_style); + exit(1); + } +} + +// --------------------------------------------------------------------- +// initialize Data +// --------------------------------------------------------------------- + +Data::Data() +{ + nellipsoids = 0; +} + +// --------------------------------------------------------------------- +// print out stats on problem +// --------------------------------------------------------------------- + +void Data::stats() +{ + char fstr[64]; + + printf(" Restart file version = %s\n",version); + printf(" Ntimestep = " BIGINT_FORMAT "\n",ntimestep); + printf(" Nprocs = %d\n",nprocs); + printf(" Natoms = " BIGINT_FORMAT "\n",natoms); + + if (nellipsoids) printf(" Nellipsoids = " BIGINT_FORMAT "\n",nellipsoids); + + printf(" Nbonds = " BIGINT_FORMAT "\n",nbonds); + printf(" Nangles = " BIGINT_FORMAT "\n",nangles); + printf(" Ndihedrals = " BIGINT_FORMAT "\n",ndihedrals); + printf(" Nimpropers = " BIGINT_FORMAT "\n",nimpropers); + + printf(" Unit style = %s\n",unit_style); + printf(" Atom style = %s\n",atom_style); + printf(" Pair style = %s\n",pair_style); + printf(" Bond style = %s\n",bond_style); + printf(" Angle style = %s\n",angle_style); + printf(" Dihedral style = %s\n",dihedral_style); + printf(" Improper style = %s\n",improper_style); + + printf(" Xlo xhi = %g %g\n",xlo,xhi); + printf(" Ylo yhi = %g %g\n",ylo,yhi); + printf(" Zlo zhi = %g %g\n",zlo,zhi); + if (triclinic) printf(" Xy xz yz = %g %g %g\n",xy,xz,yz); + printf(" Periodicity = %d %d %d\n",xperiodic,yperiodic,zperiodic); + printf(" Boundary = %d %d, %d %d, %d %d\n",boundary[0][0],boundary[0][1], + boundary[1][0],boundary[1][1],boundary[2][0],boundary[2][1]); +} + +// --------------------------------------------------------------------- +// write the data file and input file +// --------------------------------------------------------------------- + +void Data::write(FILE *fp, FILE *fp2) +{ + fprintf(fp,"LAMMPS data file from restart file: timestep = " + BIGINT_FORMAT ", procs = %d\n\n",ntimestep,nprocs); + + fprintf(fp,BIGINT_FORMAT " atoms\n",natoms); + if (nellipsoids) fprintf(fp,BIGINT_FORMAT " ellipsoids\n",nellipsoids); + if (nbonds) fprintf(fp,BIGINT_FORMAT " bonds\n",nbonds); + if (nangles) fprintf(fp,BIGINT_FORMAT " angles\n",nangles); + if (ndihedrals) fprintf(fp,BIGINT_FORMAT " dihedrals\n",ndihedrals); + if (nimpropers) fprintf(fp,BIGINT_FORMAT " impropers\n",nimpropers); + + fprintf(fp,"\n"); + + fprintf(fp,"%d atom types\n",ntypes); + if (nbondtypes) fprintf(fp,"%d bond types\n",nbondtypes); + if (nangletypes) fprintf(fp,"%d angle types\n",nangletypes); + if (ndihedraltypes) fprintf(fp,"%d dihedral types\n",ndihedraltypes); + if (nimpropertypes) fprintf(fp,"%d improper types\n",nimpropertypes); + + fprintf(fp,"\n"); + + fprintf(fp,"%-1.16e %-1.16e xlo xhi\n",xlo,xhi); + fprintf(fp,"%-1.16e %-1.16e ylo yhi\n",ylo,yhi); + fprintf(fp,"%-1.16e %-1.16e zlo zhi\n",zlo,zhi); + if (triclinic) fprintf(fp,"%-1.16e %-1.16e %-1.16e xy xz yz\n",xy,xz,yz); + + // write ff styles to input file + + if (fp2) { + fprintf(fp2,"# LAMMPS input file from restart file: " + "timestep = " BIGINT_FORMAT ", procs = %d\n\n",ntimestep,nprocs); + + if (pair_style) fprintf(fp2,"pair_style %s\n",pair_style); + if (bond_style) fprintf(fp2,"bond_style %s\n",bond_style); + if (angle_style) fprintf(fp2,"angle_style %s\n",angle_style); + if (dihedral_style) fprintf(fp2,"dihedral_style %s\n",dihedral_style); + if (improper_style) fprintf(fp2,"improper_style %s\n",improper_style); + fprintf(fp2,"special_bonds %g %g %g %g %g %g\n", + special_lj[1],special_lj[2],special_lj[3], + special_lj[1],special_coul[2],special_coul[3]); + fprintf(fp2,"\n"); + } + + // mass to either data file or input file + + if (mass) { + if (fp2) { + fprintf(fp2,"\n"); + for (int i = 1; i <= ntypes; i++) fprintf(fp2,"mass %d %g\n",i,mass[i]); + fprintf(fp2,"\n"); + } else { + fprintf(fp,"\nMasses\n\n"); + for (int i = 1; i <= ntypes; i++) fprintf(fp,"%d %g\n",i,mass[i]); + } + } + + // pair coeffs to data file + + if (pair_style && fp2 == NULL) { + if ((strcmp(pair_style,"none") != 0) && + (strcmp(pair_style,"adp") != 0) && + (strcmp(pair_style,"airebo") != 0) && + (strcmp(pair_style,"coul/cut") != 0) && + (strcmp(pair_style,"coul/debye") != 0) && + (strcmp(pair_style,"coul/long") != 0) && + (strcmp(pair_style,"eam") != 0) && + (strcmp(pair_style,"eam/alloy") != 0) && + (strcmp(pair_style,"eam/fs") != 0) && + (strcmp(pair_style,"eim") != 0) && + (strcmp(pair_style,"eff/cut") != 0) && + (strcmp(pair_style,"gran/history") != 0) && + (strcmp(pair_style,"gran/no_history") != 0) && + (strcmp(pair_style,"gran/hertzian") != 0) && + (strcmp(pair_style,"meam") != 0) && + (strcmp(pair_style,"reax") != 0) && + (strcmp(pair_style,"reax/c") != 0) && + (strcmp(pair_style,"sw") != 0) && + (strcmp(pair_style,"table") != 0) && + (strcmp(pair_style,"tersoff") != 0) && + (strcmp(pair_style,"tersoff/zbl") != 0) && + (strcmp(pair_style,"hybrid") != 0) && + (strcmp(pair_style,"hybrid/overlay") != 0)) + fprintf(fp,"\nPair Coeffs\n\n"); + + if (strcmp(pair_style,"born/coul/long") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g %g %g\n",i, + pair_born_A[i],pair_born_rho[i],pair_born_sigma[i], + pair_born_C[i],pair_born_D[i]); + + } else if ((strcmp(pair_style,"buck") == 0) || + (strcmp(pair_style,"buck/coul/cut") == 0) || + (strcmp(pair_style,"buck/coul/long") == 0) || + (strcmp(pair_style,"buck/long") == 0)) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + pair_buck_A[i],pair_buck_rho[i],pair_buck_C[i]); + + } else if (strcmp(pair_style,"colloid") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + pair_colloid_A12[i],pair_colloid_sigma[i], + pair_colloid_d2[i],pair_colloid_d2[i]); + + } else if (strcmp(pair_style,"dipole/cut") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g\n",i, + pair_dipole_epsilon[i],pair_dipole_sigma[i]); + + } else if (strcmp(pair_style,"dpd") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g\n",i, + pair_dpd_a0[i],pair_dpd_gamma[i]); + + } else if (strcmp(pair_style,"dpd/tstat") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g\n",i, + pair_dpd_gamma[i]); + + } else if (strcmp(pair_style,"gayberne") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g %g %g %g %g %g\n",i, + pair_gb_epsilon[i],pair_gb_sigma[i], + pair_gb_epsa[i],pair_gb_epsb[i],pair_gb_epsc[i], + pair_gb_epsa[i],pair_gb_epsb[i],pair_gb_epsc[i]); + + } else if ((strcmp(pair_style,"lj/charmm/coul/charmm") == 0) || + (strcmp(pair_style,"lj/charmm/coul/charmm/implicit") == 0) || + (strcmp(pair_style,"lj/charmm/coul/long") == 0)) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + pair_charmm_epsilon[i],pair_charmm_sigma[i], + pair_charmm_eps14[i],pair_charmm_sigma14[i]); + + } else if ((strcmp(pair_style,"lj/class2") == 0) || + (strcmp(pair_style,"lj/class2/coul/cut") == 0) || + (strcmp(pair_style,"lj/class2/coul/long") == 0)) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g\n",i, + pair_class2_epsilon[i],pair_class2_sigma[i]); + + } else if ((strcmp(pair_style,"lj/cut") == 0) || + (strcmp(pair_style,"lj96/cut") == 0) || + (strcmp(pair_style,"lj/cut/coul/cut") == 0) || + (strcmp(pair_style,"lj/cut/coul/debye") == 0) || + (strcmp(pair_style,"lj/cut/coul/long") == 0) || + (strcmp(pair_style,"lj/cut/coul/long/tip4p") == 0) || + (strcmp(pair_style,"lj/coul") == 0)) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g\n",i, + pair_lj_epsilon[i],pair_lj_sigma[i]); + + } else if (strcmp(pair_style,"lj/expand") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + pair_ljexpand_epsilon[i],pair_ljexpand_sigma[i], + pair_ljexpand_shift[i]); + + } else if ((strcmp(pair_style,"lj/gromacs") == 0) || + (strcmp(pair_style,"lj/gromacs/coul/gromacs") == 0)) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g\n",i, + pair_ljgromacs_epsilon[i],pair_ljgromacs_sigma[i]); + + } else if (strcmp(pair_style,"lj/smooth") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g\n",i, + pair_ljsmooth_epsilon[i],pair_ljsmooth_sigma[i]); + + } else if (strcmp(pair_style,"morse") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + pair_morse_d0[i],pair_morse_alpha[i],pair_morse_r0[i]); + + } else if (strcmp(pair_style,"soft") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g\n",i, + pair_soft_A[i]); + + } else if (strcmp(pair_style,"yukawa") == 0) { + for (int i = 1; i <= ntypes; i++) + fprintf(fp,"%d %g\n",i, + pair_yukawa_A[i]); + + } else if ((strcmp(pair_style,"cg/cmm") == 0) || + (strcmp(pair_style,"cg/cmm/coul/cut") == 0) || + (strcmp(pair_style,"cg/cmm/coul/long") == 0)) { + printf("ERROR: Cannot write pair_style %s to data file\n", + pair_style); + exit(1); + } + } + + // pair coeffs to input file + // only supported styles = cg/cmm + + if (pair_style && fp2) { + if ((strcmp(pair_style,"cg/cmm") == 0) || + (strcmp(pair_style,"cg/cmm/coul/cut") == 0) || + (strcmp(pair_style,"cg/cmm/coul/long") == 0)) { + for (int i = 1; i <= ntypes; i++) { + for (int j = i; j <= ntypes; j++) { + fprintf(fp2,"pair_coeff %d %d %s %g %g\n",i,j, + cg_type_list[pair_cg_cmm_type[i][j]], + pair_cg_epsilon[i][j],pair_cg_sigma[i][j]); + } + } + + } else { + printf("ERROR: Cannot write pair_style %s to input file\n", + pair_style); + exit(1); + } + } + + // bond coeffs to data file + + if (bond_style && fp2 == NULL) { + if ((strcmp(bond_style,"none") != 0) && + (strcmp(bond_style,"table") != 0) && + (strcmp(bond_style,"hybrid") != 0)) + fprintf(fp,"\nBond Coeffs\n\n"); + + if (strcmp(bond_style,"class2") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + bond_class2_r0[i],bond_class2_k2[i], + bond_class2_k3[i],bond_class2_k4[i]); + + } else if (strcmp(bond_style,"fene") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + bond_fene_k[i],bond_fene_r0[i], + bond_fene_epsilon[i],bond_fene_sigma[i]); + + } else if (strcmp(bond_style,"fene/expand") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g %g %g\n",i, + bond_feneexpand_k[i],bond_feneexpand_r0[i], + bond_feneexpand_epsilon[i],bond_feneexpand_sigma[i], + bond_feneexpand_shift[i]); + + } else if (strcmp(bond_style,"harmonic") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g\n",i, + bond_harmonic_k[i],bond_harmonic_r0[i]); + + } else if (strcmp(bond_style,"harmonicshift") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + bond_harmonicshift_umin[i],bond_harmonicshift_r0[i], + bond_harmonicshift_rc[i]); + + } else if (strcmp(bond_style,"harmonicshiftcut") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + bond_harmonicshiftcut_umin[i],bond_harmonicshiftcut_r0[i], + bond_harmonicshiftcut_rc[i]); + + } else if (strcmp(bond_style,"morse") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + bond_morse_d0[i],bond_morse_alpha[i],bond_morse_r0[i]); + + } else if (strcmp(bond_style,"nonlinear") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + bond_nonlinear_epsilon[i],bond_nonlinear_r0[i], + bond_nonlinear_lamda[i]); + + } else if (strcmp(bond_style,"quartic") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp,"%d %g %g %g %g %g\n",i, + bond_quartic_k[i],bond_quartic_b1[i],bond_quartic_b2[i], + bond_quartic_rc[i],bond_quartic_u0[i]); + } + } + + // bond coeffs to input file + // only supported styles = harmonic + + if (bond_style && fp2) { + if (strcmp(bond_style,"harmonic") == 0) { + for (int i = 1; i <= nbondtypes; i++) + fprintf(fp2,"bond_coeff %d %g %g\n",i, + bond_harmonic_k[i],bond_harmonic_r0[i]); + + } else { + printf("ERROR: Cannot write bond_style %s to input file\n", + bond_style); + exit(1); + } + } + + // angle coeffs to data file + + if (angle_style && fp2 == NULL) { + if ((strcmp(angle_style,"none") != 0) && + (strcmp(angle_style,"table") != 0) && + (strcmp(angle_style,"hybrid") != 0)) + fprintf(fp,"\nAngle Coeffs\n\n"); + + if (strcmp(angle_style,"charmm") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + angle_charmm_k[i],angle_charmm_theta0[i]/PI*180.0, + angle_charmm_k_ub[i],angle_charmm_r_ub[i]); + + } else if (strcmp(angle_style,"class2") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + angle_class2_theta0[i]/PI*180.0,angle_class2_k2[i], + angle_class2_k3[i],angle_class2_k4[i]); + + fprintf(fp,"\nBondBond Coeffs\n\n"); + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + angle_class2_bb_k[i], + angle_class2_bb_r1[i],angle_class2_bb_r2[i]); + + fprintf(fp,"\nBondAngle Coeffs\n\n"); + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + angle_class2_ba_k1[i],angle_class2_ba_k2[i], + angle_class2_ba_r1[i],angle_class2_ba_r2[i]); + + } else if (strcmp(angle_style,"cosine") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g\n",i,angle_cosine_k[i]); + + } else if (strcmp(angle_style,"cosineshift") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g\n",i,angle_cosineshift_umin[i], + angle_cosineshift_theta0[i]/PI*180.0); + + } else if (strcmp(angle_style,"cosineshiftexp") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g %g\n",i,angle_cosineshiftexp_umin[i], + angle_cosineshiftexp_theta0[i]/PI*180.0, + angle_cosineshiftexp_a[i]); + + } else if ((strcmp(angle_style,"cosine/squared") == 0) || + (strcmp(angle_style,"cosine/delta") == 0)) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g\n",i, + angle_cosine_squared_k[i], + angle_cosine_squared_theta0[i]/PI*180.0); + + } else if (strcmp(angle_style,"harmonic") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g\n",i, + angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0); + + } else if (strcmp(angle_style,"cg/cmm") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp,"%d %g %g %s %g %g\n",i, + angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0, + cg_type_list[angle_cg_cmm_type[i]],angle_cg_cmm_epsilon[i], + angle_cg_cmm_sigma[i]); + } + } + + // angle coeffs to input file + // only supported styles = cosine/squared, harmonic, cg/cmm + + if (angle_style && fp2) { + if ((strcmp(angle_style,"cosine/squared") == 0) || + (strcmp(angle_style,"cosine/delta") == 0)) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp2,"angle_coeffs %d %g %g\n",i, + angle_cosine_squared_k[i], + angle_cosine_squared_theta0[i]/PI*180.0); + + } else if (strcmp(angle_style,"harmonic") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp2,"angle_coeffs %d %g %g\n",i, + angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0); + + } else if (strcmp(angle_style,"cg/cmm") == 0) { + for (int i = 1; i <= nangletypes; i++) + fprintf(fp2,"angle_coeffs %d %g %g %s %g %g\n",i, + angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0, + cg_type_list[angle_cg_cmm_type[i]],angle_cg_cmm_epsilon[i], + angle_cg_cmm_sigma[i]); + + } else { + printf("ERROR: Cannot write angle_style %s to input file\n", + angle_style); + exit(1); + } + } + + if (dihedral_style) { + if ((strcmp(dihedral_style,"none") != 0) && + (strcmp(dihedral_style,"table") != 0) && + (strcmp(dihedral_style,"hybrid") != 0)) + fprintf(fp,"\nDihedral Coeffs\n\n"); + + if (strcmp(dihedral_style,"charmm") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %d %d %g\n",i, + dihedral_charmm_k[i],dihedral_charmm_multiplicity[i], + dihedral_charmm_sign[i],dihedral_charmm_weight[i]); + + } else if (strcmp(dihedral_style,"class2") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g %g %g %g\n",i, + dihedral_class2_k1[i], + dihedral_class2_phi1[i]/PI*180.0, + dihedral_class2_k2[i], + dihedral_class2_phi2[i]/PI*180.0, + dihedral_class2_k3[i], + dihedral_class2_phi3[i]/PI*180.0); + + fprintf(fp,"\nMiddleBondTorsion Coeffs\n\n"); + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g %g\n",i, + dihedral_class2_mbt_f1[i],dihedral_class2_mbt_f2[i], + dihedral_class2_mbt_f3[i],dihedral_class2_mbt_r0[i]); + + fprintf(fp,"\nEndBondTorsion Coeffs\n\n"); + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g %g %g %g %g %g\n",i, + dihedral_class2_ebt_f1_1[i],dihedral_class2_ebt_f2_1[i], + dihedral_class2_ebt_f3_1[i], + dihedral_class2_ebt_f1_2[i],dihedral_class2_ebt_f2_2[i], + dihedral_class2_ebt_f3_2[i], + dihedral_class2_ebt_r0_1[i], + dihedral_class2_ebt_r0_2[i]); + + fprintf(fp,"\nAngleTorsion Coeffs\n\n"); + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g %g %g %g %g %g\n",i, + dihedral_class2_at_f1_1[i],dihedral_class2_at_f2_1[i], + dihedral_class2_at_f3_1[i], + dihedral_class2_at_f1_2[i],dihedral_class2_at_f2_2[i], + dihedral_class2_at_f3_2[i], + dihedral_class2_at_theta0_1[i]/PI*180.0, + dihedral_class2_at_theta0_2[i]/PI*180.0); + + fprintf(fp,"\nAngleAngleTorsion Coeffs\n\n"); + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + dihedral_class2_aat_k[i], + dihedral_class2_aat_theta0_1[i]/PI*180.0, + dihedral_class2_aat_theta0_2[i]/PI*180.0); + + fprintf(fp,"\nBondBond13 Coeffs\n\n"); + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + dihedral_class2_bb13_k[i], + dihedral_class2_bb13_r10[i],dihedral_class2_bb13_r30[i]); + + } else if (strcmp(dihedral_style,"harmonic") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %d %d\n",i, + dihedral_harmonic_k[i],dihedral_harmonic_multiplicity[i], + dihedral_harmonic_sign[i]); + + } else if (strcmp(dihedral_style,"cosineshiftexp") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g\n",i, + dihedral_cosineshiftexp_umin[i], + dihedral_cosineshiftexp_theta[i]*180.0/PI, + dihedral_cosineshiftexp_a[i] + ); + + } else if (strcmp(dihedral_style,"helix") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g\n",i,dihedral_helix_aphi[i], + dihedral_helix_bphi[i],dihedral_helix_cphi[i]); + + } else if (strcmp(dihedral_style,"multi/harmonic") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) + fprintf(fp,"%d %g %g %g %g %g\n",i, + dihedral_multi_a1[i],dihedral_multi_a2[i], + dihedral_multi_a3[i],dihedral_multi_a4[i], + dihedral_multi_a5[i]); + + } else if (strcmp(dihedral_style,"opls") == 0) { + for (int i = 1; i <= ndihedraltypes; i++) // restore factor of 2 + fprintf(fp,"%d %g %g %g %g\n",i, + 2.0*dihedral_opls_k1[i],2.0*dihedral_opls_k2[i], + 2.0*dihedral_opls_k3[i],2.0*dihedral_opls_k4[i]); + } + } + + if (improper_style) { + if ((strcmp(improper_style,"none") != 0) && + (strcmp(improper_style,"hybrid") != 0)) + fprintf(fp,"\nImproper Coeffs\n\n"); + + if (strcmp(improper_style,"class2") == 0) { + for (int i = 1; i <= nimpropertypes; i++) + fprintf(fp,"%d %g %g\n",i, + improper_class2_k0[i],improper_class2_chi0[i]/PI*180.0); + + fprintf(fp,"\nAngleAngle Coeffs\n\n"); + for (int i = 1; i <= nimpropertypes; i++) + fprintf(fp,"%d %g %g %g %g %g %g\n",i, + improper_class2_aa_k1[i],improper_class2_aa_k2[i], + improper_class2_aa_k3[i], + improper_class2_aa_theta0_1[i]/PI*180.0, + improper_class2_aa_theta0_2[i]/PI*180.0, + improper_class2_aa_theta0_3[i]/PI*180.0); + + } else if (strcmp(improper_style,"cvff") == 0) { + for (int i = 1; i <= nimpropertypes; i++) + fprintf(fp,"%d %g %d %d\n",i, + improper_cvff_k[i],improper_cvff_sign[i], + improper_cvff_multiplicity[i]); + + } else if (strcmp(improper_style,"harmonic") == 0) { + for (int i = 1; i <= nimpropertypes; i++) + fprintf(fp,"%d %g %g\n",i, + improper_harmonic_k[i],improper_harmonic_chi[i]/PI*180.0); + } + } + + if (natoms) { + fprintf(fp,"\nAtoms\n\n"); + + int ix,iy,iz; + for (bigint i = 0; i < natoms; i++) { + + ix = (image[i] & 1023) - 512; + iy = (image[i] >> 10 & 1023) - 512; + iz = (image[i] >> 20) - 512; + + if (style_hybrid == 0) { + if (style_angle) write_atom_angle(fp,i,ix,iy,iz); + if (style_atomic) write_atom_atomic(fp,i,ix,iy,iz); + if (style_bond) write_atom_bond(fp,i,ix,iy,iz); + if (style_charge) write_atom_charge(fp,i,ix,iy,iz); + if (style_dipole) write_atom_dipole(fp,i,ix,iy,iz); + if (style_ellipsoid) write_atom_ellipsoid(fp,i,ix,iy,iz); + if (style_full) write_atom_full(fp,i,ix,iy,iz); + if (style_sphere) write_atom_sphere(fp,i,ix,iy,iz); + if (style_molecular) write_atom_molecular(fp,i,ix,iy,iz); + if (style_peri) write_atom_peri(fp,i,ix,iy,iz); + fprintf(fp,"\n"); + + } else { + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e", + tag[i],type[i],x[i],y[i],z[i]); + for (int k = 1; k <= style_hybrid; k++) { + if (k == style_angle) write_atom_angle_extra(fp,i); + if (k == style_atomic) write_atom_atomic_extra(fp,i); + if (k == style_bond) write_atom_bond_extra(fp,i); + if (k == style_charge) write_atom_charge_extra(fp,i); + if (k == style_dipole) write_atom_dipole_extra(fp,i); + if (k == style_ellipsoid) write_atom_ellipsoid_extra(fp,i); + if (k == style_full) write_atom_full_extra(fp,i); + if (k == style_sphere) write_atom_sphere_extra(fp,i); + if (k == style_molecular) write_atom_molecular_extra(fp,i); + if (k == style_peri) write_atom_peri_extra(fp,i); + } + fprintf(fp," %d %d %d\n",ix,iy,iz); + } + } + } + + if (natoms) { + fprintf(fp,"\nVelocities\n\n"); + for (bigint i = 0; i < natoms; i++) + + if (style_hybrid == 0) { + if (style_angle) write_vel_angle(fp,i); + if (style_atomic) write_vel_atomic(fp,i); + if (style_bond) write_vel_bond(fp,i); + if (style_charge) write_vel_charge(fp,i); + if (style_dipole) write_vel_dipole(fp,i); + if (style_ellipsoid) write_vel_ellipsoid(fp,i); + if (style_full) write_vel_full(fp,i); + if (style_sphere) write_vel_sphere(fp,i); + if (style_molecular) write_vel_molecular(fp,i); + if (style_peri) write_vel_peri(fp,i); + fprintf(fp,"\n"); + + } else { + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); + for (int k = 1; k <= style_hybrid; k++) { + if (k == style_angle) write_vel_angle_extra(fp,i); + if (k == style_atomic) write_vel_atomic_extra(fp,i); + if (k == style_bond) write_vel_bond_extra(fp,i); + if (k == style_charge) write_vel_charge_extra(fp,i); + if (k == style_dipole) write_vel_dipole_extra(fp,i); + if (k == style_ellipsoid) write_vel_ellipsoid_extra(fp,i); + if (k == style_full) write_vel_full_extra(fp,i); + if (k == style_sphere) write_vel_sphere_extra(fp,i); + if (k == style_molecular) write_vel_molecular_extra(fp,i); + if (k == style_peri) write_vel_peri_extra(fp,i); + } + fprintf(fp,"\n"); + } + } + + if (nellipsoids) { + fprintf(fp,"\nEllipsoids\n\n"); + for (bigint i = 0; i < natoms; i++) { + if (ellipsoid[i]) + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e " + "%-1.16e %-1.16e %-1.16e %-1.16e \n", + tag[i],2.0*shapex[i],2.0*shapey[i],2.0*shapez[i], + quatw[i],quati[i],quatj[i],quatk[i]); + } + } + + if (nbonds) { + fprintf(fp,"\nBonds\n\n"); + for (bigint i = 0; i < nbonds; i++) + fprintf(fp,BIGINT_FORMAT " %d %d %d\n", + i+1,bond_type[i],bond_atom1[i],bond_atom2[i]); + } + + if (nangles) { + fprintf(fp,"\nAngles\n\n"); + for (bigint i = 0; i < nangles; i++) + fprintf(fp,BIGINT_FORMAT " %d %d %d %d\n", + i+1,angle_type[i],angle_atom1[i],angle_atom2[i],angle_atom3[i]); + } + + if (ndihedrals) { + fprintf(fp,"\nDihedrals\n\n"); + for (bigint i = 0; i < ndihedrals; i++) + fprintf(fp,BIGINT_FORMAT " %d %d %d %d %d\n", + i+1,dihedral_type[i],dihedral_atom1[i],dihedral_atom2[i], + dihedral_atom3[i],dihedral_atom4[i]); + } + + if (nimpropers) { + fprintf(fp,"\nImpropers\n\n"); + for (bigint i = 0; i < nimpropers; i++) + fprintf(fp,BIGINT_FORMAT " %d %d %d %d %d\n", + i+1,improper_type[i],improper_atom1[i],improper_atom2[i], + improper_atom3[i],improper_atom4[i]); + } +} + +// --------------------------------------------------------------------- +// per-atom write routines +// one routine per atom style +// --------------------------------------------------------------------- + +void Data::write_atom_angle(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],molecule[i],type[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_atomic(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],type[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_bond(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],molecule[i],type[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_charge(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],type[i],q[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_dipole(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e " + "%-1.16e %-1.16e %d %d %d", + tag[i],type[i],q[i],x[i],y[i],z[i], + mux[i],muy[i],muz[i],ix,iy,iz); +} + +void Data::write_atom_ellipsoid(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],type[i],ellipsoid[i],density[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_full(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],molecule[i],type[i],q[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_sphere(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],type[i],2.0*radius[i],density[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_molecular(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],molecule[i],type[i],x[i],y[i],z[i],ix,iy,iz); +} + +void Data::write_atom_peri(FILE *fp, int i, int ix, int iy, int iz) +{ + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d", + tag[i],type[i],vfrac[i],rmass[i],x[i],y[i],z[i],ix,iy,iz); +} + +// --------------------------------------------------------------------- +// per-atom write routines of extra quantities unique to style +// one routine per atom style +// --------------------------------------------------------------------- + +void Data::write_atom_angle_extra(FILE *fp, int i) +{ + fprintf(fp," %d",molecule[i]); +} + +void Data::write_atom_atomic_extra(FILE *fp, int i) {} + +void Data::write_atom_bond_extra(FILE *fp, int i) +{ + fprintf(fp," %d",molecule[i]); +} + +void Data::write_atom_charge_extra(FILE *fp, int i) +{ + fprintf(fp," %-1.16e",q[i]); +} + +void Data::write_atom_dipole_extra(FILE *fp, int i) +{ + fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e",q[i],mux[i],muy[i],muz[i]); +} + +void Data::write_atom_ellipsoid_extra(FILE *fp, int i) +{ + fprintf(fp," %d %-1.16e",ellipsoid[i],density[i]); +} + +void Data::write_atom_full_extra(FILE *fp, int i) +{ + fprintf(fp," %d %-1.16e",molecule[i],q[i]); +} + +void Data::write_atom_sphere_extra(FILE *fp, int i) +{ + fprintf(fp," %-1.16e %-1.16e",2.0*radius[i],density[i]); +} + +void Data::write_atom_molecular_extra(FILE *fp, int i) +{ + fprintf(fp," %d",molecule[i]); +} + +void Data::write_atom_peri_extra(FILE *fp, int i) +{ + fprintf(fp," %-1.16e %-1.16e",vfrac[i],rmass[i]); +} + +// --------------------------------------------------------------------- +// per-atom velocity write routines +// one routine per atom style +// --------------------------------------------------------------------- + +void Data::write_vel_angle(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_atomic(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_bond(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_charge(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_dipole(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_ellipsoid(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e", + tag[i],vx[i],vy[i],vz[i],angmomx[i],angmomy[i],angmomz[i]); +} + +void Data::write_vel_full(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_sphere(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e", + tag[i],vx[i],vy[i],vz[i],omegax[i],omegay[i],omegaz[i]); +} + +void Data::write_vel_molecular(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +void Data::write_vel_peri(FILE *fp, int i) +{ + fprintf(fp,"%d %-1.16e %-1.16e %-1.16e",tag[i],vx[i],vy[i],vz[i]); +} + +// --------------------------------------------------------------------- +// per-atom velocity write routines of extra quantities unique to style +// one routine per atom style +// --------------------------------------------------------------------- + +void Data::write_vel_angle_extra(FILE *fp, int i) {} +void Data::write_vel_atomic_extra(FILE *fp, int i) {} +void Data::write_vel_bond_extra(FILE *fp, int i) {} +void Data::write_vel_charge_extra(FILE *fp, int i) {} +void Data::write_vel_dipole_extra(FILE *fp, int i) {} + +void Data::write_vel_ellipsoid_extra(FILE *fp, int i) +{ + fprintf(fp," %-1.16e %-1.16e %-1.16e",angmomx[i],angmomy[i],angmomz[i]); +} + +void Data::write_vel_full_extra(FILE *fp, int i) {} + +void Data::write_vel_sphere_extra(FILE *fp, int i) +{ + fprintf(fp," %-1.16e %-1.16e %-1.16e",omegax[i],omegay[i],omegaz[i]); +} + +void Data::write_vel_molecular_extra(FILE *fp, int i) {} +void Data::write_vel_peri_extra(FILE *fp, int i) {} + +// --------------------------------------------------------------------- +// strip known accelerator suffixes from style name +// --------------------------------------------------------------------- + +void strip_suffix(char *style) +{ + char *slash = strrchr(style,'/'); + if (slash == NULL) return; + + int i=0; + + const char *suffix_list[] = { "/opt", "/gpu", "/cuda", "/omp", NULL }; + const char *suffix = suffix_list[0]; + while (suffix != NULL) { + if (strcmp(slash,suffix) == 0) { + *slash = '\0'; + return; + } + ++i; + suffix = suffix_list[i]; + } +} + +// --------------------------------------------------------------------- +// binary reads from restart file +// --------------------------------------------------------------------- + +int read_int(FILE *fp) +{ + int value; + fread(&value,sizeof(int),1,fp); + return value; +} + +double read_double(FILE *fp) +{ + double value; + fread(&value,sizeof(double),1,fp); + return value; +} + +char *read_char(FILE *fp) +{ + int n; + fread(&n,sizeof(int),1,fp); + if (n == 0) return NULL; + char *value = new char[n]; + fread(value,sizeof(char),n,fp); + return value; +} + +bigint read_bigint(FILE *fp) +{ + bigint value; + fread(&value,sizeof(bigint),1,fp); + return value; +}