How to add your own function into xcrvfit v4.x.x.

These are the notes that I use. You probably have some programming experience before you want to try this on your own. You can submit function requests to the author if all this looks a bit daunting.
  1. make sure you have the 'make' command and can compile c-code on your machine.

  2. think of a descriptive codename or key for your new function (eg AMIDE_PH)

  3. cd src/fastcrvfit, goto the directory that has c source code

  4. edit crvfit.h
    	- Give a unique ID number for your new function. You can add it to the end
    	of the function list if you want:
    		#define AMIDE_PH    29  
    

  5. edit calc.c
    	- define your function using c-code math (for example)
    
     	case AMIDE_PH:
    		b = pow(10.0,-x);
    		c = a[1] * pow(10.0,-14) / b;
    		d = a[2] * b;
    		e = a[3];
    		f = c + d + e;
    		*fx = 1.0 / (1.0 + f * a[0]);
    		break;
    

  6. edit init.c
    	Add initialization entry for your new function in c. This includes
    	the names you wish to give the parameters. For example:
    
    /* Amide pH Depedence */
        fitLabel[AMIDE_PH]          = "Amide pH dependence";
    	fitNote[AMIDE_PH]           = "Notes: 1 / (1 + kex * T1)";
    	fitParmNum[AMIDE_PH]        = 4;
    	fitParmStr[AMIDE_PH][0]    = "T1.......:";
    	fitParmStr[AMIDE_PH][1]    = "kOH......:";
    	fitParmStr[AMIDE_PH][2]    = "kH.......:";
    	fitParmStr[AMIDE_PH][3]    = "kH2O.....:";
    

  7. edit main.c
    	Add entry to get_fit_func procedure. For Example:
    
    	if (0 == strcmp("AMIDE_PH", aStr)) { return(AMIDE_PH); }
    

  8. make (creates an executable for fastcrvfit). Fix any compilation errors before proceding past this point. Make sure your function is correct.

  9. Test your function! See test.run and follow the example. Make sure you have the correct results from your test function before proceding.


    Once your new function is working, proceed to the tcl code to update the user interface.


  10. First, copy this new fastcrvfit executable to the location that corresponds in the tcl/tk code. In my case the command is:
    cp fastcrvfit ../../bin/fastcrvfit
    

  11. cd tcl (goto the directory that has all the tcl source code)

  12. edit function.tcl
    	- Decide which group the function fits into (standard, common-nmr, or
    	user-submitted) and add the key to the list. For example:
    
    		set xcv(function,common-nmr) {
    			T1_RELAX T2_RELAX R2_DIMER R2X_DIMER PH_TITR \
    			XY1 XY2 GAUSS DISP AMIDE_PH SUM_LOREN }
    
    	- Create a function description section (see other examples in the file) 
    
    		set key                 AMIDE_PH
    		set myFunc($key,name)   "Amide pH dependence"
    		set myFunc($key,note)   "Amide pH dependence"
    		set myFunc($key,parms)  "T1 kOH kH kH2O"
    
    	- Define the function using tcl math
    
    		if { $id == $myFunc(AMIDE_PH) } {
    			set b [expr pow(10,-$x)]
    			set c [expr $panvar(parms,1) * pow(10,-14) / $b]
    			set d [expr $panvar(parms,2) * $b]
    			set e $panvar(parms,3)
    			set f [expr $c + $d + $e]
    			return [expr 1.0 / (1.0 + $f * $panvar(parms,0))]
    		}
    	

  13. edit main.tcl
    	- update version of xcrvfit so users know this is a new version. 
    
    	set xcv(VERSION)        "v4.x.x"
    	

  14. cd lib, update VERSION file

  15. cd test (check that the tcl changes we made are correct)
    
    	- mkdir AMIDE_PH
    	- create an input dataset
    	- create the test.run file for easy testing, see examples.
    	- type "test.run". Make sure your new function is working in the gui.
    


    Once fully tested, we now create an xcrvfit module for sharing. Contact the author that you have a new function you wish to include in the public distribution of xcrvfit.


  16. cd devtools (we need to update documentation to include this new function)
    	- update README file for new version
    	- cd docs, edit index.html
    		- update version
       		- add new function description for web pages
    

  17. cd devtools
    	- edit pack-compile and decide which executables we will build. I have a
    	solaris, mac osx and linux box. Run the script.
    
    	- Run pack-final. This script makes a tar file of everything that xcrvfit
    	needs and installation script. 
    

  18. update xcrvfit website to point to new version and announce
    		rm latest
    		ln -s html-v4.0.12 latest
    		vi index.html