New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
stpctl.F90 in branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC – NEMO

source: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/stpctl.F90 @ 8485

Last change on this file since 8485 was 6487, checked in by davestorkey, 8 years ago

Changes from nemo_v3_6_STABLE_copy branch.
Custom merge into /branches/UKMO/dev_r5518_GO6_package/NEMOGCM: r6237 cf. r5781 of /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM@6486

File size: 8.0 KB
RevLine 
[3]1MODULE stpctl
[1489]2   !!======================================================================
[3]3   !!                       ***  MODULE  stpctl  ***
4   !! Ocean run control :  gross check of the ocean time stepping
[1489]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   !!----------------------------------------------------------------------
[3]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
[6487]19   USE sbc_oce         ! surface boundary conditions variables
[3]20   USE in_out_manager  ! I/O manager
21   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
22   USE lib_mpp         ! distributed memory computing
[367]23   USE dynspg_oce      ! pressure gradient schemes
[2528]24   USE c1d             ! 1D vertical configuration
[3]25
[6487]26
[3]27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC stp_ctl           ! routine called by step.F90
31   !!----------------------------------------------------------------------
[2528]32   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
[1489]33   !! $Id$
[2528]34   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
[1489]35   !!----------------------------------------------------------------------
[3]36
37CONTAINS
38
39   SUBROUTINE stp_ctl( kt, kindic )
40      !!----------------------------------------------------------------------
41      !!                    ***  ROUTINE stp_ctl  ***
42      !!                     
43      !! ** Purpose :   Control the run
44      !!
45      !! ** Method  : - Save the time step in numstp
46      !!              - Print it each 50 time steps
47      !!              - Print solver statistics in numsol
48      !!              - Stop the run IF problem for the solver ( indec < 0 )
49      !!
[1489]50      !! ** Actions :   'time.step' file containing the last ocean time-step
51      !!               
[3]52      !!----------------------------------------------------------------------
53      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
54      INTEGER, INTENT( inout ) ::   kindic  ! indicator of solver convergence
[1489]55      !!
[6487]56      CHARACTER(len = 32) ::        clfname ! time stepping output file name
[3]57      INTEGER  ::   ji, jj, jk              ! dummy loop indices
58      INTEGER  ::   ii, ij, ik              ! temporary integers
[1489]59      REAL(wp) ::   zumax, zsmin, zssh2     ! temporary scalars
[3]60      INTEGER, DIMENSION(3) ::   ilocu      !
61      INTEGER, DIMENSION(2) ::   ilocs      !
62      !!----------------------------------------------------------------------
63
64      IF( kt == nit000 .AND. lwp ) THEN
65         WRITE(numout,*)
66         WRITE(numout,*) 'stp_ctl : time-stepping control'
[79]67         WRITE(numout,*) '~~~~~~~'
[6487]68         ! open time.step file with special treatment for SAS
69         IF ( nn_components == jp_iam_sas ) THEN
70            clfname = 'time.step.sas'
71         ELSE
72            clfname = 'time.step'
73         ENDIF
74         CALL ctl_opn( numstp, TRIM(clfname), 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
[3]75      ENDIF
76
[1489]77      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
78      IF(lwp) REWIND( numstp )                       !  --------------------------
[3]79
[1489]80      !                                              !* Test maximum of velocity (zonal only)
81      !                                              !  ------------------------
82      !! zumax = MAXVAL( ABS( un(:,:,:) ) )                ! slower than the following loop on NEC SX5
[79]83      zumax = 0.e0
[3]84      DO jk = 1, jpk
85         DO jj = 1, jpj
86            DO ji = 1, jpi
87               zumax = MAX(zumax,ABS(un(ji,jj,jk)))
88          END DO
89        END DO
90      END DO       
[1489]91      IF( lk_mpp )   CALL mpp_max( zumax )                 ! max over the global domain
92      !
93      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zumax
94      !
[1561]95      IF( zumax > 20.e0 ) THEN
[417]96         IF( lk_mpp ) THEN
97            CALL mpp_maxloc(ABS(un),umask,zumax,ii,ij,ik)
[181]98         ELSE
[417]99            ilocu = MAXLOC( ABS( un(:,:,:) ) )
100            ii = ilocu(1) + nimpp - 1
101            ij = ilocu(2) + njmpp - 1
102            ik = ilocu(3)
[15]103         ENDIF
[3]104         IF(lwp) THEN
105            WRITE(numout,cform_err)
106            WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s'
107            WRITE(numout,*) ' ====== '
108            WRITE(numout,9400) kt, zumax, ii, ij, ik
109            WRITE(numout,*)
110            WRITE(numout,*) '          output of last fields in numwso'
111         ENDIF
[1561]112         kindic = -3
[3]113      ENDIF
[1442]1149400  FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5)
[3]115
[1489]116      !                                              !* Test minimum of salinity
117      !                                              !  ------------------------
[3294]118      !! zsmin = MINVAL( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )  slower than the following loop on NEC SX5
[79]119      zsmin = 100.e0
[3]120      DO jj = 2, jpjm1
121         DO ji = 1, jpi
[3294]122            IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,tsn(ji,jj,1,jp_sal))
[3]123         END DO
124      END DO
[1489]125      IF( lk_mpp )   CALL mpp_min( zsmin )                ! min over the global domain
126      !
127      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin
128      !
[3]129      IF( zsmin < 0.) THEN
[181]130         IF (lk_mpp) THEN
[3294]131            CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij )
[181]132         ELSE
[3294]133            ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )
[181]134            ii = ilocs(1) + nimpp - 1
135            ij = ilocs(2) + njmpp - 1
[1489]136         ENDIF
137         !
[3]138         IF(lwp) THEN
139            WRITE(numout,cform_err)
140            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
141            WRITE(numout,*) '======= '
142            WRITE(numout,9500) kt, zsmin, ii, ij
143            WRITE(numout,*)
144            WRITE(numout,*) '          output of last fields in numwso'
145         ENDIF
[1561]146         kindic = -3
[3]147      ENDIF
[1442]1489500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5)
[3]149
[2528]150     
151      IF( lk_c1d )  RETURN          ! No log file in case of 1D vertical configuration
152
[1489]153      ! log file (solver or ssh statistics)
154      ! --------
[1528]155      IF( lk_dynspg_flt ) THEN      ! elliptic solver statistics (if required)
[1489]156         !
[1566]157         IF(lwp) WRITE(numsol,9200) kt, niter, res, SQRT(epsr)/eps       ! Solver
[1489]158         !
[1566]159         IF( kindic < 0 .AND. zsmin > 0.e0 .AND. zumax <= 20.e0 ) THEN   ! create a abort file if problem found
[1489]160            IF(lwp) THEN
161               WRITE(numout,*) ' stpctl: the elliptic solver DO not converge or explode'
162               WRITE(numout,*) ' ====== '
163               WRITE(numout,9200) kt, niter, res, sqrt(epsr)/eps
164               WRITE(numout,*)
165               WRITE(numout,*) ' stpctl: output of last fields'
166               WRITE(numout,*) ' ======  '
167            ENDIF
168         ENDIF
169         !
[1581]170      ELSE                                   !* ssh statistics (and others...)
171         IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file)
172            CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
[1489]173         ENDIF
174         !
175         zssh2 = SUM( sshn(:,:) * sshn(:,:) * tmask_i(:,:) )
176         IF( lk_mpp )   CALL mpp_sum( zssh2 )      ! sum over the global domain
177         !
178         IF(lwp) WRITE(numsol,9300) kt, zssh2, zumax, zsmin      ! ssh statistics
179         !
180      ENDIF
181
[1588]1829200  FORMAT('it:', i8, ' iter:', i4, ' r: ',e16.10, ' b: ',e16.10 )
[1489]1839300  FORMAT(' it :', i8, ' ssh2: ', e16.10, ' Umax: ',e16.10,' Smin: ',e16.10)
184      !
[3]185   END SUBROUTINE stp_ctl
186
187   !!======================================================================
188END MODULE stpctl
Note: See TracBrowser for help on using the repository browser.