File indexing completed on 2024-03-02 06:10:01 UTC
view on githubraw file Latest commit 5cf43646 on 2024-03-01 18:50:49 UTC
1b116cf4a9 Gael*0001 #include "CTRL_OPTIONS.h"
0002
4cee17c1be Patr*0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
851b1c1340 Patr*0033
4cee17c1be Patr*0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 subroutine optim_numbmod(
0047 O nn
0048 & )
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 IMPLICIT NONE
0070
0071
0072
0073 #include "EEPARAMS.h"
0074 #include "SIZE.h"
0075
5cf4364659 Mart*0076 #include "CTRL_SIZE.h"
65754df434 Mart*0077 #include "CTRL.h"
4cee17c1be Patr*0078 #include "optim.h"
0079 #include "minimization.h"
6ec844236d Patr*0080 #include "CTRL_OBCS.h"
269edaaf5e Patr*0081 #ifndef ECCO_CTRL_DEPRECATED
0082 # include "ctrl_local_params.h"
0083 #endif
4cee17c1be Patr*0084
0085
0086
0087 integer nn
0088
0089
0090
5cf4364659 Mart*0091 integer ivar
4cee17c1be Patr*0092 integer il
0093 integer errio
0094
0095 _RL ff
0096
0097 #if defined (DYNAMIC)
0098 _RL vv(nn)
0099 #elif defined (USE_POINTER) || (MAX_INDEPEND == 0)
0100 _RL vv
0101 pointer (pvv,vv(1))
0102 #else
0103 integer nmax
0104 parameter( nmax = MAX_INDEPEND )
0105 _RL vv(nmax)
0106 #endif
0107
0108 character*(max_len_prec) record
0109
0110 logical lheaderonly
0111
0112
0113
0114 integer ilnblnk
0115
0116
0117
0118 namelist /CTRL_NML/
c204fd9ffc Patr*0119 & xx_theta_file, xx_salt_file,
0120 & xx_hflux_file, xx_hflux_remo_intercept, xx_hflux_remo_slope,
4cee17c1be Patr*0121 & xx_hfluxstartdate1, xx_hfluxstartdate2, xx_hfluxperiod,
c204fd9ffc Patr*0122 & xx_sflux_file, xx_sflux_remo_intercept, xx_sflux_remo_slope,
4cee17c1be Patr*0123 & xx_sfluxstartdate1, xx_sfluxstartdate2, xx_sfluxperiod,
c204fd9ffc Patr*0124 & xx_tauu_file, xx_tauu_remo_intercept, xx_tauu_remo_slope,
4cee17c1be Patr*0125 & xx_tauustartdate1, xx_tauustartdate2, xx_tauuperiod,
c204fd9ffc Patr*0126 & xx_tauv_file, xx_tauv_remo_intercept, xx_tauv_remo_slope,
acff328b8b Mart*0127 & xx_tauvstartdate1, xx_tauvstartdate2, xx_tauvperiod,
c204fd9ffc Patr*0128 & xx_atemp_file, xx_atemp_remo_intercept, xx_atemp_remo_slope,
acff328b8b Mart*0129 & xx_atempstartdate1, xx_atempstartdate2, xx_atempperiod,
c204fd9ffc Patr*0130 & xx_aqh_file, xx_aqh_remo_intercept, xx_aqh_remo_slope,
acff328b8b Mart*0131 & xx_aqhstartdate1, xx_aqhstartdate2, xx_aqhperiod,
c204fd9ffc Patr*0132 & xx_precip_file, xx_precip_remo_intercept, xx_precip_remo_slope,
9ba82a4741 Patr*0133 & xx_precipstartdate1, xx_precipstartdate2, xx_precipperiod,
c204fd9ffc Patr*0134 & xx_swflux_file, xx_swflux_remo_intercept, xx_swflux_remo_slope,
9ba82a4741 Patr*0135 & xx_swfluxstartdate1, xx_swfluxstartdate2, xx_swfluxperiod,
c204fd9ffc Patr*0136 & xx_swdown_file, xx_swdown_remo_intercept, xx_swdown_remo_slope,
9ba82a4741 Patr*0137 & xx_swdownstartdate1, xx_swdownstartdate2, xx_swdownperiod,
c204fd9ffc Patr*0138 & xx_lwflux_file, xx_lwflux_remo_intercept, xx_lwflux_remo_slope,
0139 & xx_lwfluxstartdate1, xx_lwfluxstartdate2, xx_lwfluxperiod,
0140 & xx_lwdown_file, xx_lwdown_remo_intercept, xx_lwdown_remo_slope,
0141 & xx_lwdownstartdate1, xx_lwdownstartdate2, xx_lwdownperiod,
0142 & xx_evap_file, xx_evap_remo_intercept, xx_evap_remo_slope,
0143 & xx_evapstartdate1, xx_evapstartdate2, xx_evapperiod,
d5b8fa0522 Mart*0144 & xx_snowprecip_file, xx_snowprecip_remo_intercept,
c204fd9ffc Patr*0145 & xx_snowprecip_remo_slope, xx_snowprecipperiod,
0146 & xx_snowprecipstartdate1, xx_snowprecipstartdate2,
d5b8fa0522 Mart*0147 & xx_apressure_file, xx_apressure_remo_intercept,
c204fd9ffc Patr*0148 & xx_apressure_remo_slope, xx_apressureperiod,
0149 & xx_apressurestartdate1, xx_apressurestartdate2,
0150 & xx_runoff_file, xx_runoff_remo_intercept, xx_runoff_remo_slope,
0151 & xx_runoffstartdate1, xx_runoffstartdate2, xx_runoffperiod,
0152 & xx_uwind_file, xx_uwind_remo_intercept, xx_uwind_remo_slope,
acff328b8b Mart*0153 & xx_uwindstartdate1, xx_uwindstartdate2, xx_uwindperiod,
c204fd9ffc Patr*0154 & xx_vwind_file, xx_vwind_remo_intercept, xx_vwind_remo_slope,
acff328b8b Mart*0155 & xx_vwindstartdate1, xx_vwindstartdate2, xx_vwindperiod,
c204fd9ffc Patr*0156 & xx_obcsn_file, xx_obcss_file, xx_obcsw_file, xx_obcse_file,
acff328b8b Mart*0157 & xx_obcsnstartdate1, xx_obcsnstartdate2, xx_obcsnperiod,
0158 & xx_obcssstartdate1, xx_obcssstartdate2, xx_obcssperiod,
0159 & xx_obcswstartdate1, xx_obcswstartdate2, xx_obcswperiod,
0160 & xx_obcsestartdate1, xx_obcsestartdate2, xx_obcseperiod,
c204fd9ffc Patr*0161 & xx_diffkr_file, xx_kapgm_file, xx_tr1_file,
0162 & xx_sst_file, xx_sss_file,
91d99130a0 Davi*0163 & xx_sststartdate1, xx_sststartdate2, xx_sstperiod,
0164 & xx_sssstartdate1, xx_sssstartdate2, xx_sssperiod,
c204fd9ffc Patr*0165 & xx_depth_file, xx_efluxy_file, xx_efluxp_file,
0166 & xx_bottomdrag_file, xx_edtaux_file, xx_edtauy_file,
0167 & xx_uvel_file, xx_vvel_file, xx_etan_file,
d5b8fa0522 Mart*0168 & xx_shifwflx_file,
0169 & xx_shifwflx_remo_intercept, xx_shifwflx_remo_slope,
e189f4121c Mart*0170 & xx_shifwflxstartdate1, xx_shifwflxstartdate2, xx_shifwflxperiod,
c204fd9ffc Patr*0171 & doInitXX, doPackDiag, doZscaleUnpack, doZscalePack,
93558ef104 Gael*0172 & doMainUnpack, doMainPack, doAdmtlmBypassAD, delZexp,
0173 & xx_hfluxm_file, doSinglePrecTapelev
4cee17c1be Patr*0174
0175 namelist /CTRL_PACKNAMES/
1f82d30822 Patr*0176 & yadmark, yctrlid, yctrlposunpack, yctrlpospack,
4cee17c1be Patr*0177 & ctrlname, costname, scalname, maskname, metaname
0178
1f82d30822 Patr*0179 namelist /OPTIM/
4cee17c1be Patr*0180 & optimcycle,
0181 & numiter, nfunc, fmin, iprint,
0182 & epsf, epsx, epsg,
0183 & nupdate, eps
0184
d5b8fa0522 Mart*0185
0186
0187
0188
0189 myygloballo = 1
0190 myxgloballo = 1
0191
4cee17c1be Patr*0192
0193 optimcycle = 0
0194 nvars = 0
0195 numiter = 1
0196 nfunc = 1
0197 fmin = 0.0
0198 iprint = 10
0199 epsx = 1.e-6
0200 epsg = 1.e-6
0201 eps = -1.e-6
0202 nupdate = 1
0203 ff = 0.
91d99130a0 Davi*0204
0205 yctrlid = 'MIT_CE_000'
4cee17c1be Patr*0206
0207 modeldataunit = 14
0208 scrunit1 = 11
0209
0210
0211 open(unit=scrunit1,status='scratch')
0212
0213 open(unit = modeldataunit,file = 'data.ctrl',
0214 & status = 'old', iostat = errio)
0215 if ( errio .lt. 0 ) then
0216 stop ' stopped in optim_numbmod'
0217 endif
0218
0219 do while ( .true. )
0220 read(modeldataunit, fmt='(a)', end=21) record
0221 il = max(ilnblnk(record),1)
0222 if ( record(1:1) .ne. commentcharacter )
0223 & write(unit=scrunit1, fmt='(a)') record(:il)
0224 enddo
0225 21 continue
0226 close( modeldataunit )
0227
0228 rewind( scrunit1 )
0229 read(unit = scrunit1, nml = ctrl_nml)
0230 read(unit = scrunit1, nml = ctrl_packnames)
0231 close( scrunit1 )
0232 print*, ' OPTIM_NUMBMOD: Control options have been read.'
0233
1f82d30822 Patr*0234
91d99130a0 Davi*0235
1f82d30822 Patr*0236
0237
4cee17c1be Patr*0238
0239 open(unit=scrunit1,status='scratch')
0240
0241 open(unit = modeldataunit,file = 'data.optim',
0242 & status = 'old', iostat = errio)
0243 if ( errio .lt. 0 ) then
0244 stop ' stopped in optim_numbmod'
0245 endif
0246
0247 do while ( .true. )
0248 read(modeldataunit, fmt='(a)', end=22) record
0249 il = max(ilnblnk(record),1)
0250 if ( record(1:1) .ne. commentcharacter )
0251 & write(unit=scrunit1, fmt='(a)') record(:il)
0252 enddo
0253 22 continue
0254 close( modeldataunit )
0255
0256 rewind( scrunit1 )
1f82d30822 Patr*0257 read(unit = scrunit1, nml = optim)
4cee17c1be Patr*0258 close( scrunit1 )
0259 print*, ' OPTIM_NUMBMOD: Minimization options have been read.'
0260
0261 if (eps .gt. 0.0) then
0262 epsf = eps
0263 epsx = eps
0264 epsg = eps
0265 endif
0266
5cf4364659 Mart*0267
0268
0269 do ivar=1,maxcvars
0270 ncvarindex(ivar) = -1
0271 ncvarrecs(ivar) = -1
0272 ncvarxmax(ivar) = -1
0273 ncvarymax(ivar) = -1
0274 ncvarnrmax(ivar) = -1
0275 ncvargrd(ivar) = 'X'
0276 ncvartype(ivar) = 'UNSET'
0277 enddo
0278
4cee17c1be Patr*0279 lheaderonly = .true.
0280 call optim_readdata ( nn, ctrlname, lheaderonly, ff, vv)
0281
0282
0283 print*
0284 print*, ' OPTIM_NUMBMOD: Iteration number = ', optimcycle
0285 print*, ' number of control variables = ', nn
0286 print*, ' Data will be read from the following files:'
0287 print*
0288
0289
0290
0291
0292 return
0293 end