<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi,<br><br>massA and massB in mdatoms are only set when doing free-energy calculations.<br>massT gives the mass of a particle.<br>Unfortunately there is a serious lack of documentation in the data type include files<br>(and in most other parts of the code).<br><br>Berk<br><br>> Date: Tue, 31 Aug 2010 10:46:51 +0300<br>> From: InonShar@TAU.ac.IL<br>> To: gmx-users@gromacs.org<br>> Subject: [gmx-users] mdatoms->massA pointer dereferencing<br>> <br>> Good morning!<br>> <br>> I'm having C trouble with something which should be simple enough: <br>> GROMACS uses a struct called mdatoms which, amongst other things, houses <br>> the atom masses during the simulation. I'm trying to access this data <br>> (an array of the masses of all atoms). I've tried to consult internet <br>> sources and my local tech support team, but it seems the problem is that <br>> I'm misunderstanding the GROMACS programing. Any help would be greatly <br>> apprecia
ted.<br>> As I understand it, there's mdatoms, which is comprised of various stuff <br>> among which is the pointer massA.<br>> <br>> From mdatom.c:<br>> <br>> line 209: md->massA[i] = mA;<br>> <br>> Since md and mdatoms are of the same struct type, I believe <br>> mdatoms->massA is the pointer to the array I'm looking for.<br>> <br>> I've tried all these various combinations in the attempt to access the <br>> elements of this array, to no avail...<br>> <br>> In md.c:<br>> <br>> .<br>> .<br>> .<br>> include <mdatoms.h><br>> .<br>> .<br>> .<br>> t_mdatoms.h *mdatoms<br>> .<br>> .<br>> .<br>> line 447: ...mdatoms->massT...<br>> .<br>> .<br>> .<br>> if (bFirstStep){<br>> fprintf(trajectory,"%d\n",max_trajectory_atom);<br>> for(trajectory_atom=0;trajectory_atom<max_trajectory_atom;trajectory_atom++){<br>> fprintf(stderr,"%d/n",trajectory_atom);<br>> fprintf
(stderr,"%g ",mdatoms->massA[trajectory_atom]); //segmentation <br>> fault ON RUN-TIME<br>> // fprintf(trajectory,"%g ",mdatoms->massA->trajectory_atom); //error: <br>> request for member ‘trajectory_atom’ in something not a structure or <br>> union ON COMPILATION<br>> // fprintf(trajectory,"%g ",mdatoms->massA.trajectory_atom); //error: <br>> request for member ‘trajectory_atom’ in something not a structure or <br>> union ON COMPILATION<br>> // real *atomsmasses = mdatoms->massA;fprintf(trajectory,"%g <br>> ",atomsmasses[trajectory_atom]);//segfault on run-time<br>> // fprintf(trajectory,"%g ",mdatoms->tmassA); works, on the other hand, <br>> tmassA being a number rather than pointer or array<br>> <br>> The command I issue and the output is:<br>> <br>> ~$ mdrun_d -quiet -v -pd -nt 1<br>> <br>> :-) G R O M A C S (-:<br>> <br>> GROup of MAchos and Cynical Suckers<br>> <br>> :-) VERSION 4.5-beta4
(-:<br>> <br>> <br>> Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.<br>> Copyright (c) 1991-2000, University of Groningen, The Netherlands.<br>> Copyright (c) 2001-2008, The GROMACS development team,<br>> check out http://www.gromacs.org for more information.<br>> <br>> This program is free software; you can redistribute it and/or<br>> modify it under the terms of the GNU General Public License<br>> as published by the Free Software Foundation; either version 2<br>> of the License, or (at your option) any later version.<br>> <br>> :-) mdrun_d (double precision) (-:<br>> <br>> <br>> Back Off! I just backed up md.log to ./#md.log.3#<br>> Getting Loaded...<br>> Reading file topol.tpr, VERSION 4.5-beta2 (double precision)<br>> Note: tpx file_version 71, software version 73<br>> Loaded with Money<br>> <br>> <br>> Back Off! I just backed up traj.trr to ./#traj.trr.3#<br>> <br>> Back Of
f! I just backed up ener.edr to ./#ener.edr.3#<br>> starting mdrun 'Single Atom of Sulfur Between Two Gold Atoms'<br>> 6 steps, 0.0 ps.<br>> <br>> <br>> 0<br>> Segmentation fault<br>> <br>> <br>> The last two lines mean that the loop is entered ( trajectory_atom gets <br>> value zero ) and as soon as "md->massA[trajectory_atom]" is accessed, <br>> the program crashes. This was the result I got before. I tried accessing <br>> only elements 1 and above (by changing trajectory_atom to <br>> trajectory_atom+1 ) but got the same result.<br>> <br>> Thanks!<br>> <br>> -- <br>> Inon Sharony<br>> éðåï ùøåðé<br>> 972-3-6407634<br>> Please consider your environmental responsibility before printing this e-mail.<br>> <br>> -- <br>> gmx-users mailing list gmx-users@gromacs.org<br>> http://lists.gromacs.org/mailman/listinfo/gmx-users<br>> Please search the archive at http://www.gromacs.org/search before pos
ting!<br>> Please don't post (un)subscribe requests to the list. Use the <br>> www interface or send it to gmx-users-request@gromacs.org.<br>> Can't post? Read http://www.gromacs.org/mailing_lists/users.php<br>                                            </body>
</html>