1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_CPPOPTIONS.h" |
5 |
|
6 |
subroutine cost_geoid( |
7 |
O sphcost, |
8 |
I shc, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_geoid |
14 |
c ================================================================== |
15 |
c |
16 |
c o Evaluate the cost function of the geoid contribution. |
17 |
c |
18 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
19 |
c |
20 |
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
21 |
c - Restructured the code in order to create a package |
22 |
c for the MITgcmUV. |
23 |
c |
24 |
c changed: Ralf Giering Ralf.Giering@FastOpt.de 12-Jun-2001 |
25 |
c - totally rewrite for parallel processing |
26 |
c |
27 |
c heimbach@mit.edu 05-May-2005 |
28 |
c - debugged and restructuted |
29 |
c |
30 |
c ================================================================== |
31 |
c SUBROUTINE cost_geoid |
32 |
c ================================================================== |
33 |
|
34 |
implicit none |
35 |
|
36 |
c == global variables == |
37 |
|
38 |
#include "EEPARAMS.h" |
39 |
#include "SIZE.h" |
40 |
#include "PARAMS.h" |
41 |
|
42 |
#include "ecco_cost.h" |
43 |
#ifdef ALLOW_SPHERE |
44 |
# include "sphere.h" |
45 |
#else |
46 |
integer ncShc |
47 |
parameter (ncShc=1) |
48 |
#endif |
49 |
|
50 |
c == routine arguments == |
51 |
|
52 |
_RL sphcost |
53 |
_RL shc( ncShc ) |
54 |
integer mythid |
55 |
|
56 |
#ifdef ALLOW_EGM96_ERROR_COV |
57 |
|
58 |
c == local variables == |
59 |
|
60 |
Real*8 pinv( ncshc ) |
61 |
|
62 |
integer i,j |
63 |
integer ilo,ihi |
64 |
integer ireads |
65 |
integer egmsize |
66 |
parameter( egmsize = 8 ) |
67 |
|
68 |
integer jsize, joff, jbeg, jend |
69 |
integer reclength |
70 |
|
71 |
_RL factor |
72 |
_RL recip_rr |
73 |
|
74 |
c == end of interface == |
75 |
|
76 |
c-- Only the master thread is doing I/O |
77 |
_BEGIN_MASTER( mythid ) |
78 |
|
79 |
c-- initialise cost variable for all threads |
80 |
c-- to allow usage of global_sum_r8 |
81 |
sphcost = 0. _d 0 |
82 |
do i=1,ncShc |
83 |
pinv(i) = 0. _d 0 |
84 |
enddo |
85 |
|
86 |
c-- Initialise variables. |
87 |
recip_rr = recip_rsphere*recip_rsphere |
88 |
|
89 |
c-- round up the quotient to get jsize |
90 |
jsize = ncshc / numberOfProcs |
91 |
if (jsize*numberOfProcs .lt. ncshc ) then |
92 |
jsize = jsize + 1 |
93 |
end if |
94 |
|
95 |
c-- compute sub-intervall of 1..ncshc for this processor |
96 |
joff = myProcId*jsize |
97 |
jbeg = 1 + joff |
98 |
jend = min( ncshc, joff+jsize ) |
99 |
reclength = ncshc*egmsize |
100 |
|
101 |
c-- read part of geoid error covariance matrix |
102 |
c-- and compute corresponding part of cost contribution |
103 |
CADJ loop = parallel |
104 |
do j = jbeg,jend |
105 |
|
106 |
call cost_readgeoid( |
107 |
I geoid_covariancefile, reclength, j, |
108 |
O pinv, |
109 |
I mythid ) |
110 |
|
111 |
factor = 0. |
112 |
do i = 1,ncShc |
113 |
factor = factor + pinv(i)*shc(i)*recip_rr |
114 |
enddo |
115 |
sphcost = sphcost + factor*shc(j) |
116 |
enddo |
117 |
|
118 |
_END_MASTER( mythid ) |
119 |
|
120 |
call global_sum_r8( sphcost, mythid ) |
121 |
|
122 |
#else /* ALLOW_EGM96_ERROR_COV */ |
123 |
sphcost = 0. |
124 |
|
125 |
#endif /* ALLOW_EGM96_ERROR_COV */ |
126 |
|
127 |
end |
128 |
|
129 |
|