Back to home page

MITgcm

 
 

    


File indexing completed on 2024-02-07 06:10:18 UTC

view on githubraw file Latest commit 35c4fdc7 on 2024-02-06 21:05:47 UTC
b9be1e51ef Jean*0001 #include "ECCO_OPTIONS.h"
6b47d550f4 Mart*0002 #ifdef ALLOW_CTRL
                0003 # include "CTRL_OPTIONS.h"
                0004 #endif
5001c65f45 Patr*0005 
22f8b844e3 Jean*0006 C--  File ecco_check.F:
                0007 C--   Contents
                0008 C--   o ECCO_CHECK
                0009 C--   o ECCO_CHECK_FILES
                0010 
                0011 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0012 
5001c65f45 Patr*0013       SUBROUTINE ECCO_CHECK( myThid )
22f8b844e3 Jean*0014 C     *==========================================================*
5001c65f45 Patr*0015 C     | SUBROUTINE ECCO_CHECK                                    |
                0016 C     | o Check runtime activated packages have been built in.   |
22f8b844e3 Jean*0017 C     *==========================================================*
5001c65f45 Patr*0018 C     | All packages can be selected/deselected at build time    |
                0019 C     | ( when code is compiled ) and activated/deactivated at   |
                0020 C     | runtime. This routine does a quick check to trap packages|
                0021 C     | that were activated at runtime but that were not compiled|
                0022 C     | in at build time.                                        |
22f8b844e3 Jean*0023 C     *==========================================================*
5001c65f45 Patr*0024       IMPLICIT NONE
                0025 
                0026 C     === Global variables ===
                0027 #include "SIZE.h"
                0028 #include "EEPARAMS.h"
                0029 #include "PARAMS.h"
c04085ad02 Patr*0030 #include "DYNVARS.h"
bcdcbe969d Gael*0031 #include "GRID.h"
49484c0542 Gael*0032 #ifdef ALLOW_CAL
                0033 # include "cal.h"
                0034 #endif
                0035 #ifdef ALLOW_ECCO
                0036 # include "ecco_cost.h"
                0037 #endif
7484238bfd Patr*0038 
5001c65f45 Patr*0039 C     === Routine arguments ===
                0040 C     myThid -  Number of this instances
                0041       INTEGER myThid
                0042 
f40bb882f5 Jean*0043 c     == external functions ==
025a9bb173 antn*0044       INTEGER  ILNBLNK
f40bb882f5 Jean*0045       EXTERNAL ILNBLNK
                0046 
5001c65f45 Patr*0047 C     === Local variables ===
f8e779c983 antn*0048 C     msgBuf      - Informational/error message buffer
5001c65f45 Patr*0049       CHARACTER*(MAX_LEN_MBUF) msgBuf
130273d46b Gael*0050 #ifdef ALLOW_GENCOST_CONTRIBUTION
025a9bb173 antn*0051       INTEGER igen_etagcm, il
                0052       INTEGER igen_tp, igen_ers, igen_gfo, use_mon_int, use_day_int
cbd85e4123 Gael*0053       LOGICAL exst
9f5240b52a Jean*0054       CHARACTER*(128) tempfile
a5ed45e6de An T*0055       INTEGER icount_transp
35c4fdc74b Emma*0056       INTEGER k
130273d46b Gael*0057 #endif
f40bb882f5 Jean*0058       INTEGER nRetired
cbd85e4123 Gael*0059 
7484238bfd Patr*0060       _BEGIN_MASTER(myThid)
                0061 
d4b64b229a Jean*0062       WRITE(msgBuf,'(2A)') 'ECCO_CHECK: ',
                0063      &                     ' --> Starts to check ECCO set-up'
                0064       CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0065      &                    SQUEEZE_RIGHT, myThid )
                0066 
b8fab26f74 Gael*0067 c ============ retired compile option checks
cda1c18f72 Jean*0068       nRetired = 0
8836fabb97 Gael*0069 
                0070 #ifdef ALLOW_MEAN_HFLUX_COST_CONTRIBUTION
                0071            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0072      &      'ALLOW_MEAN_HFLUX_COST_CONTRIBUTION has no',
                0073      &      'effect since cost_mean_heatflux has been retired'
                0074            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0075      &                     SQUEEZE_RIGHT , myThid )
                0076        nRetired = nRetired + 1
                0077 #endif
                0078 #ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION
                0079            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
2b959ba38e Mart*0080      &      'ALLOW_MEAN_SFLUX_COST_CONTRIBUTION has no',
8836fabb97 Gael*0081      &      'effect since cost_mean_saltflux has been retired'
                0082            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0083      &                     SQUEEZE_RIGHT , myThid )
                0084        nRetired = nRetired + 1
                0085 #endif
2b959ba38e Mart*0086 #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION
                0087            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0088      &      'ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION has no',
                0089      &      'effect since cost_ssh_globmean has been retired'
                0090            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0091      &                     SQUEEZE_RIGHT , myThid )
                0092        nRetired = nRetired + 1
                0093 #endif
8836fabb97 Gael*0094 #ifdef ALLOW_NEW_SSH_COST
                0095            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0096      &      'ALLOW_NEW_SSH_COST has no',
                0097      &      'effect since cost_ssh_new has been retired'
                0098            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0099      &                     SQUEEZE_RIGHT , myThid )
                0100        nRetired = nRetired + 1
                0101 #endif
                0102 #ifdef ALLOW_CURMTR_COST_CONTRIBUTION
                0103            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0104      &      'ALLOW_CURMTR_COST_CONTRIBUTION has no',
                0105      &      'effect since cost_curmtr has been retired'
                0106            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0107      &                     SQUEEZE_RIGHT , myThid )
                0108        nRetired = nRetired + 1
                0109 #endif
                0110 #ifdef ALLOW_DRIFTER_COST_CONTRIBUTION
                0111            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0112      &      'ALLOW_DRIFTER_COST_CONTRIBUTION has no',
                0113      &      'effect since cost_drifter has been retired'
                0114            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0115      &                     SQUEEZE_RIGHT , myThid )
                0116        nRetired = nRetired + 1
                0117 #endif
cda1c18f72 Jean*0118 #ifdef ALLOW_BP_COST_CONTRIBUTION
                0119         WRITE(msgBuf,'(3A)') 'ECCO_CHECK:',
                0120      &      ' "ALLOW_BP_COST_CONTRIBUTION" has been removed',
                0121      &      ' since cost_bp has been retired'
                0122         CALL PRINT_ERROR( msgBuf, myThid )
                0123         nRetired = nRetired + 1
                0124 #endif
8836fabb97 Gael*0125 #ifdef ALLOW_SCAT_COST_CONTRIBUTION
                0126            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0127      &      'ALLOW_SCAT_COST_CONTRIBUTION has no',
                0128      &      'effect since cost_scat etc has been retired'
                0129            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0130      &                     SQUEEZE_RIGHT , myThid )
                0131        nRetired = nRetired + 1
                0132 #endif
                0133 #ifdef ALLOW_DAILYSCAT_COST_CONTRIBUTION
                0134            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0135      &      'ALLOW_DAILYSCAT_COST_CONTRIBUTION has no',
                0136      &      'effect since cost_scat etc has been retired'
                0137            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0138      &                     SQUEEZE_RIGHT , myThid )
                0139        nRetired = nRetired + 1
                0140 #endif
                0141 #ifdef ALLOW_DRIFT_COST_CONTRIBUTION
                0142            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0143      &      'ALLOW_DRIFT_COST_CONTRIBUTION has no',
                0144      &      'effect since cost_drift has been retired'
                0145            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0146      &                     SQUEEZE_RIGHT , myThid )
                0147        nRetired = nRetired + 1
                0148 #endif
                0149 #ifdef ALLOW_DRIFTW_COST_CONTRIBUTION
                0150            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0151      &      'ALLOW_DRIFTW_COST_CONTRIBUTION has no',
                0152      &      'effect since cost_driftw has been retired'
                0153            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0154      &                     SQUEEZE_RIGHT , myThid )
                0155        nRetired = nRetired + 1
                0156 #endif
                0157 #ifdef ALLOW_COST_INI_FIN
                0158            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0159      &      'ALLOW_COST_INI_FIN has no',
                0160      &      'effect since cost_theta_ini_fin etc has been retired'
                0161            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0162      &                     SQUEEZE_RIGHT , myThid )
                0163        nRetired = nRetired + 1
                0164 #endif
                0165 #ifdef ALLOW_COST_TRANSPORT
                0166            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0167      &      'ALLOW_COST_TRANSPORT has no',
                0168      &      'effect since cost_trans_merid etc has been retired'
                0169            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0170      &                     SQUEEZE_RIGHT , myThid )
                0171        nRetired = nRetired + 1
                0172 #endif
                0173 #ifdef ALLOW_COST_ATLANTIC
                0174            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0175      &      'ALLOW_COST_ATLANTIC has no',
                0176      &      'effect since cost_atlantic has been retired'
                0177            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0178      &                     SQUEEZE_RIGHT , myThid )
                0179        nRetired = nRetired + 1
                0180 #endif
                0181 #ifdef ALLOW_TRANSPORT_COST_CONTRIBUTION
                0182            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0183      &      'ALLOW_TRANSPORT_COST_CONTRIBUTION has no',
                0184      &      'effect since cost_gen_transport has been retired'
                0185            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0186      &                     SQUEEZE_RIGHT , myThid )
                0187        nRetired = nRetired + 1
                0188 #endif
                0189 #ifdef ALLOW_EGM96_ERROR_COV
                0190            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0191      &      'ALLOW_EGM96_ERROR_COV has no',
                0192      &      'effect since cost_geoid etc has been retired'
                0193            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0194      &                     SQUEEZE_RIGHT , myThid )
                0195        nRetired = nRetired + 1
                0196 #endif
                0197 #ifdef ALLOW_IESTAU_COST_CONTRIBUTION
                0198            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0199      &      'ALLOW_IESTAU_COST_CONTRIBUTION has no',
                0200      &      'effect since cost_ies etc has been retired'
                0201            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0202      &                     SQUEEZE_RIGHT , myThid )
                0203        nRetired = nRetired + 1
                0204 #endif
                0205 #ifdef ALLOW_SIGMAR_COST_CONTRIBUTION
                0206            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0207      &      'ALLOW_SIGMAR_COST_CONTRIBUTION has no',
                0208      &      'effect since cost_sigmar has been retired'
                0209            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0210      &                     SQUEEZE_RIGHT , myThid )
                0211        nRetired = nRetired + 1
                0212 #endif
                0213 #ifdef ALLOW_EDDYPSI_COST_CONTRIBUTION
                0214            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0215      &      'ALLOW_EDDYPSI_COST_CONTRIBUTION has no',
                0216      &      'effect since cost_tau_eddy has been retired'
                0217            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0218      &                     SQUEEZE_RIGHT , myThid )
                0219        nRetired = nRetired + 1
                0220 #endif
                0221 
                0222       IF ( nRetired .GT. 0 ) THEN
                0223        WRITE(msgBuf,'(2A)') 'S/R ECCO_CHECK: ',
cda1c18f72 Jean*0224      &  '  retired compile-time options need to be removed'
8836fabb97 Gael*0225        CALL PRINT_ERROR( msgBuf, myThid )
cda1c18f72 Jean*0226        CALL ALL_PROC_DIE( 0 )
8836fabb97 Gael*0227        STOP 'ABNORMAL END: S/R ECCO_CHECK'
                0228       ENDIF
                0229 
b8fab26f74 Gael*0230 c ============ retired run-time parameter checks
cda1c18f72 Jean*0231       nRetired = 0
b8fab26f74 Gael*0232 
                0233 #ifdef ALLOW_GENCOST_CONTRIBUTION
f40bb882f5 Jean*0234       DO k=1,NGENCOST
b8fab26f74 Gael*0235        IF (gencost_scalefile(k).NE.' ') THEN
                0236            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0237      &      'gencost_scalefile has been retired; ',
                0238      &      'gencost_posproc_c should now be used instead'
                0239            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
7484238bfd Patr*0240      &                     SQUEEZE_RIGHT , myThid )
b8fab26f74 Gael*0241            nRetired = nRetired + 1
                0242        ENDIF
                0243        IF (gencost_smooth2Ddiffnbt(k).NE.0) THEN
                0244            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0245      &      'gencost_smooth2Ddiffnbt has been retired; ',
                0246      &      'gencost_posproc_i should now be used instead'
                0247            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0248      &                     SQUEEZE_RIGHT , myThid )
                0249            nRetired = nRetired + 1
                0250        ENDIF
                0251        IF (gencost_timevaryweight(k)) THEN
                0252            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0253      &      'gencost_timevaryweight has been retired; ',
                0254      &      'gencost_posproc should now be used instead'
                0255            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0256      &                     SQUEEZE_RIGHT , myThid )
                0257            nRetired = nRetired + 1
                0258        ENDIF
                0259        IF (gencost_nrecperiod(k).NE.0) THEN
                0260            WRITE(msgBuf,'(3A)') '** WARNING ** ECCO_CHECK:',
                0261      &      'gencost_nrecperiod has been retired; ',
                0262      &      'gencost_posproc clim should now be used instead'
                0263            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0264      &                     SQUEEZE_RIGHT , myThid )
                0265            nRetired = nRetired + 1
                0266        ENDIF
                0267 
                0268       ENDDO
                0269 #endif
                0270 
                0271       IF ( nRetired .GT. 0 ) THEN
                0272        WRITE(msgBuf,'(2A)') 'S/R ECCO_CHECK: ',
                0273      &  '  retired run-time options were found in data.ecco'
                0274        CALL PRINT_ERROR( msgBuf, myThid )
cda1c18f72 Jean*0275        CALL ALL_PROC_DIE( 0 )
7484238bfd Patr*0276        STOP 'ABNORMAL END: S/R ECCO_CHECK'
                0277       ENDIF
                0278 
b8fab26f74 Gael*0279 c ============ backward compatibility checks
49484c0542 Gael*0280       IF ( (using_topex).AND.(.NOT.using_tpj) ) using_tpj=.TRUE.
                0281 
7484238bfd Patr*0282       _END_MASTER(myThid)
5001c65f45 Patr*0283 
b8fab26f74 Gael*0284 c ============ generic cost function related checks
                0285 
130273d46b Gael*0286 #ifdef ALLOW_GENCOST_CONTRIBUTION
a5ed45e6de An T*0287       icount_transp=0
025a9bb173 antn*0288       igen_tp = 0
                0289       igen_ers = 0
                0290       igen_gfo = 0
f40bb882f5 Jean*0291       DO k=1,NGENCOST
17944dd1e8 Gael*0292 
f40bb882f5 Jean*0293          IF (gencost_pointer3d(k).GT.NGENCOST3D) THEN
5cce2b5d76 Gael*0294            WRITE(msgBuf,'(2A)')
                0295      &      'ECCO_CHECK: too many 3D cost terms; please',
                0296      &      'increase NGENCOST3D and recompile.'
                0297            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0298      &                     SQUEEZE_RIGHT , myThid )
                0299            CALL PRINT_ERROR( msgBuf , myThid )
                0300            STOP 'ABNORMAL END: S/R ECCO_CHECK'
f40bb882f5 Jean*0301          ENDIF
5cce2b5d76 Gael*0302 
f40bb882f5 Jean*0303          IF (gencost_msk_pointer3d(k).GT.NGENCOST3D) THEN
17944dd1e8 Gael*0304            WRITE(msgBuf,'(2A)')
                0305      &      'ECCO_CHECK: too many 3D msk terms; please',
                0306      &      'increase NGENCOST3D and recompile.'
                0307            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0308      &                     SQUEEZE_RIGHT , myThid )
                0309            CALL PRINT_ERROR( msgBuf , myThid )
                0310            STOP 'ABNORMAL END: S/R ECCO_CHECK'
f40bb882f5 Jean*0311          ENDIF
17944dd1e8 Gael*0312 
f40bb882f5 Jean*0313          IF ( gencost_datafile(k) .NE. ' ' ) THEN
9f3ef6a237 Gael*0314 
130273d46b Gael*0315            CALL ECCO_CHECK_FILES( using_gencost(k), 'gencost',
49484c0542 Gael*0316      &       gencost_datafile(k), gencost_startdate1(k), myThid )
9f3ef6a237 Gael*0317 
cbd85e4123 Gael*0318 c--
f40bb882f5 Jean*0319            IF ( (gencost_preproc(1,k).EQ.'variaweight').AND.
                0320      &          ( gencost_errfile(k) .NE. ' ' ) ) THEN
cbd85e4123 Gael*0321              CALL ECCO_CHECK_FILES( using_gencost(k), 'gencost',
                0322      &         gencost_errfile(k), gencost_startdate1(k), myThid )
f40bb882f5 Jean*0323            ELSEIF ( gencost_errfile(k) .NE. ' ' ) THEN
                0324              il = ILNBLNK(gencost_errfile(k))
cbd85e4123 Gael*0325              inquire( file=gencost_errfile(k)(1:il), exist=exst )
f40bb882f5 Jean*0326              IF (.NOT.exst) THEN
cbd85e4123 Gael*0327                using_gencost(k)=.FALSE.
f40bb882f5 Jean*0328                il = ILNBLNK(gencost_name(k))
cbd85e4123 Gael*0329                WRITE(msgBuf,'(4A)')
                0330      &           '** WARNING ** ECCO_CHECK_FILES: missing error file',
                0331      &           ' so ',gencost_name(k)(1:il),' gets switched off'
                0332                CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0333      &                    SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0334              ENDIF
                0335            ENDIF
cbd85e4123 Gael*0336 
9f3ef6a237 Gael*0337 c altimetry related checks
b8fab26f74 Gael*0338 
025a9bb173 antn*0339          IF (gencost_name(k).EQ.'sshv4-tp') THEN
                0340            igen_tp = k
                0341            using_tpj = using_gencost(k)
                0342          ENDIF
                0343          IF (gencost_name(k).EQ.'sshv4-ers') THEN
                0344            igen_ers = k
                0345            using_ers = using_gencost(k)
                0346          ENDIF
                0347          IF (gencost_name(k).EQ.'sshv4-gfo') THEN
                0348            igen_gfo = k
                0349            using_gfo = using_gencost(k)
                0350          ENDIF
f40bb882f5 Jean*0351          IF (gencost_name(k).EQ.'sshv4-mdt') using_mdt=using_gencost(k)
9f3ef6a237 Gael*0352 
                0353 c seaice related checks
f40bb882f5 Jean*0354          IF (gencost_name(k).EQ.'siv4-conc')
3f6d0eeb99 Gael*0355      &       using_cost_seaice=using_gencost(k)
f40bb882f5 Jean*0356          IF (gencost_name(k).EQ.'siv4-deconc')
3f6d0eeb99 Gael*0357      &       using_cost_seaice=using_gencost(k)
f40bb882f5 Jean*0358          IF (gencost_name(k).EQ.'siv4-exconc')
3f6d0eeb99 Gael*0359      &       using_cost_seaice=using_gencost(k)
f40bb882f5 Jean*0360 catn-- put STOP statement if use old siv4 names:
                0361          IF (gencost_name(k).EQ.'siv4-sst') THEN
0a8c2c2ff2 An T*0362            WRITE(msgBuf,'(2A)')
                0363      &      'ECCO_CHECK: OLD seaice gencost_name siv4-sst is retired,',
                0364      &      ' NEW name is siv4-deconc'
                0365            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0366      &                     SQUEEZE_RIGHT , myThid )
                0367            CALL PRINT_ERROR( msgBuf , myThid )
                0368            STOP 'ABNORMAL END: S/R ECCO_CHECK'
f40bb882f5 Jean*0369          ENDIF
                0370          IF (gencost_name(k).EQ.'siv4-vol') THEN
0a8c2c2ff2 An T*0371            WRITE(msgBuf,'(2A)')
                0372      &      'ECCO_CHECK: OLD seaice gencost_name siv4-vol is retired,',
                0373      &      ' NEW name is siv4-exconc'
                0374            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0375      &                     SQUEEZE_RIGHT , myThid )
                0376            CALL PRINT_ERROR( msgBuf , myThid )
                0377            STOP 'ABNORMAL END: S/R ECCO_CHECK'
f40bb882f5 Jean*0378          ENDIF
9f3ef6a237 Gael*0379 
f8e779c983 antn*0380 c-atn add another block for cost that do not need datafile but
877e0f385b An T*0381 c should have checks for other things:
                0382 c here, separate into different gencost_flag block
f40bb882f5 Jean*0383          ELSE  !if ( gencost_datafile(k) .NE. ' ' ) THEN
877e0f385b An T*0384 c---------------- block -1 ----------------------------
                0385 c block -1: cost ssh-[mdt,lsc,amsre-lsc] do not need datafile
                0386 c but need errfile. at the moment do not accomodate variaweight.
f40bb882f5 Jean*0387           IF (gencost_flag(k).EQ. -1) THEN
                0388             IF (gencost_errfile(k) .NE. ' ') THEN
                0389              il = ILNBLNK(gencost_errfile(k))
877e0f385b An T*0390              inquire( file=gencost_errfile(k)(1:il), exist=exst )
f40bb882f5 Jean*0391              IF (.NOT.exst) THEN
877e0f385b An T*0392               using_gencost(k)=.FALSE.
f40bb882f5 Jean*0393               il = ILNBLNK(gencost_name(k))
877e0f385b An T*0394               WRITE(msgBuf,'(4A)')
                0395      &          '** WARNING ** ECCO_CHECK_FILES: missing error file',
                0396      &          ' so ',gencost_name(k)(1:il),' gets switched off'
                0397               CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0398      &                   SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0399              ENDIF
                0400             ELSEIF(.NOT.(gencost_name(k).EQ.'sshv4-gmsl')) THEN
877e0f385b An T*0401              using_gencost(k)=.FALSE.
f40bb882f5 Jean*0402              il = ILNBLNK(gencost_name(k))
877e0f385b An T*0403              WRITE(msgBuf,'(4A)')
                0404      &        '** WARNING ** ECCO_CHECK_FILES: error file not defined',
                0405      &        ' so ',gencost_name(k)(1:il),' gets switched off'
                0406              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0407      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0408             ENDIF
877e0f385b An T*0409 
                0410 c---------------- block -3 ----------------------------
                0411 c-- boxmean: require [err,bar]file, can have datafile, not checked here
                0412 c-- also not checked for variwei at the moment
f40bb882f5 Jean*0413           ELSEIF(gencost_flag(k) .EQ. -3 ) THEN
877e0f385b An T*0414            WRITE(msgBuf,'(A,i3,L5)')
447bdc4b79 Gael*0415      &     'entering boxmean/horflux check,k,using_gencost(k): ,',
877e0f385b An T*0416      &     k,using_gencost(k)
                0417            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0418      &                        SQUEEZE_RIGHT , myThid)
                0419 
f40bb882f5 Jean*0420             IF (gencost_errfile(k) .NE. ' ') THEN
47d80787ea Gael*0421               WRITE(msgBuf,'(3A)') 'S/R ECCO_CHECK: boxmean now ',
                0422      &          ' uses gencost_mask instead of gencost_errfile --',
                0423      &          ' please update data.ecco accordingly'
                0424               CALL PRINT_ERROR( msgBuf, myThid )
                0425               STOP 'ABNORMAL END: S/R ECCO_CHECK'
f40bb882f5 Jean*0426             ENDIF
47d80787ea Gael*0427 
f40bb882f5 Jean*0428             IF (gencost_mask(k) .EQ. ' ') THEN
47d80787ea Gael*0429               using_gencost(k)=.FALSE.
f40bb882f5 Jean*0430               il = ILNBLNK(gencost_name(k))
47d80787ea Gael*0431               WRITE(msgBuf,'(4A)')
                0432      &          '** WARNING ** ECCO_CHECK_FILES: gencost_mask is',
                0433      &          ' undefined so ',gencost_name(k)(1:il),
                0434      &          ' gets switched off'
                0435               CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0436      &                   SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0437             ENDIF
47d80787ea Gael*0438 
f40bb882f5 Jean*0439             IF ((gencost_mask(k) .NE. ' ').AND.
                0440      &          (gencost_barfile(k)(1:9).EQ.'m_boxmean')) THEN
                0441              il = ILNBLNK(gencost_mask(k))
                0442              WRITE(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'C'
47d80787ea Gael*0443              inquire( file=tempfile(1:il+1), exist=exst )
f40bb882f5 Jean*0444              IF (.NOT.exst) THEN
47d80787ea Gael*0445                using_gencost(k)=.FALSE.
f40bb882f5 Jean*0446                il = ILNBLNK(gencost_name(k))
47d80787ea Gael*0447                WRITE(msgBuf,'(4A)')
                0448      &           '** WARNING ** ECCO_CHECK_FILES: missing mask C file',
                0449      &           ' so ',gencost_name(k)(1:il),' gets switched off'
                0450                CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0451      &                    SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0452              ENDIF
                0453             ENDIF
47d80787ea Gael*0454 
f40bb882f5 Jean*0455             IF ((gencost_mask(k) .NE. ' ').AND.
                0456      &          (gencost_barfile(k)(1:9).EQ.'m_horflux')) THEN
                0457              il = ILNBLNK(gencost_mask(k))
                0458              WRITE(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'W'
47d80787ea Gael*0459              inquire( file=tempfile(1:il+1), exist=exst )
f40bb882f5 Jean*0460              IF (.NOT.exst) THEN
47d80787ea Gael*0461                using_gencost(k)=.FALSE.
f40bb882f5 Jean*0462                il = ILNBLNK(gencost_name(k))
47d80787ea Gael*0463                WRITE(msgBuf,'(4A)')
                0464      &           '** WARNING ** ECCO_CHECK_FILES: missing mask W file',
                0465      &           ' so ',gencost_name(k)(1:il),' gets switched off'
                0466                CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0467      &                    SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0468              ENDIF
47d80787ea Gael*0469 c
f40bb882f5 Jean*0470              il = ILNBLNK(gencost_mask(k))
                0471              WRITE(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'S'
47d80787ea Gael*0472              inquire( file=tempfile(1:il+1), exist=exst )
f40bb882f5 Jean*0473              IF (.NOT.exst) THEN
47d80787ea Gael*0474                using_gencost(k)=.FALSE.
f40bb882f5 Jean*0475                il = ILNBLNK(gencost_name(k))
47d80787ea Gael*0476                WRITE(msgBuf,'(4A)')
                0477      &           '** WARNING ** ECCO_CHECK_FILES: missing mask S file',
                0478      &           ' so ',gencost_name(k)(1:il),' gets switched off'
                0479                CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0480      &                    SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0481              ENDIF
                0482             ENDIF
47d80787ea Gael*0483 
877e0f385b An T*0484 c-- check barfile, make sure character m_[theta,salt] match exactly
                0485 c-- (upper/lower-case matters) in cost_gencost_customize
f40bb882f5 Jean*0486            IF (.NOT.(
bdae1843b8 Gael*0487      &          (gencost_barfile(k)(1:15).EQ.'m_boxmean_theta').OR.
                0488      &          (gencost_barfile(k)(1:13).EQ.'m_boxmean_eta').OR.
447bdc4b79 Gael*0489      &          (gencost_barfile(k)(1:14).EQ.'m_boxmean_salt').OR.
248a3ebb42 Gael*0490      &          (gencost_barfile(k)(1:17).EQ.'m_boxmean_ptracer').OR.
38d78826c7 Ciar*0491      &          (gencost_barfile(k)(1:13).EQ.'m_boxmean_vol').OR.
7b8b86ab99 Timo*0492      &          (gencost_barfile(k)(1:16).EQ.'m_boxmean_shifwf').OR.
                0493      &          (gencost_barfile(k)(1:16).EQ.'m_boxmean_shihtf').OR.
c525843658 Emma*0494      &          (gencost_barfile(k)(1:13).EQ.'m_horflux_vol')
f40bb882f5 Jean*0495      &        )) THEN
877e0f385b An T*0496             using_gencost(k)=.FALSE.
f40bb882f5 Jean*0497             il=ILNBLNK(gencost_barfile(k))
877e0f385b An T*0498             WRITE(msgBuf,'(3A)')
                0499      &      '** WARNING ** S/R ECCO_CHECK: barfile ',
                0500      &      gencost_barfile(k)(1:il),': has no matched model var.'
                0501             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0502      &                          SQUEEZE_RIGHT, myThid )
                0503             WRITE(msgBuf,'(A)') 'Edit cost_gencost_customize to fix. '
                0504             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0505      &                          SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0506             il = ILNBLNK(gencost_name(k))
877e0f385b An T*0507           WRITE(msgBuf,'(2A)') gencost_name(k)(1:il),' is switched off'
                0508             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0509      &                          SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0510            ENDIF !barfile
877e0f385b An T*0511 
                0512 c---------------- block -4 ----------------------------
736e27304c Timo*0513 c-- transs: require [mask,bar][W,S]file, can have datafile, but
877e0f385b An T*0514 c-- not checked here. also not checked for variwei at the moment
f40bb882f5 Jean*0515          ELSEIF ( (gencost_flag(k).EQ. -4) .OR.
                0516      &            (gencost_flag(k).EQ. -5) ) THEN
877e0f385b An T*0517           WRITE(msgBuf,'(A,i3,L5)')
df462307fb Timo*0518      &     'ecco_check for gencost transp & moc; k,using_gencost(k): ,',
877e0f385b An T*0519      &     k,using_gencost(k)
                0520           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0521      &                        SQUEEZE_RIGHT , myThid)
                0522 
736e27304c Timo*0523 C ---
                0524 C Warn the user that this is a less tested objective function
0d7023b5ce Jean*0525 C TBD: Write a more consistent transport objective function
736e27304c Timo*0526 C ---
                0527 
f40bb882f5 Jean*0528           IF ((gencost_barfile(k)(1:7).EQ.'m_trVol').AND.
                0529      &        (gencost_flag(k).EQ.-4)) THEN
0d7023b5ce Jean*0530            WRITE(msgBuf,'(A)')
df462307fb Timo*0531      &  '** WARNING ** ECCO_CHECK: cost_gencost_transp.F not tested'
736e27304c Timo*0532            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0533      &                         SQUEEZE_RIGHT, myThid )
0d7023b5ce Jean*0534            WRITE(msgBuf,'(A)')
736e27304c Timo*0535      &   ' See m_horflux_vol via cost_gencost_boxmean.F.'
                0536            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0537      &                         SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0538           ELSEIF( (gencost_barfile(k)(1:8).EQ.'m_trHeat').OR.
                0539      &            (gencost_barfile(k)(1:8).EQ.'m_trSalt') ) THEN
0d7023b5ce Jean*0540            WRITE(msgBuf,'(2A)')
736e27304c Timo*0541      &   '** WARNING ** ECCO_CHECK: m_tr[Heat,Salt] to be used with',
                0542      &   ' caution because:'
                0543            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0544      &                         SQUEEZE_RIGHT, myThid )
0d7023b5ce Jean*0545            WRITE(msgBuf,'(A)')
736e27304c Timo*0546      &  '  (1) advection inconsistent unless ENUM_CENTERED_2ND is used'
                0547            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0548      &                         SQUEEZE_RIGHT, myThid )
0d7023b5ce Jean*0549            WRITE(msgBuf,'(A)')
736e27304c Timo*0550      &  '  (2) bolus velocities not included'
                0551            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0552      &                         SQUEEZE_RIGHT, myThid )
0d7023b5ce Jean*0553            WRITE(msgBuf,'(A)')
736e27304c Timo*0554      &  '  (3) diffusion components not included'
                0555            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0556      &                         SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0557          ENDIF
736e27304c Timo*0558 
                0559 C ---
                0560 C Note to user: use gencost_mask not errfile
                0561 C ---
f40bb882f5 Jean*0562           IF (gencost_errfile(k) .NE. ' ') THEN
df462307fb Timo*0563             WRITE(msgBuf,'(3A)') 'S/R ECCO_CHECK: transp & moc now ',
                0564      &        ' use gencost_mask instead of gencost_errfile --',
736e27304c Timo*0565      &        ' please update data.ecco accordingly'
                0566             CALL PRINT_ERROR( msgBuf, myThid )
                0567             STOP 'ABNORMAL END: S/R ECCO_CHECK'
f40bb882f5 Jean*0568           ENDIF
736e27304c Timo*0569 
f40bb882f5 Jean*0570           IF (gencost_mask(k) .EQ. ' ') THEN
736e27304c Timo*0571             using_gencost(k)=.FALSE.
f40bb882f5 Jean*0572             il = ILNBLNK(gencost_name(k))
736e27304c Timo*0573             WRITE(msgBuf,'(4A)')
                0574      &        '** WARNING ** ECCO_CHECK_FILES: gencost_mask is',
                0575      &        ' undefined so ',gencost_name(k)(1:il),
                0576      &        ' gets switched off'
                0577             CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0578      &                 SQUEEZE_RIGHT , myThid)
                0579 
f40bb882f5 Jean*0580           ELSE
a5ed45e6de An T*0581 c-- West ----------------------
f40bb882f5 Jean*0582            il = ILNBLNK(gencost_mask(k))
                0583            WRITE(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'W'
039a16fdf5 Gael*0584            inquire( file=tempfile(1:il+1), exist=exst )
f40bb882f5 Jean*0585            WRITE(msgBuf,'(2A,L5)') 'ecco_check file, exst: ',
039a16fdf5 Gael*0586      &       tempfile(1:il+1),exst
a5ed45e6de An T*0587            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0588      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0589            IF (.NOT.exst) THEN
877e0f385b An T*0590              using_gencost(k)=.FALSE.
                0591              WRITE(msgBuf,'(2A)')
736e27304c Timo*0592      &         '** WARNING ** ECCO_CHECK_FILES: missing mask file: ',
039a16fdf5 Gael*0593      &         tempfile(1:il+1)
877e0f385b An T*0594              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0595      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0596              il = ILNBLNK(gencost_name(k))
877e0f385b An T*0597              WRITE(msgBuf,'(3A)')
                0598      &         ' so ',gencost_name(k)(1:il),' gets switched off'
                0599              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0600      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0601            ENDIF
a5ed45e6de An T*0602 c-- South --------------------
f40bb882f5 Jean*0603            il = ILNBLNK(gencost_mask(k))
                0604            WRITE(tempfile(1:128),'(2A)') gencost_mask(k)(1:il),'S'
039a16fdf5 Gael*0605            inquire( file=tempfile(1:il+1), exist=exst )
f40bb882f5 Jean*0606            WRITE(msgBuf,'(2A,L5)') 'ecco_check file, exst: ',
039a16fdf5 Gael*0607      &       tempfile(1:il+1),exst
a5ed45e6de An T*0608            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0609      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0610            IF (.NOT.exst) THEN
877e0f385b An T*0611              using_gencost(k)=.FALSE.
                0612              WRITE(msgBuf,'(2A)')
736e27304c Timo*0613      &         '** WARNING ** ECCO_CHECK_FILES: missing mask file: ',
039a16fdf5 Gael*0614      &         tempfile(1:il+1)
877e0f385b An T*0615              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0616      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0617              il = ILNBLNK(gencost_name(k))
877e0f385b An T*0618              WRITE(msgBuf,'(3A)')
                0619      &         ' so ',gencost_name(k)(1:il),' gets switched off'
                0620              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0621      &                  SQUEEZE_RIGHT , myThid)
f40bb882f5 Jean*0622            ENDIF
                0623          ENDIF ! gencost_mask.EQ.' '
877e0f385b An T*0624 
                0625 c-- check barfile, make sure character m_tr[Vol,Heat,Salt] match exactly
                0626 c-- (upper/lower-case matters) in cost_gencost_customize
f40bb882f5 Jean*0627           IF(.NOT.( (gencost_barfile(k)(1:7).EQ.'m_trVol') .OR.
877e0f385b An T*0628      &              (gencost_barfile(k)(1:8).EQ.'m_trHeat').OR.
f40bb882f5 Jean*0629      &              (gencost_barfile(k)(1:8).EQ.'m_trSalt') )) THEN
877e0f385b An T*0630            using_gencost(k)=.FALSE.
f40bb882f5 Jean*0631            il=ILNBLNK(gencost_barfile(k))
877e0f385b An T*0632            WRITE(msgBuf,'(3A)')
                0633      &     '** WARNING ** S/R ECCO_CHECK: barfile ',
                0634      &     gencost_barfile(k)(1:il),': has no matched model var.'
                0635            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0636      &                         SQUEEZE_RIGHT, myThid )
                0637            WRITE(msgBuf,'(A)') 'Edit cost_gencost_customize to fix. '
                0638            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0639      &                         SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0640            il = ILNBLNK(gencost_name(k))
877e0f385b An T*0641            WRITE(msgBuf,'(2A)') gencost_name(k)(1:il),' is switched off'
                0642            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0643      &                         SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0644           ENDIF !barfile
a5ed45e6de An T*0645 c-- set using_cost_transp
f40bb882f5 Jean*0646           IF ((using_gencost(k)).AND.(gencost_flag(k).EQ.-4))
df462307fb Timo*0647      &      icount_transp=icount_transp+1
f40bb882f5 Jean*0648           IF (icount_transp.GT.0) using_cost_transp = .TRUE.
a5ed45e6de An T*0649 c-- final report to make sure using_cost_transp is set correctly
                0650           WRITE(msgBuf,'(2A,i3,L5)')
                0651      &     'ecco_check: gencost transp; icount_transp,',
                0652      &     'using_cost_transp: ',icount_transp,using_cost_transp
                0653           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0654      &                        SQUEEZE_RIGHT , myThid)
736e27304c Timo*0655 
f40bb882f5 Jean*0656          ENDIF  !gencost_flag
877e0f385b An T*0657 
f40bb882f5 Jean*0658          ENDIF !if ( gencost_datafile(k) .NE. ' ' ) THEN
                0659       ENDDO
9f3ef6a237 Gael*0660 
025a9bb173 antn*0661 c check that one of the used gencost term defines etagcm (needed in sshv4)
9f3ef6a237 Gael*0662       IF ( (using_tpj ).OR.(using_ers).OR.(using_gfo)
                0663      &     .OR.(using_mdt) ) using_cost_altim = .TRUE.
c77c347932 Gael*0664 
025a9bb173 antn*0665       igen_etagcm=0
f40bb882f5 Jean*0666       DO k=1,NGENCOST
                0667         IF ( (gencost_barfile(k)(1:5).EQ.'m_eta').AND.
025a9bb173 antn*0668      &       (using_gencost(k)) )  igen_etagcm=k
f40bb882f5 Jean*0669       ENDDO
c77c347932 Gael*0670 
025a9bb173 antn*0671       IF ((igen_etagcm.EQ.0).AND.(using_cost_altim)) THEN
22f8b844e3 Jean*0672 c warn user as we override using_cost_altim
c77c347932 Gael*0673         using_cost_altim = .FALSE.
22f8b844e3 Jean*0674         WRITE(msgBuf,'(2A)')
                0675      &    '** WARNING ** S/R ECCO_CHECK: missing file: ',
11c3150c71 Mart*0676      &    'for altimeter data so cost gets switched off'
22f8b844e3 Jean*0677         CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0678      &                      SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0679       ELSE
c77c347932 Gael*0680 c print result to screen
d4b64b229a Jean*0681         WRITE(msgBuf,'(A,I3)')
                0682      &  'etagcm defined by gencost =',igen_etagcm
                0683         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0684      &                      SQUEEZE_RIGHT, myThid )
f40bb882f5 Jean*0685       ENDIF
c77c347932 Gael*0686 
025a9bb173 antn*0687 C If more than one within the data set [tp,ers,gfo] are present, they must have
                0688 C the same avgperiod, e.g., day or month. Here we check for inconsistency:
                0689       IF (using_cost_altim) THEN
                0690        use_mon_int = 0
                0691        use_day_int = 0
                0692        IF ( using_tpj ) THEN
                0693         IF (gencost_avgperiod(igen_tp) .EQ.'month' .OR.
                0694      &      gencost_avgperiod(igen_tp) .EQ.'MONTH') THEN
                0695           use_mon_int = use_mon_int + 1
                0696         ELSE
                0697           use_day_int = use_day_int + 1
                0698         ENDIF
                0699        ENDIF
                0700        IF ( using_ers ) THEN
                0701         IF (gencost_avgperiod(igen_ers) .EQ.'month' .OR.
                0702      &      gencost_avgperiod(igen_ers) .EQ.'MONTH') THEN
                0703           use_mon_int = use_mon_int + 1
                0704         ELSE
                0705           use_day_int = use_day_int + 1
                0706         ENDIF
                0707        ENDIF
                0708        IF ( using_gfo ) THEN
                0709         IF (gencost_avgperiod(igen_gfo).EQ.'month' .OR.
                0710      &      gencost_avgperiod(igen_gfo).EQ.'MONTH' ) THEN
                0711           use_mon_int = use_mon_int + 1
                0712         ELSE
                0713           use_day_int = use_day_int + 1
                0714         ENDIF
                0715        ENDIF
                0716        IF ( use_mon_int .GT. 0 .AND. use_day_int .GT. 0 ) THEN
                0717          WRITE(msgBuf,'(2A)')
                0718      &    'ECCO_CHECK: cost sshv4: data set TP/ERS/GFO must be all ',
                0719      &    'daily or monthly, but cannot be mixed.'
                0720          CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0721      &                       SQUEEZE_RIGHT, myThid )
                0722          CALL PRINT_ERROR( msgBuf, myThid )
                0723          STOP 'ABNORMAL END: S/R ECCO_CHECK'
                0724        ENDIF
                0725       ENDIF
                0726 
906a61c194 Ou W*0727 #endif /* ALLOW_GENCOST_CONTRIBUTION */
                0728 
                0729 C ============ other pkg/ecco related checks
                0730       _BEGIN_MASTER(myThid)
                0731 
                0732 #ifndef ALLOW_PSBAR_STERIC
                0733       IF (ecco_output_sterGloH) THEN
                0734          WRITE(msgBuf,'(3A)') 'ECCO_CHECK:',
                0735      &         ' Cannot set ecco_output_sterGloH to TRUE',
                0736      &         ' with #undef ALLOW_PSBAR_STERIC'
                0737          CALL PRINT_ERROR( msgBuf, myThid )
                0738          STOP 'ABNORMAL END: S/R ECCO_CHECK'
                0739       ENDIF
130273d46b Gael*0740 #endif
d4b64b229a Jean*0741 
                0742 C--   Summarize the ECCO cost function setup.
                0743       CALL ECCO_SUMMARY( myThid )
                0744 
                0745       WRITE(msgBuf,'(2A)') 'ECCO_CHECK: ',
                0746      &                     ' <-- Ends Normally'
                0747       CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0748      &                    SQUEEZE_RIGHT, myThid )
                0749       WRITE(msgBuf,'(A)') ' '
                0750       CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0751      &                    SQUEEZE_RIGHT, myThid )
                0752 
906a61c194 Ou W*0753       _END_MASTER(myThid)
130273d46b Gael*0754 
5001c65f45 Patr*0755       RETURN
                0756       END
984d1519c6 Gael*0757 
22f8b844e3 Jean*0758 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
984d1519c6 Gael*0759 
22f8b844e3 Jean*0760       SUBROUTINE ECCO_CHECK_FILES(
                0761      O using_cost_local,
                0762      I localname, localobsfile, localstartdate1,
984d1519c6 Gael*0763      I myThid )
22f8b844e3 Jean*0764 
                0765 C     *==========================================================*
984d1519c6 Gael*0766 C     | SUBROUTINE ECCO_CHECK_FILES                              |
                0767 C     | o Check that obs files are present for specified years.  |
                0768 C     |   If not then set using_cost_local to false.             |
22f8b844e3 Jean*0769 C     *==========================================================*
984d1519c6 Gael*0770       IMPLICIT NONE
                0771 
                0772 C     === Global variables ===
                0773 #include "SIZE.h"
                0774 #include "EEPARAMS.h"
                0775 #include "PARAMS.h"
13d362b8c1 Ou W*0776 #include "ECCO_SIZE.h"
                0777 #include "ECCO.h"
984d1519c6 Gael*0778 #ifdef ALLOW_CAL
                0779 # include "cal.h"
                0780 #endif
                0781 
                0782 C     === Routine arguments ===
                0783 C     myThid -  Number of this instances
                0784       INTEGER myThid
                0785       LOGICAL using_cost_local
f40bb882f5 Jean*0786       CHARACTER*(*) localname
                0787       CHARACTER*(MAX_LEN_FNAM) localobsfile
                0788       INTEGER localstartdate1
                0789 
                0790 c     == external functions ==
                0791       INTEGER  ILNBLNK
                0792       EXTERNAL ILNBLNK
22f8b844e3 Jean*0793 
984d1519c6 Gael*0794 C     === Local variables ===
f8e779c983 antn*0795 C     msgBuf      - Informational/error message buffer
984d1519c6 Gael*0796       CHARACTER*(MAX_LEN_MBUF) msgBuf
130273d46b Gael*0797       INTEGER irec, mody, modm, yday, locy, il
e7db56ba12 Gael*0798       LOGICAL exst, singleFileTest, yearlyFileTest
f40bb882f5 Jean*0799       CHARACTER*(128) fname
984d1519c6 Gael*0800 
                0801 c     == end of interface ==
                0802 
                0803 c left for later : refine test accounting for localstartdate1
                0804 
                0805 #ifdef ALLOW_CAL
                0806 
                0807       _BEGIN_MASTER(myThid)
                0808 
                0809       IF ( (using_cost_local).AND.(localobsfile.EQ.' ') ) THEN
                0810 c warn user as we override using_cost_local
                0811              WRITE(msgBuf,'(4A)')
                0812      &       '** WARNING ** ECCO_CHECK_FILES: missing file',
                0813      &       ' definition so ',localname,' gets switched off'
                0814              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0815      &                    SQUEEZE_RIGHT , myThid)
                0816 c switch off cost function term
                0817              using_cost_local = .FALSE.
                0818       ENDIF
                0819 
                0820       singleFileTest = .FALSE.
                0821       IF (using_cost_local) THEN
                0822            inquire( file=localobsfile, exist=exst )
                0823            IF ( exst ) singleFileTest=.TRUE.
                0824       ENDIF
                0825 
e7db56ba12 Gael*0826       yearlyFileTest = .FALSE.
22f8b844e3 Jean*0827       IF ( (using_cost_local).AND.(.NOT.singleFileTest) ) THEN
984d1519c6 Gael*0828         DO irec = 1, nmonsrec
                0829            mody   = modelstartdate(1)/10000
                0830            modm   = modelstartdate(1)/100 - mody*100
                0831            yday   = mody + INT((modm-1+irec-1)/12)
                0832 
130273d46b Gael*0833            locy   = localstartdate1/10000
                0834 
984d1519c6 Gael*0835            il=ilnblnk(localobsfile)
f40bb882f5 Jean*0836            WRITE(fname(1:128),'(2a,i4)')
984d1519c6 Gael*0837      &       localobsfile(1:il), '_', yday
                0838            inquire( file=fname, exist=exst )
                0839 
130273d46b Gael*0840            IF ( (.NOT.exst).AND.(yday.GE.locy) ) THEN
984d1519c6 Gael*0841 c warn user as we override using_cost_local
                0842              WRITE(msgBuf,'(5A)')
11c3150c71 Mart*0843      &       '** WARNING ** ECCO_CHECK_FILES: missing ',fname,
984d1519c6 Gael*0844      &       ' so ',localname,' gets switched off'
                0845              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0846      &                    SQUEEZE_RIGHT , myThid)
                0847 c switch off cost function term
                0848              using_cost_local = .FALSE.
e7db56ba12 Gael*0849            ELSEIF ( (exst).AND.(yday.GE.locy) ) THEN
                0850              yearlyFileTest = .TRUE.
984d1519c6 Gael*0851            ENDIF
                0852         ENDDO
                0853       ENDIF
e7db56ba12 Gael*0854 
                0855       IF (using_cost_local) THEN
                0856       IF ( (.NOT.yearlyFileTest).AND.(.NOT.singleFileTest) ) THEN
                0857 c warn user as we override using_cost_local
                0858              WRITE(msgBuf,'(4A)')
                0859      &       '** WARNING ** ECCO_CHECK_FILES: no data ',
                0860      &       ' so ',localname,' gets switched off'
                0861              CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
                0862      &                    SQUEEZE_RIGHT , myThid)
                0863 c switch off cost function term
                0864              using_cost_local = .FALSE.
                0865       ENDIF
                0866       ENDIF
22f8b844e3 Jean*0867 
984d1519c6 Gael*0868       _END_MASTER(myThid)
                0869 
                0870 #endif /* ALLOW_CAL */
                0871 
                0872       RETURN
                0873       END