The algorithms for the Modularized Flux Testbed (MFT) can be downloaded through this web site or taken from our public FTP site (anonymous FTP to coaps.fsu.edu, change directories to pub/bourasssa/mft). Thanks to John Steffen, Auston Todd, and Jiangyi Hu for the MatLab wrapper.
The following three files are needed to call the MFT library from MatLab. The test data files are NOT needed, but a useful to validate that the model is running correctly. The example program below reads the test data and outputs data that can be compared to data in the bottom matrix in the testdata12 file (note that the columns do not match).
mexmft12.c: MEX file that calls mft12.c,
mft12.c: the library of algorithms,
mft12.h: header file with function prototypes,
run_MFT_flux.m: Example main program for testing MatLab version of the ht_adj code,
testdata12.dat or testdata12.csv: input and output data for the test program.Use of the Test Routine
This code is designed for Linux systems, and might have to be modified for other platforms.
The test program can be used to check for compiler related changes in output.
The test code also demonstrates how to call the main MFT routines.
The test program reads in data from the file testdata12.dat, and outputs
to the screen.
This output should match the table in the file testdata12.dat (middle table for pmix, last table for ht_adj).
Compile the mexmft12.c file within the Matlab interface using: mex mexmft12.c
The matlab code injests a 1 by 27 input array and produces a 1 by 15 output array. Use the following matlab code to read in multiple lines of data:
BE AWARE: if the c code (mft12.c) is modified, the changed code will be used by the MatLab program only after it is recompiled:
mex mexmft12.c
Example Variable Declaration and Calls
It is a lot easier to program if you have examples, and even better if you can cut and paste. These examples are taken from the test codes.
pmix (not fully working; needs to be updated)
ht_adj
clear all;
Example for reading a text file
testdata12 = textread('testdata12.dat','',62,'headerlines',1);
testdata12(:,1) = [];
for i = 1:length(testdata12)
data = (testdata12(i,:));
outputarray(i,:) = mexmft12(data);
end
Example for reading a comma separated file (CSV) file
testdata12 = csvread('testdata12.csv',1);
for i = 1:length(testdata12)
data = (testdata12(i,:));
outputarray(i,:) = mexmft12(data);
end
Note: testdata12 is the name of the array of test data. This can change depending on your naming preference.
The above code is available here
Additional Information
The flux and seastate model is programmed in 'C'. The bulk of the documentation is in the subroutine pmix. Wrappers for calling the programs from IDL and FORTRAN have been developed for the '12 version of the code.Status: mostly tested for ht_adj; pmix still needs work for mixed languages and testing
Warnings:
1) There are very few checks on the range of input parameters: unbelievable input will result in unbelievable output.
2) Use the output count. If it is zero or less, there is a problem. In some cases the fluxes are near zero, but in other cases they are grossly unreliable.
THANKS!
Special thanks to John Steffen, Austin Todd, Rachel Weihs, and Jason Keefer for developing the MatLab wrapper.
Last update: 09 Sept. 2014