~fluidity-core/fluidity/refactor-netcdf

« back to all changes in this revision

Viewing changes to ocean_forcing/tests/test_kara_ocean_fluxes.cpp

  • Committer: Jon Hill
  • Date: 2013-02-16 09:01:40 UTC
  • mfrom: (3981.7.159 fluidity)
  • Revision ID: jon.hill@imperial.ac.uk-20130216090140-bplzxqzdk1eik4za
Megre from trunk, fixing several conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include "../FluxesReader.h"
3
3
#include "../BulkForcing.h"
4
4
#include <fstream>
 
5
#include "global_parameters.h"
 
6
#include "coordinates.h"
5
7
 
6
8
using namespace std;
7
9
 
11
13
    void test_kara_ocean_fluxes_fc();
12
14
}
13
15
 
14
 
extern int projections(int nPoints, double *x, double *y, double *z, string current_coord, string output_coord);
15
16
extern void report_test(const string& title, const bool& fail, const bool& warn, const string& msg);
16
17
 
17
18
void test_kara_ocean_fluxes_fc() {
19
20
   
20
21
#ifdef HAVE_LIBUDUNITS
21
22
    FluxesReader FluxesReader_ERAdata;
22
 
    int err = -1;
23
23
    bool fail = true;
24
24
    bool warn = false;
25
25
    char errorMessage[256];
26
26
    int NNodes = 1;
27
 
    double error;
28
27
    double time = 86400;
29
28
    vector<double> T(NNodes, 0.0), S(NNodes, 35.0), Vx(NNodes, 0.0), Vy(NNodes, 0.0), Vz(NNodes, 0.0),
30
29
    F_as(NNodes, 0.0), Q_as(NNodes, 0.0), tau_u(NNodes, 0.0), tau_v(NNodes, 0.0),
31
30
    X(NNodes, 0.0), Y(NNodes, 0.0), Z(NNodes, 0.0), Q_solar(NNodes, 0.0), e(NNodes,0.0),
32
 
    q_l(NNodes,0.0), q_h(NNodes,0.0), q_e(NNodes, 0.0), q_p(NNodes, 0.0), x(NNodes,0.0), 
33
 
    y(NNodes,0.0), z(NNodes,0.0);
 
31
    q_l(NNodes,0.0), q_h(NNodes,0.0), q_e(NNodes, 0.0), q_p(NNodes, 0.0);
34
32
 
35
33
    // set up the normal input file (ERA40)
36
34
    FluxesReader_global.RegisterDataFile("../../tests/data/stationPapa_1970.nc");
62
60
    int const nFields_in=9, nFields_out=7;
63
61
    double values_in[nFields_in];
64
62
    double values_out[nFields_out];
65
 
    int ret;
66
63
    double accumulated_correction = 6.0*60.0*60.0;
67
64
 
68
65
    int n = 1;
71
68
    X[0] = -3.35835e+06;
72
69
    Y[0] = -2.35154e+06;
73
70
    Z[0] = 4.88594e+06;
74
 
    y[0] = Y[0] , x[0] = X[0] , z[0] = Z[0];
75
 
    ret = projections(n, &x[0], &y[0], &z[0], "cart", "spherical");
76
 
    if (ret != 0) {
77
 
        cerr<<"Error converting coord system"<<endl;
78
 
    }
79
 
    
80
 
    FluxesReader_ERAdata.GetScalars(x[0], y[0], values_out);
81
 
    FluxesReader_global.GetScalars(x[0], y[0], values_in);
 
71
    double surface_radius = 6.37101e+06;
 
72
    double longitude = 0.0;
 
73
    double latitude = 0.0;
 
74
    double height = 0.0;
 
75
    cartesian_2_lon_lat_height_c(&X[0], &Y[0], &Z[0],
 
76
                                 &longitude, &latitude, &height,
 
77
                                 &surface_radius);
 
78
   
 
79
    FluxesReader_ERAdata.GetScalars(longitude, latitude, values_out);
 
80
    FluxesReader_global.GetScalars(longitude, latitude, values_in);
82
81
    double temp =  (values_in[3] - values_out[3]);
83
82
    temp = temp / accumulated_correction; // correcting for accumulated values
84
83
    temp = temp / 5.67e-8;                // SB constant
110
109
    for (int t = 86400 ; t < 2592000; t += 21600) {
111
110
    
112
111
        FluxesReader_ERAdata.SetTimeSeconds(t);
113
 
        FluxesReader_ERAdata.GetScalars(x[0], y[0], values_out);
 
112
        FluxesReader_ERAdata.GetScalars(longitude, latitude, values_out);
114
113
        FluxesReader_global.SetTimeSeconds(t);
115
 
        FluxesReader_global.GetScalars(x[0], y[0], values_in);
 
114
        FluxesReader_global.GetScalars(longitude, latitude, values_in);
116
115
 
117
116
        // now let's work out the fluxes for our test location
118
117
        double Tau_u_out = values_out[4]/(accumulated_correction*ocean_density);