Skip to main content
Skip to main content

MFT Routines for C Users

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).

The following files can be used to call the MFT library from 'C'.

mft12.c: the library of algorithms,

mft12.h: header file with function prototypes,

The programs ctest_ht_adj12.c (fluxes and height adjustment) and ctest_mft12.c (just fluxes) can be used to test the installation. The input data in testdata12.dat can be used to verify that the code is working. The same file has output data from ctest_mft12.c in the 2nd matrix, and output for ctest_ht_adj12.c in the 3rd matrix.

ctest_mft12.c: (Not working yet) example and test program for 'C',

ctest_ht_adj12.c: example and test program for 'C',

call_mft12.c: (Not working yet) 'C' shell used to call MFT 'C' code from with a different I/O structure (this code is not needed unless this interface is preferred),

testdata12.dat: 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 second table in the file testdata12.dat.

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)

int astab, air_moist_prm, count, dyn_in_prm, eqv_neut, flux_model, i, num, sfc_moist_prm, ss_prm, sst_prm, warn, z0_mom_prm, z0_TQ_prm, stable_prm;

float *dom_phs_spd, *h_sig, *lhf, *q_at_z, *q_star, *shf, *t_at_z, *tau, *t_star, *u_at_z, *u_star, *wave_age, *ww_stab, *z_over_L, *zo_m;

float air_moist_val, CONVECT, CONV_CRIT, dyn_in_val, dyn_in_val2, Qnet, pressure, ref_ht_tq, ref_ht_wind, salinity, sfc_moist_val, ss_val, t_air, t_skin, wave_ang, wind_ang, z_wanted;

FILE *fp_test_data;

if( ( fp_test_data = fopen( "testdata12.dat", "r" )) == NULL)
{
printf( "Can not open the file testdata12.dat\n" );
exit( 1 );
}

lhf = (float *) malloc( sizeof( float ) );
shf = (float *) malloc( sizeof( float ) );
tau = (float *) malloc( 2 * sizeof( float ) );
u_star = (float *) malloc( 2 * sizeof( float ) );
t_star = (float *) malloc( sizeof( float ) );
q_star = (float *) malloc( sizeof( float ) );
z_over_L = (float *) malloc( sizeof( float ) );
wave_age = (float *) malloc( sizeof( float ) );
dom_phs_spd = (float *) malloc( sizeof( float ) );
h_sig = (float *) malloc( sizeof( float ) );
ww_stab = (float *) malloc( sizeof( float ) );
zo_m = (float *) malloc( 2 * sizeof( float ) );
u_at_z = (float *) malloc( sizeof( float ) );
t_at_z = (float *) malloc( sizeof( float ) );
q_at_z = (float *) malloc( sizeof( float ) );

count = pmix( dyn_in_prm, dyn_in_val, rel_wind_ang, CONVECT, CONV_CRIT, pressure, air_moist_prm, air_moist_val, sfc_moist_prm, sfc_moist_val, salinity, ss_prm, ss_val, t_air, t_skin, ref_ht_wind, ref_ht_tq, astab, warn, shf, lhf, tau, u_star, t_star, q_star, z_over_L, wave_age, dom_phs_spd, h_sig, ww_stab, zo_m );

ht_adj

int astab, air_moist_prm, count, dyn_in_prm, eqv_neut, flux_model, i, num, sfc_moist_prm, ss_prm, sst_prm, warn, z0_mom_prm, z0_TQ_prm, stable_prm;

float *dom_phs_spd, *h_sig, *lhf, *q_at_z, *q_star, *shf, *t_at_z, *tau, *t_star, *u_at_z, *u_star, *wave_age, *ww_stab, *z_over_L, *zo_m;

float air_moist_val, CONVECT, CONV_CRIT, dyn_in_val, dyn_in_val2, Qnet, pressure, ref_ht_tq, ref_ht_wind, salinity, sfc_moist_val, ss_val, t_air, t_skin, wave_ang, wind_ang, z_wanted;

FILE *fp_test_data;

if( ( fp_test_data = fopen( "testdata12.dat", "r" )) == NULL)
{
printf( "Can not open the file testdata12.dat\n" );
exit( 1 );
}

lhf = (float *) malloc( sizeof( float ) );
shf = (float *) malloc( sizeof( float ) );
tau = (float *) malloc( 2 * sizeof( float ) );
u_star = (float *) malloc( 2 * sizeof( float ) );
t_star = (float *) malloc( sizeof( float ) );
q_star = (float *) malloc( sizeof( float ) );
z_over_L = (float *) malloc( sizeof( float ) );
wave_age = (float *) malloc( sizeof( float ) );
dom_phs_spd = (float *) malloc( sizeof( float ) );
h_sig = (float *) malloc( sizeof( float ) );
ww_stab = (float *) malloc( sizeof( float ) );
zo_m = (float *) malloc( 2 * sizeof( float ) );
u_at_z = (float *) malloc( sizeof( float ) );
t_at_z = (float *) malloc( sizeof( float ) );
q_at_z = (float *) malloc( sizeof( float ) );

count = pmix( dyn_in_prm, dyn_in_val, rel_wind_ang, CONVECT, CONV_CRIT, pressure, air_moist_prm, air_moist_val, sfc_moist_prm, sfc_moist_val, salinity, ss_prm, ss_val, t_air, t_skin, ref_ht_wind, ref_ht_tq, astab, warn, shf, lhf, tau, u_star, t_star, q_star, z_over_L, wave_age, dom_phs_spd, h_sig, ww_stab, zo_m );

/* Initialization of variables has been removed - see ctest_ht_adj12.c for an example */

/* begin loop for series of test_data */
fscanf( fp_test_data, "%*[^\n]\n" ); /* skip the header line */
printf( "run U |ustar| ustar1 ustar2 tstar qstar zref/L cp wa Hsig tau1 tau2 shf lhf u(z) t(z) q(z)\n" );
for (i= 0; i < 62; i++) {
fscanf( fp_test_data, "%i %i %f %f %i %f %i %f %i %f %f %f %f %f %f %f %f %i\n",
&num, &dyn_in_prm, &dyn_in_val, &dyn_in_val2, &ss_prm, &ss_val, &air_moist_prm, &air_moist_val, &sfc_moist_prm, &sfc_moist_val, &t_skin, &t_air, &ref_ht_wind, &ref_ht_tq, &pressure, &salinity, &CONVECT, &astab );

count = ht_adj_( dyn_in_prm, dyn_in_val, dyn_in_val2, CONVECT, CONV_CRIT, pressure, air_moist_prm, air_moist_val, sfc_moist_prm, sfc_moist_val, salinity, ss_prm, ss_val, t_air, sst_prm, t_skin, ref_ht_wind, ref_ht_tq, z_wanted, astab, eqv_neut, Qnet, warn, flux_model, z0_mom_prm, z0_TQ_prm, stable_prm, shf, lhf, tau, u_star, t_star, q_star, z_over_L, wave_age, dom_phs_spd, h_sig, ww_stab, zo_m, u_at_z, t_at_z, q_at_z );

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.

Last update: 25 Sept. 2012


home page
URL research
URL publications URL scatterometry URL flux
model URL contact info URL

2000 Levy Avenue
Building A, Suite 292
Tallahassee, FL 32306-2741
Phone: (850) 644-4581
Fax: (850) 644-4841
contact@coaps.fsu.edu

© 2024 Center for Ocean-Atmospheric Prediction Studies (COAPS), Florida State University

Center for Ocean-Atmospheric Prediction Studies (COAPS)