Back to home page

MITgcm

 
 

    


File indexing completed on 2023-09-21 05:10:51 UTC

view on githubraw file Latest commit 96b00645 on 2023-09-20 15:15:14 UTC
5ca83cd8f7 Dani*0001 #include "STREAMICE_OPTIONS.h"
                0002 
                0003 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0004 
                0005 CBOP
                0006       SUBROUTINE STREAMICE_INIT_VARIA( myThid )
                0007 C     /============================================================\
                0008 C     | SUBROUTINE STREAMICE_INIT_VARIA                             |
                0009 C     | o Routine to initialize STREAMICE variables.                |
                0010 C     |============================================================|
                0011 C     | Initialize STREAMICE parameters and variables.              |
                0012 C     \============================================================/
                0013       IMPLICIT NONE
                0014 
                0015 C     === Global variables ===
                0016 #include "SIZE.h"
                0017 #include "GRID.h"
                0018 #include "SET_GRID.h"
                0019 #include "EEPARAMS.h"
                0020 #include "PARAMS.h"
                0021 #include "STREAMICE.h"
                0022 #include "STREAMICE_CG.h"
                0023 #include "STREAMICE_ADV.h"
                0024 
                0025 C     === Routine arguments ===
                0026 C     myThid -  Number of this instance of STREAMICE_INIT_VARIA
                0027       INTEGER myThid
                0028 CEndOfInterface
                0029 
                0030 #ifdef ALLOW_STREAMICE
                0031 C     === Local variables ===
                0032 C     I,J,bi,bj - Loop counters
07e785229e dngo*0033       INTEGER i, j, k, bi, bj, Gi, Gj
5ca83cd8f7 Dani*0034       INTEGER col_y, col_x
                0035       _RL slope_pos, c1, x, y, lenx, leny
                0036       CHARACTER*(MAX_LEN_MBUF) msgBuf
07e785229e dngo*0037 #ifdef STREAMICE_3D_GLEN_CONST
                0038       INTEGER r
                0039 #endif
                0040 #ifdef ALLOW_CTRL
5ca83cd8f7 Dani*0041       _RS     dummyRS
07e785229e dngo*0042 #endif
5ca83cd8f7 Dani*0043 
                0044 CEOP
                0045 
                0046 C     ZERO OUT FLOATING POINT ARRAYS
                0047 
                0048       DO bj = myByLo(myThid), myByHi(myThid)
                0049        DO bi = myBxLo(myThid), myBxHi(myThid)
217ff6d33b Jean*0050         DO j=1-OLy,sNy+OLy
                0051          DO i=1-OLx,sNx+OLx
5ca83cd8f7 Dani*0052           H_streamIce(i,j,bi,bj) = 0. _d 0
                0053           U_streamice(i,j,bi,bj) = 0. _d 0
                0054           V_streamice(i,j,bi,bj) = 0. _d 0
                0055           visc_streamice(i,j,bi,bj) = 0. _d 0
                0056           tau_beta_eff_streamice(i,j,bi,bj) = 0. _d 0
                0057           float_frac_streamice(i,j,bi,bj) = 0. _d 0
                0058           base_el_streamice(i,j,bi,bj) = 0. _d 0
                0059           surf_el_streamice(i,j,bi,bj) = 0. _d 0
                0060           area_shelf_streamice(i,j,bi,bj) = 0. _d 0
                0061           mass_ice_streamice(i,j,bi,bj) = 0. _d 0
                0062           BDOT_streamice(i,j,bi,bj) = 0. _d 0
0fbff46b46 dngo*0063           u_streamice_ext(i,j,bi,bj) = 0. _d 0
                0064           v_streamice_ext(i,j,bi,bj) = 0. _d 0
52d1822301 Dani*0065 #ifdef ALLOW_STREAMICE_TIMEDEP_FORCING
                0066           BDOT_streamice1(i,j,bi,bj) = 0. _d 0
96b006450c dngo*0067           streamice_bdot_maxmelt1(i,j,bi,bj) = 0. _d 0
                0068           streamice_bglen1(i,j,bi,bj) = 0. _d 0
                0069           streamice_beta1(i,j,bi,bj) = 0. _d 0
c266793079 Jean*0070 #endif
96b006450c dngo*0071           streamice_bdot_depth_maxmelt_v(i,j,bi,bj) = 0. _d 0
                0072           streamice_bdot_maxmelt_v(i,j,bi,bj) = 0. _d 0
5ca83cd8f7 Dani*0073           ADOT_streamice(i,j,bi,bj) = streamice_adot_uniform
                0074           C_basal_friction(i,j,bi,bj) = C_basal_fric_const
bdd8102d3e Dani*0075 #ifndef STREAMICE_3D_GLEN_CONST
5ca83cd8f7 Dani*0076           B_glen(i,j,bi,bj) = B_glen_isothermal
bdd8102d3e Dani*0077 #else
                0078           do k=1,Nr
                0079            B_glen(i,j,k,bi,bj) = B_glen_isothermal
                0080           enddo
                0081 #endif
5ca83cd8f7 Dani*0082           H_streamice_prev(i,j,bi,bj) = 0. _d 0
bdd8102d3e Dani*0083 #ifdef STREAMICE_STRESS_BOUNDARY_CONTROL
c266793079 Jean*0084           STREAMICE_u_normal_pert(i,j,bi,bj) = 0. _d 0
                0085           STREAMICE_v_normal_pert(i,j,bi,bj) = 0. _d 0
                0086           STREAMICE_u_shear_pert(i,j,bi,bj) = 0. _d 0
                0087           STREAMICE_v_shear_pert(i,j,bi,bj) = 0. _d 0
bdd8102d3e Dani*0088           STREAMICE_u_normal_stress(i,j,bi,bj) = 0. _d 0
                0089           STREAMICE_v_normal_stress(i,j,bi,bj) = 0. _d 0
                0090           STREAMICE_u_shear_stress(i,j,bi,bj) = 0. _d 0
                0091           STREAMICE_v_shear_stress(i,j,bi,bj) = 0. _d 0
52d1822301 Dani*0092 #ifdef ALLOW_STREAMICE_TIMEDEP_FORCING
                0093           STREAMICE_u_normal_stress1(i,j,bi,bj) = 0. _d 0
                0094           STREAMICE_v_normal_stress1(i,j,bi,bj) = 0. _d 0
                0095           STREAMICE_u_shear_stress1(i,j,bi,bj) = 0. _d 0
                0096           STREAMICE_v_shear_stress1(i,j,bi,bj) = 0. _d 0
                0097 #endif
bdd8102d3e Dani*0098 #endif
5ca83cd8f7 Dani*0099 #ifdef ALLOW_STREAMICE_2DTRACER
                0100 #ifdef STREAMICE_TRACER_AB
                0101          GAD_trac_2d (i,j,bi,bj) = 0. _d 0
07e785229e dngo*0102 c         GAD_trac_2dNm1 (i,j,bi,bj) = 0. _d 0
5ca83cd8f7 Dani*0103 #endif
                0104 #endif
c266793079 Jean*0105 #ifdef ALLOW_AUTODIFF
5ca83cd8f7 Dani*0106           ru_old_si(i,j,bi,bj) = 0. _d 0
                0107           rv_old_si(i,j,bi,bj) = 0. _d 0
                0108           zu_old_si(i,j,bi,bj) = 0. _d 0
                0109           zv_old_si(i,j,bi,bj) = 0. _d 0
07e785229e dngo*0110 c          h_after_uflux_SI(i,j,bi,bj) = 0. _d 0
5ca83cd8f7 Dani*0111 #endif
                0112 #ifdef USE_ALT_RLOW
                0113           R_low_si(i,j,bi,bj) = 0. _d 0
                0114 #endif
                0115 
                0116 #ifdef STREAMICE_HYBRID_STRESS
                0117           do k=1,Nr
                0118            visc_streamice_full(i,j,k,bi,bj) =
                0119      &     eps_glen_min**((1-n_glen)/n_glen)
217ff6d33b Jean*0120           enddo
5ca83cd8f7 Dani*0121           streamice_taubx (i,j,bi,bj) = 0. _d 0
                0122           streamice_tauby (i,j,bi,bj) = 0. _d 0
                0123 #endif
                0124          ENDDO
                0125         ENDDO
                0126 
                0127 #ifdef ALLOW_COST_TEST
                0128         cost_func1_streamice (bi,bj) = 0.0
bdd8102d3e Dani*0129         cost_vel_streamice (bi,bj) = 0.0
                0130         cost_surf_streamice (bi,bj) = 0.0
96b006450c dngo*0131         cost_smooth_fric_streamice (bi,bj) = 0.0
                0132         cost_smooth_glen_streamice (bi,bj) = 0.0
                0133         cost_prior_streamice (bi,bj) = 0.0
5ca83cd8f7 Dani*0134 #endif
                0135 
                0136        ENDDO
                0137       ENDDO
                0138 
07e785229e dngo*0139       DO j = 1-OLy, sNy+OLy
                0140        DO i = 1-OLx, sNx+OLx
5ca83cd8f7 Dani*0141         DO bj = myByLo(myThid), myByHi(myThid)
                0142          DO bi = myBxLo(myThid), myBxHi(myThid)
                0143 cc          DO k=1,4
                0144            DO col_x=-1,1
                0145             DO col_y=-1,1
                0146              streamice_cg_A1(i,j,bi,bj,col_x,col_y)=0.0
                0147              streamice_cg_A2(i,j,bi,bj,col_x,col_y)=0.0
                0148              streamice_cg_A3(i,j,bi,bj,col_x,col_y)=0.0
                0149              streamice_cg_A4(i,j,bi,bj,col_x,col_y)=0.0
                0150             ENDDO
                0151            ENDDO
                0152 cc          ENDDO
                0153          ENDDO
                0154         ENDDO
                0155        ENDDO
                0156       ENDDO
                0157 
                0158 C     INIT. INTEGER ARRAYS
                0159 
                0160       DO bj = myByLo(myThid), myByHi(myThid)
                0161        DO bi = myBxLo(myThid), myBxHi(myThid)
217ff6d33b Jean*0162         DO j=1-OLy,sNy+OLy
                0163          DO i=1-OLx,sNx+OLx
5ca83cd8f7 Dani*0164           STREAMICE_hmask(i,j,bi,bj) = -1.0
                0165           STREAMICE_umask(i,j,bi,bj) = 0.0
                0166           STREAMICE_vmask(i,j,bi,bj) = 0.0
                0167           STREAMICE_ufacemask(i,j,bi,bj) = 0.0
                0168           STREAMICE_vfacemask(i,j,bi,bj) = 0.0
                0169           STREAMICE_float_cond(i,j,bi,bj) = 0.0
                0170          ENDDO
                0171         ENDDO
                0172        ENDDO
                0173       ENDDO
                0174 
                0175 #ifdef USE_ALT_RLOW
07e785229e dngo*0176 c init alternate array for topog
5ca83cd8f7 Dani*0177       IF ( STREAMICEtopogFile .NE. ' ' ) THEN
                0178         _BARRIER
                0179 C The 0 is the "iteration" argument. The ' ' is an empty suffix
217ff6d33b Jean*0180        CALL READ_FLD_XY_RL( STREAMICEtopogFile, '',
5ca83cd8f7 Dani*0181      &      R_low_si, 0, myThid )
217ff6d33b Jean*0182 
5ca83cd8f7 Dani*0183       ELSE
                0184         WRITE(msgBuf,'(A)') 'STREAMICE TOPOG - FILENAME MISSING'
                0185         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0186      &                    SQUEEZE_RIGHT , 1)
                0187       ENDIF
                0188 #endif
                0189 
07e785229e dngo*0190 c initialize thickness
5ca83cd8f7 Dani*0191 
                0192 #ifndef STREAMICE_GEOM_FILE_SETUP
217ff6d33b Jean*0193 
5ca83cd8f7 Dani*0194       IF ( STREAMICEthickInit.EQ.'PARAM' ) THEN
                0195 
                0196       WRITE(msgBuf,'(A)') 'initializing analytic thickness'
                0197       CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0198      &                    SQUEEZE_RIGHT , 1)
                0199 
                0200        slope_pos = shelf_edge_pos - shelf_flat_width
217ff6d33b Jean*0201        c1 = 0.0
5ca83cd8f7 Dani*0202        IF (shelf_slope_scale .GT. 0.0) THEN
                0203         c1 = 1.0 / shelf_slope_scale
                0204        ENDIF
                0205 
                0206        DO bj = myByLo(myThid), myByHi(myThid)
                0207         DO bi = myBxLo(myThid), myBxHi(myThid)
                0208          DO j=1,sNy
                0209           DO i=1,sNx
                0210            Gi = (myXGlobalLo-1)+(bi-1)*sNx+i
                0211            Gj = (myYGlobalLo-1)+(bj-1)*sNy+j
217ff6d33b Jean*0212 
5ca83cd8f7 Dani*0213            IF ((Gi.lt.Nx).and.(Gj.lt.Ny)) THEN
217ff6d33b Jean*0214 
5ca83cd8f7 Dani*0215 C             IF (flow_dir .EQ. 2.0) THEN
                0216             IF (.TRUE.) THEN
                0217              IF (xC(i-1,j,bi,bj).GE.shelf_edge_pos) THEN
                0218               area_shelf_streamice(i,j,bi,bj) = 0. _d 0
                0219               STREAMICE_hmask(i,j,bi,bj) = 0. _d 0
                0220              ELSE
                0221 
                0222               IF (xC(i,j,bi,bj).GT.slope_pos) THEN
                0223                H_streamice (i,j,bi,bj) = shelf_min_draft
                0224               ELSE
217ff6d33b Jean*0225                H_streamice (i,j,bi,bj) = (shelf_min_draft +
                0226      &          (shelf_max_draft - shelf_min_draft) *
e321477f28 Dani*0227      &          min (oneRL, (c1*(slope_pos-xC(i,j,bi,bj)))**2))
5ca83cd8f7 Dani*0228               ENDIF
                0229 
                0230               IF (xC(i,j,bi,bj).GT.shelf_edge_pos) THEN
                0231                area_shelf_streamice(i,j,bi,bj) = rA(i,j,bi,bj) *
                0232      &          (shelf_edge_pos-xG(i,j,bi,bj)) /
                0233      &          (xG(i+1,j,bi,bj)-xG(i,j,bi,bj))
                0234                IF (area_shelf_streamice(i,j,bi,bj).gt. 0. _d 0) THEN
                0235                 STREAMICE_hmask(i,j,bi,bj) = 2.0
                0236                ELSE
                0237                 STREAMICE_hmask(i,j,bi,bj) = 0.0
                0238                 H_streamice(i,j,bi,bj) = 0.0
                0239                ENDIF
                0240               ELSE
217ff6d33b Jean*0241                area_shelf_streamice(i,j,bi,bj) = rA(i,j,bi,bj)
5ca83cd8f7 Dani*0242                STREAMICE_hmask(i,j,bi,bj) = 1.0
                0243               ENDIF
                0244 
                0245              ENDIF
                0246             ENDIF
217ff6d33b Jean*0247            ENDIF
5ca83cd8f7 Dani*0248           ENDDO
                0249          ENDDO
                0250         ENDDO
                0251        ENDDO
                0252 
                0253       ELSE IF ( STREAMICEthickInit.EQ.'FILE' ) THEN
                0254 
                0255        IF ( STREAMICEthickFile .NE. ' ' ) THEN
                0256         _BARRIER
                0257 C The 0 is the "iteration" argument. The ' ' is an empty suffix
                0258         CALL READ_FLD_XY_RL( STREAMICEthickFile, ' ', H_streamice,
                0259      &      0, myThid )
                0260         DO bj = myByLo(myThid), myByHi(myThid)
                0261          DO bi = myBxLo(myThid), myBxHi(myThid)
                0262           DO j=1,sNy
                0263            DO i=1,sNx
                0264             Gi = (myXGlobalLo-1)+(bi-1)*sNx+i
                0265             Gj = (myYGlobalLo-1)+(bj-1)*sNy+j
                0266             IF ((Gi.lt.Nx.OR.STREAMICE_EW_periodic).and.
                0267      &          (Gj.lt.Ny.OR.STREAMICE_NS_periodic)) THEN
                0268              IF (H_streamice(i,j,bi,bj).GT.0. _d 0) THEN
                0269               area_shelf_streamice(i,j,bi,bj) = rA(i,j,bi,bj)
                0270               STREAMICE_hmask(i,j,bi,bj) = 1.0
                0271              ELSE
                0272               area_shelf_streamice(i,j,bi,bj) = 0. _d 0
                0273               STREAMICE_hmask(i,j,bi,bj) = 0. _d 0
                0274              ENDIF
                0275              Do k=1,Nr
                0276              STREAMICE_ctrl_mask(i,j,k,bi,bj) = 1. _d 0
                0277              enddo
                0278             ENDIF
                0279            ENDDO
                0280           ENDDO
                0281          ENDDO
                0282         ENDDO
                0283        ELSE
                0284         WRITE(msgBuf,'(A)') 'INIT THICKNESS - FILENAME MISSING'
                0285         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0286      &                    SQUEEZE_RIGHT , 1)
                0287        ENDIF
217ff6d33b Jean*0288 
5ca83cd8f7 Dani*0289       ELSE
                0290 
                0291        WRITE(msgBuf,'(A)') 'INIT THICKNESS - NOT IMPLENTED'
                0292        CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0293      &                    SQUEEZE_RIGHT , 1)
                0294       ENDIF
                0295 
                0296 #else
07e785229e dngo*0297 c STREAMICE_GEOM_FILE_SETUP - init thickness and hmask MUST come from file
5ca83cd8f7 Dani*0298 
                0299       IF ( STREAMICEthickFile .NE. ' ' ) THEN
                0300         _BARRIER
                0301 C The 0 is the "iteration" argument. The ' ' is an empty suffix
                0302       CALL READ_FLD_XY_RL( STREAMICEthickFile, ' ', H_streamice,
                0303      &      0, myThid )
                0304       ELSE
                0305        WRITE(msgBuf,'(A)') 'INIT THICKNESS - FILENAME MISSING'
                0306        CALL PRINT_ERROR( msgBuf, myThid)
                0307       ENDIF
                0308 
                0309       IF ( STREAMICEhMaskFile .NE. ' ' ) THEN
                0310         _BARRIER
                0311 C The 0 is the "iteration" argument. The ' ' is an empty suffix
                0312       CALL READ_FLD_XY_RS( STREAMICEhMaskFile, ' ', STREAMICE_hmask,
                0313      &      0, myThid )
                0314       ELSE
                0315        WRITE(msgBuf,'(A)') 'INIT HMASK - FILENAME MISSING'
                0316        CALL PRINT_ERROR( msgBuf, myThid)
                0317       ENDIF
                0318 
85b328ee93 dngo*0319       DO bj = myByLo(myThid), myByHi(myThid)
                0320        DO bi = myBxLo(myThid), myBxHi(myThid)
07e785229e dngo*0321         DO j=1-OLy,sNy+OLy
                0322          DO i=1-OLx,sNx+OLx
4bb1a1fbf9 Jean*0323           IF ( H_streamice(i,j,bi,bj) .GT. zeroRL .AND.
                0324      &         STREAMICE_hmask(i,j,bi,bj) .EQ. oneRS ) THEN
85b328ee93 dngo*0325            area_shelf_streamice(i,j,bi,bj) = rA(i,j,bi,bj)
                0326           ENDIF
                0327          ENDDO
                0328         ENDDO
                0329        ENDDO
                0330       ENDDO
                0331 
217ff6d33b Jean*0332 #endif
07e785229e dngo*0333 c STREAMICE_GEOM_FILE_SETUP
5ca83cd8f7 Dani*0334 
548d867d60 Dani*0335       IF ( .NOT. ( startTime .EQ. baseTime .AND.  nIter0 .EQ. 0
                0336      &     .AND. pickupSuff .EQ. ' ') ) THEN
c266793079 Jean*0337 
548d867d60 Dani*0338                           CALL STREAMICE_READ_PICKUP ( myThid )
c266793079 Jean*0339 
548d867d60 Dani*0340       ENDIF
                0341 
07e785229e dngo*0342 c finish initialize thickness
5ca83cd8f7 Dani*0343 
07e785229e dngo*0344 c initialize glen constant
5ca83cd8f7 Dani*0345 
                0346       IF ( STREAMICEGlenConstConfig.EQ.'FILE' ) THEN
                0347 
                0348        IF ( STREAMICEGlenConstFile .NE. ' ' ) THEN
                0349         _BARRIER
                0350 
bdd8102d3e Dani*0351 #ifdef STREAMICE_3D_GLEN_CONST
                0352 
                0353         CALL READ_FLD_XYZ_RL( STREAMICEGlenConstFile, ' ',
                0354      &      B_glen, 0, myThid )
                0355 
                0356 #else
                0357 
217ff6d33b Jean*0358         CALL READ_FLD_XY_RL( STREAMICEGlenConstFile, ' ',
5ca83cd8f7 Dani*0359      &      B_glen, 0, myThid )
96b006450c dngo*0360         CALL READ_FLD_XY_RL( STREAMICEGlenConstFile, ' ',
                0361      &      B_glen_init, 0, myThid )
5ca83cd8f7 Dani*0362 
bdd8102d3e Dani*0363 #endif
5ca83cd8f7 Dani*0364        ELSE
                0365         WRITE(msgBuf,'(A)') 'INIT GLEN - FILENAME MISSING'
                0366         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0367      &                    SQUEEZE_RIGHT , 1)
                0368        ENDIF
217ff6d33b Jean*0369 
5ca83cd8f7 Dani*0370       ELSE IF (STREAMICEGlenConstConfig.EQ.'UNIFORM' ) THEN
                0371 
                0372         DO bj = myByLo(myThid), myByHi(myThid)
                0373          DO bi = myBxLo(myThid), myBxHi(myThid)
                0374           DO j=1,sNy
                0375            DO i=1,sNx
bdd8102d3e Dani*0376 #ifdef STREAMICE_3D_GLEN_CONST
                0377             DO r=1,Nr
                0378              B_glen(i,j,r,bi,bj) = B_glen_isothermal
                0379             ENDDO
                0380 #else
                0381              B_glen(i,j,bi,bj) = B_glen_isothermal
                0382 #endif
5ca83cd8f7 Dani*0383            ENDDO
                0384           ENDDO
                0385          ENDDO
                0386         ENDDO
                0387 
                0388       ELSE
                0389 
                0390        WRITE(msgBuf,'(A)') 'INIT GLEN CONSTANT - NOT IMPLENTED'
                0391        CALL PRINT_ERROR( msgBuf, myThid)
                0392        STOP 'ABNORMAL END: S/R STREAMICE_INIT_VAR'
                0393       ENDIF
                0394 
07e785229e dngo*0395 c finish initialize glen constant
5ca83cd8f7 Dani*0396 
07e785229e dngo*0397 c initialize melt rates
0a8c8b23d7 Dani*0398 
                0399       IF ( STREAMICEBdotConfig.EQ.'FILE' ) THEN
                0400 
                0401        IF ( STREAMICEBdotFile .NE. ' ' ) THEN
                0402         _BARRIER
                0403 
                0404         CALL READ_FLD_XY_RL( STREAMICEBdotFile, ' ',
                0405      &      BDOT_streamice, 0, myThid )
                0406 
                0407        ELSE
                0408         WRITE(msgBuf,'(A)') 'INIT BDOT - FILENAME MISSING'
                0409         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0410      &                    SQUEEZE_RIGHT , 1)
                0411        ENDIF
                0412 
96b006450c dngo*0413       ELSEIF ( STREAMICEBdotConfig.EQ.'PARAM' ) THEN
                0414 
                0415        IF ( STREAMICEBdotDepthFile .NE. ' ' ) THEN
                0416         _BARRIER
                0417 
                0418         CALL READ_FLD_XY_RL( STREAMICEBdotDepthFile, ' ',
                0419      &      streamice_bdot_depth_maxmelt_v, 0, myThid )
                0420 
                0421        ENDIF
                0422 
                0423        IF ( STREAMICEBdotMaxMeltFile .NE. ' ' ) THEN
                0424         _BARRIER
                0425 
                0426         CALL READ_FLD_XY_RL( STREAMICEBdotMaxMeltFile, ' ',
                0427      &     streamice_bdot_maxmelt_v , 0, myThid )
                0428 
                0429        ENDIF
                0430 
0a8c8b23d7 Dani*0431       ENDIF
                0432 
07e785229e dngo*0433 c finish initialize melt rates
                0434 
                0435 c initialize SMB rates
                0436 
                0437       IF ( STREAMICEAdotConfig.EQ.'FILE' ) THEN
                0438 
                0439        IF ( STREAMICEAdotFile .NE. ' ' ) THEN
                0440         _BARRIER
                0441 
                0442         CALL READ_FLD_XY_RL( STREAMICEAdotFile, ' ',
                0443      &      ADOT_streamice, 0, myThid )
                0444 
                0445        ELSE
                0446         WRITE(msgBuf,'(A)') 'INIT ADOT - FILENAME MISSING'
                0447         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0448      &                    SQUEEZE_RIGHT , 1)
                0449        ENDIF
                0450 
                0451       ENDIF
                0452 
                0453 c finish initialize SMB rates
0a8c8b23d7 Dani*0454 
0fbff46b46 dngo*0455       IF ( STREAMICE_vel_ext.OR.STREAMICE_vel_ext_cgrid ) THEN
                0456 
                0457        IF ( STREAMICE_uvel_ext_file .NE. ' ' ) THEN
                0458         _BARRIER
                0459 
                0460         CALL READ_FLD_XY_RL( STREAMICE_uvel_ext_file, ' ',
                0461      &      u_streamice_ext, 0, myThid )
                0462 
                0463         DO bj = myByLo(myThid), myByHi(myThid)
                0464          DO bi = myBxLo(myThid), myBxHi(myThid)
                0465           DO j=1-OLy,sNy+OLy
                0466            DO i=1-OLx,sNx+OLx
                0467             U_streamice(i,j,bi,bj) = U_streamice_ext(i,j,bi,bj)
                0468            ENDDO
                0469           ENDDO
                0470          ENDDO
                0471         ENDDO
                0472 
                0473        ELSE
                0474         WRITE(msgBuf,'(A)') 'INIT UVEL - FILENAME MISSING'
                0475         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0476      &                    SQUEEZE_RIGHT , 1)
                0477        ENDIF
                0478 
                0479        IF ( STREAMICE_vvel_ext_file .NE. ' ' ) THEN
                0480         _BARRIER
                0481 
                0482         CALL READ_FLD_XY_RL( STREAMICE_vvel_ext_file, ' ',
                0483      &      v_streamice_ext, 0, myThid )
                0484 
                0485         DO bj = myByLo(myThid), myByHi(myThid)
                0486          DO bi = myBxLo(myThid), myBxHi(myThid)
                0487           DO j=1-OLy,sNy+OLy
                0488            DO i=1-OLx,sNx+OLx
                0489             V_streamice(i,j,bi,bj) = V_streamice_ext(i,j,bi,bj)
                0490            ENDDO
                0491           ENDDO
                0492          ENDDO
                0493         ENDDO
                0494 
                0495        ELSE
                0496         WRITE(msgBuf,'(A)') 'INIT VVEL - FILENAME MISSING'
                0497         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0498      &                    SQUEEZE_RIGHT , 1)
                0499        ENDIF
                0500 
                0501       ENDIF
                0502 
07e785229e dngo*0503 c initialize basal traction
5ca83cd8f7 Dani*0504 
                0505       IF ( STREAMICEbasalTracConfig.EQ.'FILE' ) THEN
                0506 
                0507        IF ( STREAMICEbasalTracFile .NE. ' ' ) THEN
                0508         _BARRIER
                0509 
217ff6d33b Jean*0510         CALL READ_FLD_XY_RL( STREAMICEbasalTracFile, ' ',
5ca83cd8f7 Dani*0511      &      C_basal_friction, 0, myThid )
96b006450c dngo*0512         CALL READ_FLD_XY_RL( STREAMICEbasalTracFile, ' ',
                0513      &      C_basal_fric_init, 0, myThid )
5ca83cd8f7 Dani*0514 
                0515        ELSE
                0516         WRITE(msgBuf,'(A)') 'INIT C_BASAL - FILENAME MISSING'
                0517         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0518      &                    SQUEEZE_RIGHT , 1)
                0519        ENDIF
217ff6d33b Jean*0520 
5ca83cd8f7 Dani*0521       ELSE IF (STREAMICEbasalTracConfig.EQ.'UNIFORM' ) THEN
                0522 
                0523         DO bj = myByLo(myThid), myByHi(myThid)
                0524          DO bi = myBxLo(myThid), myBxHi(myThid)
                0525           DO j=1,sNy
                0526            DO i=1,sNx
                0527             C_basal_friction(i,j,bi,bj) = C_basal_fric_const
                0528            ENDDO
                0529           ENDDO
                0530          ENDDO
                0531         ENDDO
                0532 
                0533       ELSE IF (STREAMICEbasalTracConfig.EQ.'2DPERIODIC' ) THEN
217ff6d33b Jean*0534 
5ca83cd8f7 Dani*0535        lenx = sNx*nSx*nPx*delX(1)
                0536        leny = sNy*nSy*nPy*delY(1)
                0537        DO bj = myByLo(myThid), myByHi(myThid)
                0538         DO bi = myBxLo(myThid), myBxHi(myThid)
                0539          DO j=1,sNy
                0540           DO i=1,sNx
                0541            x = xC(i,j,bi,bj)
                0542            y = yC(i,j,bi,bj)
217ff6d33b Jean*0543            C_basal_friction(i,j,bi,bj) =
5ca83cd8f7 Dani*0544      &      sqrt(C_basal_fric_const**2*
                0545      &        (1+sin(2*streamice_kx_b_init*PI*x/lenx)*
                0546      &           sin(2*streamice_ky_b_init*PI*y/leny)))
                0547           ENDDO
                0548          ENDDO
                0549         ENDDO
                0550        ENDDO
                0551 
                0552       ELSE IF (STREAMICEbasalTracConfig.EQ.'1DPERIODIC' ) THEN
217ff6d33b Jean*0553 
5ca83cd8f7 Dani*0554        lenx = sNx*nSx*nPx*delX(1)
                0555        DO bj = myByLo(myThid), myByHi(myThid)
                0556         DO bi = myBxLo(myThid), myBxHi(myThid)
                0557          DO j=1,sNy
                0558           DO i=1,sNx
                0559            x = xC(i,j,bi,bj)
                0560            y = yC(i,j,bi,bj)
217ff6d33b Jean*0561            C_basal_friction(i,j,bi,bj) =
5ca83cd8f7 Dani*0562      &      sqrt(C_basal_fric_const**2*(1+
                0563      &        sin(2*streamice_kx_b_init*PI*x/lenx)))
                0564           ENDDO
                0565          ENDDO
                0566         ENDDO
                0567        ENDDO
                0568 
                0569       ELSE
                0570 
                0571        WRITE(msgBuf,'(A)') 'INIT TRAC - NOT IMPLENTED'
                0572        CALL PRINT_ERROR( msgBuf, myThid)
                0573        STOP 'ABNORMAL END: S/R STREAMICE_INIT_VAR'
                0574       ENDIF
                0575 
07e785229e dngo*0576 c finish initialize basal trac
5ca83cd8f7 Dani*0577 
                0578 #ifdef ALLOW_STREAMICE_2DTRACER
                0579 
                0580       IF ( STREAMICETRAC2DINITFILE .NE. ' ' ) THEN
                0581          _BARRIER
                0582 
                0583         CALL READ_FLD_XY_RL( STREAMICETRAC2dInitFile, ' ',
                0584      &      trac2d, 0, myThid )
                0585 
                0586        ELSE
                0587         WRITE(msgBuf,'(A)') 'TRAC2dInit - NO FILE SPECIFIED'
                0588         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0589      &                    SQUEEZE_RIGHT , 1)
                0590         DO bj = myByLo(myThid), myByHi(myThid)
                0591          DO bi = myBxLo(myThid), myBxHi(myThid)
                0592           DO j=1,sNy
                0593            DO i=1,sNx
                0594             trac2d(i,j,bi,bj) = 0.0
                0595            ENDDO
                0596           ENDDO
                0597          ENDDO
                0598         ENDDO
                0599 
                0600        ENDIF
                0601 
                0602       _EXCH_XY_RL (trac2d, myThid)
                0603 
                0604 #endif /*STREAMICE_ALLOW_2DTRACER*/
                0605 
bdd8102d3e Dani*0606 #ifdef STREAMICE_STRESS_BOUNDARY_CONTROL
                0607       IF ( STREAMICEuNormalStressFile .NE. ' ') THEN
                0608         _BARRIER
                0609        CALL READ_FLD_XY_RL ( STREAMICEuNormalStressFile, ' ',
                0610      &  streamice_u_normal_stress, 0, myThid )
                0611       ELSE
                0612        WRITE(msgBuf,'(A)') 'IMPOSED NORMAL U STRESS NOT SET'
                0613        CALL PRINT_ERROR( msgBuf, myThid)
                0614       ENDIF
                0615 
                0616       IF ( STREAMICEvNormalStressFile .NE. ' ') THEN
                0617         _BARRIER
                0618        CALL READ_FLD_XY_RL ( STREAMICEvNormalStressFile, ' ',
                0619      &  streamice_v_normal_stress, 0, myThid )
                0620       ELSE
                0621        WRITE(msgBuf,'(A)') 'IMPOSED NORMAL V STRESS NOT SET'
                0622        CALL PRINT_ERROR( msgBuf, myThid)
                0623       ENDIF
                0624 
                0625       IF ( STREAMICEuShearStressFile .NE. ' ') THEN
                0626         _BARRIER
                0627        CALL READ_FLD_XY_RL ( STREAMICEuShearStressFile, ' ',
                0628      &  streamice_u_shear_stress, 0, myThid )
                0629       ELSE
                0630        WRITE(msgBuf,'(A)') 'IMPOSED SHEAR U STRESS NOT SET'
                0631        CALL PRINT_ERROR( msgBuf, myThid)
                0632       ENDIF
                0633 
                0634       IF ( STREAMICEvShearStressFile .NE. ' ') THEN
                0635         _BARRIER
                0636        CALL READ_FLD_XY_RL ( STREAMICEvShearStressFile, ' ',
                0637      &  streamice_v_shear_stress, 0, myThid )
                0638       ELSE
                0639        WRITE(msgBuf,'(A)') 'IMPOSED SHEAR V STRESS NOT SET'
                0640        CALL PRINT_ERROR( msgBuf, myThid)
                0641       ENDIF
                0642 
c266793079 Jean*0643       CALL EXCH_XY_RL
bdd8102d3e Dani*0644      & (streamice_v_shear_stress, myThid)
c266793079 Jean*0645       CALL EXCH_XY_RL
bdd8102d3e Dani*0646      & (streamice_u_shear_stress, myThid)
c266793079 Jean*0647       CALL EXCH_XY_RL
bdd8102d3e Dani*0648      & (streamice_v_normal_stress, myThid)
c266793079 Jean*0649       CALL EXCH_XY_RL
bdd8102d3e Dani*0650      & (streamice_u_normal_stress, myThid)
                0651 
                0652 #endif /*STREAMICE_STRESS_BOUNDARY_CONTROL*/
                0653 
5ca83cd8f7 Dani*0654       CALL STREAMICE_UPD_FFRAC_UNCOUPLED ( myThid )
                0655 
                0656       _EXCH_XY_RL(H_streamice, myThid )
f1d1cc05cd Dani*0657       _EXCH_XY_RS(STREAMICE_hmask, myThid )
5ca83cd8f7 Dani*0658       _EXCH_XY_RL(area_shelf_streamice, myThid )
                0659       _EXCH_XY_RL(C_basal_friction, myThid )
0fbff46b46 dngo*0660       _EXCH_XY_RL(u_streamice_ext, myThid )
                0661       _EXCH_XY_RL(v_streamice_ext, myThid )
bdd8102d3e Dani*0662 #ifndef STREAMICE_3D_GLEN_CONST
5ca83cd8f7 Dani*0663       _EXCH_XY_RL(B_glen, myThid )
bdd8102d3e Dani*0664 #else
                0665       CALL EXCH_3D_RL(B_glen, Nr,myThid )
                0666 #endif
                0667 
5ca83cd8f7 Dani*0668 #ifdef USE_ALT_RLOW
                0669       _EXCH_XY_RL(R_low_si, myThid )
                0670 #endif
                0671 
07e785229e dngo*0672 c#ifdef STREAMICE_HYBRID_STRESS
5ca83cd8f7 Dani*0673 
07e785229e dngo*0674 c      CALL STREAMICE_VISC_BETA (myThid)
5ca83cd8f7 Dani*0675 
07e785229e dngo*0676 c DNG THIS CALL IS TO INITIALISE VISCOSITY
                0677 c     TO AVOID POSSIBLE ADJOINT INSTABILITIES
                0678 c     IT IS WRITTEN OVER IN FIRST TIMESTEP
5ca83cd8f7 Dani*0679 
351fd6b6a4 Dani*0680 #if (defined (ALLOW_AUTODIFF))
                0681 #ifndef ALLOW_STREAMICE_OAD_FP
5ca83cd8f7 Dani*0682 
                0683        CALL STREAMICE_UPD_FFRAC_UNCOUPLED ( myThid )
                0684        CALL STREAMICE_VELMASK_UPD (myThid)
95afe7199b Dani*0685 
351fd6b6a4 Dani*0686        CALL STREAMICE_VEL_SOLVE ( myThid,
95afe7199b Dani*0687      &                           streamice_max_nl_iter,
                0688      &                           streamice_max_cg_iter,
                0689      &                           0 )
                0690 
5ca83cd8f7 Dani*0691 #endif
95afe7199b Dani*0692 #endif
                0693 
217ff6d33b Jean*0694       CALL WRITE_FLD_XY_RL ( "C_basal_fric", "",
5ca83cd8f7 Dani*0695      & C_basal_friction, 0, myThid )
                0696       CALL WRITE_FLD_XY_RL ( "B_glen_sqrt", "",
                0697      & B_glen, 0, myThid )
217ff6d33b Jean*0698       CALL WRITE_FLD_XY_RL ( "H_streamice", "init",
5ca83cd8f7 Dani*0699      & H_streamIce, 0, myThid )
                0700 #ifdef ALLOW_STREAMICE_2DTRACER
                0701       CALL WRITE_FLD_XY_RL ( "2DTracer", "init",
                0702      & trac2d, 0, myThid )
                0703 #endif
217ff6d33b Jean*0704       CALL WRITE_FLD_XY_RL ( "area_shelf_streamice", "init",
5ca83cd8f7 Dani*0705      & area_shelf_streamice, 0, myThid )
217ff6d33b Jean*0706       CALL WRITE_FLD_XY_RS ( "STREAMICE_hmask", "init",
5ca83cd8f7 Dani*0707      & STREAMICE_hmask, 0, myThid )
                0708 #ifdef ALLOW_CTRL
                0709       CALL ACTIVE_WRITE_GEN_RS( 'maskCtrlst', STREAMICE_ctrl_mask,
217ff6d33b Jean*0710      &  'XY', Nr, 1, .FALSE., 0, myThid, dummyRS )
5ca83cd8f7 Dani*0711 #endif
07e785229e dngo*0712 c      call active_write_xyz( 'maskCtrlS', STREAMICE_ctrl_mask, 1, 0,
                0713 c     & myThid, dummy)
                0714 c       CALL STREAMICE_VELMASK_UPD (myThid)
                0715 c       CALL STREAMICE_UPD_FFRAC_UNCOUPLED ( myThid )
                0716 c       CALL STREAMICE_VEL_SOLVE( myThid )
5ca83cd8f7 Dani*0717 
217ff6d33b Jean*0718       CALL WRITE_FLD_XY_RL ( "U_init", "",
5ca83cd8f7 Dani*0719      &   C_basal_friction, 0, myThid )
217ff6d33b Jean*0720       CALL WRITE_FLD_XY_RL ( "V_init", "",
5ca83cd8f7 Dani*0721      &   V_streamice, 0, myThid )
                0722 #ifdef USE_ALT_RLOW
217ff6d33b Jean*0723       CALL WRITE_FLD_XY_RL ( "R_low_si", "init",
5ca83cd8f7 Dani*0724      & R_low_si, 0, myThid )
                0725 #endif
                0726 
07e785229e dngo*0727 c       CALL WRITE_FULLARRAY_RL ("H",H_streamice,1,0,0,1,0,myThid)
                0728 c       CALL WRITE_FULLARRAY_RS ("hmask",STREAMICE_hmask,1,0,0,1,0,myThid)
                0729 c       CALL WRITE_FULLARRAY_RL ("umask",STREAMICE_umask,1,0,0,1,0,myThid)
5ca83cd8f7 Dani*0730 
                0731 #endif /* ALLOW_STREAMICE */
                0732 
                0733       RETURN
                0734       END