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 | !! 3.7 ! 2016-09 (G. Madec) Remove solver |
---|
12 | !! 4.0 ! 2017-04 (G. Madec) regroup global communications |
---|
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 | !!---------------------------------------------------------------------- |
---|
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 | !! - Stop the run IF problem encountered by setting indic=-3 |
---|
46 | !! Problems checked: |ssh| maximum larger than 10 m |
---|
47 | !! |U| maximum larger than 10 m/s |
---|
48 | !! negative sea surface salinity |
---|
49 | !! |
---|
50 | !! ** Actions : "time.step" file = last ocean time-step |
---|
51 | !! "run.stat" file = run statistics |
---|
52 | !!---------------------------------------------------------------------- |
---|
53 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
54 | INTEGER, INTENT(inout) :: kindic ! error indicator |
---|
55 | !! |
---|
56 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
57 | INTEGER :: iih, ijh ! local integers |
---|
58 | INTEGER :: iiu, iju, iku ! - - |
---|
59 | INTEGER :: iis, ijs ! - - |
---|
60 | REAL(wp) :: zzz ! local real |
---|
61 | INTEGER , DIMENSION(3) :: ilocu |
---|
62 | INTEGER , DIMENSION(2) :: ilocs, iloch |
---|
63 | REAL(wp), DIMENSION(3) :: zmax |
---|
64 | !!---------------------------------------------------------------------- |
---|
65 | ! |
---|
66 | IF( kt == nit000 .AND. lwp ) THEN |
---|
67 | WRITE(numout,*) |
---|
68 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
69 | WRITE(numout,*) '~~~~~~~' |
---|
70 | ! ! open time.step file |
---|
71 | CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
72 | ! ! open run.stat file |
---|
73 | CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
74 | ENDIF |
---|
75 | ! |
---|
76 | IF(lwp) THEN !== current time step ==! ("time.step" file) |
---|
77 | WRITE ( numstp, '(1x, i8)' ) kt |
---|
78 | REWIND( numstp ) |
---|
79 | ENDIF |
---|
80 | ! |
---|
81 | ! !== test of extrema ==! |
---|
82 | zmax(1) = MAXVAL( ABS( sshn(:,:) ) ) ! ssh max |
---|
83 | zmax(2) = MAXVAL( ABS( un(:,:,:) ) ) ! velocity max (zonal only) |
---|
84 | zmax(3) = MAXVAL( -tsn(:,:,1,jp_sal) , mask = tmask(:,:,1) == 1._wp ) ! minus surface salinity max |
---|
85 | ! |
---|
86 | IF( lk_mpp ) CALL mpp_max_multiple( zmax(:), 3 ) ! max over the global domain |
---|
87 | ! |
---|
88 | IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN |
---|
89 | WRITE(numout,*) ' ==>> time-step= ', kt, ' |ssh| max: ', zmax(1), ' |U| max: ', zmax(2), & |
---|
90 | & ' SSS min: ' , - zmax(3) |
---|
91 | ENDIF |
---|
92 | ! |
---|
93 | IF ( zmax(1) > 10._wp .OR. & ! too large sea surface height ( > 10 m) |
---|
94 | & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) |
---|
95 | & zmax(3) > 0._wp ) THEN ! negative sea surface salinity |
---|
96 | IF( lk_mpp ) THEN |
---|
97 | CALL mpp_maxloc( ABS(sshn) , tmask(:,:,1), zzz, iih, ijh ) |
---|
98 | CALL mpp_maxloc( ABS(un) , umask , zzz, iiu, iju, iku ) |
---|
99 | CALL mpp_minloc( tsn(:,:,1,jp_sal), tmask(:,:,1), zzz, iis, ijs ) |
---|
100 | ELSE |
---|
101 | iloch = MINLOC( ABS( sshn(:,:) ) ) |
---|
102 | ilocu = MAXLOC( ABS( un(:,:,:) ) ) |
---|
103 | ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1._wp ) |
---|
104 | iih = iloch(1) + nimpp - 1 ; ijh = iloch(2) + njmpp - 1 |
---|
105 | iiu = ilocu(1) + nimpp - 1 ; iju = ilocu(2) + njmpp - 1 ; iku = ilocu(3) |
---|
106 | iis = ilocs(1) + nimpp - 1 ; ijs = ilocs(2) + njmpp - 1 |
---|
107 | ENDIF |
---|
108 | IF(lwp) THEN |
---|
109 | WRITE(numout,cform_err) |
---|
110 | WRITE(numout,*) ' stpctl: |ssh| > 10 m or |U| > 10 m/s or SSS < 0' |
---|
111 | WRITE(numout,*) ' ====== ' |
---|
112 | WRITE(numout,9100) kt, zmax(1), iih, ijh |
---|
113 | WRITE(numout,9200) kt, zmax(2), iiu, iju, iku |
---|
114 | WRITE(numout,9300) kt, - zmax(3), iis, ijs |
---|
115 | WRITE(numout,*) |
---|
116 | WRITE(numout,*) ' output of last computed fields in output.abort.nc file' |
---|
117 | ENDIF |
---|
118 | kindic = -3 |
---|
119 | ENDIF |
---|
120 | 9100 FORMAT (' kt=',i8,' |ssh| max: ',1pg11.4,', at i j : ',2i5) |
---|
121 | 9200 FORMAT (' kt=',i8,' |U| max: ',1pg11.4,', at i j k: ',3i5) |
---|
122 | 9300 FORMAT (' kt=',i8,' SSS min: ',1pg11.4,', at i j : ',2i5) |
---|
123 | ! |
---|
124 | ! !== run statistics ==! ("run.stat" file) |
---|
125 | IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3) |
---|
126 | ! |
---|
127 | 9400 FORMAT(' it :', i8, ' |ssh|_max: ', e16.10, ' |U|_max: ',e16.10,' SSS_min: ',e16.10) |
---|
128 | ! |
---|
129 | END SUBROUTINE stp_ctl |
---|
130 | |
---|
131 | !!====================================================================== |
---|
132 | END MODULE stpctl |
---|