Back to home page

MITgcm

 
 

    


File indexing completed on 2023-03-29 05:10:07 UTC

view on githubraw file Latest commit cda1c18f on 2023-03-28 22:31:47 UTC
8f7d13d0c9 Jean*0001 #include "ECCO_OPTIONS.h"
6b47d550f4 Mart*0002 #ifdef ALLOW_CTRL
                0003 # include "CTRL_OPTIONS.h"
                0004 #endif
0c0a2531ee Patr*0005 
cda1c18f72 Jean*0006       SUBROUTINE ECCO_READPARMS( myThid )
0c0a2531ee Patr*0007 
                0008 c     ==================================================================
                0009 c     SUBROUTINE ecco_readparms
                0010 c     ==================================================================
                0011 c
5001c65f45 Patr*0012 c     o This routine initialises the package cost.
                0013 c     started: Ralf Giering 18-Jan-2001
0c0a2531ee Patr*0014 c
                0015 c     ==================================================================
                0016 c     SUBROUTINE ecco_readparms
                0017 c     ==================================================================
                0018 
44d3986245 Jean*0019       IMPLICIT NONE
0c0a2531ee Patr*0020 
                0021 c     == global variables ==
                0022 #include "EEPARAMS.h"
5001c65f45 Patr*0023 #include "SIZE.h"
                0024 #include "GRID.h"
0c0a2531ee Patr*0025 #include "PARAMS.h"
5001c65f45 Patr*0026 
c509d7e04a Gael*0027 #ifdef ALLOW_ECCO
cf705a6c8e Mart*0028 # include "ECCO_SIZE.h"
                0029 # include "ECCO.h"
                0030 # include "ecco_local_params.h"
c509d7e04a Gael*0031 #endif
                0032 #ifdef ALLOW_CTRL
                0033 # include "CTRL_OBCS.h"
                0034 #endif
49484c0542 Gael*0035 #ifdef ALLOW_CAL
                0036 # include "cal.h"
                0037 #endif
0c0a2531ee Patr*0038 
                0039 c     == routine arguments ==
9f5240b52a Jean*0040       INTEGER myThid
0c0a2531ee Patr*0041 
44d3986245 Jean*0042 c     == external functions ==
9f5240b52a Jean*0043       INTEGER  ilnblnk
                0044       EXTERNAL ilnblnk
44d3986245 Jean*0045 
0c0a2531ee Patr*0046 c     == local variables ==
f8e779c983 antn*0047 C     msgBuf      - Informational/error message buffer
9aaf43452b Patr*0048 C     iUnit       - Work variable for IO unit number
                0049       CHARACTER*(MAX_LEN_MBUF) msgBuf
9f5240b52a Jean*0050       INTEGER k, k2, iUnit
e7db56ba12 Gael*0051 #ifdef ALLOW_GENCOST_CONTRIBUTION
c17b89ca05 Gael*0052       INTEGER IL, kk, gencost_k3d, gencost_msk_k3d, ioUnit
447bdc4b79 Gael*0053       CHARACTER*(128) tempfile
                0054       LOGICAL exst
                0055       _RS     dummyRS(1)
e7db56ba12 Gael*0056 #endif
                0057 
d39bcf1629 An T*0058 Catn-- retired parameters
9f5240b52a Jean*0059       INTEGER nRetired
cda1c18f72 Jean*0060       CHARACTER*(2) cost_yftype
                0061       CHARACTER*(MAX_LEN_FNAM) topexmeanfile
                0062       LOGICAL using_cost_bp, using_cost_scat
d39bcf1629 An T*0063 
0c0a2531ee Patr*0064 c     == end of interface ==
                0065 
5001c65f45 Patr*0066 c--   Read the namelist input.
951926fb9b Jean*0067       namelist /ecco_cost_nml/
5001c65f45 Patr*0068      &                   data_errfile,
9b12a028cc Patr*0069      &                   tbarfile, sbarfile,sstbarfile,
d534937279 Matt*0070      &                   psbarfile, bpbarfile,iestaubarfile,
5001c65f45 Patr*0071      &                   ubarfile, vbarfile, wbarfile,
                0072      &                   tauxbarfile, tauybarfile,
8c157ed454 Patr*0073      &                   hfluxmeanbarfile, sfluxmeanbarfile,
d39bcf1629 An T*0074      &                   costTranspDataFile, mdtdatfile,
                0075      &                   mdtstartdate1, mdtstartdate2,
                0076      &                   mdtenddate1, mdtenddate2,
9f3ef6a237 Gael*0077      &                   using_cost_altim,
f8e779c983 antn*0078      &                   using_cost_bp, using_cost_scat,
2ac072a19d Gael*0079      &                   using_cost_sst, using_cost_seaice,
f1e0eff8fe An T*0080      &                   using_cost_transp,
49484c0542 Gael*0081      &                   using_mdt, using_tpj, using_ers, using_gfo,
                0082      &                   using_topex,
5001c65f45 Patr*0083      &                   topexstartdate1, topexstartdate2,
c9ba60667e Patr*0084      &                   topexperiod, topexfile, tpTimeMaskFile,
                0085      &                   topexintercept, topexslope, ersTimeMaskFile,
                0086      &                   ersstartdate1, ersstartdate2, gfoTimeMaskFile,
5001c65f45 Patr*0087      &                   ersperiod, ersfile,
69531f39dd Patr*0088      &                   ersintercept, ersslope,
4fd9553bc8 Patr*0089      &                   gfostartdate1, gfostartdate2,
                0090      &                   gfoperiod, gfofile,
69531f39dd Patr*0091      &                   gfointercept, gfoslope,
951926fb9b Jean*0092      &                   scatstartdate1, scatstartdate2,
5001c65f45 Patr*0093      &                   scatperiod, scatxdatfile, scatydatfile,
                0094      &                   scatx_errfile, scaty_errfile,
8f7d13d0c9 Jean*0095      &                   ssh_errfile, sshv4cost_scalefile,
087d6770fc Gael*0096      &                   sshv4cost_errfile, sshv4cost_errfactor,
350884e02b Patr*0097      &                   tp_errfile, ers_errfile, gfo_errfile,
5001c65f45 Patr*0098      &                   tmistartdate1, tmistartdate2, tmidatfile,
951926fb9b Jean*0099      &                   sststartdate1, sststartdate2, sstdatfile,
                0100      &                   sssstartdate1, sssstartdate2, sssdatfile,
                0101      &                   bpstartdate1, bpstartdate2, bpdatfile,
d534937279 Matt*0102      &                   iesstartdate1, iesstartdate2, iesdatfile,
c9ba60667e Patr*0103      &                   tdatfile, sdatfile, ctdtfile, ctdsfile,
                0104      &                   ctdtclimfile, ctdsclimfile, xbtfile,
5001c65f45 Patr*0105      &                   argotstartdate1, argotstartdate2, argotfile,
                0106      &                   argosstartdate1, argosstartdate2, argosfile,
                0107      &                   udriftfile, vdriftfile,
                0108      &                   udrifterrfile, vdrifterrfile,
                0109      &                   curmtrufile,curmtrvfile,
                0110      &                   salterrfile, temperrfile, velerrfile,
2b3c0560b2 Patr*0111      &                   salt0errfile, temp0errfile, vel0errfile,
30125f96e6 Patr*0112      &                   etan0errfile, uvel0errfile, vvel0errfile,
d534937279 Matt*0113      &                   ssterrfile, ssserrfile, bperrfile,ieserrfile,
5001c65f45 Patr*0114      &                   hflux_errfile, sflux_errfile,
                0115      &                   tauu_errfile, tauv_errfile,
951926fb9b Jean*0116      &                   atemp_errfile, aqh_errfile,
02568c8633 Patr*0117      &                   precip_errfile, swflux_errfile, swdown_errfile,
fed442e87e Patr*0118      &                   lwflux_errfile, lwdown_errfile, evap_errfile,
                0119      &                   snowprecip_errfile, apressure_errfile,
5001c65f45 Patr*0120      &                   uwind_errfile, vwind_errfile,
                0121      &                   geoid_errfile, geoid_covariancefile,
bad79706a2 Gael*0122      &                   bottomdrag_errfile,edtau_errfile,
7e2482cabc Gael*0123      &                   kapgm_errfile,kapredi_errfile,diffkr_errfile,
55bf8021cb Gael*0124      &                   usercost_datafile, usercost_errfile,
5001c65f45 Patr*0125      &                   mult_hflux, mult_sflux, mult_tauu, mult_tauv,
4bf6063982 Patr*0126      &                   mult_hfluxmm, mult_sfluxmm,
951926fb9b Jean*0127      &                   mult_atemp, mult_aqh,
02568c8633 Patr*0128      &                   mult_precip, mult_swflux, mult_swdown,
fed442e87e Patr*0129      &                   mult_lwflux, mult_lwdown, mult_evap,
                0130      &                   mult_snowprecip, mult_apressure,
d7ee8fe52e Patr*0131      &                   mult_uwind, mult_vwind,
087d6770fc Gael*0132      &                   mult_hmean, mult_h, mult_sshv4cost,
951926fb9b Jean*0133      &                   mult_tp, mult_ers, mult_gfo,
706976e7e4 Patr*0134      &                   mult_temp, mult_salt,
e284aa03cc Patr*0135      &                   mult_tmi, mult_sst, mult_sss, mult_bp,
d534937279 Matt*0136      &                   mult_ctdt, mult_ctds, mult_ies,
951926fb9b Jean*0137      &                   mult_ctdtclim, mult_ctdsclim,
5001c65f45 Patr*0138      &                   mult_xbt, mult_drift,
                0139      &                   mult_argot, mult_argos,
                0140      &                   mult_scatx, mult_scaty,
                0141      &                   mult_sdrift, mult_tdrift, mult_wdrift,
                0142      &                   mult_temp0, mult_salt0,
30125f96e6 Patr*0143      &                   mult_etan0, mult_uvel0, mult_vvel0,
c509d7e04a Gael*0144 #if (defined (ALLOW_CTRL) && defined (ALLOW_OBCS))
5001c65f45 Patr*0145      &                   mult_obcsn, mult_obcss,
                0146      &                   mult_obcsw, mult_obcse, mult_obcsvol,
c509d7e04a Gael*0147      &                   mult_ageos,
                0148 #endif
                0149      &                   mult_curmtr,
7e2482cabc Gael*0150      &                   mult_kapgm, mult_kapredi, mult_diffkr,
bad79706a2 Gael*0151      &                   mult_edtau, mult_bottomdrag,
55bf8021cb Gael*0152      &                   mult_usercost, mult_transp,
f2b10b358f Patr*0153      &                   mult_smooth_ic, mult_smooth_bc,
d7ee8fe52e Patr*0154      &                   whflux0, wsflux0, wtau0,
bad79706a2 Gael*0155      &                   wbottomdrag0,
951926fb9b Jean*0156      &                   watemp0, waqh0,
02568c8633 Patr*0157      &                   wprecip0, wswflux0, wswdown0, wwind0,
fed442e87e Patr*0158      &                   wsnowprecip0, wlwflux0, wlwdown0, wevap0,
                0159      &                   wapressure0, wdiffkr0, wkapgm0, wedtau0,
7e2482cabc Gael*0160      &                   wkapredi0, wmean_hflux, wmean_sflux, wmean_tau,
951926fb9b Jean*0161      &                   wmean_atemp, wmean_aqh, wmean_precip,
02568c8633 Patr*0162      &                   wmean_swflux, wmean_swdown, wmean_wind,
fed442e87e Patr*0163      &                   wmean_lwflux, wmean_lwdown, wmean_evap,
                0164      &                   wmean_snowprecip, wmean_apressure,
906a61c194 Ou W*0165      &                   cost_iprec, ecco_output_sterGloH,
                0166      &                   ecco_keepTSeriesOutp_open,
                0167      &                   cost_yftype, topexmeanfile
0c0a2531ee Patr*0168 
8c157ed454 Patr*0169 #ifdef ALLOW_GENCOST_CONTRIBUTION
                0170       namelist /ecco_gencost_nml/
f8e779c983 antn*0171      &         using_gencost,
69f8f4c84c Patr*0172      &         gencost_barfile,
8f7d13d0c9 Jean*0173      &         gencost_datafile,
d181f9168b Gael*0174      &         gencost_name,
68315fab79 Gael*0175      &         gencost_scalefile,
d3a3bee25e Patr*0176      &         gencost_errfile,
81e05fa829 Gael*0177      &         gencost_itracer,
a565f49279 Jean*0178      &         gencost_kLev_select,
5cce2b5d76 Gael*0179      &         gencost_preproc,
3bd7a4549f Gael*0180      &         gencost_preproc_c,
                0181      &         gencost_preproc_i,
                0182      &         gencost_preproc_r,
92d10a5666 Gael*0183      &         gencost_posproc,
3bd7a4549f Gael*0184      &         gencost_posproc_c,
                0185      &         gencost_posproc_i,
                0186      &         gencost_posproc_r,
92d10a5666 Gael*0187      &         gencost_outputlevel,
d3a3bee25e Patr*0188      &         gencost_mask,
69f8f4c84c Patr*0189      &         gencost_spmin,
                0190      &         gencost_spmax,
                0191      &         gencost_spzero,
6b2230d510 Ou W*0192      &         gencost_wei1d,
69f8f4c84c Patr*0193      &         gencost_avgperiod,
92d10a5666 Gael*0194      &         gencost_nrecperiod,
49484c0542 Gael*0195      &         gencost_startdate1,
                0196      &         gencost_startdate2,
                0197      &         gencost_enddate1,
                0198      &         gencost_enddate2,
89d9f37d02 An T*0199      &         gencost_smooth2Ddiffnbt,
6b2230d510 Ou W*0200      &         gencost_is1d,
5cce2b5d76 Gael*0201      &         gencost_is3d,
17944dd1e8 Gael*0202      &         gencost_msk_is3d,
aa93ca8e85 Ciar*0203      &         gencost_useDensityMask,
                0204      &         gencost_refPressure,
                0205      &         gencost_sigmaLow,
                0206      &         gencost_sigmaHigh,
                0207      &         gencost_tanhScale,
8227586f14 An T*0208      &         gencost_timevaryweight,
8c157ed454 Patr*0209      &         mult_gencost
5cce2b5d76 Gael*0210 #endif /* ALLOW_GENCOST_CONTRIBUTION */
8c157ed454 Patr*0211 
58023ceed9 Gael*0212       IF ( .NOT.useECCO ) THEN
                0213 C-    pkg ECCO is not used
                0214         _BEGIN_MASTER(myThid)
                0215 C-    Track pkg activation status:
                0216 C     print a (weak) warning if data.ecco is found
                0217          CALL PACKAGES_UNUSED_MSG( 'useECCO', ' ', ' ' )
                0218         _END_MASTER(myThid)
                0219         RETURN
                0220       ENDIF
                0221 
5001c65f45 Patr*0222       _BEGIN_MASTER( myThid )
cda1c18f72 Jean*0223       nRetired = 0
0c0a2531ee Patr*0224 
5001c65f45 Patr*0225 c--     Set default values.
984d1519c6 Gael*0226 
                0227 c run time switches for main cost terms
9f3ef6a237 Gael*0228 #if (defined (ALLOW_SSH_COST_CONTRIBUTION) && \
                0229      !defined (ALLOW_GENCOST_CONTRIBUTION) )
984d1519c6 Gael*0230       using_cost_altim=.TRUE.
                0231 #else
                0232       using_cost_altim=.FALSE.
                0233 #endif
86576896a0 Gael*0234 #ifdef ALLOW_SEAICE_COST_CONTRIBUTION
                0235       using_cost_seaice=.TRUE.
                0236 #else
                0237       using_cost_seaice=.FALSE.
                0238 #endif
c2dc7fc123 An T*0239 
f1e0eff8fe An T*0240 c- set default to false
                0241       using_cost_transp=.FALSE.
c2dc7fc123 An T*0242 
984d1519c6 Gael*0243 #ifdef ALLOW_SST_COST_CONTRIBUTION
                0244       using_cost_sst=.TRUE.
                0245 #else
                0246       using_cost_sst=.FALSE.
                0247 #endif
                0248 
                0249 c other run time parameters
5001c65f45 Patr*0250         data_errfile          =    ' '
                0251         tbarfile              =    'tbar'
                0252         sbarfile              =    'sbar'
61d31abfa0 Jean*0253         sstbarfile            =    'sstbar'
5001c65f45 Patr*0254         psbarfile             =    'psbar'
e284aa03cc Patr*0255         bpbarfile             =    'bpbar'
d534937279 Matt*0256         iestaubarfile         =    'iestaubar'
5001c65f45 Patr*0257         ubarfile              =    'ubar'
                0258         vbarfile              =    'vbar'
                0259         wbarfile              =    'wbar'
                0260         tauxbarfile           =    'tauxbar'
                0261         tauybarfile           =    'tauybar'
8c157ed454 Patr*0262         hfluxmeanbarfile      =    'hfluxmeanbar'
                0263         sfluxmeanbarfile      =    'sfluxmeanbar'
7484238bfd Patr*0264         costTranspDataFile    =    ' '
9f3ef6a237 Gael*0265         using_tpj             = .false.
5001c65f45 Patr*0266         topexstartdate1       =      0
                0267         topexstartdate2       =      0
                0268         topexperiod           =      0. _d 0
69531f39dd Patr*0269         topexintercept        =      0. _d 0
                0270         topexslope            =      0. _d 0
5001c65f45 Patr*0271         topexfile             =    ' '
d39bcf1629 An T*0272 catn: defaulting mdt[start,end]date1 to pavlis so that
                0273 catn  eccov4 will run without needing to read in these params
9f3ef6a237 Gael*0274         using_mdt             =.FALSE.
d39bcf1629 An T*0275         mdtdatfile            =    ' '
                0276         mdtstartdate1         =      19930101
                0277         mdtstartdate2         =      0
                0278         mdtenddate1           =      20041231
                0279         mdtenddate2           =      0
5001c65f45 Patr*0280         using_ers             = .false.
                0281         ersstartdate1         =      0
                0282         ersstartdate2         =      0
                0283         ersperiod             =      0. _d 0
69531f39dd Patr*0284         ersintercept          =      0. _d 0
                0285         ersslope              =      0. _d 0
5001c65f45 Patr*0286         ersfile               =    ' '
4fd9553bc8 Patr*0287         using_gfo             = .false.
                0288         gfostartdate1         =      0
                0289         gfostartdate2         =      0
                0290         gfoperiod             =      0. _d 0
69531f39dd Patr*0291         gfointercept          =      0. _d 0
                0292         gfoslope              =      0. _d 0
4fd9553bc8 Patr*0293         gfofile               =    ' '
5001c65f45 Patr*0294         scatstartdate1        =      0
                0295         scatstartdate2        =      0
                0296         scatperiod            =      0. _d 0
                0297         scatxdatfile          =    ' '
                0298         scatydatfile          =    ' '
                0299         ssh_errfile           =    ' '
350884e02b Patr*0300         tp_errfile            =    ' '
                0301         ers_errfile           =    ' '
                0302         gfo_errfile           =    ' '
5001c65f45 Patr*0303         scatx_errfile         =    ' '
                0304         scaty_errfile         =    ' '
                0305         tmistartdate1         =      0
                0306         tmistartdate2         =      0
                0307         tmidatfile            =    ' '
                0308         sststartdate1         =      0
                0309         sststartdate2         =      0
                0310         sstdatfile            =    ' '
                0311         sssstartdate1         =      0
                0312         sssstartdate2         =      0
                0313         sssdatfile            =    ' '
e284aa03cc Patr*0314         bpstartdate1          =      0
                0315         bpstartdate2          =      0
                0316         bpdatfile             =    ' '
d534937279 Matt*0317         iesstartdate1         =      0
                0318         iesstartdate2         =      0
                0319         iesdatfile            =    ' '
5001c65f45 Patr*0320         tdatfile              =    ' '
                0321         sdatfile              =    ' '
                0322         ctdtfile              =    ' '
                0323         ctdsfile              =    ' '
                0324         ctdtclimfile          =    ' '
                0325         ctdsclimfile          =    ' '
                0326         curmtrufile           =    ' '
                0327         curmtrvfile           =    ' '
                0328         xbtfile               =    ' '
                0329         argotstartdate1       =      0
                0330         argotstartdate2       =      0
                0331         argotfile             =    ' '
                0332         argosstartdate1       =      0
                0333         argosstartdate2       =      0
                0334         argosfile             =    ' '
                0335         udriftfile            =    ' '
                0336         vdriftfile            =    ' '
                0337         udrifterrfile         =    ' '
                0338         vdrifterrfile         =    ' '
                0339         salterrfile           =    ' '
                0340         temperrfile           =    ' '
                0341         velerrfile            =    ' '
76ae088f98 Patr*0342         salt0errfile          =    ' '
                0343         temp0errfile          =    ' '
30125f96e6 Patr*0344         etan0errfile          =    ' '
                0345         uvel0errfile          =    ' '
                0346         vvel0errfile          =    ' '
76ae088f98 Patr*0347         vel0errfile           =    ' '
da86325d70 Gael*0348         ssterrfile            =    ' '
                0349         ssserrfile            =    ' '
49b79243e8 Gael*0350         bperrfile             =    ' '
d534937279 Matt*0351         ieserrfile            =    ' '
5001c65f45 Patr*0352         hflux_errfile         =    ' '
                0353         sflux_errfile         =    ' '
                0354         tauu_errfile          =    ' '
                0355         tauv_errfile          =    ' '
                0356         atemp_errfile         =    ' '
                0357         aqh_errfile           =    ' '
d7ee8fe52e Patr*0358         precip_errfile        =    ' '
5ceb56546e Patr*0359         swflux_errfile        =    ' '
02568c8633 Patr*0360         swdown_errfile        =    ' '
fed442e87e Patr*0361         lwflux_errfile        =    ' '
                0362         lwdown_errfile        =    ' '
                0363         evap_errfile          =    ' '
                0364         snowprecip_errfile    =    ' '
                0365         apressure_errfile     =    ' '
5001c65f45 Patr*0366         uwind_errfile         =    ' '
                0367         vwind_errfile         =    ' '
                0368         geoid_errfile         =    ' '
                0369         geoid_covariancefile  =    ' '
bad79706a2 Gael*0370         bottomdrag_errfile    =    ' '
                0371         edtau_errfile         =    ' '
                0372         kapgm_errfile         =    ' '
c9ba60667e Patr*0373         kapredi_errfile       =    ' '
bad79706a2 Gael*0374         diffkr_errfile        =    ' '
55bf8021cb Gael*0375         do k=1,NUSERCOST
cda1c18f72 Jean*0376          usercost_datafile(k) =    ' '
                0377          usercost_errfile(k)  =    ' '
55bf8021cb Gael*0378         enddo
087d6770fc Gael*0379         do k=1,NSSHV4COST
2a529ed9f1 Gael*0380          sshv4cost_scalefile(k) =    ' '
                0381          sshv4cost_errfile(k)   =    ' '
                0382          sshv4cost_errfactor(k) =     1. _d 0
087d6770fc Gael*0383         enddo
c9ba60667e Patr*0384         tpTimeMaskFile        =    ' '
                0385         ersTimeMaskFile       =    ' '
                0386         gfoTimeMaskFile       =    ' '
                0387 
5001c65f45 Patr*0388         mult_hflux            =      0. _d 0
                0389         mult_sflux            =      0. _d 0
4bf6063982 Patr*0390         mult_hfluxmm          =      0. _d 0
                0391         mult_sfluxmm          =      0. _d 0
5001c65f45 Patr*0392         mult_tauu             =      0. _d 0
                0393         mult_tauv             =      0. _d 0
                0394         mult_atemp            =      0. _d 0
                0395         mult_aqh              =      0. _d 0
d7ee8fe52e Patr*0396         mult_precip           =      0. _d 0
5ceb56546e Patr*0397         mult_swflux           =      0. _d 0
02568c8633 Patr*0398         mult_swdown           =      0. _d 0
fed442e87e Patr*0399         mult_lwflux           =      0. _d 0
                0400         mult_lwdown           =      0. _d 0
                0401         mult_evap             =      0. _d 0
                0402         mult_snowprecip       =      0. _d 0
                0403         mult_apressure        =      0. _d 0
5001c65f45 Patr*0404         mult_uwind            =      0. _d 0
                0405         mult_vwind            =      0. _d 0
                0406         mult_hmean            =      0. _d 0
706976e7e4 Patr*0407         mult_h                =      1. _d 0
                0408         mult_tp               =      0. _d 0
                0409         mult_ers              =      0. _d 0
                0410         mult_gfo              =      0. _d 0
5001c65f45 Patr*0411         mult_temp             =      0. _d 0
                0412         mult_salt             =      0. _d 0
                0413         mult_temp0            =      0. _d 0
                0414         mult_salt0            =      0. _d 0
30125f96e6 Patr*0415         mult_etan0            =      0. _d 0
                0416         mult_uvel0            =      0. _d 0
                0417         mult_vvel0            =      0. _d 0
5001c65f45 Patr*0418         mult_tmi              =      0. _d 0
                0419         mult_sst              =      0. _d 0
                0420         mult_sss              =      0. _d 0
e284aa03cc Patr*0421         mult_bp               =      0. _d 0
d534937279 Matt*0422         mult_ies              =      0. _d 0
5001c65f45 Patr*0423         mult_ctdt             =      0. _d 0
                0424         mult_ctds             =      0. _d 0
                0425         mult_ctdtclim         =      0. _d 0
                0426         mult_ctdsclim         =      0. _d 0
                0427         mult_xbt              =      0. _d 0
                0428         mult_argot            =      0. _d 0
                0429         mult_argos            =      0. _d 0
                0430         mult_drift            =      0. _d 0
                0431         mult_tdrift           =      0. _d 0
                0432         mult_sdrift           =      0. _d 0
                0433         mult_wdrift           =      0. _d 0
                0434         mult_scatx            =      0. _d 0
                0435         mult_scaty            =      0. _d 0
c509d7e04a Gael*0436 #if (defined (ALLOW_CTRL) && defined (ALLOW_OBCS))
5001c65f45 Patr*0437         mult_obcsn            =      0. _d 0
                0438         mult_obcss            =      0. _d 0
                0439         mult_obcsw            =      0. _d 0
                0440         mult_obcse            =      0. _d 0
                0441         mult_obcsvol          =      0. _d 0
                0442         mult_ageos            =      0. _d 0
c509d7e04a Gael*0443 #endif
5001c65f45 Patr*0444         mult_curmtr           =      0. _d 0
                0445         mult_kapgm            =      0. _d 0
cda1c18f72 Jean*0446         mult_kapredi          =      0. _d 0
5001c65f45 Patr*0447         mult_diffkr           =      0. _d 0
bad79706a2 Gael*0448         mult_edtau            =      0. _d 0
                0449         mult_bottomdrag       =      0. _d 0
55bf8021cb Gael*0450         do k=1,NUSERCOST
cda1c18f72 Jean*0451          mult_usercost(k)     =      0. _d 0
55bf8021cb Gael*0452         enddo
087d6770fc Gael*0453         do k=1,NSSHV4COST
cda1c18f72 Jean*0454          mult_sshv4cost(k)    =      0. _d 0
087d6770fc Gael*0455         enddo
f2b10b358f Patr*0456         mult_smooth_ic        =      0. _d 0
                0457         mult_smooth_bc        =      0. _d 0
d851bc4637 Patr*0458         mult_transp           =      0. _d 0
d7ee8fe52e Patr*0459         watemp0               =      0. _d 0
                0460         waqh0                 =      0. _d 0
                0461         wprecip0              =      0. _d 0
5ceb56546e Patr*0462         wswflux0              =      0. _d 0
02568c8633 Patr*0463         wswdown0              =      0. _d 0
fed442e87e Patr*0464         wlwflux0              =      0. _d 0
                0465         wlwdown0              =      0. _d 0
                0466         wevap0                =      0. _d 0
                0467         wsnowprecip0          =      0. _d 0
                0468         wapressure0           =      0. _d 0
d7ee8fe52e Patr*0469         wwind0                =      0. _d 0
0e094cd207 Patr*0470         wdiffkr0              =      1. _d 0
                0471         wkapgm0               =      1. _d 0
cda1c18f72 Jean*0472         wkapredi0             =      1. _d 0
0e094cd207 Patr*0473         wedtau0               =      1. _d 0
d7ee8fe52e Patr*0474         whflux0               =      0. _d 0
                0475         wsflux0               =      0. _d 0
                0476         wtau0                 =      0. _d 0
bad79706a2 Gael*0477         wbottomdrag0          =      1. _d 0
eeaf8785b4 Patr*0478         wmean_atemp           =      0. _d 0
                0479         wmean_aqh             =      0. _d 0
                0480         wmean_precip          =      0. _d 0
                0481         wmean_swflux          =      0. _d 0
02568c8633 Patr*0482         wmean_swdown          =      0. _d 0
fed442e87e Patr*0483         wmean_lwflux          =      0. _d 0
                0484         wmean_lwdown          =      0. _d 0
                0485         wmean_evap            =      0. _d 0
                0486         wmean_snowprecip      =      0. _d 0
                0487         wmean_apressure       =      0. _d 0
eeaf8785b4 Patr*0488         wmean_wind            =      0. _d 0
                0489         wmean_hflux           =      0. _d 0
                0490         wmean_sflux           =      0. _d 0
                0491         wmean_tau             =      0. _d 0
6bec9496d6 Jean*0492         cost_iprec  = precFloat32
906a61c194 Ou W*0493         ecco_output_sterGloH  =      .FALSE.
                0494         ecco_keepTSeriesOutp_open =  .FALSE.
5001c65f45 Patr*0495 
cda1c18f72 Jean*0496 C--   retired parameters
                0497         cost_yftype     =   'RL'
                0498         topexmeanfile   =    ' '
                0499         using_cost_bp   = .FALSE.
                0500         using_cost_scat = .FALSE.
d39bcf1629 An T*0501 
                0502 c--     Next, read the data.ecco file.
9aaf43452b Patr*0503         WRITE(msgBuf,'(A)') 'ECCO_READPARMS: opening data.ecco'
                0504         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0505      &                      SQUEEZE_RIGHT, myThid )
9aaf43452b Patr*0506 
                0507         CALL OPEN_COPY_DATA_FILE(
                0508      I                          'data.ecco', 'ECCO_READPARMS',
                0509      O                          iUnit,
                0510      I                          myThid )
                0511 
                0512         READ(  iUnit, nml = ecco_cost_nml )
                0513 
8f7d13d0c9 Jean*0514         WRITE(msgBuf,'(A)')
8c157ed454 Patr*0515      &       'ECCO_READPARMS: finished reading #1: ecco_cost_nml'
9aaf43452b Patr*0516         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0517      &                      SQUEEZE_RIGHT, myThid )
0c0a2531ee Patr*0518 
6bec9496d6 Jean*0519 C--   Check parameters:
cda1c18f72 Jean*0520 C-    retired parameters:
                0521       IF ( cost_yftype.NE.'RL' ) THEN
                0522        WRITE(msgBuf,'(2A)') 'S/R ECCO_READPARMS: ',
                0523      &  '"cost_yftype" is no longer allowed in file "data.ecco"'
                0524        CALL PRINT_ERROR( msgBuf, myThid )
d39bcf1629 An T*0525        nRetired = nRetired + 1
cda1c18f72 Jean*0526       ENDIF
                0527       IF ( using_cost_bp ) THEN
                0528        WRITE(msgBuf,'(2A)') 'S/R ECCO_READPARMS: ',
                0529      &  '"using_cost_bp" is no longer allowed in file "data.ecco"'
                0530        CALL PRINT_ERROR( msgBuf, myThid )
                0531        nRetired = nRetired + 1
                0532       ENDIF
                0533       IF ( using_cost_scat ) THEN
                0534        WRITE(msgBuf,'(2A)') 'S/R ECCO_READPARMS: ',
                0535      &  '"using_cost_scat" is no longer allowed in file "data.ecco"'
                0536        CALL PRINT_ERROR( msgBuf, myThid )
                0537        nRetired = nRetired + 1
                0538       ENDIF
                0539       IF ( topexmeanfile .NE. ' ' ) THEN
d39bcf1629 An T*0540        WRITE(msgBuf,'(A,A)')
                0541      &  'S/R ECCO_READPARMS: "topexmeanfile" ',
                0542      &  'is no longer allowed in file "data.ecco"'
                0543        CALL PRINT_ERROR( msgBuf, myThid )
                0544        WRITE(msgBuf,'(A)')
                0545      &  'S/R ECCO_READPARMS: set "mdtdatfile" instead'
                0546        CALL PRINT_ERROR( msgBuf, myThid )
cda1c18f72 Jean*0547        nRetired = nRetired + 1
d39bcf1629 An T*0548       ENDIF
                0549       IF ( nRetired .GT. 0 ) THEN
                0550        WRITE(msgBuf,'(2A)') 'S/R ECCO_READPARMS: ',
                0551      &  'Error reading parameter file "data.ecco"'
                0552        CALL PRINT_ERROR( msgBuf, myThid )
                0553        WRITE(msgBuf,'(A)')
cda1c18f72 Jean*0554      &  'some out-of-date parameters were found in the namelist(s)'
d39bcf1629 An T*0555        CALL PRINT_ERROR( msgBuf, myThid )
cda1c18f72 Jean*0556        CALL ALL_PROC_DIE( 0 )
d39bcf1629 An T*0557        STOP 'ABNORMAL END: S/R ECCO_READPARMS'
                0558       ENDIF
6bec9496d6 Jean*0559 
8c157ed454 Patr*0560       _END_MASTER( myThid )
                0561 
3bd7a4549f Gael*0562 c     empty pre/post-processing :
                0563 c     =========================
                0564 
                0565       _BEGIN_MASTER( myThid )
                0566       do k2=1,NGENPPROC
447bdc4b79 Gael*0567        no_preproc(k2)     = ' '
                0568        no_preproc_c(k2)   = ' '
                0569        no_preproc_i(k2)   = 0
                0570        no_preproc_r(k2)   = 0. _d 0
                0571        no_posproc(k2)     = ' '
                0572        no_posproc_c(k2)   = ' '
                0573        no_posproc_i(k2)   = 0
                0574        no_posproc_r(k2)   = 0. _d 0
1b2ca1f822 Gael*0575        clim_preproc(k2)   = ' '
                0576        clim_preproc_i(k2) = 0
dca8cfd541 Gael*0577        anom_preproc(k2)   = ' '
3bd7a4549f Gael*0578       enddo
1b2ca1f822 Gael*0579       clim_preproc(1)   = 'clim'
                0580       clim_preproc_i(1) = 12
dca8cfd541 Gael*0581       anom_preproc(1)   = 'anom'
3bd7a4549f Gael*0582       _END_MASTER( myThid )
                0583 
8c157ed454 Patr*0584 #ifdef ALLOW_GENCOST_CONTRIBUTION
                0585 
                0586       _BEGIN_MASTER( myThid )
                0587 
                0588 c--   Set default values.
                0589       do k=1,NGENCOST
130273d46b Gael*0590          using_gencost(k)      = .FALSE.
                0591          gencost_flag(k)       = 0
8c157ed454 Patr*0592          gencost_avgperiod(k)  = '     '
49484c0542 Gael*0593          gencost_startdate1(k) = 0
                0594          gencost_startdate2(k) = 0
                0595          gencost_enddate1(k) = 0
                0596          gencost_enddate2(k) = 0
d3a3bee25e Patr*0597          gencost_datafile(k)   = ' '
d181f9168b Gael*0598          gencost_name(k)       = 'gencost'
3bd7a4549f Gael*0599          do k2=1,NGENPPROC
                0600           gencost_preproc(k2,k)   = ' '
                0601           gencost_preproc_c(k2,k) = ' '
                0602           gencost_preproc_i(k2,k) = 0
                0603           gencost_preproc_r(k2,k) = 0. _d 0
                0604           gencost_posproc(k2,k)   = ' '
                0605           gencost_posproc_c(k2,k) = ' '
                0606           gencost_posproc_i(k2,k) = 0
                0607           gencost_posproc_r(k2,k) = 0. _d 0
                0608          enddo
92d10a5666 Gael*0609          gencost_outputlevel(k)= 0
d3a3bee25e Patr*0610          gencost_errfile(k)    = ' '
81e05fa829 Gael*0611          gencost_itracer(k)    = 1
a565f49279 Jean*0612          gencost_kLev_select(k)= 1
47d80787ea Gael*0613          gencost_mask(k)       = ' '
d181f9168b Gael*0614          gencost_barfile(k)    = ' '
89d9f37d02 An T*0615          gencost_spmin(k)      = 0. _d 0
                0616          gencost_spmax(k)      = 0. _d 0
                0617          gencost_spzero(k)     = 9876. _d 0
6b2230d510 Ou W*0618          gencost_wei1d(k)      = 0. _d 0
bf3a68e762 Gael*0619          mult_gencost(k)       = 1. _d 0
6b2230d510 Ou W*0620          gencost_is1d(k)       = .FALSE.
5cce2b5d76 Gael*0621          gencost_is3d(k)       = .FALSE.
aa93ca8e85 Ciar*0622          gencost_useDensityMask(k) = .FALSE.
                0623          gencost_refPressure(k) = 0. _d 0
                0624          gencost_sigmaLow(k)    = 0. _d 0
                0625          gencost_sigmaHigh(k)   = 1. _d 3
                0626          gencost_tanhScale(k)   = 1. _d 5
447bdc4b79 Gael*0627          gencost_pointer3d(k)  = 0
44d3986245 Jean*0628          gencost_msk_is3d(k)   = .FALSE.
17944dd1e8 Gael*0629          gencost_msk_pointer3d(k)  = 0
447bdc4b79 Gael*0630 c boxmean/horflux masks
f8e779c983 antn*0631          call ecco_zero(gencost_mskCsurf(1-OLx,1-OLy,1,1,k),
                0632      &          1,zeroRL,myThid)
                0633          call ecco_zero(gencost_mskWsurf(1-OLx,1-OLy,1,1,k),
                0634      &          1,zeroRL,myThid)
                0635          call ecco_zero(gencost_mskSsurf(1-OLx,1-OLy,1,1,k),
                0636      &          1,zeroRL,myThid)
9f5240b52a Jean*0637          do k2 = 1,Nr
447bdc4b79 Gael*0638           gencost_mskVertical(k2,k)= 1. _d 0
f8e779c983 antn*0639          enddo
447bdc4b79 Gael*0640 c deprecated:
                0641         gencost_nrecperiod(k) = 0
                0642         gencost_scalefile(k)  = ' '
b8fab26f74 Gael*0643         gencost_smooth2Ddiffnbt(k) = 0
447bdc4b79 Gael*0644         gencost_timevaryweight(k)  = .FALSE.
8c157ed454 Patr*0645       enddo
                0646 
17944dd1e8 Gael*0647 #ifdef ALLOW_GENCOST3D
                0648       do k=1,NGENCOST3D
                0649 c boxmean/horflux masks
f8e779c983 antn*0650          call ecco_zero(gencost_mskC(1-OLx,1-OLy,1,1,1,k),
                0651      &          Nr,zeroRL,myThid)
                0652          call ecco_zero(gencost_mskW(1-OLx,1-OLy,1,1,1,k),
                0653      &          Nr,zeroRL,myThid)
                0654          call ecco_zero(gencost_mskS(1-OLx,1-OLy,1,1,1,k),
                0655      &          Nr,zeroRL,myThid)
17944dd1e8 Gael*0656       enddo
                0657 #endif
                0658 
8c157ed454 Patr*0659       READ(  iUnit, nml = ecco_gencost_nml )
                0660 
8f7d13d0c9 Jean*0661       WRITE(msgBuf,'(A)')
8c157ed454 Patr*0662      &     'ECCO_READPARMS: finished reading #2: ecco_gencost_nml'
                0663       CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0664      &                    SQUEEZE_RIGHT, myThid )
8c157ed454 Patr*0665 
5cce2b5d76 Gael*0666       gencost_k3d=1
17944dd1e8 Gael*0667       gencost_msk_k3d=1
5cce2b5d76 Gael*0668 
130273d46b Gael*0669       do k=1,NGENCOST
5cce2b5d76 Gael*0670 
                0671 c pre-specified generic cost terms using otherwise created barfiles
e7db56ba12 Gael*0672          if ( (gencost_name(k).EQ.'sshv4-mdt').OR.
                0673      &        (gencost_name(k).EQ.'sshv4-tp').OR.
                0674      &        (gencost_name(k).EQ.'sshv4-ers').OR.
                0675      &        (gencost_name(k).EQ.'sshv4-gfo').OR.
                0676      &        (gencost_name(k).EQ.'sshv4-lsc').OR.
4e6b53b435 Gael*0677      &        (gencost_name(k).EQ.'sshv4-gmsl').OR.
49484c0542 Gael*0678      &        (gencost_name(k).EQ.'bpv4-grace').OR.
e7db56ba12 Gael*0679      &        (gencost_name(k).EQ.'sstv4-amsre').OR.
130273d46b Gael*0680      &        (gencost_name(k).EQ.'sstv4-amsre-lsc') ) then
                0681            gencost_flag(k)=-1
                0682            using_gencost(k)=.TRUE.
877e0f385b An T*0683 
                0684 catn move boxmean outside -1 to have its own check
                0685 catn preserve -2 for potential separate group above into cost
                0686 catn with and without requirements of datafile or errfile
447bdc4b79 Gael*0687          elseif ( (gencost_barfile(k)(1:9).EQ.'m_boxmean').OR.
                0688      &            (gencost_barfile(k)(1:9).EQ.'m_horflux') ) then
877e0f385b An T*0689            gencost_flag(k)=-3
                0690            using_gencost(k)=.TRUE.
                0691            il=ilnblnk(gencost_name(k))
447bdc4b79 Gael*0692            WRITE(msgBuf,'(A,I3,3A,L5)') 'gencost k_boxmean/horflux=',
                0693      &     k,' ',gencost_name(k)(1:il),': ',using_gencost(k)
877e0f385b An T*0694            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0695      &                         SQUEEZE_RIGHT, myThid )
877e0f385b An T*0696 
17944dd1e8 Gael*0697            if ( gencost_msk_is3d(k) ) then
                0698              gencost_msk_pointer3d(k)=gencost_msk_k3d
                0699              gencost_msk_k3d=gencost_msk_k3d+1
                0700            endif
                0701 
877e0f385b An T*0702 catn add cost global transport using gencost framework
                0703          elseif ( gencost_name(k)(1:6).EQ.'transp' ) then
                0704            gencost_flag(k)=-4
                0705            using_gencost(k)=.TRUE.
                0706            il=ilnblnk(gencost_name(k))
447bdc4b79 Gael*0707            WRITE(msgBuf,'(A,i3,3A,L5)') 'gencost k_transp=',
                0708      &     k,' ',gencost_name(k)(1:il),': ',using_gencost(k)
877e0f385b An T*0709            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0710      &                         SQUEEZE_RIGHT, myThid )
877e0f385b An T*0711 
df462307fb Timo*0712 cts moc cost function using gencost framework
                0713          elseif ( gencost_name(k)(1:3).EQ.'moc' ) then
                0714            gencost_flag(k)=-5
                0715            using_gencost(k)=.TRUE.
                0716            il=ilnblnk(gencost_name(k))
                0717            WRITE(msgBuf,'(A,i2,2A,L5)') 'gencost k_moc=',
                0718      &     k,gencost_name(k)(1:il),': ',using_gencost(k)
                0719            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0720      &                         SQUEEZE_RIGHT, myThid )
df462307fb Timo*0721 
5cce2b5d76 Gael*0722 c pre-specified generic cost terms that create their own barfile
f8e779c983 antn*0723          elseif (
a443ec37be Gael*0724      &        (gencost_name(k).EQ.'siv4-conc').OR.
0a8c2c2ff2 An T*0725      &        (gencost_name(k).EQ.'siv4-deconc').OR.
                0726      &        (gencost_name(k).EQ.'siv4-exconc') ) then
a443ec37be Gael*0727            gencost_flag(k)=2
                0728            using_gencost(k)=.TRUE.
130273d46b Gael*0729 c fully interactive generic cost terms
5cce2b5d76 Gael*0730          elseif ( gencost_datafile(k) .NE. ' ' ) then
130273d46b Gael*0731            gencost_flag(k)=1
                0732            using_gencost(k)=.TRUE.
                0733          endif
49484c0542 Gael*0734 
bf3a68e762 Gael*0735 c identified three dimensional variables
                0736          if ( (gencost_barfile(k)(1:7).EQ.'m_theta').OR.
                0737      &        (gencost_barfile(k)(1:6).EQ.'m_salt').OR.
                0738      &        (gencost_barfile(k)(1:8).EQ.'m_diffkr').OR.
                0739      &        (gencost_barfile(k)(1:7).EQ.'m_kapgm').OR.
447bdc4b79 Gael*0740      &        (gencost_barfile(k)(1:9).EQ.'m_kapredi').OR.
                0741      &        (gencost_barfile(k)(1:7).EQ.'m_trVol').OR.
c13fbfe5a9 Nora*0742      &        (gencost_barfile(k)(1:8).EQ.'m_trHeat').OR.
                0743      &        (gencost_barfile(k)(1:8).EQ.'m_trSalt')
877e0f385b An T*0744      &       )
bf3a68e762 Gael*0745      &        gencost_is3d(k)=.TRUE.
                0746 
                0747 c assign a 3D storage array, then increment 3D variables counter
5cce2b5d76 Gael*0748          if ( gencost_is3d(k) ) then
                0749            gencost_pointer3d(k)=gencost_k3d
                0750            gencost_k3d=gencost_k3d+1
                0751          endif
                0752 
130273d46b Gael*0753       enddo
                0754 
447bdc4b79 Gael*0755 C--   load masks if needed:
                0756       do k=1,NGENCOST
c17b89ca05 Gael*0757            kk=gencost_msk_pointer3d(k)
47d80787ea Gael*0758            if ( ( gencost_mask(k) .NE. ' ' ).AND.
0d7023b5ce Jean*0759      &          (gencost_flag(k).EQ.-3 .or.
df462307fb Timo*0760      &           gencost_flag(k).eq.-4 .or.
                0761      &           gencost_flag(k).eq.-5    ) ) then
447bdc4b79 Gael*0762 c
47d80787ea Gael*0763             il = ilnblnk(gencost_mask(k))
                0764             write(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'C'
447bdc4b79 Gael*0765             inquire( file=tempfile(1:il+1), exist=exst )
17944dd1e8 Gael*0766             if (exst.AND.(.NOT.gencost_msk_is3d(k))) then
f8e779c983 antn*0767              CALL READ_REC_3D_RL( tempfile, cost_iprec, 1,
                0768      &            gencost_mskCsurf(1-OLx,1-OLy,1,1,k), 1, 1, myThid )
17944dd1e8 Gael*0769 #ifdef ALLOW_GENCOST3D
                0770             elseif (exst.AND.(gencost_msk_pointer3d(k).LE.
                0771      &                        NGENCOST3D)) then
f8e779c983 antn*0772              CALL READ_REC_3D_RL( tempfile, cost_iprec, Nr,
                0773      &            gencost_mskC(1-OLx,1-OLy,1,1,1,kk), 1, 1, myThid )
17944dd1e8 Gael*0774 #endif
447bdc4b79 Gael*0775             endif
                0776 c
47d80787ea Gael*0777             il = ilnblnk(gencost_mask(k))
                0778             write(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'W'
447bdc4b79 Gael*0779             inquire( file=tempfile(1:il+1), exist=exst )
17944dd1e8 Gael*0780             if (exst.AND.(.NOT.gencost_msk_is3d(k))) then
f8e779c983 antn*0781              CALL READ_REC_3D_RL( tempfile, cost_iprec, 1,
                0782      &            gencost_mskWsurf(1-OLx,1-OLy,1,1,k), 1, 1, myThid )
17944dd1e8 Gael*0783 #ifdef ALLOW_GENCOST3D
                0784             elseif (exst.AND.(gencost_msk_pointer3d(k).LE.
                0785      &                        NGENCOST3D)) then
f8e779c983 antn*0786              CALL READ_REC_3D_RL( tempfile, cost_iprec, Nr,
                0787      &            gencost_mskW(1-OLx,1-OLy,1,1,1,kk), 1, 1, myThid )
17944dd1e8 Gael*0788 #endif
447bdc4b79 Gael*0789             endif
                0790 c
47d80787ea Gael*0791             il = ilnblnk(gencost_mask(k))
                0792             write(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'S'
447bdc4b79 Gael*0793             inquire( file=tempfile(1:il+1), exist=exst )
17944dd1e8 Gael*0794             if (exst.AND.(.NOT.gencost_msk_is3d(k))) then
f8e779c983 antn*0795              CALL READ_REC_3D_RL( tempfile, cost_iprec, 1,
                0796      &            gencost_mskSsurf(1-OLx,1-OLy,1,1,k), 1, 1, myThid )
17944dd1e8 Gael*0797 #ifdef ALLOW_GENCOST3D
                0798             elseif (exst.AND.(gencost_msk_pointer3d(k).LE.
                0799      &                        NGENCOST3D)) then
f8e779c983 antn*0800              CALL READ_REC_3D_RL( tempfile, cost_iprec, Nr,
                0801      &            gencost_mskS(1-OLx,1-OLy,1,1,1,kk), 1, 1, myThid )
17944dd1e8 Gael*0802 #endif
447bdc4b79 Gael*0803             endif
                0804 c
47d80787ea Gael*0805             il = ilnblnk(gencost_mask(k))
                0806             write(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'K'
447bdc4b79 Gael*0807             inquire( file=tempfile(1:il+1), exist=exst )
                0808             if (exst) then
                0809              ioUnit = 0
f8e779c983 antn*0810              CALL MDS_READVEC_LOC( tempfile, cost_iprec, ioUnit, 'RL',
                0811      &        Nr, gencost_mskVertical(1,k), dummyRS, 0, 0, 1, myThid )
447bdc4b79 Gael*0812             endif
                0813 c
                0814            endif!errfile
                0815       enddo
                0816 
8c157ed454 Patr*0817 C--   Check parameters:
                0818       do k=1,NGENCOST
69f8f4c84c Patr*0819 
9aeddbf372 Gael*0820 cgf ensure backward compatibility:
985662a3b3 Gael*0821         if (gencost_barfile(k).NE.' ') then
9aeddbf372 Gael*0822          if (gencost_barfile(k)(1:2).NE.'m_') then
985662a3b3 Gael*0823           il=ilnblnk(gencost_barfile(k))
                0824           WRITE(msgBuf,'(A,A)') 'm_',gencost_barfile(k)(1:il)
                0825           gencost_barfile(k)=msgBuf(1:il+2)
9aeddbf372 Gael*0826          endif
                0827          if (gencost_barfile(k)(1:8).EQ.'m_tauZon') then
                0828           il=ilnblnk(gencost_barfile(k))
                0829           WRITE(msgBuf,'(A,A)') 'm_ustress',gencost_barfile(k)(9:il)
                0830           gencost_barfile(k)=msgBuf(1:il+1)
                0831          endif
                0832          if (gencost_barfile(k)(1:8).EQ.'m_tauMer') then
                0833           il=ilnblnk(gencost_barfile(k))
                0834           WRITE(msgBuf,'(A,A)') 'm_vstress',gencost_barfile(k)(9:il)
                0835           gencost_barfile(k)=msgBuf(1:il+1)
                0836          endif
985662a3b3 Gael*0837         endif
                0838 
877e0f385b An T*0839 catn separate out blocks of gencost_flag so that each block is checked
                0840         if ( using_gencost(k)) then
                0841          if ( gencost_flag(k).GE.1 ) then
7a7bc10d23 Patr*0842 
                0843           if ( gencost_name(k) .EQ. 'gencost' )
1fa8e77fb9 Gael*0844      &        gencost_name(k) = gencost_datafile(k)
                0845 
7a7bc10d23 Patr*0846           if ( gencost_avgperiod(k) .NE. 'day  ' .AND.
69f8f4c84c Patr*0847      &        gencost_avgperiod(k) .NE. 'DAY  ' .AND.
                0848      &        gencost_avgperiod(k) .NE. 'month' .AND.
                0849      &        gencost_avgperiod(k) .NE. 'MONTH' .AND.
e7d9258ace Gael*0850      &        gencost_avgperiod(k) .NE. 'step' .AND.
                0851      &        gencost_avgperiod(k) .NE. 'STEP' .AND.
985662a3b3 Gael*0852      &        gencost_avgperiod(k) .NE. 'const' .AND.
                0853      &        gencost_avgperiod(k) .NE. 'CONST' .AND.
69f8f4c84c Patr*0854      &        gencost_avgperiod(k) .NE. 'year ' .AND.
                0855      &        gencost_avgperiod(k) .NE. 'YEAR ' ) then
e7db56ba12 Gael*0856 
                0857             il=ilnblnk(gencost_name(k))
                0858             WRITE(msgBuf,'(A,I2,2A)')
                0859      &          'ERROR in ECCO_READPARMS: for gencost',k,
                0860      &          '  ',gencost_name(k)(1:il)
                0861             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
44d3986245 Jean*0862      &                          SQUEEZE_RIGHT, myThid )
8f7d13d0c9 Jean*0863             STOP
8c157ed454 Patr*0864      &           'ECCO_READPARMS: gencost_avgperiod not properly set'
44d3986245 Jean*0865           endif
61aa767fd2 Gael*0866 
7a7bc10d23 Patr*0867           if ( gencost_spmin(k) .EQ. 0. _d 0 .AND.
69f8f4c84c Patr*0868      &        gencost_spmax(k) .EQ. 0. _d 0 ) then
e7db56ba12 Gael*0869             il=ilnblnk(gencost_name(k))
                0870             WRITE(msgBuf,'(A,I2,2A)')
                0871      &          'ERROR in ECCO_READPARMS: for gencost',k,
                0872      &          '  ',gencost_name(k)(1:il)
                0873             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
44d3986245 Jean*0874      &                          SQUEEZE_RIGHT, myThid )
69f8f4c84c Patr*0875             STOP
                0876      &       'ECCO_READPARMS: gencost_spmin, gencost_spmax not set'
7a7bc10d23 Patr*0877           endif
69f8f4c84c Patr*0878 
7a7bc10d23 Patr*0879           if ( gencost_spzero(k) .EQ. 9876. _d 0 ) then
e7db56ba12 Gael*0880             il=ilnblnk(gencost_name(k))
                0881             WRITE(msgBuf,'(A,I2,2A)')
                0882      &          'ERROR in ECCO_READPARMS: for gencost',k,
                0883      &          '  ',gencost_name(k)(1:il)
                0884             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
44d3986245 Jean*0885      &                          SQUEEZE_RIGHT, myThid )
69f8f4c84c Patr*0886             STOP
                0887      &       'ECCO_READPARMS: gencost_spzero not set'
7a7bc10d23 Patr*0888           endif
69f8f4c84c Patr*0889 
877e0f385b An T*0890 catn -- checking for -1 flag
                0891          elseif( gencost_flag(k) .eq. -1 ) then
                0892 catn -- checking boxmean and transp
                0893          elseif( gencost_flag(k).lt.-1) then
                0894             if ( gencost_avgperiod(k) .NE. 'day  ' .AND.
                0895      &           gencost_avgperiod(k) .NE. 'DAY  ' .AND.
                0896      &           gencost_avgperiod(k) .NE. 'month' .AND.
                0897      &           gencost_avgperiod(k) .NE. 'MONTH' .AND.
                0898      &           gencost_avgperiod(k) .NE. 'step' .AND.
                0899      &           gencost_avgperiod(k) .NE. 'STEP' .AND.
                0900      &           gencost_avgperiod(k) .NE. 'const' .AND.
                0901      &           gencost_avgperiod(k) .NE. 'CONST' .AND.
                0902      &           gencost_avgperiod(k) .NE. 'year ' .AND.
                0903      &           gencost_avgperiod(k) .NE. 'YEAR ' ) then
                0904 
                0905               il=ilnblnk(gencost_name(k))
                0906               WRITE(msgBuf,'(A,I2,2A)')
                0907      &          'ERROR in ECCO_READPARMS: for gencost',k,
                0908      &          '  ',gencost_name(k)(1:il)
                0909               CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
44d3986245 Jean*0910      &                            SQUEEZE_RIGHT, myThid )
877e0f385b An T*0911             STOP
                0912      &           'ECCO_READPARMS: gencost_avgperiod not properly set'
                0913             endif
                0914          endif !gencost_flag
                0915         endif !using_gencost
61aa767fd2 Gael*0916 
8c157ed454 Patr*0917       end do
                0918 
                0919       _END_MASTER( myThid )
                0920 
                0921 #endif /* ALLOW_GENCOST_CONTRIBUTION */
                0922 
                0923       _BEGIN_MASTER( myThid )
                0924 
7a77863887 Mart*0925 #ifdef SINGLE_DISK_IO
                0926       CLOSE(iUnit)
                0927 #else
                0928       CLOSE(iUnit,STATUS='DELETE')
                0929 #endif /* SINGLE_DISK_IO */
8c157ed454 Patr*0930 
                0931       _END_MASTER( myThid )
                0932 
8f7d13d0c9 Jean*0933       WRITE(msgBuf,'(A)')
8c157ed454 Patr*0934      &     'ECCO_READPARMS: done'
                0935       CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
44d3986245 Jean*0936      &                    SQUEEZE_RIGHT, myThid )
0c0a2531ee Patr*0937 
                0938       _BARRIER
                0939 
f8e779c983 antn*0940       RETURN
                0941       END