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 trunk/NEMO/OPA_SRC – NEMO

source: trunk/NEMO/OPA_SRC/stpctl.F90 @ 367

Last change on this file since 367 was 367, checked in by opalod, 18 years ago

nemo_v1_update_035 : CT : OBCs adapted to the new surface pressure gradient algorithms

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1MODULE stpctl
2   !!==============================================================================
3   !!                       ***  MODULE  stpctl  ***
4   !! Ocean run control :  gross check of the ocean time stepping
5   !!==============================================================================
6
7   !!----------------------------------------------------------------------
8   !!   stp_ctl      : Control the run
9   !!----------------------------------------------------------------------
10   !! * Modules used
11   USE oce             ! ocean dynamics and tracers variables
12   USE dom_oce         ! ocean space and time domain variables
13   USE sol_oce         ! ocean space and time domain variables
14   USE in_out_manager  ! I/O manager
15   USE solisl          ! ???
16   USE diawri          ! ocean output file
17   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
18   USE lib_mpp         ! distributed memory computing
19   USE dynspg_oce      ! pressure gradient schemes
20
21   IMPLICIT NONE
22   PRIVATE
23
24   !! * Accessibility
25   PUBLIC stp_ctl           ! routine called by step.F90
26   !!----------------------------------------------------------------------
27
28CONTAINS
29
30   SUBROUTINE stp_ctl( kt, kindic )
31      !!----------------------------------------------------------------------
32      !!                    ***  ROUTINE stp_ctl  ***
33      !!                     
34      !! ** Purpose :   Control the run
35      !!
36      !! ** Method  : - Save the time step in numstp
37      !!              - Print it each 50 time steps
38      !!              - Print solver statistics in numsol
39      !!              - Stop the run IF problem for the solver ( indec < 0 )
40      !!
41      !! History :
42      !!        !  91-03  ()
43      !!        !  91-11  (G. Madec)
44      !!        !  92-06  (M. Imbard)
45      !!        !  97-06  (A.M. Treguier)
46      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
47      !!----------------------------------------------------------------------
48      !! * Arguments
49      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
50      INTEGER, INTENT( inout ) ::   kindic  ! indicator of solver convergence
51
52      !! * local declarations
53      INTEGER  ::   ji, jj, jk              ! dummy loop indices
54      INTEGER  ::   ii, ij, ik              ! temporary integers
55      REAL(wp) ::   zumax, zsmin            ! temporary scalars
56      INTEGER, DIMENSION(3) ::   ilocu      !
57      INTEGER, DIMENSION(2) ::   ilocs      !
58      !!----------------------------------------------------------------------
59      !!  OPA 9.0 , LOCEAN-IPSL (2005)
60      !! $Header$
61      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
62      !!----------------------------------------------------------------------
63
64      IF( kt == nit000 .AND. lwp ) THEN
65         WRITE(numout,*)
66         WRITE(numout,*) 'stp_ctl : time-stepping control'
67         WRITE(numout,*) '~~~~~~~'
68         ! open time.step file
69         CALL ctlopn( numstp, 'time.step', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp, 1 )
70      ENDIF
71
72      ! save the current time step in numstp
73      ! ------------------------------------
74      IF(lwp) WRITE(numstp,9100) kt
75      IF(lwp) REWIND(numstp)
769100  FORMAT(1x, i8)
77
78
79      ! elliptic solver statistics (if required)
80      ! --------------------------
81      IF( lk_dynspg_flt .OR. lk_dynspg_rl ) THEN
82         ! Solver
83         IF(lwp) WRITE(numsol,9200) kt, niter, res, SQRT(epsr)/eps
84
85         ! Islands (if exist)
86         IF( lk_isl )   CALL isl_stp_ctl( kt, kindic )
87
88
89         ! Output in numwso and numwvo IF kindic<0
90         ! ---------------------------------------
91         !    (i.e. problem for the solver)
92         IF( kindic < 0 ) THEN
93            IF(lwp) THEN
94               WRITE(numout,*) ' stpctl: the elliptic solver DO not converge or explode'
95               WRITE(numout,*) ' ====== '
96               WRITE(numout,9200) kt, niter, res, sqrt(epsr)/eps
97               WRITE(numout,*)
98               WRITE(numout,*) ' stpctl: output of last fields in numwso'
99               WRITE(numout,*) '                                  numwvo'
100               WRITE(numout,*) ' ======  *******************************'
101            ENDIF
102            CALL dia_wri( kt, kindic )
103         ENDIF
104      ENDIF
105
1069200  FORMAT(' it :', i8, ' niter :', i4, ' res :',e20.10,' b :',e20.10)
107
108      ! Test maximum of velocity (zonal only)
109      ! ------------------------
110      !! zumax = MAXVAL( ABS( un(:,:,:) ) )   ! slower than the following loop on NEC SX5
111      zumax = 0.e0
112      DO jk = 1, jpk
113         DO jj = 1, jpj
114            DO ji = 1, jpi
115               zumax = MAX(zumax,ABS(un(ji,jj,jk)))
116          END DO
117        END DO
118      END DO       
119      IF( lk_mpp )   CALL mpp_max( zumax )   ! max over the global domain
120
121      IF( MOD( kt, nwrite ) == 1 ) THEN
122         IF(lwp) WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zumax
123      ENDIF
124      IF( zumax >  20.) THEN
125         IF (lk_mpp ) THEN
126            CALL mpp_maxloc(un,umask,zumax,ii,ij,ik)
127         ELSE
128           ilocu = MAXLOC( ABS( un(:,:,:) ) )
129           ii = ilocu(1) + nimpp - 1
130           ij = ilocu(2) + njmpp - 1
131           ik = ilocu(3)
132         ENDIF
133         IF(lwp) THEN
134            WRITE(numout,cform_err)
135            WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s'
136            WRITE(numout,*) ' ====== '
137            WRITE(numout,9400) kt, zumax, ii, ij, ik
138            WRITE(numout,*)
139            WRITE(numout,*) '          output of last fields in numwso'
140         ENDIF
141         kindic  = -3
142         CALL dia_wri( kt, kindic )
143      ENDIF
1449400  FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i4)
145
146
147      ! Test minimum of salinity
148      ! ------------------------
149      !! zsmin = MINVAL( sn(:,:,1), mask = tmask(:,:,1) == 1.e0 )   
150      !                slower than the following loop on NEC SX5
151      zsmin = 100.e0
152      DO jj = 2, jpjm1
153         DO ji = 1, jpi
154            IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,sn(ji,jj,1))
155         END DO
156      END DO
157      IF( lk_mpp )   CALL mpp_min( zsmin )   ! min over the global domain
158
159      IF( MOD( kt, nwrite ) == 1 ) THEN
160         IF(lwp) WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin
161      ENDIF
162      IF( zsmin < 0.) THEN
163         IF (lk_mpp) THEN
164            CALL mpp_minloc ( sn(:,:,1),tmask(:,:,1), zsmin, ii,ij )
165         ELSE
166            ilocs = MINLOC( sn(:,:,1), mask = tmask(:,:,1) == 1.e0 )
167            ii = ilocs(1) + nimpp - 1
168            ij = ilocs(2) + njmpp - 1
169         END IF
170
171         IF(lwp) THEN
172            WRITE(numout,cform_err)
173            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
174            WRITE(numout,*) '======= '
175            WRITE(numout,9500) kt, zsmin, ii, ij
176            WRITE(numout,*)
177            WRITE(numout,*) '          output of last fields in numwso'
178         ENDIF
179         IF( kindic < 0 ) THEN
180            IF(lwp) WRITE(numout,*) ' stpctl diabort done. We wont do it again '
181         ELSE
182            kindic  = -3
183            CALL dia_wri(kt,kindic)
184         ENDIF
185      ENDIF
1869500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i4)
187
188   END SUBROUTINE stp_ctl
189
190   !!======================================================================
191END MODULE stpctl
Note: See TracBrowser for help on using the repository browser.