[gmx-developers] how to write a xtc file in c
Dongsheng Zhang
dong at pampas.chem.purdue.edu
Sun Aug 13 14:51:14 CEST 2006
Dear Yang ye,
Bothe libgmx.la and libgmx.a are under /hield/lib . and all .h files are
under /hield/include/gromacs
Do you have any idea why compiler gave those error message?( such as
undefined reference to `close_xtc )
If you want, I can give you my code ( it is short), you can try to
compile it in your machine.
Thank you for your help!
Dongsheng
On Sun, 2006-08-13 at 15:34 +0800, Yang Ye wrote:
> my mistake, shall be libgmx.la and libgmx.a
>
> Yang Ye
>
> Dongsheng Zhang wrote:
> > Dear Yang Ye,
> >
> >
> > The problem is I can't find libgmx.o anywhere. I have tried to use find
> > command to search it. Could you please tell me where it supposes to be
> > after gromacs installed?
> >
> >
> >
> > All the best!
> >
> > Dongsheng
> >
> >
> > On Sat, 2006-08-12 at 22:19 +0800, Yang Ye wrote:
> >
> >> Hi, Dong sheng
> >>
> >> It wasn't the problem of "Append -lgmx to LIBS". The parameters required by GCC are to be spread into different variable to make it clearer.
> >>
> >> Your current Makefile doesn't make LDFLAGS work.
> >>
> >> Try this
> >>
> >> CC=gcc
> >> CFLAGS=-c -Wall -I/hielo/include/gromacs
> >> LDFLAGS=-L/hielo/lib
> >> LIBS=-lgmx -lm
> >>
> >> all: xtc
> >>
> >> xtc:
> >> $(CC) $(CFLAGS) ${LDFLAGS} ${LIBS} accessXtc.c -o accessXTC
> >>
> >>
> >>
> >> Make sure that under /hield/lib, there is libgmx.o and under
> >> /hielo/include/gromacs, there are all the .h files.
> >>
> >> Yang Ye
> >>
> >> Dongsheng Zhang wrote:
> >>
> >>> Dear Yang Ye,
> >>>
> >>> Thank you very much for your great help to give me the basic work flow.
> >>> I still have trouble to compile my file accessXtc.c. the following is my
> >>> simple Makefile:
> >>>
> >>>
> >>> CC=gcc
> >>> CFLAGS=-c -Wall -I/hielo/include/gromacs
> >>> LDFLAGS=-L/hielo/lib
> >>> LIBS=-lgmx
> >>>
> >>> all: xtc
> >>>
> >>> xtc: xtc.o
> >>> gcc xtc.o -o a.out
> >>> xtc.o: accessXtc.c
> >>> $(CC) $(CFLAGS) $(LIBS) accessXtc.c -o xtc.o
> >>>
> >>>
> >>> I believe I miss your fourth point "Append -lgmx to LIBS". I don't know
> >>> what -lgmx really means. Where is gmx library? The make command gives
> >>> me the following error message:
> >>>
> >>> xtc.o(.text+0x1f): In function `main':
> >>> : undefined reference to `open_xtc'
> >>> xtc.o(.text+0x6d): In function `main':
> >>> : undefined reference to `close_xtc'
> >>> xtc.o(.text+0x103): In function `writeXtc':
> >>> : undefined reference to `cos'
> >>> xtc.o(.text+0x117): In function `writeXtc':
> >>> : undefined reference to `sin'
> >>> xtc.o(.text+0x130): In function `writeXtc':
> >>> : undefined reference to `open_xtc'
> >>> xtc.o(.text+0x176): In function `writeXtc':
> >>> : undefined reference to `read_first_xtc'
> >>> xtc.o(.text+0x1db): In function `writeXtc':
> >>> : undefined reference to `read_next_xtc'
> >>> xtc.o(.text+0x20e): In function `writeXtc':
> >>> : undefined reference to `close_xtc'
> >>> xtc.o(.text+0x2e5): In function `writeXtc':
> >>> : undefined reference to `open_xtc'
> >>> xtc.o(.text+0x32b): In function `writeXtc':
> >>> : undefined reference to `read_first_xtc'
> >>> xtc.o(.text+0x390): In function `writeXtc':
> >>> : undefined reference to `read_next_xtc'
> >>> xtc.o(.text+0x3c3): In function `writeXtc':
> >>> : undefined reference to `close_xtc'
> >>> xtc.o(.text+0x4f1): In function `writeXtc':
> >>> : undefined reference to `write_xtc'
> >>> collect2: ld returned 1 exit status
> >>> make: *** [xtc] Error 1
> >>>
> >>>
> >>> Please give me more help.
> >>>
> >>>
> >>> Have a nice weekend!
> >>>
> >>> Dongsheng
> >>>
> >>> On Sat, 2006-08-12 at 09:09 +0800, Yang Ye wrote:
> >>>
> >>>
> >>>> 1. Use #include in the C file
> >>>> In Makefile
> >>>> 2. Append -I/gromacs/include to CFLAGS
> >>>> 3. Append -L/gromacs/lib to LDFLAGS
> >>>> 4. Append -lgmx to LIBS
> >>>>
> >>>> Yang Ye
> >>>>
> >>>> Dongsheng Zhang wrote:
> >>>>
> >>>>
> >>>>> Dear Yang Ye or other gmx developers,
> >>>>>
> >>>>> I have finished writing the code to read and write a xtc file, but I
> >>>>> have trouble to compile it. from the web site:
> >>>>>
> >>>>> http://www.gromacs.org/documentation/reference/online/xtc.html
> >>>>>
> >>>>> I find:
> >>>>>
> >>>>> To use the library function include "xtcio.h" in your file and link with
> >>>>> -lgmx.$(CPU)
> >>>>>
> >>>>>
> >>>>> Could you please tell me how to specify the link?
> >>>>>
> >>>>>
> >>>>> Thanks a lot!
> >>>>>
> >>>>> Dongsheng
> >>>>>
> >>>>>
> >>>>> On Thu, 2006-08-10 at 17:39 +0800, Yang Ye wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Mark Abraham wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> Dongsheng Zhang wrote:
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> Dear GMX developers,
> >>>>>>>>
> >>>>>>>> I want to write a xtc file to do rerun to get a special potential
> >>>>>>>> energy. Could you please tell me how to write a xtc file in c from a gro
> >>>>>>>> file (with multiple frames got from a xtc file, without velocity)? Thank
> >>>>>>>> you for your help!
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>> Read the source code - to find the right functions to call look how
> >>>>>>> trjconv or something does it, then grep the src/*/*.c files for the
> >>>>>>> function definition.
> >>>>>>>
> >>>>>>> Also http://www.gromacs.org/documentation/reference/online/xtc.html
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> This document shall help you.
> >>>>>>
> >>>>>> Here is basic workflow:
> >>>>>>
> >>>>>> 1. Open XTC
> >>>>>> int xfile = -1;
> >>>>>> char *xfilename = "out.xtc";
> >>>>>>
> >>>>>> xfile = open_xtc(xfilename, "w");
> >>>>>>
> >>>>>> 2. Close
> >>>>>> if (xfile!=-1) {
> >>>>>> close_xtc(xfile);
> >>>>>> xfile = -1;
> >>>>>> //OK
> >>>>>> } else {
> >>>>>> //Error
> >>>>>> }
> >>>>>>
> >>>>>> 3. Write XTC
> >>>>>> long step = -1;
> >>>>>> double sim_time = 0.0;
> >>>>>>
> >>>>>> matrix mat;
> >>>>>> int i;
> >>>>>> rvec *x_data;
> >>>>>> double ppos[3];
> >>>>>> int img[3];
> >>>>>> int pnode;
> >>>>>>
> >>>>>> int n_total_particles;
> >>>>>>
> >>>>>> Particle p_data;
> >>>>>>
> >>>>>> if (xfile==-1) {
> >>>>>> //Error
> >>>>>> }
> >>>>>>
> >>>>>> if (n_total_particles <1) {
> >>>>>> //Error
> >>>>>> }
> >>>>>>
> >>>>>> mat[0][0] = CONV_UNIT_L(box_l[0]);
> >>>>>> mat[0][1] = 0.0;
> >>>>>> mat[0][2] = 0.0;
> >>>>>> mat[1][0] = 0.0;
> >>>>>> mat[1][1] = CONV_UNIT_L(box_l[1]);
> >>>>>> mat[1][2] = 0.0;
> >>>>>> mat[2][0] = 0.0;
> >>>>>> mat[2][1] = 0.0;
> >>>>>> mat[2][2] = CONV_UNIT_L(box_l[2]);
> >>>>>>
> >>>>>> x_data = (rvec *)malloc(sizeof(rvec)*(n_total_particles+1));
> >>>>>>
> >>>>>> for (i = 0; i < n_total_particles; i++) {
> >>>>>> x_data[i][0] = X;
> >>>>>> x_data[i][1] = Y;
> >>>>>> x_data[i][2] = Z;
> >>>>>> }
> >>>>>>
> >>>>>> write_xtc(xfile, n_total_particles, step, sim_time, mat, x_data, 1000);
> >>>>>> step++;
> >>>>>>
> >>>>>> free(x_data);
> >>>>>>
> >>>>>> return OK;
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> Mark
> >>>>>>> _______________________________________________
> >>>>>>> gmx-developers mailing list
> >>>>>>> gmx-developers at gromacs.org
> >>>>>>> http://www.gromacs.org/mailman/listinfo/gmx-developers
> >>>>>>> Please don't post (un)subscribe requests to the list. Use the www
> >>>>>>> interface or send it to gmx-developers-request at gromacs.org.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> _______________________________________________
> >>>>>> gmx-developers mailing list
> >>>>>> gmx-developers at gromacs.org
> >>>>>> http://www.gromacs.org/mailman/listinfo/gmx-developers
> >>>>>> Please don't post (un)subscribe requests to the list. Use the
> >>>>>> www interface or send it to gmx-developers-request at gromacs.org.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>> _______________________________________________
> >>>>> gmx-developers mailing list
> >>>>> gmx-developers at gromacs.org
> >>>>> http://www.gromacs.org/mailman/listinfo/gmx-developers
> >>>>> Please don't post (un)subscribe requests to the list. Use the
> >>>>> www interface or send it to gmx-developers-request at gromacs.org.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> _______________________________________________
> >>>> gmx-developers mailing list
> >>>> gmx-developers at gromacs.org
> >>>> http://www.gromacs.org/mailman/listinfo/gmx-developers
> >>>> Please don't post (un)subscribe requests to the list. Use the
> >>>> www interface or send it to gmx-developers-request at gromacs.org.
> >>>>
> >>>>
> >>> _______________________________________________
> >>> gmx-developers mailing list
> >>> gmx-developers at gromacs.org
> >>> http://www.gromacs.org/mailman/listinfo/gmx-developers
> >>> Please don't post (un)subscribe requests to the list. Use the
> >>> www interface or send it to gmx-developers-request at gromacs.org.
> >>>
> >>>
> >>>
> >>
> >> _______________________________________________
> >> gmx-developers mailing list
> >> gmx-developers at gromacs.org
> >> http://www.gromacs.org/mailman/listinfo/gmx-developers
> >> Please don't post (un)subscribe requests to the list. Use the
> >> www interface or send it to gmx-developers-request at gromacs.org.
> >>
> > _______________________________________________
> > gmx-developers mailing list
> > gmx-developers at gromacs.org
> > http://www.gromacs.org/mailman/listinfo/gmx-developers
> > Please don't post (un)subscribe requests to the list. Use the
> > www interface or send it to gmx-developers-request at gromacs.org.
> >
> >
>
>
>
>
>
> _______________________________________________
> gmx-developers mailing list
> gmx-developers at gromacs.org
> http://www.gromacs.org/mailman/listinfo/gmx-developers
> Please don't post (un)subscribe requests to the list. Use the
> www interface or send it to gmx-developers-request at gromacs.org.
More information about the gromacs.org_gmx-developers
mailing list