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/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC – NEMO

source: branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/stpctl.F90 @ 7897

Last change on this file since 7897 was 7897, checked in by gm, 7 years ago

#1880: (HPC-08) 3D lbc_lnk with any 3rd dim + regroup global comm in stpctl.F90

  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1MODULE 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   !!            3.7  ! 2016-09  (G. Madec)  Remove solver
12   !!            4.0  ! 2017-04  (G. Madec)  regroup
13   !!----------------------------------------------------------------------
14
15   !!----------------------------------------------------------------------
16   !!   stp_ctl      : Control the run
17   !!----------------------------------------------------------------------
18   USE oce             ! ocean dynamics and tracers variables
19   USE dom_oce         ! ocean space and time domain variables
20   USE c1d             ! 1D vertical configuration
21   !
22   USE in_out_manager  ! I/O manager
23   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
24   USE lib_mpp         ! distributed memory computing
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC stp_ctl           ! routine called by step.F90
30   !!----------------------------------------------------------------------
31   !! NEMO/OPA 4.0 , NEMO Consortium (2017)
32   !! $Id$
33   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
34   !!----------------------------------------------------------------------
35CONTAINS
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      !!              - Stop the run IF problem encountered by setting indic=-3
46      !!                Problems checked: U max>10 m/s and SSS min < 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   ! error indicator
53      !!
54      INTEGER  ::   ji, jj, jk             ! dummy loop indices
55      INTEGER  ::   ii, ij, ik             ! local integers
56      INTEGER , DIMENSION(3) ::   ilocu    !
57      INTEGER , DIMENSION(2) ::   ilocs    !
58      REAL(wp), DIMENSION(3) ::   zmax     
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         !                                ! open run.stat file
68         CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
69      ENDIF
70      !
71      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt    !==  current time step  ==!   ("time.step" file)
72      IF(lwp) REWIND( numstp )
73      !
74      !                                            !==  test of extrema  ==!
75      zmax(1) = MAXVAL(  ABS( un(:,:,:) )  )                                  ! velocity max (zonal only)
76      zmax(2) = MAXVAL( -tsn(:,:,1,jp_sal) , mask = tmask(:,:,1) == 1._wp )   ! minus surface salinity max
77      zmax(3) = MAXVAL( sshn(:,:)*sshn(:,:), mask = tmask(:,:,1) == 1._wp )   ! ssh^2 max
78      !
79      IF( lk_mpp )   CALL mpp_max_multiple( zmax(:), 3 )          ! max over the global domain
80      !
81      IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
82         WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zmax(1), ' SSS min:', - zmax(2)
83      ENDIF
84      !
85      IF( zmax(1) > 10._wp ) THEN                     !* too large velocity ( > 10 m/s)
86         IF( lk_mpp ) THEN
87            CALL mpp_maxloc( ABS(un), umask, zmax(1), ii, ij, ik )
88         ELSE
89            ilocu = MAXLOC( ABS( un(:,:,:) ) )
90            ii = ilocu(1) + nimpp - 1
91            ij = ilocu(2) + njmpp - 1
92            ik = ilocu(3)
93         ENDIF
94         IF(lwp) THEN
95            WRITE(numout,cform_err)
96            WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s'
97            WRITE(numout,*) ' ====== '
98            WRITE(numout,9400) kt, zmax(1), ii, ij, ik
99            WRITE(numout,*)
100            WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
101         ENDIF
102         kindic = -3
103      ENDIF
1049400  FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5)
105      !
106      IF( -zmax(2) < 0._wp ) THEN                     !* negative salinity
107         IF( lk_mpp ) THEN
108            CALL mpp_minloc( tsn(:,:,1,jp_sal),tmask(:,:,1), - zmax(2), ii, ij )
109         ELSE
110            ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1._wp )
111            ii = ilocs(1) + nimpp - 1
112            ij = ilocs(2) + njmpp - 1
113         ENDIF
114         !
115         IF(lwp) THEN
116            WRITE(numout,cform_err)
117            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
118            WRITE(numout,*) '======= '
119            WRITE(numout,9500) kt, -zmax(2), ii, ij
120            WRITE(numout,*)
121            WRITE(numout,*) '          output of last fields in numwso'
122         ENDIF
123         kindic = -3
124      ENDIF
1259500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5)
126      !
127      !                                            !==  run statistics  ==!   ("run.stat" file)
128      IF(lwp) WRITE(numrun,9200) kt, zmax(3), zmax(1), - zmax(2)      !  formerly called "solver.stat" file
129      !
1309200  FORMAT(' it :', i8, ' ssh2: ', e16.10, ' Umax: ',e16.10,' Smin: ',e16.10)
131      !
132   END SUBROUTINE stp_ctl
133
134   !!======================================================================
135END MODULE stpctl
Note: See TracBrowser for help on using the repository browser.