1 |
C $Header: /u/gcmpack/MITgcm/pkg/profiles/cost_profiles.F,v 1.12 2007/06/15 05:04:00 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PROFILES_OPTIONS.h" |
5 |
|
6 |
C o==========================================================o |
7 |
C | subroutine cost_profiles | |
8 |
C | o computes the cost for netcdf profiles data | |
9 |
C | started: Gael Forget 15-March-2006 | |
10 |
C o==========================================================o |
11 |
|
12 |
SUBROUTINE cost_profiles( myiter, mytime, myThid ) |
13 |
|
14 |
IMPLICIT NONE |
15 |
|
16 |
C ======== Global data ============================ |
17 |
#include "EEPARAMS.h" |
18 |
#include "SIZE.h" |
19 |
#include "GRID.h" |
20 |
#include "DYNVARS.h" |
21 |
#ifdef ALLOW_CAL |
22 |
#include "cal.h" |
23 |
#endif |
24 |
#ifdef ALLOW_CTRL |
25 |
#include "ctrl.h" |
26 |
#include "ctrl_dummy.h" |
27 |
#include "optim.h" |
28 |
#endif |
29 |
#ifdef ALLOW_PROFILES |
30 |
#include "profiles.h" |
31 |
#include "netcdf.inc" |
32 |
#endif |
33 |
|
34 |
c == routine arguments == |
35 |
integer myiter |
36 |
_RL mytime |
37 |
integer mythid |
38 |
|
39 |
#ifdef ALLOW_PROFILES |
40 |
#ifdef ALLOW_COST |
41 |
|
42 |
C ========= Local variables ======================= |
43 |
integer K,num_file,num_var,prof_num |
44 |
integer bi,bj,iG,jG,err,fid |
45 |
_RL tmp_lon |
46 |
_RL prof_traj1D(NLEVELMAX), prof_traj1D_mean(NLEVELMAX) |
47 |
_RL prof_data1D(NLEVELMAX), prof_weights1D(NLEVELMAX) |
48 |
#ifdef ALLOW_PROFILES_GENERICGRID |
49 |
integer prof_i1D(NUM_INTERP_POINTS),prof_j1D(NUM_INTERP_POINTS) |
50 |
_RL prof_w1D(NUM_INTERP_POINTS) |
51 |
#endif |
52 |
character*(max_len_mbuf) msgbuf |
53 |
c == end of interface == |
54 |
|
55 |
_BEGIN_MASTER( mythid ) |
56 |
|
57 |
DO bj=1,nSy |
58 |
DO bi=1,nSx |
59 |
|
60 |
do num_file=1,NFILESPROFMAX |
61 |
fid=fiddata(num_file,bi,bj) |
62 |
do prof_num=1,NOBSGLOB |
63 |
if (prof_num.LE.ProfNo(num_file,bi,bj)) then |
64 |
|
65 |
#ifdef ALLOW_PROFILES_GENERICGRID |
66 |
do k=1,NUM_INTERP_POINTS |
67 |
prof_i1D(k)= prof_interp_i(num_file,prof_num,k,bi,bj) |
68 |
prof_j1D(k)= prof_interp_j(num_file,prof_num,k,bi,bj) |
69 |
prof_w1D(k)= prof_interp_weights(num_file,prof_num,k,bi,bj) |
70 |
enddo |
71 |
#endif |
72 |
|
73 |
do num_var=1,NVARMAX |
74 |
|
75 |
do K=1,NLEVELMAX |
76 |
prof_traj1D(k)=0. |
77 |
prof_traj1D_mean(k)=0. |
78 |
prof_mask1D_cur(k,bi,bj)=0. |
79 |
prof_data1D(k)=0. |
80 |
prof_weights1D(k)=0. |
81 |
enddo |
82 |
|
83 |
if (vec_quantities(num_file,num_var,bi,bj).EQV..TRUE.) then |
84 |
cgf for ssh anomalies, prof_traj1D_mean is the model time average, to be removed |
85 |
#ifdef ALLOW_SSH_COST_CONTRIBUTION |
86 |
if (num_var.EQ.6) then |
87 |
#ifndef ALLOW_PROFILES_GENERICGRID |
88 |
call profiles_interp_mean(prof_traj1D_mean, |
89 |
& prof_lon(num_file,prof_num,bi,bj), |
90 |
& prof_lat(num_file,prof_num,bi,bj), |
91 |
& num_var,num_file,mytime,bi,bj,myThid) |
92 |
#else |
93 |
call profiles_interp_mean_gg(prof_traj1D_mean, |
94 |
& prof_i1D,prof_j1D,prof_w1D, |
95 |
& num_var,num_file,mytime,bi,bj,myThid) |
96 |
|
97 |
#endif |
98 |
else |
99 |
#endif |
100 |
do K=1,ProfDepthNo(num_file,bi,bj) |
101 |
prof_traj1D_mean(K)=0. |
102 |
enddo |
103 |
#ifdef ALLOW_SSH_COST_CONTRIBUTION |
104 |
endif |
105 |
#endif |
106 |
call active_read_profile(num_file, |
107 |
& ProfDepthNo(num_file,bi,bj),prof_traj1D,num_var, |
108 |
& prof_num,.false.,optimcycle,bi,bj,mythid, |
109 |
& profiles_dummy(num_file,num_var,bi,bj)) |
110 |
|
111 |
call profiles_readvector(num_file,num_var, |
112 |
& prof_ind_glob(num_file,prof_num,bi,bj), |
113 |
& ProfDepthNo(num_file,bi,bj),prof_data1D,bi,bj,myThid) |
114 |
|
115 |
call profiles_readvector(num_file,-num_var, |
116 |
& prof_ind_glob(num_file,prof_num,bi,bj), |
117 |
& ProfDepthNo(num_file,bi,bj), |
118 |
& prof_weights1D,bi,bj,myThid) |
119 |
|
120 |
do K=1,ProfDepthNo(num_file,bi,bj) |
121 |
objf_profiles(num_file,num_var,bi,bj)= |
122 |
& objf_profiles(num_file,num_var,bi,bj) |
123 |
& +prof_weights1D(K)*prof_mask1D_cur(K,bi,bj) |
124 |
& *(prof_traj1D(K)-prof_data1D(K)-prof_traj1D_mean(K)) |
125 |
& *(prof_traj1D(K)-prof_data1D(K)-prof_traj1D_mean(K)) |
126 |
if (prof_weights1D(K).GT.0.) then |
127 |
num_profiles(num_file,num_var,bi,bj)= |
128 |
& num_profiles(num_file,num_var,bi,bj) |
129 |
& +prof_mask1D_cur(K,bi,bj) |
130 |
endif |
131 |
enddo |
132 |
endif |
133 |
|
134 |
enddo !do num_var... |
135 |
endif !if (prof_num.LE.ProfNo(num_file,bi,bj)) then |
136 |
enddo !do prof_num=.. |
137 |
|
138 |
if (ProfNo(num_file,bi,bj).GT.0) then |
139 |
do num_var=1,NVARMAX |
140 |
write(msgbuf,'(a,4I9)') 'bi,bj,prof_num,num_var ',bi,bj, |
141 |
& ProfNo(num_file,bi,bj),num_var |
142 |
call print_message( |
143 |
& msgbuf, standardmessageunit, SQUEEZE_RIGHT , mythid) |
144 |
write(msgbuf,'(a,D22.15,D22.15)') prof_names(num_var), |
145 |
& objf_profiles(num_file,num_var,bi,bj), |
146 |
& num_profiles(num_file,num_var,bi,bj) |
147 |
enddo !do num_var... |
148 |
endif |
149 |
enddo !do num_file=1,NFILESPROFMAX |
150 |
|
151 |
ENDDO |
152 |
ENDDO |
153 |
|
154 |
_END_MASTER( mythid ) |
155 |
|
156 |
C=========================================================== |
157 |
|
158 |
#endif |
159 |
#endif |
160 |
|
161 |
END |