Corrected Conversion Algorithm for CalCOFI Station Grid And Their Implementation in Several Computer Languages by Edward Weber & Thomas Moorem, NOAA Fisheries, 2013 CalCOFI Report v 54.
Matlab scripts by Robert Thombley, SIOCalCOFI with Sep2014 error correction by Augusto Valencia, UABC; based on Weber & Moor 2013.
Link to MatLab downloadable code authored by Robert Thombley, SIOCalCOFI
(Abstract from pdf) "Converting between geographic coordinates in latitude and longitude and the line and station sampling pattern of the California Cooperative Fisheries Investigations (CalCOFI) program is a commonly required task for conducting research on the California Current ecosystem. This note presents several corrections and clarifications to the previously published algorithms for performing these conversions. We include computer code to implement the algorithms in Java™1, Perl, Python, and R. We note that freely available code to conduct the conversions in Fortran, Matlab®2, JavaScript™, and Visual Basic®6 has previously been published, and an online conversion tool is also available. A future version of the PROJ.4 cartographic projections library will also include support for CalCOFI conversions, thereby allowing for convenient conversions using the GRASS GIS, PostGIS, Python, Perl, R, and many other programs and programming languages."
For individual language  Java, Perl, Python, or R  implementations & downloads, see sections below
Java Implementation (Java Download): objects of the Java class CalcofiCoordConverter hold coordinates as either “longlat” or “calcofi.” Coordinates may be retrieved using the “getCoords” method. The current coordinate system may be retrieved using the “getProjection” method. The “reproject” method accepts either “longlat” or “calcofi ” as an argument and converts to the appropriate coordinate system.  
To Convert Lat Lon to Line Sta 
To Convert Line Sta to Lat Lon: > java TestCalcofiCoordConverter 50 120 calcofi Original coordinates x 50.0 y 120.0 projection calcofi New coordinates x 129.2795443042271 y 37.34615242270663 projection longlat Backtransformed coordinates x 49.999998777973516 y 120.00000634983587 projection calcofi 
PERL Implementation (Perl Download): the Perl code is designed to read input data from a file (coords.in) and write the converted output coordinates (along with the original input coordinate data) to a file (coords.out). The section of the code that begins with “USERMODIFIED SETTINGS” can be changed to use different filenames and identify the direction of the conversion (“cc2geo” for CalCOFI station grid coordinates to geographic coordinates and “geo2cc” for geographic coordinates to CalCOFI station grid coordinates).  
Contents for cc2geo_coords.in:
Contents for cc2geo_coords.out: 
Contents for geo2cc_coords.in: LATD,LATM,LATS,LATH,LOND,LONM,LONS,LONH 34,9,0,N,121,9,0,W 34.15,0,0,N,121.15,0,0,W 37,20.7692,0,N,129,16.7727,0,W Contents for geo2cc_coords.out: LATD,LATM,LATS,LATH,LOND,LONM,LONS,LONH,LAT_DD, LON_DD,LINE,STATION 34,9,0,N,121,9,0,W,34.15,121.15,80.0000,60.0000 34.15,0,0,N,121.15,0,0,W,34.15,121.15,80.0000,60.0000 37,20.7692,0,N,129,16.7727,0,W,37.3461533333333, 129.279545,50.0000,120.0000 
Python Implementation (Python Download): the Python functions perform the conversions on single coordinate pairs as x and y arguments, or multiple points by entering tuples, lists, or arrays from the numeric python module numpy. The functions always return numpy arrays.  
> line, station = latlontostation(121.15, 34.15) > line 79.999998861026384 > station 60.000005918280479 > stationtolatlon(line, station) array([121.15000055, 34.15 ]) > lon, lat = stationtolatlon(50, 120) > lon 129.27954430422696 > lat 37.346152422706631 >latlontostation(lon, lat) array([ 49.99999878, 120.00000635]) 
Multiple points may be converted equivalently using tuples:
All three of these examples return: 
R Implementation (R Download): the R functions listed in Appendix IV work similar. 

> lineandstation < latlon.to.station(c(121.15,34.15)) > lineandstation line station [1,] 80 60.0000 > station.to.latlon(lineandstation) lon lat line 121.15 34.1 
> latlon < station.to.latlon(c(50, 120)) > latlon lon lat [1,] 129.2795 37.3461 > latlon.to.station(latlon) line station lon 50 120 
The R functions will accept matrices of two columns to perform conversions on multiple points at the same time. For example, > mat < matrix(c(80, 50, 60, 120), 2, 2) > mat [,1] [,2] [1,] 80 60 [2,] 50 120 > station.to.latlon(mat) lon lat [1,] 121.1500 34.15000 [2,] 129.2795 37.34615 By default, R uses fewer significant digits than Python or Java but this could be adjusted in the R options 

MatLab Scripts (MatLab Download) by Robert Thombley; gridlib.m 

function [lat, lon] = cc2lat(li,st)
INPUT: The calcofi line and station values 
function [line, sta] = lat2cc(la,lo) DESCRIPTION: Use this function to convert from degree decimal lat and long to calcofi grid coordinates. This uses the CalCOFI degridding algorithm (Eber and Hewitt 1979). This is the inverse of the function cc2lat. It is more complicated because this one requires some nonalgebraic iteration. INPUT: latitude and longitude values in decimal degrees to be converted OUTPUT: This function outputs a line and station value ASSUMPTIONS: All lat/long and station values are from the Northwestern hemisphere and within the middle latitudes. REFERENCE: Based on Weber & Moore 2013; Eber and Hewitt 1979, Conversion Algorithms for the CalCOFI Station Grid WRITTEN BY: Robert Thombley (2006), Scripps Institution of Oceanography, SIOCalCOFI MODIFIED BY: Augusto Valencia (2014), Universidad de Baja CaliforniaUABC (02Sep2014). 