[2113] | 1 | MODULE stpctl |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE stpctl *** |
---|
| 4 | !! Ocean run control : gross check of the ocean time stepping |
---|
| 5 | !!====================================================================== |
---|
| 6 | !! History : OPA ! 1991-03 (G. Madec) Original code |
---|
| 7 | !! 6.0 ! 1992-06 (M. Imbard) |
---|
| 8 | !! 8.0 ! 1997-06 (A.M. Treguier) |
---|
| 9 | !! NEMO 1.0 ! 2002-06 (G. Madec) F90: Free form and module |
---|
| 10 | !! 2.0 ! 2009-07 (G. Madec) Add statistic for time-spliting |
---|
| 11 | !!---------------------------------------------------------------------- |
---|
| 12 | |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
| 14 | !! stp_ctl : Control the run |
---|
| 15 | !!---------------------------------------------------------------------- |
---|
| 16 | USE oce ! ocean dynamics and tracers variables |
---|
| 17 | USE dom_oce ! ocean space and time domain variables |
---|
| 18 | USE sol_oce ! ocean space and time domain variables |
---|
| 19 | USE in_out_manager ! I/O manager |
---|
| 20 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 21 | USE lib_mpp ! distributed memory computing |
---|
| 22 | USE dynspg_oce ! pressure gradient schemes |
---|
| 23 | USE c1d ! 1D vertical configuration |
---|
| 24 | |
---|
| 25 | IMPLICIT NONE |
---|
| 26 | PRIVATE |
---|
| 27 | |
---|
| 28 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
| 29 | !!---------------------------------------------------------------------- |
---|
| 30 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
| 31 | !! $Id: stpctl.F90 3294 2012-01-28 16:44:18Z rblod $ |
---|
| 32 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 33 | !!---------------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | CONTAINS |
---|
| 36 | |
---|
| 37 | SUBROUTINE stp_ctl( kt, kindic ) |
---|
| 38 | !!---------------------------------------------------------------------- |
---|
| 39 | !! *** ROUTINE stp_ctl *** |
---|
| 40 | !! |
---|
| 41 | !! ** Purpose : Control the run |
---|
| 42 | !! |
---|
| 43 | !! ** Method : - Save the time step in numstp |
---|
| 44 | !! - Print it each 50 time steps |
---|
| 45 | !! - Print solver statistics in numsol |
---|
| 46 | !! - Stop the run IF problem for the solver ( indec < 0 ) |
---|
| 47 | !! |
---|
| 48 | !! ** Actions : 'time.step' file containing the last ocean time-step |
---|
| 49 | !! |
---|
| 50 | !!---------------------------------------------------------------------- |
---|
| 51 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
| 52 | INTEGER, INTENT( inout ) :: kindic ! indicator of solver convergence |
---|
| 53 | !! |
---|
| 54 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 55 | INTEGER :: ii, ij, ik ! temporary integers |
---|
| 56 | REAL(wp) :: zumax, zsmin, zssh2 ! temporary scalars |
---|
| 57 | INTEGER, DIMENSION(3) :: ilocu ! |
---|
| 58 | INTEGER, DIMENSION(2) :: ilocs ! |
---|
| 59 | !!---------------------------------------------------------------------- |
---|
| 60 | |
---|
| 61 | IF( kt == nit000 .AND. lwp ) THEN |
---|
| 62 | WRITE(numout,*) |
---|
| 63 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
| 64 | WRITE(numout,*) '~~~~~~~' |
---|
| 65 | ! open time.step file |
---|
| 66 | CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
| 67 | ENDIF |
---|
| 68 | |
---|
| 69 | IF(lwp) WRITE ( numstp, '(1x, i8)' ) kt !* save the current time step in numstp |
---|
| 70 | IF(lwp) REWIND( numstp ) ! -------------------------- |
---|
| 71 | |
---|
| 72 | ! !* Test maximum of velocity (zonal only) |
---|
| 73 | ! ! ------------------------ |
---|
| 74 | !! zumax = MAXVAL( ABS( un(:,:,:) ) ) ! slower than the following loop on NEC SX5 |
---|
| 75 | zumax = 0.e0 |
---|
| 76 | DO jk = 1, jpk |
---|
| 77 | DO jj = 1, jpj |
---|
| 78 | DO ji = 1, jpi |
---|
| 79 | zumax = MAX(zumax,ABS(un(ji,jj,jk))) |
---|
| 80 | END DO |
---|
| 81 | END DO |
---|
| 82 | END DO |
---|
| 83 | IF( lk_mpp ) CALL mpp_max( zumax ) ! max over the global domain |
---|
| 84 | ! |
---|
| 85 | IF( MOD( kt, nwrite ) == 1 .AND. lwp ) WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zumax |
---|
| 86 | ! |
---|
| 87 | IF( zumax > 20.e0 ) THEN |
---|
| 88 | IF( lk_mpp ) THEN |
---|
| 89 | CALL mpp_maxloc(ABS(un),umask,zumax,ii,ij,ik) |
---|
| 90 | ELSE |
---|
| 91 | ilocu = MAXLOC( ABS( un(:,:,:) ) ) |
---|
| 92 | ii = ilocu(1) + nimpp - 1 |
---|
| 93 | ij = ilocu(2) + njmpp - 1 |
---|
| 94 | ik = ilocu(3) |
---|
| 95 | ENDIF |
---|
| 96 | IF(lwp) THEN |
---|
| 97 | WRITE(numout,cform_err) |
---|
| 98 | WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s' |
---|
| 99 | WRITE(numout,*) ' ====== ' |
---|
| 100 | WRITE(numout,9400) kt, zumax, ii, ij, ik |
---|
| 101 | WRITE(numout,*) |
---|
| 102 | WRITE(numout,*) ' output of last fields in numwso' |
---|
| 103 | ENDIF |
---|
| 104 | kindic = -3 |
---|
| 105 | ENDIF |
---|
| 106 | 9400 FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5) |
---|
| 107 | |
---|
| 108 | ! !* Test minimum of salinity |
---|
| 109 | ! ! ------------------------ |
---|
| 110 | !! zsmin = MINVAL( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 ) slower than the following loop on NEC SX5 |
---|
| 111 | zsmin = 100.e0 |
---|
| 112 | DO jj = 2, jpjm1 |
---|
| 113 | DO ji = 1, jpi |
---|
| 114 | IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,tsn(ji,jj,1,jp_sal)) |
---|
| 115 | END DO |
---|
| 116 | END DO |
---|
| 117 | IF( lk_mpp ) CALL mpp_min( zsmin ) ! min over the global domain |
---|
| 118 | ! |
---|
| 119 | IF( MOD( kt, nwrite ) == 1 .AND. lwp ) WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin |
---|
| 120 | ! |
---|
| 121 | !! |
---|
| 122 | ! Ajout OM. |
---|
| 123 | IF( zsmin < 0.1) THEN |
---|
| 124 | IF (lk_mpp) THEN |
---|
| 125 | CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij ) |
---|
| 126 | ELSE |
---|
| 127 | ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 ) |
---|
| 128 | ii = ilocs(1) + nimpp - 1 |
---|
| 129 | ij = ilocs(2) + njmpp - 1 |
---|
| 130 | ENDIF |
---|
| 131 | ! |
---|
| 132 | IF(lwp) THEN |
---|
| 133 | WRITE(numout,cform_err) |
---|
| 134 | WRITE(numout,*) 'stp_ctl : sea surface salinity below 0.1' |
---|
| 135 | WRITE(numout,*) '======= ' |
---|
| 136 | WRITE(numout,9500) kt, zsmin, ii, ij |
---|
| 137 | WRITE(numout,*) |
---|
| 138 | ENDIF |
---|
| 139 | !!kindic = -3 |
---|
| 140 | !! |
---|
| 141 | ! Correct minimum salinity |
---|
| 142 | tsn(:,:,1,jp_sal) = MAX ( tsn(:,:,1,jp_sal), 0.1 ) |
---|
| 143 | ENDIF |
---|
| 144 | !! Fin ajout O.M. |
---|
| 145 | |
---|
| 146 | !! |
---|
| 147 | IF( zsmin < 0.) THEN |
---|
| 148 | IF (lk_mpp) THEN |
---|
| 149 | CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij ) |
---|
| 150 | ELSE |
---|
| 151 | ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 ) |
---|
| 152 | ii = ilocs(1) + nimpp - 1 |
---|
| 153 | ij = ilocs(2) + njmpp - 1 |
---|
| 154 | ENDIF |
---|
| 155 | ! |
---|
| 156 | IF(lwp) THEN |
---|
| 157 | WRITE(numout,cform_err) |
---|
| 158 | WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity' |
---|
| 159 | WRITE(numout,*) '======= ' |
---|
| 160 | WRITE(numout,9500) kt, zsmin, ii, ij |
---|
| 161 | WRITE(numout,*) |
---|
| 162 | WRITE(numout,*) ' output of last fields in numwso' |
---|
| 163 | ENDIF |
---|
| 164 | kindic = -3 |
---|
| 165 | ENDIF |
---|
| 166 | 9500 FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5) |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | IF( lk_c1d ) RETURN ! No log file in case of 1D vertical configuration |
---|
| 170 | |
---|
| 171 | ! log file (solver or ssh statistics) |
---|
| 172 | ! -------- |
---|
| 173 | IF( lk_dynspg_flt ) THEN ! elliptic solver statistics (if required) |
---|
| 174 | ! |
---|
| 175 | IF(lwp) WRITE(numsol,9200) kt, niter, res, SQRT(epsr)/eps ! Solver |
---|
| 176 | ! |
---|
| 177 | IF( kindic < 0 .AND. zsmin > 0.e0 .AND. zumax <= 20.e0 ) THEN ! create a abort file if problem found |
---|
| 178 | IF(lwp) THEN |
---|
| 179 | WRITE(numout,*) ' stpctl: the elliptic solver DO not converge or explode' |
---|
| 180 | WRITE(numout,*) ' ====== ' |
---|
| 181 | WRITE(numout,9200) kt, niter, res, sqrt(epsr)/eps |
---|
| 182 | WRITE(numout,*) |
---|
| 183 | WRITE(numout,*) ' stpctl: output of last fields' |
---|
| 184 | WRITE(numout,*) ' ====== ' |
---|
| 185 | ENDIF |
---|
| 186 | ENDIF |
---|
| 187 | ! |
---|
| 188 | ELSE !* ssh statistics (and others...) |
---|
| 189 | IF( kt == nit000 .AND. lwp ) THEN ! open ssh statistics file (put in solver.stat file) |
---|
| 190 | CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
| 191 | ENDIF |
---|
| 192 | ! |
---|
| 193 | zssh2 = SUM( sshn(:,:) * sshn(:,:) * tmask_i(:,:) ) |
---|
| 194 | IF( lk_mpp ) CALL mpp_sum( zssh2 ) ! sum over the global domain |
---|
| 195 | ! |
---|
| 196 | IF(lwp) WRITE(numsol,9300) kt, zssh2, zumax, zsmin ! ssh statistics |
---|
| 197 | ! |
---|
| 198 | ENDIF |
---|
| 199 | |
---|
| 200 | 9200 FORMAT('it:', i8, ' iter:', i4, ' r: ',e16.10, ' b: ',e16.10 ) |
---|
| 201 | 9300 FORMAT(' it :', i8, ' ssh2: ', e16.10, ' Umax: ',e16.10,' Smin: ',e16.10) |
---|
| 202 | ! |
---|
| 203 | END SUBROUTINE stp_ctl |
---|
| 204 | |
---|
| 205 | !!====================================================================== |
---|
| 206 | END MODULE stpctl |
---|