[11930] | 1 | MODULE stpctl |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE stpctl *** |
---|
| 4 | !! Ocean run control : gross check of the ocean time stepping |
---|
| 5 | !! version for STATION_ASF test-case |
---|
| 6 | !!====================================================================== |
---|
| 7 | !! History : OPA ! 1991-03 (G. Madec) Original code |
---|
| 8 | !! 6.0 ! 1992-06 (M. Imbard) |
---|
| 9 | !! 8.0 ! 1997-06 (A.M. Treguier) |
---|
| 10 | !! NEMO 1.0 ! 2002-06 (G. Madec) F90: Free form and module |
---|
| 11 | !! 2.0 ! 2009-07 (G. Madec) Add statistic for time-spliting |
---|
| 12 | !! 3.7 ! 2016-09 (G. Madec) Remove solver |
---|
| 13 | !! 4.0 ! 2017-04 (G. Madec) regroup global communications |
---|
| 14 | !!---------------------------------------------------------------------- |
---|
| 15 | |
---|
| 16 | !!---------------------------------------------------------------------- |
---|
| 17 | !! stp_ctl : Control the run |
---|
| 18 | !!---------------------------------------------------------------------- |
---|
| 19 | USE dom_oce ! ocean space and time domain variables |
---|
| 20 | USE sbc_oce ! surface fluxes and stuff |
---|
[12249] | 21 | USE diawri ! Standard run outputs (dia_wri_state routine) |
---|
[11930] | 22 | ! |
---|
| 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 |
---|
| 26 | |
---|
| 27 | USE netcdf ! NetCDF library |
---|
| 28 | IMPLICIT NONE |
---|
| 29 | PRIVATE |
---|
| 30 | |
---|
| 31 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
| 32 | |
---|
| 33 | INTEGER :: idrun, idtime, idtau, idqns, idemp, istatus |
---|
| 34 | LOGICAL :: lsomeoce |
---|
| 35 | !!---------------------------------------------------------------------- |
---|
| 36 | !! NEMO/SAS 4.0 , NEMO Consortium (2018) |
---|
| 37 | !! $Id: stpctl.F90 10603 2019-01-29 11:18:09Z acc $ |
---|
| 38 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
| 39 | !!---------------------------------------------------------------------- |
---|
| 40 | CONTAINS |
---|
| 41 | |
---|
[12249] | 42 | SUBROUTINE stp_ctl( kt, Kbb, Kmm, kindic ) |
---|
[11930] | 43 | !!---------------------------------------------------------------------- |
---|
| 44 | !! *** ROUTINE stp_ctl *** |
---|
| 45 | !! |
---|
| 46 | !! ** Purpose : Control the run |
---|
| 47 | !! |
---|
| 48 | !! ** Method : - Save the time step in numstp |
---|
| 49 | !! - Print it each 50 time steps |
---|
| 50 | !! - Stop the run IF problem encountered by setting indic=-3 |
---|
| 51 | !! |
---|
| 52 | !! ** Actions : "time.step" file = last ocean time-step |
---|
| 53 | !! "run.stat" file = run statistics |
---|
[12249] | 54 | !! nstop indicator sheared among all local domain (lk_mpp=T) |
---|
[11930] | 55 | !!---------------------------------------------------------------------- |
---|
| 56 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
[12249] | 57 | INTEGER, INTENT(in ) :: Kbb, Kmm ! ocean time level index |
---|
[11930] | 58 | INTEGER, INTENT(inout) :: kindic ! error indicator |
---|
| 59 | !! |
---|
| 60 | REAL(wp), DIMENSION(3) :: zmax |
---|
| 61 | LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns |
---|
| 62 | CHARACTER(len=20) :: clname |
---|
| 63 | !!---------------------------------------------------------------------- |
---|
| 64 | ! |
---|
| 65 | ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) |
---|
[12249] | 66 | ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) |
---|
| 67 | ll_wrtruns = ll_colruns .AND. lwm |
---|
[11930] | 68 | IF( kt == nit000 .AND. lwp ) THEN |
---|
| 69 | WRITE(numout,*) |
---|
| 70 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
| 71 | WRITE(numout,*) '~~~~~~~' |
---|
| 72 | ! ! open time.step file |
---|
[12249] | 73 | IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
[11930] | 74 | ! ! open run.stat file(s) at start whatever |
---|
| 75 | ! ! the value of sn_cfctl%ptimincr |
---|
[12249] | 76 | IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN |
---|
[11930] | 77 | CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
| 78 | clname = 'run.stat.nc' |
---|
| 79 | IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) |
---|
| 80 | istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun ) |
---|
| 81 | istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime ) |
---|
| 82 | istatus = NF90_DEF_VAR( idrun, 'tau_max', NF90_DOUBLE, (/ idtime /), idtau ) |
---|
| 83 | istatus = NF90_DEF_VAR( idrun, 'qns_max', NF90_DOUBLE, (/ idtime /), idqns ) |
---|
| 84 | istatus = NF90_DEF_VAR( idrun, 'emp_max', NF90_DOUBLE, (/ idtime /), idemp ) |
---|
| 85 | istatus = NF90_ENDDEF(idrun) |
---|
| 86 | ENDIF |
---|
| 87 | ENDIF |
---|
| 88 | IF( kt == nit000 ) lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 |
---|
| 89 | ! |
---|
[12249] | 90 | IF(lwm .AND. ll_wrtstp) THEN !== current time step ==! ("time.step" file) |
---|
[11930] | 91 | WRITE ( numstp, '(1x, i8)' ) kt |
---|
| 92 | REWIND( numstp ) |
---|
| 93 | ENDIF |
---|
| 94 | ! |
---|
| 95 | ! !== test of extrema ==! |
---|
| 96 | zmax(1) = MAXVAL( taum(:,:) , mask = tmask(:,:,1) == 1._wp ) ! max wind stress module |
---|
| 97 | zmax(2) = MAXVAL( ABS( qns(:,:) ) , mask = tmask(:,:,1) == 1._wp ) ! max non-solar heat flux |
---|
| 98 | zmax(3) = MAXVAL( ABS( emp(:,:) ) , mask = tmask(:,:,1) == 1._wp ) ! max E-P |
---|
| 99 | ! |
---|
| 100 | IF( ll_colruns ) THEN |
---|
| 101 | CALL mpp_max( "stpctl", zmax ) ! max over the global domain |
---|
[12249] | 102 | nstop = NINT( zmax(3) ) ! nstop indicator sheared among all local domains |
---|
[11930] | 103 | ENDIF |
---|
| 104 | ! !== run statistics ==! ("run.stat" files) |
---|
| 105 | IF( ll_wrtruns ) THEN |
---|
| 106 | WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3) |
---|
| 107 | istatus = NF90_PUT_VAR( idrun, idtau, (/ zmax(1)/), (/kt/), (/1/) ) |
---|
| 108 | istatus = NF90_PUT_VAR( idrun, idqns, (/ zmax(2)/), (/kt/), (/1/) ) |
---|
| 109 | istatus = NF90_PUT_VAR( idrun, idemp, (/ zmax(3)/), (/kt/), (/1/) ) |
---|
| 110 | IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) |
---|
| 111 | IF( kt == nitend ) istatus = NF90_CLOSE(idrun) |
---|
| 112 | END IF |
---|
| 113 | ! !== error handling ==! |
---|
[12249] | 114 | IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. ( & ! domain contains some ocean points, check for sensible ranges |
---|
[11930] | 115 | & zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 ) |
---|
| 116 | & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2) |
---|
| 117 | & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( kg/m^2/s) |
---|
| 118 | & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN ! NaN encounter in the tests |
---|
| 119 | |
---|
[12254] | 120 | !! We are 1D so no need to find a spatial location of the rogue point. |
---|
[11930] | 121 | |
---|
| 122 | WRITE(ctmp1,*) ' stp_ctl: |tau_mod| > 5 N/m2 or |qns| > 2000 W/m2 or |emp| > 1.E-3 or NaN encounter in the tests' |
---|
| 123 | WRITE(ctmp2,9500) kt, zmax(1), zmax(2), zmax(3) |
---|
| 124 | WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort.nc file' |
---|
| 125 | |
---|
[12249] | 126 | CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file |
---|
[11930] | 127 | |
---|
[12249] | 128 | IF( .NOT. sn_cfctl%l_glochk ) THEN |
---|
[11930] | 129 | WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea |
---|
| 130 | CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) |
---|
| 131 | ELSE |
---|
| 132 | CALL ctl_stop( ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) |
---|
| 133 | ENDIF |
---|
| 134 | |
---|
| 135 | kindic = -3 |
---|
| 136 | ! |
---|
| 137 | ENDIF |
---|
| 138 | ! |
---|
| 139 | 9500 FORMAT(' it :', i8, ' tau_max: ', D23.16, ' |qns|_max: ', D23.16,' |emp|_max: ', D23.16) |
---|
| 140 | ! |
---|
| 141 | END SUBROUTINE stp_ctl |
---|
| 142 | |
---|
| 143 | !!====================================================================== |
---|
| 144 | END MODULE stpctl |
---|