📄 mknb_declarations.c
字号:
/* * $Id: mknb_declarations.c,v 1.4.2.1 2008/02/29 07:02:44 spoel Exp $ * * This source code is part of * * G R O M A C S * * GROningen MAchine for Chemical Simulations * * VERSION 3.3.3 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2008, The GROMACS development team, * check out http://www.gromacs.org for more information. * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * If you want to redistribute modifications, please consider that * scientific software is very special. Version control is crucial - * bugs must be traceable. We will be happy to consider code for * inclusion in the official distribution, but derived work must not * be called official GROMACS. Details are found in the README & COPYING * files - if they are missing, get the official version at www.gromacs.org. * * To help us fund GROMACS development, we humbly ask that you cite * the papers on the package - you can find them in the top README file. * * For more info, check our website at http://www.gromacs.org * * And Hey: * Groningen Machine for Chemical Simulation *//* This file is NOT threadsafe, but it is only used to create * the nonbonded functions during the build process, so it will never be * executed by multiple threads. */#include <string.h>#include <stdlib.h>#include <mknb_common.h>#include <mknb_declarations.h>#include <mknb_metacode.h>voidmknb_function_header(char *funcname){ /* Important - make sure the C and Fortran declarations match... * The rest here is just pretty formatting that we could live without. */ if(!mknb_fortran) {#define C_REAL (mknb_double ? "double *" : "float *") fprintf(mknb_output,"void %s(\n",funcname); fprintf(mknb_output,"%19s %-8s %6s p_nri,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s iinr,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s jindex,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s jjnr,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s shift,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s shiftvec,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s fshift,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s gid,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s pos,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s faction,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s charge,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s p_facel,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s p_krf,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s p_crf,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s Vc,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s type,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s p_ntype,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s vdwparam,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s Vvdw,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s p_tabscale,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s VFtab,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s invsqrta,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s dvda,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s p_gbtabscale,\n","", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s GBtab,\n", "", C_REAL, ""); fprintf(mknb_output,"%19s %-8s %6s p_nthreads,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s count,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s mtx,\n", "", "void *", ""); fprintf(mknb_output,"%19s %-8s %6s outeriter,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s inneriter,\n", "", "int *", ""); fprintf(mknb_output,"%19s %-8s %6s work)\n{", "", C_REAL, "");#undef C_REAL } else { /* Fortran */ fprintf(mknb_output," subroutine %s(\n",funcname); fprintf(mknb_output," & nri,\n"); fprintf(mknb_output," & iinr,\n"); fprintf(mknb_output," & jindex,\n"); fprintf(mknb_output," & jjnr,\n"); fprintf(mknb_output," & shift,\n"); fprintf(mknb_output," & shiftvec,\n"); fprintf(mknb_output," & fshift,\n"); fprintf(mknb_output," & gid,\n"); fprintf(mknb_output," & pos,\n"); fprintf(mknb_output," & faction,\n"); fprintf(mknb_output," & charge,\n"); fprintf(mknb_output," & facel,\n"); fprintf(mknb_output," & krf,\n"); fprintf(mknb_output," & crf,\n"); fprintf(mknb_output," & Vc,\n"); fprintf(mknb_output," & type,\n"); fprintf(mknb_output," & ntype,\n"); fprintf(mknb_output," & vdwparam,\n"); fprintf(mknb_output," & Vvdw,\n"); fprintf(mknb_output," & tabscale,\n"); fprintf(mknb_output," & VFtab,\n"); fprintf(mknb_output," & invsqrta,\n"); fprintf(mknb_output," & dvda,\n"); fprintf(mknb_output," & gbtabscale,\n"); fprintf(mknb_output," & GBtab,\n"); fprintf(mknb_output," & nthreads,\n"); fprintf(mknb_output," & count,\n"); fprintf(mknb_output," & mtx,\n"); fprintf(mknb_output," & outeriter,\n"); fprintf(mknb_output," & inneriter,\n"); fprintf(mknb_output," & work)\n"); /* Declare fortran call arguments after header */ mknb_declare_other("implicit","none"); mknb_declare_int("nri,iinr(*),jindex(*),jjnr(*),shift(*)"); mknb_declare_real("shiftvec(*),fshift(*),pos(*),faction(*)"); mknb_declare_int("gid(*),type(*),ntype"); mknb_declare_real("charge(*),facel,krf,crf,Vc(*),vdwparam(*)"); mknb_declare_real("Vvdw(*),tabscale,VFtab(*)"); mknb_declare_real("invsqrta(*),dvda(*),gbtabscale,GBtab(*)"); /* * mask the mutex pointer as an integer passed by * reference when using fortran, or as placeholder */ mknb_declare_int("nthreads,count,mtx,outeriter,inneriter"); /* Workspace */ mknb_declare_real("work(*)"); } fprintf(mknb_output,"\n");}voidmknb_finish_function(){ mknb_comment("Write outer/inner iteration count to pointers"); mknb_assign( mknb_fortran ? "outeriter" : "*outeriter" , mknb_options.threads ? "nouter" : "nri"); mknb_assign( mknb_fortran ? "inneriter" : "*inneriter" , mknb_options.threads ? "ninner" : "nj1"); if(mknb_fortran) { mknb_code("return"); mknb_code("end"); } else { fprintf(mknb_output,"}"); } fprintf(mknb_output,"\n\n\n");} voidmknb_declare_variables(){ int i,j,firsti,firstj; char buf[255],buf2[255]; /* Never mind the if-statements when you are developing - * they are just there to avoid tons of warnings about * unused variables in the shipping code. * The for-statements have the same function - we only * declare what we need to make the generated code prettier. */ /* Scalar versions of arguments passed by reference */ if(!mknb_fortran) { mknb_declare_int("nri,ntype,nthreads"); mknb_declare_real("facel,krf,crf,tabscale,gbtabscale"); } /* loop indices and group id*/ mknb_declare_int("n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid"); if(mknb_options.threads) mknb_declare_int("nn0,nn1,nouter,ninner"); mknb_declare_real("shX,shY,shZ"); /* shift vectors */ /* scalar force and vectorial force */ if(mknb_func.do_force) mknb_declare_real("fscal,tx,ty,tz"); if((mknb_func.do_force && (mknb_func.coul==MKNB_COUL_NORMAL || mknb_func.coul==MKNB_COUL_RF)) || mknb_func.vdw==MKNB_VDW_LJ || mknb_func.vdw==MKNB_VDW_BHAM) mknb_declare_real("rinvsq"); if(mknb_func.coul) { if(mknb_func.water==MKNB_WATER_NO) mknb_declare_real("iq"); else if(mknb_func.water==MKNB_WATER_SPC_SINGLE || mknb_func.water==MKNB_WATER_TIP4P_SINGLE) mknb_declare_real("jq"); mknb_declare_real("qq,vcoul,vctot"); } if(mknb_func.vdw) { if(mknb_func.water!=MKNB_WATER_SPC_PAIR && mknb_func.water!=MKNB_WATER_TIP4P_PAIR) mknb_declare_int("nti"); mknb_declare_int("tj"); if(mknb_func.vdw!=MKNB_VDW_TAB) mknb_declare_real("rinvsix"); mknb_declare_real("Vvdw6,Vvdwtot"); if(mknb_func.vdw!=MKNB_VDW_BHAM) mknb_declare_real("Vvdw12"); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -