Back to home page

MITgcm

 
 

    


File indexing completed on 2026-03-19 05:08:34 UTC

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