-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgibbsseawater.pas
3421 lines (2612 loc) · 144 KB
/
gibbsseawater.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit GibbsSeaWater;
(*
Gibbs SeaWater (GSW) Oceanographic Toolbox of TEOS–10 (gsw_c_v3.05)
http://www.teos-10.org/pubs/gsw/html/gsw_contents.html
These declarations facilitate the use of TEOS-10
functions with FreePascal/Lazarus.
Alexander Smirnov ([email protected])
2015-2019
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License 3 as published by the Free Software
Foundation. See the GNU General Public License for more details
(http://www.gnu.org/licenses/).
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
*)
interface
{$IFDEF WINDOWS}
const
libgswteos='libgswteos-10.dll';
{$ENDIF}
{$IFDEF LINUX}
const
libgswteos='libgswteos-10.so';
{$ENDIF}
(*
Adds a barrier through Central America (Panama) and then averages
over the appropriate side of the barrier
data_in : data [unitless]
lon : Longitudes of data degrees east [0 ... +360]
lat : Latitudes of data degrees north [-90 ... +90]
longs_grid : Longitudes of regular grid degrees east [0 ... +360]
lats_grid : Latitudes of regular grid degrees north [-90 ... +90]
dlongs_grid : Longitude difference of regular grid degrees [deg longitude]
dlats_grid : Latitude difference of regular grid degrees [deg latitude]
output_data : average of data depending on which side of the
Panama canal it is on [unitless]
*)
// void gsw_add_barrier(double *input_data, double lon, double lat, double long_grid, double lat_grid, double dlong_grid, double dlat_grid, double *output_data);
(*
Replaces NaN's with non-nan mean of the 4 adjacent neighbours
data_in : data set of the 4 adjacent neighbours
data_out : non-nan mean of the 4 adjacent neighbours [unitless]
*)
// void gsw_add_mean(double *data_in, double *data_out);
(*
Calculates the adiabatic lapse rate from Conservative Temperature
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature [deg C]
p : sea pressure [dbar]
gsw_adiabatic_lapse_rate_from_ct : adiabatic lapse rate [K/Pa]
*)
//double gsw_adiabatic_lapse_rate_from_ct(double sa, double ct, double p);
function gsw_adiabatic_lapse_rate_from_ct(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates the adiabatic lapse rate of ice.
t = in-situ temperature (ITS-90) [deg C]
p = sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
Note. The output is in unit of degress Celsius per Pa,
(or equivilently K/Pa) not in units of K/dbar.
*)
//double gsw_adiabatic_lapse_rate_ice(double t, double p);
function gsw_adiabatic_lapse_rate_ice(t, p:double):double; cdecl; external libgswteos;
(*
Calculates the thermal expansion coefficient of seawater with respect to
Conservative Temperature using the computationally-efficient 48-term
expression for density in terms of SA, CT and p (IOC et al., 2010)
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature [deg C]
p : sea pressure [dbar]
gsw_alpha : thermal expansion coefficient of seawater (48 term equation)
*)
// double gsw_alpha(double sa, double ct, double p);
function gsw_alpha(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates alpha divided by beta, where alpha is the thermal expansion
coefficient and beta is the saline contraction coefficient of seawater
from Absolute Salinity and Conservative Temperature. This function uses
the computationally-efficient expression for specific volume in terms of
SA, CT and p (Roquet et al., 2014).
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature [deg C]
p : sea pressure [dbar]
alpha_on_beta : thermal expansion coefficient
with respect to [kg g^-1 K^-1]
Conservative Temperature divided by the saline
contraction coefficient at constant Conservative Temperature
*)
// double gsw_alpha_on_beta(double sa, double ct, double p);
function gsw_alpha_on_beta(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates thermal expansion coefficient of seawater with respect to
in-situ temperature
sa : Absolute Salinity [g/kg]
t : insitu temperature [deg C]
p : sea pressure [dbar]
gsw_alpha_wrt_t_exact : thermal expansion coefficient [1/K]
wrt (in-situ) temperature
*)
// double gsw_alpha_wrt_t_exact(double sa, double t, double p);
function gsw_alpha_wrt_t_exact(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the thermal expansion coefficient of ice with respect to
in-situ temperature.
t = in-situ temperature (ITS-90) [deg C]
p = sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
alpha_wrt_t_ice = thermal expansion coefficient of ice with respect
to in-situ temperature [1/K]
*)
// double gsw_alpha_wrt_t_ice(double t, double p);
function gsw_alpha_wrt_t_ice(t, p:double):double; cdecl; external libgswteos;
(*
Calculates saline (haline) contraction coefficient of seawater at
constant in-situ temperature.
sa : Absolute Salinity [g/kg]
t : in-situ temperature [deg C]
p : sea pressure [dbar]
beta_const_t_exact : haline contraction coefficient [kg/g]
*)
// double gsw_beta_const_t_exact(double sa, double t, double p);
function gsw_beta_const_t_exact(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the saline (i.e. haline) contraction coefficient of seawater
at constant Conservative Temperature using the computationally-efficient
expression for specific volume in terms of SA, CT and p
(Roquet et al., 2014).
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature (ITS-90) [deg C]
p : sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
beta : saline contraction coefficient of seawater [kg/g]
at constant Conservative Temperature
*)
// double gsw_beta(double sa, double ct, double p);
function gsw_beta(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates the cabbeling coefficient of seawater with respect to
Conservative Temperature. This function uses the computationally-
efficient expression for specific volume in terms of SA, CT and p
(Roquet et al., 2014).
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature (ITS-90) [deg C]
p : sea pressure [dbar]
cabbeling : cabbeling coefficient with respect to [1/K^2]
Conservative Temperature.
*)
// double gsw_cabbeling(double sa, double ct, double p);
function gsw_cabbeling(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates conductivity, C, from (SP,t,p) using PSS-78 in the range
2 < SP < 42. If the input Practical Salinity is less than 2 then a
modified form of the Hill et al. (1986) fomula is used for Practical
Salinity. The modification of the Hill et al. (1986) expression is to
ensure that it is exactly consistent with PSS-78 at SP = 2.
The conductivity ratio returned by this function is consistent with the
input value of Practical Salinity, SP, to 2x10^-14 psu over the full
range of input parameters (from pure fresh water up to SP = 42 psu).
This error of 2x10^-14 psu is machine precision at typical seawater
salinities. This accuracy is achieved by having four different
polynomials for the starting value of Rtx (the square root of Rt) in
four different ranges of SP, and by using one and a half iterations of
a computationally efficient modified Newton-Raphson technique (McDougall
and Wotherspoon, 2012) to find the root of the equation.
Note that strictly speaking PSS-78 (Unesco, 1983) defines Practical
Salinity in terms of the conductivity ratio, R, without actually
specifying the value of C(35,15,0) (which we currently take to be
42.9140 mS/cm).
sp : Practical Salinity [unitless]
t : in-situ temperature [ITS-90] [deg C]
p : sea pressure [dbar]
c : conductivity [ mS/cm ]
*)
// double gsw_c_from_sp(double sp, double t, double p);
function gsw_c_from_sp(sp, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the chemical potential of water in ice from in-situ
temperature and pressure.
t = in-situ temperature (ITS-90) [deg C]
p = sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
chem_potential_water_ice = chemical potential of ice [J/kg]
*)
// double gsw_chem_potential_water_ice(double t, double p);
function gsw_chem_potential_water_ice(t, p:double):double; cdecl; external libgswteos;
(*
Calculates the chemical potential of water in seawater.
SA = Absolute Salinity [g/kg]
t = in-situ temperature (ITS-90) [deg C]
p = sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
chem_potential_water_t_exact = chemical potential of water
in seawater [J/g]
*)
// double gsw_chem_potential_water_t_exact(double sa, double t, double p);
function gsw_chem_potential_water_t_exact(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the isobaric heat capacity of seawater.
t = in-situ temperature (ITS-90) [deg C]
p = sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
gsw_cp_ice = heat capacity of ice [J kg^-1 K^-1]
*)
// double gsw_cp_ice(double t, double p);
function gsw_cp_ice(t, p:double):double; cdecl; external libgswteos;
(*
Calculates isobaric heat capacity of seawater
sa : Absolute Salinity [g/kg]
t : in-situ temperature [deg C]
p : sea pressure [dbar]
gsw_cp_t_exact : heat capacity [J/(kg K)]
*)
// double gsw_cp_t_exact(double sa, double t, double p);
function gsw_cp_t_exact(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the following two derivatives of Conservative Temperature
(1) CT_SA, the derivative with respect to Absolute Salinity at
constant potential temperature (with pr = 0 dbar), and
2) CT_pt, the derivative with respect to potential temperature
(the regular potential temperature which is referenced to 0 dbar)
at constant Absolute Salinity.
SA = Absolute Salinity [ g/kg ]
pt = potential temperature (ITS-90) [ deg C ]
(whose reference pressure is 0 dbar)
CT_SA = The derivative of Conservative Temperature with respect to
Absolute Salinity at constant potential temperature
(the regular potential temperature which has reference
sea pressure of 0 dbar).
The CT_SA output has units of: [ K/(g/kg)]
CT_pt = The derivative of Conservative Temperature with respect to
potential temperature (the regular one with pr = 0 dbar)
at constant SA. CT_pt is dimensionless. [ unitless ]
*)
// void gsw_ct_first_derivatives (double sa, double pt, double *ct_sa, double *ct_pt);
Procedure gsw_ct_first_derivatives (sa, pt: double; Var ct_sa, ct_pt: double); cdecl; external libgswteos;
(*
Calculates the following three derivatives of Conservative Temperature.
These derivatives are done with respect to in-situ temperature t (in the
case of CT_T_wrt_t) or at constant in-situ tempertature (in the cases of
CT_SA_wrt_t and CT_P_wrt_t).
(1) CT_SA_wrt_t, the derivative of CT with respect to Absolute Salinity
at constant t and p, and
(2) CT_T_wrt_t, derivative of CT with respect to in-situ temperature t
at constant SA and p.
(3) CT_P_wrt_t, derivative of CT with respect to pressure P (in Pa) at
constant SA and t.
This function uses the full Gibbs function. Note that this function
avoids the NaN that would exist in CT_SA_wrt_t at SA = 0 if it were
evaluated in the straightforward way from the derivatives of the Gibbs
function function.
SA = Absolute Salinity [ g/kg ]
t = in-situ temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar)
CT_SA_wrt_t = The first derivative of Conservative Temperature with
respect to Absolute Salinity at constant t and p.
[ K/(g/kg)] i.e. [ K kg/g ]
CT_T_wrt_t = The first derivative of Conservative Temperature with
respect to in-situ temperature, t, at constant SA and p.
[ unitless ]
CT_P_wrt_t = The first derivative of Conservative Temperature with
respect to pressure P (in Pa) at constant SA and t.
[ K/Pa ]
*)
// void gsw_ct_first_derivatives_wrt_t_exact(double sa, double t, double p, double *ct_sa_wrt_t, double *ct_t_wrt_t, double *ct_p_wrt_t);
(*
Calculates the Conservative Temperature at which seawater freezes. The
Conservative Temperature freezing point is calculated from the exact
in-situ freezing temperature which is found by a modified Newton-Raphson
iteration (McDougall and Wotherspoon, 2013) of the equality of the
chemical potentials of water in seawater and in ice.
An alternative GSW function, gsw_CT_freezing_poly, it is based on a
computationally-efficient polynomial, and is accurate to within -5e-4 K
and 6e-4 K, when compared with this function.
SA = Absolute Salinity [ g/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
saturation_fraction = the saturation fraction of dissolved air in
seawater
CT_freezing = Conservative Temperature at freezing of seawater [ deg C ]
*)
// double gsw_ct_freezing(double sa, double p, double saturation_fraction);
function gsw_ct_freezing(sa, p, saturation_fraction:double):double; cdecl; external libgswteos;
(*
Calculates the first derivatives of the Conservative Temperature at
which seawater freezes, with respect to Absolute Salinity SA and
pressure P (in Pa).
SA = Absolute Salinity [ g/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
saturation_fraction = the saturation fraction of dissolved air in
seawater
CTfreezing_SA = the derivative of the Conservative Temperature at
freezing (ITS-90) with respect to Absolute Salinity at
fixed pressure [ K/(g/kg) ] i.e. [ K kg/g ]
CTfreezing_P = the derivative of the Conservative Temperature at
freezing (ITS-90) with respect to pressure (in Pa) at
fixed Absolute Salinity [ K/Pa ]
*)
// void gsw_ct_freezing_first_derivatives(double sa, double p, double saturation_fraction, double *ctfreezing_sa, double *ctfreezing_p);
Procedure gsw_ct_freezing_first_derivatives(sa, p, saturation_fraction:double; Var ctfreezing_sa, ctfreezing_p:double); cdecl; external libgswteos;
(*
Calculates the first derivatives of the Conservative Temperature at
which seawater freezes, with respect to Absolute Salinity SA and
pressure P (in Pa) of the comptationally efficient polynomial fit of the
freezing temperature (McDougall et al., 2014).
SA = Absolute Salinity [ g/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
saturation_fraction = the saturation fraction of dissolved air in
seawater
CTfreezing_SA = the derivative of the Conservative Temperature at
freezing (ITS-90) with respect to Absolute Salinity at
fixed pressure [ K/(g/kg) ] i.e. [ K kg/g]
CTfreezing_P = the derivative of the Conservative Temperature at
freezing (ITS-90) with respect to pressure (in Pa) at
fixed Absolute Salinity [ K/Pa]
*)
// void gsw_ct_freezing_first_derivatives_poly(double sa, double p, double saturation_fraction, double *ctfreezing_sa, double *ctfreezing_p);
Procedure gsw_ct_freezing_first_derivatives_poly(sa, p, saturation_fraction: double; Var ctfreezing_sa, ctfreezing_p: double); cdecl; external libgswteos;
(*
Calculates the Conservative Temperature at which seawater freezes.
The error of this fit ranges between -5e-4 K and 6e-4 K when compared
with the Conservative Temperature calculated from the exact in-situ
freezing temperature which is found by a Newton-Raphson iteration of the
equality of the chemical potentials of water in seawater and in ice.
Note that the Conservative temperature freezing temperature can be found
by this exact method using the function gsw_CT_freezing.
SA = Absolute Salinity [ g/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
saturation_fraction = the saturation fraction of dissolved air in
seawater
CT_freezing = Conservative Temperature at freezing of seawater [ deg C ]
That is, the freezing temperature expressed in
terms of Conservative Temperature (ITS-90).
*)
// double gsw_ct_freezing_poly(double sa, double p, double saturation_fraction);
function gsw_ct_freezing_poly(sa, p, saturation_fraction:double):double; cdecl; external libgswteos;
(*
Calculates the Conservative Temperature of seawater, given the Absolute
Salinity, specific enthalpy, h, and pressure p.
SA = Absolute Salinity [ g/kg ]
h = specific enthalpy [ J/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325d0 dbar )
CT = Conservative Temperature ( ITS-90) [ deg C ]
*)
// double gsw_ct_from_enthalpy(double sa, double h, double p);
function gsw_ct_from_enthalpy(sa, h, p:double):double; cdecl; external libgswteos;
(*
Calculates the Conservative Temperature of seawater, given the Absolute
Salinity, specific enthalpy, h, and pressure p.
SA = Absolute Salinity [ g/kg ]
h = specific enthalpy [ J/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325d0 dbar )
CT = Conservative Temperature ( ITS-90) [ deg C ]
*)
// double gsw_ct_from_enthalpy_exact(double sa, double h, double p);
function gsw_ct_from_enthalpy_exact(sa, h, p:double):double; cdecl; external libgswteos;
(*
Calculates Conservative Temperature with entropy as an input variable.
SA = Absolute Salinity [ g/kg ]
entropy = specific entropy [ deg C ]
CT = Conservative Temperature (ITS-90) [ deg C ]
*)
// double gsw_ct_from_entropy(double sa, double entropy);
function gsw_ct_from_entropy(sa, entropy:double):double; cdecl; external libgswteos;
(*
Calculates Conservative Temperature from potential temperature of seawater
sa : Absolute Salinity [g/kg]
pt : potential temperature with [deg C]
reference pressure of 0 dbar
gsw_ct_from_pt : Conservative Temperature [deg C]
*)
// double gsw_ct_from_pt(double sa, double pt);
function gsw_ct_from_pt(sa, pt:double):double; cdecl; external libgswteos;
(*
Calculates the Conservative Temperature of a seawater sample, for given
values of its density, Absolute Salinity and sea pressure (in dbar).
rho = density of a seawater sample (e.g. 1026 kg/m^3) [ kg/m^3 ]
Note. This input has not had 1000 kg/m^3 subtracted from it.
That is, it is 'density', not 'density anomaly'.
SA = Absolute Salinity [ g/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
CT = Conservative Temperature (ITS-90) [ deg C ]
CT_multiple = Conservative Temperature (ITS-90) [ deg C ]
Note that at low salinities, in brackish water, there are two possible
Conservative Temperatures for a single density. This programme will
output both valid solutions. To see this second solution the user
must call the programme with two outputs (i.e. [CT,CT_multiple]), if
there is only one possible solution and the programme has been
called with two outputs the second variable will be set to NaN.
*)
// void gsw_ct_from_rho(double rho, double sa, double p, double *ct, double *ct_multiple);
Procedure gsw_ct_from_rho(rho, sa, p:double; Var ct, ct_multiple:double); cdecl; external libgswteos;
(*
Calculates Conservative Temperature from in-situ temperature
sa : Absolute Salinity [g/kg]
t : in-situ temperature [deg C]
p : sea pressure [dbar]
gsw_ct_from_t : Conservative Temperature [deg C]
*)
// double gsw_ct_from_t(double sa, double t, double p);
function gsw_ct_from_t(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the Conservative Temperature of maximum density of seawater.
This function returns the Conservative temperature at which the density
of seawater is a maximum, at given Absolute Salinity, SA, and sea
pressure, p (in dbar).
SA = Absolute Salinity [ g/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
CT_maxdensity = Conservative Temperature at which [ deg C ]
the density of seawater is a maximum for
given Absolute Salinity and pressure.
*)
// double gsw_ct_maxdensity(double sa, double p);
function gsw_ct_maxdensity(sa, p:double):double; cdecl; external libgswteos;
//void gsw_ct_second_derivatives(double sa, double pt, double *ct_sa_sa, double *ct_sa_pt, double *ct_pt_pt);
(*
Calculates the Absolute Salinity Anomaly atlas value, delta_SA_atlas.
p : sea pressure [dbar]
lon : longiture [deg E]
lat : latitude [deg N]
deltasa_atlas : Absolute Salinity Anomaly atlas value [g/kg]
*)
// double gsw_deltasa_atlas(double p, double lon, double lat);
function gsw_deltasa_atlas(p, lon, lat:double):double; cdecl; external libgswteos;
(*
Calculates Absolute Salinity Anomaly, deltaSA, from Practical Salinity, SP.
sp : Practical Salinity [unitless]
p : sea pressure [dbar]
lon : longitude [deg E]
lat : latitude [deg N]
gsw_deltasa_from_sp : Absolute Salinty Anomaly [g/kg]
*)
// double gsw_deltasa_from_sp(double sp, double p, double lon, double lat);
function gsw_deltasa_from_sp(sp, p, lon, lat:double):double; cdecl; external libgswteos;
(*
Calculates the dilution coefficient of seawater. The dilution
coefficient of seawater is defined as the Absolute Salinity times the
second derivative of the Gibbs function with respect to Absolute
Salinity, that is, SA.*g_SA_SA.
SA = Absolute Salinity [ g/kg ]
t = in-situ temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
dilution_coefficient_t_exact = dilution coefficient [ (J/kg)(kg/g) ]
*)
// double gsw_dilution_coefficient_t_exact(double sa, double t, double p);
function gsw_dilution_coefficient_t_exact(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates dynamic enthalpy of seawater using the computationally-
efficient expression for specific volume in terms of SA, CT and p
(Roquet et al., 2014). Dynamic enthalpy is defined as enthalpy minus
potential enthalpy (Young, 2010).
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature (ITS-90) [deg C]
p : sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
dynamic_enthalpy : dynamic enthalpy [J/kg]
*)
// double gsw_dynamic_enthalpy(double sa, double ct, double p);
function gsw_dynamic_enthalpy(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates specific enthalpy of seawater from Absolute Salinity and
Conservative Temperature and pressure.
Note that this function uses the full Gibbs function.
SA = Absolute Salinity [g/kg]
CT = Conservative Temperature (ITS-90) [deg C]
p = sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
enthalpy_CT_exact = specific enthalpy [J/kg]
*)
// double gsw_enthalpy_ct_exact(double sa, double ct, double p);
function gsw_enthalpy_ct_exact(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates the difference of the specific enthalpy of seawater between
two different pressures, p_deep (the deeper pressure) and p_shallow
(the shallower pressure), at the same values of SA and CT. This
function uses the computationally-efficient expression for specific
volume in terms of SA, CT and p (Roquet et al., 2014). The output
(enthalpy_diff_CT) is the specific enthalpy evaluated at (SA,CT,p_deep)
minus the specific enthalpy at (SA,CT,p_shallow).
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
p_shallow = upper sea pressure [ dbar ]
( i.e. shallower absolute pressure - 10.1325 dbar )
p_deep = lower sea pressure [ dbar ]
( i.e. deeper absolute pressure - 10.1325 dbar )
enthalpy_diff_CT = difference of specific enthalpy [ J/kg ]
(deep minus shallow)
*)
// double gsw_enthalpy_diff(double sa, double ct, double p_shallow, double p_deep);
function gsw_enthalpy_diff(sa, ct, p_shallow, p_deep:double):double; cdecl; external libgswteos;
(*
Calculates specific enthalpy of seawater using the computationally-
efficient expression for specific volume in terms of SA, CT and p
(Roquet et al., 2014).
sa : Absolute Salinity [g/kg]
ct : Conservative Temperature (ITS-90) [deg C]
p : sea pressure [dbar]
( i.e. absolute pressure - 10.1325 dbar )
enthalpy : specific enthalpy of seawater [J/kg]
*)
// double gsw_enthalpy(double sa, double ct, double p);
function gsw_enthalpy(sa, ct, p:double):double; cdecl; external libgswteos;
(*
Calculates the following two derivatives of specific enthalpy (h)
(1) h_SA, the derivative with respect to Absolute Salinity at
constant CT and p, and
(2) h_CT, derivative with respect to CT at constant SA and p.
Note that h_P is specific volume (1/rho) it can be calulated by calling
gsw_specvol_CT_exact(SA,CT,p). This function uses the full Gibbs function.
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
h_SA = The first derivative of specific enthalpy with respect to
Absolute Salinity at constant CT and p.
[ J/(kg (g/kg))] i.e. [ J/g ]
h_CT = The first derivative of specific enthalpy with respect to
CT at constant SA and p. [ J/(kg K) ]
*)
// void gsw_enthalpy_first_derivatives_ct_exact(double sa, double ct, double p, double *h_sa, double *h_ct);
(*
Calculates the following two derivatives of specific enthalpy (h) of
seawater using the computationally-efficient expression for
specific volume in terms of SA, CT and p (Roquet et al., 2014).
(1) h_SA, the derivative with respect to Absolute Salinity at
constant CT and p, and
(2) h_CT, derivative with respect to CT at constant SA and p.
Note that h_P is specific volume (1/rho) it can be caclulated by calling
gsw_specvol(SA,CT,p).
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
h_SA = The first derivative of specific enthalpy with respect to
Absolute Salinity at constant CT and p.
[ J/(kg (g/kg))] i.e. [ J/g ]
h_CT = The first derivative of specific enthalpy with respect to
CT at constant SA and p. [ J/(kg K) ]
*)
// void gsw_enthalpy_first_derivatives(double sa, double ct, double p, double *h_sa, double *h_ct);
(*
Calculates the specific enthalpy of ice (h_Ih).
t = in-situ temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
gsw_enthalpy_ice : specific enthalpy of ice [ J/kg ]
*)
// double gsw_enthalpy_ice(double t, double p);
function gsw_enthalpy_ice(t, p:double):double; cdecl; external libgswteos;
(*
Calculates three second-order derivatives of specific enthalpy (h).
Note that this function uses the full Gibbs function.
sa = Absolute Salinity [ g/kg ]
ct = Conservative Temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
h_sa_sa = The second derivative of specific enthalpy with respect to
Absolute Salinity at constant ct & p. [ J/(kg (g/kg)^2) ]
h_sa_ct = The second derivative of specific enthalpy with respect to
sa and ct at constant p. [ J/(kg K(g/kg)) ]
h_ct_ct = The second derivative of specific enthalpy with respect to
ct at constant sa and p. [ J/(kg K^2) ]
*)
// void gsw_enthalpy_second_derivatives_ct_exact(double sa, double ct, double p, double *h_sa_sa, double *h_sa_ct, double *h_ct_ct);
(*
Calculates the following three second-order derivatives of specific
enthalpy (h),using the computationally-efficient expression for
specific volume in terms of SA, CT and p (Roquet et al., 2014).
(1) h_SA_SA, second-order derivative with respect to Absolute Salinity
at constant CT & p.
(2) h_SA_CT, second-order derivative with respect to SA & CT at
constant p.
(3) h_CT_CT, second-order derivative with respect to CT at constant SA
and p.
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
h_SA_SA = The second derivative of specific enthalpy with respect to
Absolute Salinity at constant CT & p. [ J/(kg (g/kg)^2) ]
h_SA_CT = The second derivative of specific enthalpy with respect to
SA and CT at constant p. [ J/(kg K(g/kg)) ]
h_CT_CT = The second derivative of specific enthalpy with respect to
CT at constant SA and p. [ J/(kg K^2) ]
*)
// void gsw_enthalpy_second_derivatives(double sa, double ct, double p, double *h_sa_sa, double *h_sa_ct, double *h_ct_ct);
(*
This function calculates enthalpy at the Standard Ocean Salinity, SSO,
and at a Conservative Temperature of zero degrees C, as a function of
pressure, p, in dbar, using a streamlined version of the
computationally-efficient expression for specific volume, that is, a
streamlined version of the code "gsw_enthalpy(SA,CT,p)".
p : sea pressure [dbar]
enthalpy_sso_0 : enthalpy(sso,0,p)
*)
// double gsw_enthalpy_sso_0(double p);
function gsw_enthalpy_sso_0(p:double):double; cdecl; external libgswteos;
(*
Calculates the specific enthalpy of seawater
sa : Absolute Salinity [g/kg]
t : in-situ temperature [deg C]
p : sea pressure [dbar]
gsw_enthalpy_t_exact : specific enthalpy [J/kg]
*)
// double gsw_enthalpy_t_exact(double sa, double t, double p);
function gsw_enthalpy_t_exact(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates the following two partial derivatives of specific entropy
(eta)
(1) eta_SA, the derivative with respect to Absolute Salinity at
constant Conservative Temperature, and
(2) eta_CT, the derivative with respect to Conservative Temperature at
constant Absolute Salinity.
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
eta_SA = The derivative of specific entropy with respect to
Absolute Salinity (in units of g kg^-1) at constant
Conservative Temperature.
eta_SA has units of: [ J/(kg K(g/kg))] or [ J/(g K) ]
eta_CT = The derivative of specific entropy with respect to
Conservative Temperature at constant Absolute Salinity.
eta_CT has units of: [ J/(kg K^2) ]
*)
// void gsw_entropy_first_derivatives(double sa, double ct, double *eta_sa, double *eta_ct);
(*
Calculates specific entropy of seawater from Conservative Temperature.
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
entropy = specific entropy [ deg C ]
*)
// double gsw_entropy_from_ct(sa, ct)
function gsw_entropy_from_ct(sa, ct:double):double; cdecl; external libgswteos;
(*
Calculates specific entropy of seawater.
SA = Absolute Salinity [ g/kg ]
pt = potential temperature (ITS-90) [ deg C ]
entropy = specific entropy [ J/(kg*K) ]
*)
// double gsw_entropy_from_pt(double sa, double pt);
function gsw_entropy_from_pt(sa, pt:double):double; cdecl; external libgswteos;
(*
Calculates the specific entropy of seawater
sa : Absolute Salinity [g/kg]
t : in-situ temperature [deg C]
p : sea pressure [dbar]
gsw_entropy_from_t : specific entropy [J/(kg K)]
*)
// double gsw_entropy_from_t(double sa, double t, double p);
function gsw_entropy_from_t(sa, t, p:double):double; cdecl; external libgswteos;
(*
Calculates specific entropy of ice.
t = in-situ temperature (ITS-90) [ deg C ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
ice_entropy = specific entropy of ice [ J kg^-1 K^-1 ]
*)
// double gsw_entropy_ice(double t, double p);
function gsw_entropy_ice(t, p:double):double; cdecl; external libgswteos;
(*
Entropy minus the terms that are a function of only SA
sa : Absolute Salinity [g/kg]
t : in-situ temperature [deg C]
p : sea pressure [dbar]
entropy_part : entropy part
*)
// double gsw_entropy_part(double sa, double t, double p);
function gsw_entropy_part(sa, t, p:double):double; cdecl; external libgswteos;
(*
Entropy part evaluated at the sea surface
sa : Absolute Salinity [g/kg]
pt0 : insitu temperature [deg C]
entropy_part_zerop : entropy part at the sea surface
*)
// double gsw_entropy_part_zerop(double sa, double pt0);
function gsw_entropy_part_zerop(sa, pt0:double):double; cdecl; external libgswteos;
(*
Calculates the following three second-order partial derivatives of
specific entropy (eta)
(1) eta_SA_SA, the second derivative with respect to Absolute
Salinity at constant Conservative Temperature, and
(2) eta_SA_CT, the derivative with respect to Absolute Salinity and
Conservative Temperature.
(3) eta_CT_CT, the second derivative with respect to Conservative
Temperature at constant Absolute Salinity.
SA = Absolute Salinity [ g/kg ]
CT = Conservative Temperature (ITS-90) [ deg C ]
eta_SA_SA = The second derivative of specific entropy with respect
to Absolute Salinity (in units of g kg^-1) at constant
Conservative Temperature.
eta_SA_SA has units of: [ J/(kg K(g/kg)^2)]
eta_SA_CT = The second derivative of specific entropy with respect
to Conservative Temperature at constant Absolute
Salinity. eta_SA_CT has units of: [ J/(kg (g/kg) K^2) ]
eta_CT_CT = The second derivative of specific entropy with respect
to Conservative Temperature at constant Absolute
Salinity. eta_CT_CT has units of: [ J/(kg K^3) ]
*)
// void gsw_entropy_second_derivatives(double sa, double ct, double *eta_sa_sa, double *eta_sa_ct, double *eta_ct_ct);
(*
Calculates fdelta.
p : sea pressure [dbar]
lon : longitude [deg E]
lat : latitude [deg N]
gsw_fdelta : Absolute Salinty Anomaly [unitless]
*)
// double gsw_fdelta(double p, double lon, double lat);
function gsw_fdelta(p, lon, lat:double):double; cdecl; external libgswteos;
(*
Calculates the mass fraction of ice (mass of ice divided by mass of ice
plus seawater), w_Ih_final, which results from given values of the bulk
Absolute Salinity, SA_bulk, bulk enthalpy, h_bulk, occuring at pressure
p. The final values of Absolute Salinity, SA_final, and Conservative
Temperature, CT_final, of the interstitial seawater phase are also
returned. This code assumes that there is no dissolved air in the
seawater (that is, saturation_fraction is assumed to be zero
throughout the code).
When the mass fraction w_Ih_final is calculated as being a positive
value, the seawater-ice mixture is at thermodynamic equlibrium.
This code returns w_Ih_final = 0 when the input bulk enthalpy, h_bulk,
is sufficiently large (i.e. sufficiently "warm") so that there is no ice
present in the final state. In this case the final state consists of
only seawater rather than being an equlibrium mixture of seawater and
ice which occurs when w_Ih_final is positive. Note that when
w_Ih_final = 0, the final seawater is not at the freezing temperature.
SA_bulk = bulk Absolute Salinity of the seawater and ice mixture
[ g/kg ]
h_bulk = bulk enthalpy of the seawater and ice mixture [ J/kg ]
p = sea pressure [ dbar ]
( i.e. absolute pressure - 10.1325 dbar )
SA_final = Absolute Salinity of the seawater in the final state,
whether or not any ice is present. [ g/kg ]
CT_final = Conservative Temperature of the seawater in the the final
state, whether or not any ice is present. [ deg C ]
w_Ih_final = mass fraction of ice in the final seawater-ice mixture.
If this ice mass fraction is positive, the system is at
thermodynamic equilibrium. If this ice mass fraction is
zero there is no ice in the final state which consists
only of seawater which is warmer than the freezing
temperature. [unitless]
*)
// void gsw_frazil_properties(double sa_bulk, double h_bulk, double p, double *sa_final, double *ct_final, double *w_ih_final);
(*
Calculates the mass fraction of ice (mass of ice divided by mass of ice
plus seawater), w_Ih_final, which results from given values of the bulk
Absolute Salinity, SA_bulk, bulk potential enthalpy, h_pot_bulk,
occuring at pressure p. The final equilibrium values of Absolute
Salinity, SA_final, and Conservative Temperature, CT_final, of the
interstitial seawater phase are also returned. This code assumes that
there is no dissolved air in the seawater (that is, saturation_fraction
is assumed to be zero thoughout the code).
When the mass fraction w_Ih_final is calculated as being a positive
value, the seawater-ice mixture is at thermodynamic equlibrium.