[3] | 1 | MODULE 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 |
---|
[9019] | 11 | !! 3.7 ! 2016-09 (G. Madec) Remove solver |
---|
| 12 | !! 4.0 ! 2017-04 (G. Madec) regroup global communications |
---|
[1489] | 13 | !!---------------------------------------------------------------------- |
---|
[3] | 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 |
---|
[6140] | 20 | USE c1d ! 1D vertical configuration |
---|
[9210] | 21 | USE diawri ! Standard run outputs (dia_wri_state routine) |
---|
[6140] | 22 | ! |
---|
[3] | 23 | USE in_out_manager ! I/O manager |
---|
| 24 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 25 | USE lib_mpp ! distributed memory computing |
---|
[10364] | 26 | USE zdf_oce , ONLY : ln_zad_Aimp ! ocean vertical physics variables |
---|
[9210] | 27 | USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy |
---|
[3] | 28 | |
---|
[9441] | 29 | USE netcdf ! NetCDF library |
---|
[3] | 30 | IMPLICIT NONE |
---|
| 31 | PRIVATE |
---|
| 32 | |
---|
| 33 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
[9441] | 34 | |
---|
[10364] | 35 | INTEGER :: idrun, idtime, idssh, idu, ids1, ids2, idt1, idt2, idc1, idw1, istatus |
---|
[10425] | 36 | LOGICAL :: lsomeoce |
---|
[13151] | 37 | !!stoops |
---|
| 38 | # include "domzgr_substitute.h90" |
---|
[3] | 39 | !!---------------------------------------------------------------------- |
---|
[9598] | 40 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
[1489] | 41 | !! $Id$ |
---|
[10068] | 42 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[1489] | 43 | !!---------------------------------------------------------------------- |
---|
[3] | 44 | CONTAINS |
---|
| 45 | |
---|
[12377] | 46 | SUBROUTINE stp_ctl( kt, Kbb, Kmm, kindic ) |
---|
[3] | 47 | !!---------------------------------------------------------------------- |
---|
| 48 | !! *** ROUTINE stp_ctl *** |
---|
| 49 | !! |
---|
| 50 | !! ** Purpose : Control the run |
---|
| 51 | !! |
---|
| 52 | !! ** Method : - Save the time step in numstp |
---|
| 53 | !! - Print it each 50 time steps |
---|
[9019] | 54 | !! - Stop the run IF problem encountered by setting indic=-3 |
---|
[10425] | 55 | !! Problems checked: |ssh| maximum larger than 10 m |
---|
[9019] | 56 | !! |U| maximum larger than 10 m/s |
---|
| 57 | !! negative sea surface salinity |
---|
[3] | 58 | !! |
---|
[9019] | 59 | !! ** Actions : "time.step" file = last ocean time-step |
---|
| 60 | !! "run.stat" file = run statistics |
---|
[9210] | 61 | !! nstop indicator sheared among all local domain (lk_mpp=T) |
---|
[3] | 62 | !!---------------------------------------------------------------------- |
---|
[6140] | 63 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
[12377] | 64 | INTEGER, INTENT(in ) :: Kbb, Kmm ! ocean time level index |
---|
[6140] | 65 | INTEGER, INTENT(inout) :: kindic ! error indicator |
---|
[1489] | 66 | !! |
---|
[10425] | 67 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 68 | INTEGER, DIMENSION(2) :: ih ! min/max loc indices |
---|
| 69 | INTEGER, DIMENSION(3) :: iu, is1, is2 ! min/max loc indices |
---|
| 70 | REAL(wp) :: zzz ! local real |
---|
[12614] | 71 | REAL(wp), DIMENSION(3) :: zmax |
---|
[10570] | 72 | LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns |
---|
[9565] | 73 | CHARACTER(len=20) :: clname |
---|
[3] | 74 | !!---------------------------------------------------------------------- |
---|
[6140] | 75 | ! |
---|
[10570] | 76 | ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) |
---|
[12377] | 77 | ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) |
---|
[10570] | 78 | ll_wrtruns = ll_colruns .AND. lwm |
---|
[3] | 79 | IF( kt == nit000 .AND. lwp ) THEN |
---|
| 80 | WRITE(numout,*) |
---|
| 81 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
[79] | 82 | WRITE(numout,*) '~~~~~~~' |
---|
[9019] | 83 | ! ! open time.step file |
---|
[10425] | 84 | IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
[10570] | 85 | ! ! open run.stat file(s) at start whatever |
---|
| 86 | ! ! the value of sn_cfctl%ptimincr |
---|
[12377] | 87 | IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN |
---|
[10425] | 88 | CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
[9565] | 89 | clname = 'run.stat.nc' |
---|
| 90 | IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) |
---|
| 91 | istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun ) |
---|
[9441] | 92 | istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime ) |
---|
| 93 | istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh ) |
---|
[9808] | 94 | istatus = NF90_DEF_VAR( idrun, 'abs_u_max', NF90_DOUBLE, (/ idtime /), idu ) |
---|
[9441] | 95 | istatus = NF90_ENDDEF(idrun) |
---|
| 96 | ENDIF |
---|
[3] | 97 | ENDIF |
---|
[10425] | 98 | IF( kt == nit000 ) lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 |
---|
[6140] | 99 | ! |
---|
[10570] | 100 | IF(lwm .AND. ll_wrtstp) THEN !== current time step ==! ("time.step" file) |
---|
[9019] | 101 | WRITE ( numstp, '(1x, i8)' ) kt |
---|
| 102 | REWIND( numstp ) |
---|
[3] | 103 | ENDIF |
---|
[6140] | 104 | ! |
---|
[9019] | 105 | ! !== test of extrema ==! |
---|
[9023] | 106 | IF( ll_wd ) THEN |
---|
[12377] | 107 | zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref*tmask(:,:,1) ) ) ! ssh max |
---|
[9023] | 108 | ELSE |
---|
[12614] | 109 | zmax(1) = MINVAL( e3t(:,:,1,Kmm) ) ! ssh min |
---|
[9023] | 110 | ENDIF |
---|
[12377] | 111 | zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ) ) ! velocity max (zonal only) |
---|
[12614] | 112 | zmax(3) = REAL( nstop , wp ) ! stop indicator |
---|
[1489] | 113 | ! |
---|
[10570] | 114 | IF( ll_colruns ) THEN |
---|
[10425] | 115 | CALL mpp_max( "stpctl", zmax ) ! max over the global domain |
---|
[12614] | 116 | nstop = NINT( zmax(3) ) ! nstop indicator sheared among all local domains |
---|
[9210] | 117 | ENDIF |
---|
[10425] | 118 | ! !== run statistics ==! ("run.stat" files) |
---|
[10570] | 119 | IF( ll_wrtruns ) THEN |
---|
[12614] | 120 | WRITE(numrun,9500) kt, zmax(1), zmax(2) |
---|
[10425] | 121 | istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) ) |
---|
| 122 | istatus = NF90_PUT_VAR( idrun, idu, (/ zmax(2)/), (/kt/), (/1/) ) |
---|
| 123 | IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) |
---|
| 124 | IF( kt == nitend ) istatus = NF90_CLOSE(idrun) |
---|
| 125 | END IF |
---|
| 126 | ! !== error handling ==! |
---|
[12377] | 127 | IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. ( & ! domain contains some ocean points, check for sensible ranges |
---|
[12614] | 128 | & zmax(1) < 0._wp .OR. & ! negative sea surface height |
---|
[9808] | 129 | & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) |
---|
[12614] | 130 | & ISNAN( zmax(1) + zmax(2) ) ) ) THEN ! NaN encounter in the tests |
---|
[12377] | 131 | IF( lk_mpp .AND. sn_cfctl%l_glochk ) THEN |
---|
| 132 | ! have use mpp_max (because sn_cfctl%l_glochk=.T. and distributed) |
---|
| 133 | CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,Kmm)) , ssmask(:,:) , zzz, ih ) |
---|
| 134 | CALL mpp_maxloc( 'stpctl', ABS(uu(:,:,:,Kmm)) , umask (:,:,:), zzz, iu ) |
---|
[7852] | 135 | ELSE |
---|
[12377] | 136 | ! find local min and max locations |
---|
| 137 | ih(:) = MAXLOC( ABS( ssh(:,:,Kmm) ) ) + (/ nimpp - 1, njmpp - 1 /) |
---|
| 138 | iu(:) = MAXLOC( ABS( uu (:,:,:,Kmm) ) ) + (/ nimpp - 1, njmpp - 1, 0 /) |
---|
[7852] | 139 | ENDIF |
---|
[10425] | 140 | |
---|
[12614] | 141 | WRITE(ctmp1,*) ' stp_ctl: (e3t0) ssh < 0 m or |U| > 10 m/s or NaN encounter in the tests' |
---|
[10425] | 142 | WRITE(ctmp2,9100) kt, zmax(1), ih(1) , ih(2) |
---|
| 143 | WRITE(ctmp3,9200) kt, zmax(2), iu(1) , iu(2) , iu(3) |
---|
[12614] | 144 | WRITE(ctmp4,*) ' ===> output of last computed fields in output.abort.nc file' |
---|
[10425] | 145 | |
---|
[12377] | 146 | CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file |
---|
[10425] | 147 | |
---|
[12377] | 148 | IF( .NOT. sn_cfctl%l_glochk ) THEN |
---|
[10425] | 149 | WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea |
---|
[12614] | 150 | CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp8, ' ', ctmp2, ctmp3, ctmp4 ) |
---|
[10425] | 151 | ELSE |
---|
[12614] | 152 | CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4 ) |
---|
[7852] | 153 | ENDIF |
---|
[10425] | 154 | |
---|
[7852] | 155 | kindic = -3 |
---|
[9210] | 156 | ! |
---|
[7852] | 157 | ENDIF |
---|
[10425] | 158 | ! |
---|
[12614] | 159 | 9100 FORMAT (' kt=',i8,' |ssh| min: ',1pg11.4,', at i j : ',2i5) |
---|
[9019] | 160 | 9200 FORMAT (' kt=',i8,' |U| max: ',1pg11.4,', at i j k: ',3i5) |
---|
[12614] | 161 | 9500 FORMAT(' it :', i8, ' |ssh|_max: ', D23.16, ' |U|_max: ', D23.16) |
---|
[7852] | 162 | ! |
---|
[3] | 163 | END SUBROUTINE stp_ctl |
---|
| 164 | |
---|
| 165 | !!====================================================================== |
---|
| 166 | END MODULE stpctl |
---|