[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 | !! 4.x ! 2019-10 (L. Brodeau) adapted for STATION_ASF test-case |
---|
| 15 | !!---------------------------------------------------------------------- |
---|
| 16 | |
---|
| 17 | !!---------------------------------------------------------------------- |
---|
| 18 | !! stp_ctl : Control the run |
---|
| 19 | !!---------------------------------------------------------------------- |
---|
| 20 | !USE oce ! ocean dynamics and tracers variables |
---|
| 21 | USE dom_oce ! ocean space and time domain variables |
---|
| 22 | !USE ice , ONLY : vt_i, u_ice, tm_i |
---|
| 23 | ! |
---|
| 24 | USE sbc_oce ! surface fluxes and stuff |
---|
| 25 | USE diawri |
---|
| 26 | ! |
---|
| 27 | USE in_out_manager ! I/O manager |
---|
| 28 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 29 | USE lib_mpp ! distributed memory computing |
---|
| 30 | |
---|
| 31 | USE netcdf ! NetCDF library |
---|
| 32 | IMPLICIT NONE |
---|
| 33 | PRIVATE |
---|
| 34 | |
---|
| 35 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
| 36 | |
---|
| 37 | INTEGER :: idrun, idtime, idtau, idqns, idemp, istatus |
---|
| 38 | LOGICAL :: lsomeoce |
---|
| 39 | !!---------------------------------------------------------------------- |
---|
| 40 | !! NEMO/SAS 4.0 , NEMO Consortium (2018) |
---|
| 41 | !! $Id: stpctl.F90 10603 2019-01-29 11:18:09Z acc $ |
---|
| 42 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
| 43 | !!---------------------------------------------------------------------- |
---|
| 44 | |
---|
| 45 | CONTAINS |
---|
| 46 | |
---|
| 47 | SUBROUTINE stp_ctl( kt, kindic ) |
---|
| 48 | !!---------------------------------------------------------------------- |
---|
| 49 | !! *** ROUTINE stp_ctl *** |
---|
| 50 | !! |
---|
| 51 | !! ** Purpose : Control the run |
---|
| 52 | !! |
---|
| 53 | !! ** Method : - Save the time step in numstp |
---|
| 54 | !! - Print it each 50 time steps |
---|
| 55 | !! - Stop the run IF problem encountered by setting indic=-3 |
---|
| 56 | !! |
---|
| 57 | !! ** Actions : "time.step" file = last ocean time-step |
---|
| 58 | !! "run.stat" file = run statistics |
---|
| 59 | !!---------------------------------------------------------------------- |
---|
| 60 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
| 61 | INTEGER, INTENT(inout) :: kindic ! error indicator |
---|
| 62 | !! |
---|
| 63 | REAL(wp), DIMENSION(3) :: zmax |
---|
| 64 | LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns |
---|
| 65 | CHARACTER(len=20) :: clname |
---|
| 66 | !!---------------------------------------------------------------------- |
---|
| 67 | ! |
---|
| 68 | ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) |
---|
[12210] | 69 | ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_prtctl .OR. sn_cfctl%l_runstat ) |
---|
[11930] | 70 | ll_wrtruns = ll_colruns |
---|
| 71 | IF( kt == nit000 .AND. lwp ) THEN |
---|
| 72 | WRITE(numout,*) |
---|
| 73 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
| 74 | WRITE(numout,*) '~~~~~~~' |
---|
| 75 | ! ! open time.step file |
---|
| 76 | CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
| 77 | ! ! open run.stat file(s) at start whatever |
---|
| 78 | ! ! the value of sn_cfctl%ptimincr |
---|
[12210] | 79 | IF( sn_cfctl%l_prtctl .OR. sn_cfctl%l_runstat ) THEN |
---|
[11930] | 80 | CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
| 81 | clname = 'run.stat.nc' |
---|
| 82 | IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) |
---|
| 83 | istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun ) |
---|
| 84 | istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime ) |
---|
| 85 | istatus = NF90_DEF_VAR( idrun, 'tau_max', NF90_DOUBLE, (/ idtime /), idtau ) |
---|
| 86 | istatus = NF90_DEF_VAR( idrun, 'qns_max', NF90_DOUBLE, (/ idtime /), idqns ) |
---|
| 87 | istatus = NF90_DEF_VAR( idrun, 'emp_max', NF90_DOUBLE, (/ idtime /), idemp ) |
---|
| 88 | istatus = NF90_ENDDEF(idrun) |
---|
| 89 | ENDIF |
---|
| 90 | ENDIF |
---|
| 91 | IF( kt == nit000 ) lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 |
---|
| 92 | ! |
---|
| 93 | IF(ll_wrtstp) THEN !== current time step ==! ("time.step" file) |
---|
| 94 | WRITE ( numstp, '(1x, i8)' ) kt |
---|
| 95 | REWIND( numstp ) |
---|
| 96 | ENDIF |
---|
| 97 | ! |
---|
| 98 | ! !== test of extrema ==! |
---|
| 99 | zmax(1) = MAXVAL( taum(:,:) , mask = tmask(:,:,1) == 1._wp ) ! max wind stress module |
---|
| 100 | zmax(2) = MAXVAL( ABS( qns(:,:) ) , mask = tmask(:,:,1) == 1._wp ) ! max non-solar heat flux |
---|
| 101 | zmax(3) = MAXVAL( ABS( emp(:,:) ) , mask = tmask(:,:,1) == 1._wp ) ! max E-P |
---|
| 102 | ! |
---|
| 103 | IF( ll_colruns ) THEN |
---|
| 104 | CALL mpp_max( "stpctl", zmax ) ! max over the global domain |
---|
| 105 | ENDIF |
---|
| 106 | ! !== run statistics ==! ("run.stat" files) |
---|
| 107 | IF( ll_wrtruns ) THEN |
---|
| 108 | WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3) |
---|
| 109 | istatus = NF90_PUT_VAR( idrun, idtau, (/ zmax(1)/), (/kt/), (/1/) ) |
---|
| 110 | istatus = NF90_PUT_VAR( idrun, idqns, (/ zmax(2)/), (/kt/), (/1/) ) |
---|
| 111 | istatus = NF90_PUT_VAR( idrun, idemp, (/ zmax(3)/), (/kt/), (/1/) ) |
---|
| 112 | IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) |
---|
| 113 | IF( kt == nitend ) istatus = NF90_CLOSE(idrun) |
---|
| 114 | END IF |
---|
| 115 | ! !== error handling ==! |
---|
[12210] | 116 | IF( ( sn_cfctl%l_prtctl .OR. lsomeoce ) .AND. ( & ! have use mpp_max (because sn_cfctl%l_prtctl=.T.) or contains some ocean points |
---|
[11930] | 117 | & zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 ) |
---|
| 118 | & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2) |
---|
| 119 | & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( kg/m^2/s) |
---|
| 120 | & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN ! NaN encounter in the tests |
---|
| 121 | |
---|
| 122 | !! We are 1D so no need to find a spatial location of the fuck-up! |
---|
| 123 | |
---|
| 124 | 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' |
---|
| 125 | WRITE(ctmp2,9500) kt, zmax(1), zmax(2), zmax(3) |
---|
| 126 | WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort.nc file' |
---|
| 127 | |
---|
| 128 | CALL dia_wri_state( 'output.abort' ) ! create an output.abort file |
---|
| 129 | |
---|
[12210] | 130 | IF( .NOT. sn_cfctl%l_prtctl ) THEN |
---|
[11930] | 131 | WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea |
---|
| 132 | CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) |
---|
| 133 | ELSE |
---|
| 134 | CALL ctl_stop( ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) |
---|
| 135 | ENDIF |
---|
| 136 | |
---|
| 137 | kindic = -3 |
---|
| 138 | ! |
---|
| 139 | ENDIF |
---|
| 140 | ! |
---|
| 141 | 9500 FORMAT(' it :', i8, ' tau_max: ', D23.16, ' |qns|_max: ', D23.16,' |emp|_max: ', D23.16) |
---|
| 142 | ! |
---|
| 143 | END SUBROUTINE stp_ctl |
---|
| 144 | |
---|
| 145 | !!====================================================================== |
---|
| 146 | END MODULE stpctl |
---|