Changeset 12685
- Timestamp:
- 2020-04-06T11:52:15+02:00 (3 years ago)
- Location:
- NEMO/branches/2020/r12581_ticket2418
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2020/r12581_ticket2418/src/OCE/stpctl.F90
r12684 r12685 19 19 USE dom_oce ! ocean space and time domain variables 20 20 USE c1d ! 1D vertical configuration 21 USE zdf_oce , ONLY : ln_zad_Aimp ! ocean vertical physics variables 22 USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy 23 ! 21 24 USE diawri ! Standard run outputs (dia_wri_state routine) 22 !23 25 USE in_out_manager ! I/O manager 24 26 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 25 27 USE lib_mpp ! distributed memory computing 26 USE zdf_oce , ONLY : ln_zad_Aimp ! ocean vertical physics variables 27 USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy 28 28 ! 29 29 USE netcdf ! NetCDF library 30 30 IMPLICIT NONE … … 74 74 ! 75 75 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 76 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 77 ll_wrtruns = ll_colruns.AND. lwm76 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 77 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 78 78 ! 79 79 IF( kt == nit000 ) THEN … … 212 212 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 213 213 ! 214 IF( ll_colruns ) THEN ! all processes are synchronized -> use lwp to do theprint in opened ocean.output files214 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 215 215 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 216 216 ELSE ! only mpi subdomains with errors are here -> STOP now -
NEMO/branches/2020/r12581_ticket2418/src/SAS/stpctl.F90
r12684 r12685 20 20 USE dom_oce ! ocean space and time domain variables 21 21 USE ice , ONLY : vt_i, u_ice, tm_i 22 ! 22 23 USE diawri ! Standard run outputs (dia_wri_state routine) 23 !24 24 USE in_out_manager ! I/O manager 25 25 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 26 26 USE lib_mpp ! distributed memory computing 27 27 ! 28 28 USE netcdf ! NetCDF library 29 29 IMPLICIT NONE … … 73 73 ! 74 74 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 75 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 76 ll_wrtruns = ll_colruns.AND. lwm75 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 76 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 77 77 ! 78 78 IF( kt == nit000 ) THEN … … 172 172 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 173 173 ! 174 IF( ll_colruns ) THEN ! all processes are synchronized -> use lwp to do theprint in opened ocean.output files174 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 175 175 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 176 176 ELSE ! only mpi subdomains with errors are here -> STOP now -
NEMO/branches/2020/r12581_ticket2418/tests/CANAL/MY_SRC/stpctl.F90
r12684 r12685 19 19 USE dom_oce ! ocean space and time domain variables 20 20 USE c1d ! 1D vertical configuration 21 USE zdf_oce , ONLY : ln_zad_Aimp ! ocean vertical physics variables 22 USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy 23 ! 21 24 USE diawri ! Standard run outputs (dia_wri_state routine) 22 !23 25 USE in_out_manager ! I/O manager 24 26 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 25 27 USE lib_mpp ! distributed memory computing 26 USE zdf_oce , ONLY : ln_zad_Aimp ! ocean vertical physics variables 27 USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy 28 28 ! 29 29 USE netcdf ! NetCDF library 30 30 IMPLICIT NONE … … 74 74 ! 75 75 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 76 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 77 ll_wrtruns = ll_colruns.AND. lwm76 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 77 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 78 78 ! 79 79 IF( kt == nit000 ) THEN … … 212 212 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 213 213 ! 214 IF( ll_colruns ) THEN ! all processes are synchronized -> use lwp to do theprint in opened ocean.output files214 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 215 215 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 216 216 ELSE ! only mpi subdomains with errors are here -> STOP now -
NEMO/branches/2020/r12581_ticket2418/tests/STATION_ASF/MY_SRC/stpctl.F90
r12593 r12685 19 19 USE dom_oce ! ocean space and time domain variables 20 20 USE sbc_oce ! surface fluxes and stuff 21 ! 21 22 USE diawri ! Standard run outputs (dia_wri_state routine) 22 !23 23 USE in_out_manager ! I/O manager 24 24 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 25 25 USE lib_mpp ! distributed memory computing 26 26 ! 27 27 USE netcdf ! NetCDF library 28 28 IMPLICIT NONE … … 31 31 PUBLIC stp_ctl ! routine called by step.F90 32 32 33 INTEGER :: nrunid, ntauid, nqnsid, nempid 33 INTEGER :: nrunid ! netcdf file id 34 INTEGER, DIMENSION(3) :: nvarid ! netcdf variable id 34 35 !!---------------------------------------------------------------------- 35 36 !! NEMO/SAS 4.0 , NEMO Consortium (2018) … … 39 40 CONTAINS 40 41 41 SUBROUTINE stp_ctl( kt, K bb, Kmm )42 SUBROUTINE stp_ctl( kt, Kmm ) 42 43 !!---------------------------------------------------------------------- 43 44 !! *** ROUTINE stp_ctl *** 44 !! 45 !! 45 46 !! ** Purpose : Control the run 46 47 !! 47 48 !! ** Method : - Save the time step in numstp 48 49 !! - Print it each 50 time steps 49 !! - Stop the run IF problem encountered by setting indic=-3 50 !! - Stop the run IF problem encountered by setting nstop > 0 51 !! Problems checked: wind stress module max larger than 5 N/m^2 52 !! non-solar heat flux max larger than 2000 W/m^2 53 !! Evaporation-Precip max larger than 1.E-3 kg/m^2/s 50 54 !! 51 55 !! ** Actions : "time.step" file = last ocean time-step 52 56 !! "run.stat" file = run statistics 53 !! nstop indicator sheared among all local domain (lk_mpp=T)57 !! nstop indicator sheared among all local domain 54 58 !!---------------------------------------------------------------------- 55 59 INTEGER, INTENT(in ) :: kt ! ocean time-step index 56 INTEGER, INTENT(in ) :: K bb, Kmm ! ocean time level index60 INTEGER, INTENT(in ) :: Kmm ! ocean time level index 57 61 !! 58 INTEGER :: idtime, istatus 59 REAL(wp), DIMENSION(3) :: zmax 60 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 61 LOGICAL, DIMENSION(jpi,jpj) :: llmsk 62 CHARACTER(len=20) :: clname 62 INTEGER :: ji ! dummy loop indices 63 INTEGER :: idtime, istatus 64 INTEGER, DIMENSION(2,3) :: iloc ! min/max loc indices 65 REAL(wp) :: zzz ! local real 66 REAL(wp), DIMENSION(4) :: zmax, zmaxlocal, zarea 67 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 68 LOGICAL, DIMENSION(jpi,jpj) :: llmsk 69 CHARACTER(len=20) :: clname 63 70 !!---------------------------------------------------------------------- 71 IF( nstop > 0 .AND. ngrdstop > -1 ) RETURN ! stpctl was already called by a child grid 64 72 ! 65 73 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 66 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 67 ll_wrtruns = ll_colruns.AND. lwm74 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 75 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 68 76 ! 69 77 IF( kt == nit000 ) THEN … … 85 93 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 86 94 istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) 87 istatus = NF90_DEF_VAR( nrunid, 'tau_max', NF90_DOUBLE, (/ idtime /), n tauid)88 istatus = NF90_DEF_VAR( nrunid, 'qns_max', NF90_DOUBLE, (/ idtime /), n qnsid)89 istatus = NF90_DEF_VAR( nrunid, 'emp_max', NF90_DOUBLE, (/ idtime /), n empid)95 istatus = NF90_DEF_VAR( nrunid, 'tau_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) 96 istatus = NF90_DEF_VAR( nrunid, 'qns_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 97 istatus = NF90_DEF_VAR( nrunid, 'emp_max', NF90_DOUBLE, (/ idtime /), nvarid(3) ) 90 98 istatus = NF90_ENDDEF(nrunid) 91 99 ENDIF … … 105 113 zmax(2) = MAXVAL( ABS( qns(:,:) ) , mask = llmsk ) ! max non-solar heat flux 106 114 zmax(3) = MAXVAL( ABS( emp(:,:) ) , mask = llmsk ) ! max E-P 107 ! 115 zmax(4) = REAL( nstop, wp ) ! stop indicator 116 ! !== get global extrema ==! 117 ! !== done by all processes if writting run.stat ==! 108 118 IF( ll_colruns ) THEN 119 zmaxlocal(:) = zmax(:) 109 120 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 110 nstop = NINT( zmax( 3) ) ! nstop indicator sheared among all local domains121 nstop = NINT( zmax(4) ) ! update nstop indicator (now sheared among all local domains) 111 122 ENDIF 112 ! !== run statistics ==! ("run.stat" files) 123 ! !== write "run.stat" files ==! 124 ! !== done only by 1st subdomain at writting timestep ==! 113 125 IF( ll_wrtruns ) THEN 114 126 WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3) 115 istatus = NF90_PUT_VAR( nrunid, ntauid, (/ zmax(1)/), (/kt/), (/1/) ) 116 istatus = NF90_PUT_VAR( nrunid, nqnsid, (/ zmax(2)/), (/kt/), (/1/) ) 117 istatus = NF90_PUT_VAR( nrunid, nempid, (/ zmax(3)/), (/kt/), (/1/) ) 118 IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(nrunid) 119 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 127 istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 128 istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 129 istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/ zmax(3)/), (/kt/), (/1/) ) 130 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 120 131 END IF 121 ! !== error handling ==! 122 IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. ( & ! domain contains some ocean points, check for sensible ranges 123 & zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 ) 124 & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2) 125 & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( kg/m^2/s) 126 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN ! NaN encounter in the tests 127 128 !! We are 1D so no need to find a spatial location of the rogue point. 129 132 ! !== error handling ==! 133 ! !== done by all processes at every time step ==! 134 ! 135 IF( zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 ) 136 & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2 ) 137 & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( > 1.E-3 kg/m^2/s ) 138 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) THEN ! NaN encounter in the tests 139 ! 140 IF( ll_colruns ) THEN ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 141 ! first: close the netcdf file, so we can read it 142 IF( lwm .AND. kt /= nitend ) istatus = NF90_CLOSE(nrunid) 143 ! get global loc on the min/max 144 CALL mpp_maxloc( 'stpctl', vt_i(:,:) , tmask(:,:,1), zzz, iloc(1:2,1) ) ! mpp_maxloc ok if mask = F 145 CALL mpp_maxloc( 'stpctl',ABS( u_ice(:,:) ) , tmask(:,:,1), zzz, iloc(1:2,2) ) 146 CALL mpp_minloc( 'stpctl', tm_i(:,:) - 273.15_wp, tmask(:,:,1), zzz, iloc(1:2,3) ) 147 ! find which subdomain has the max. 148 zarea(:) = 0._wp 149 DO ji = 1, 4 150 IF( zmaxlocal(ji) == zmax(ji) ) zarea(ji) = narea 151 END DO 152 CALL mpp_max( "stpctl", zarea ) ! max over the global domain 153 ELSE ! find local min and max locations: 154 ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 155 iloc(1:2,1) = MAXLOC( vt_i(:,:) , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 156 iloc(1:2,2) = MAXLOC( ABS( u_ice(:,:) ) , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 157 iloc(1:2,3) = MINLOC( tm_i(:,:) - 273.15_wp, mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 158 zarea(:) = narea ! this is local information 159 ENDIF 160 ! 130 161 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' 131 WRITE(ctmp2,9500) kt, zmax(1), zmax(2), zmax(3) 132 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort.nc file' 133 162 WRITE(ctmp2,9100) kt, ' |tau| max', zmax(1), iloc(1,1), iloc(2,1), NINT(zarea(1))-1 163 WRITE(ctmp3,9100) kt, ' |qns| max', zmax(2), iloc(1,2), iloc(2,3), NINT(zarea(2))-1 164 WRITE(ctmp4,9100) kt, ' emp max', zmax(3), iloc(1,2), iloc(2,3), NINT(zarea(3))-1 165 IF( Agrif_Root() ) THEN 166 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort* files' 167 ELSE 168 WRITE(ctmp6,*) ' ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 169 ENDIF 170 ! 134 171 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 135 136 IF( .NOT. sn_cfctl%l_glochk ) THEN 137 WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea 138 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) 139 ELSE 140 CALL ctl_stop( ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) 172 ! 173 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 174 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 175 ELSE ! only mpi subdomains with errors are here -> STOP now 176 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 141 177 ENDIF 142 143 kindic = -3 178 ! 179 IF( nstop == 0 ) nstop = 1 180 ngrdstop = Agrif_Fixed() 144 181 ! 145 182 ENDIF 146 183 ! 184 9100 FORMAT(' kt ',i8,a,1pg11.4,' at i j',2i6,' MPI rank',i6) 147 185 9500 FORMAT(' it :', i8, ' tau_max: ', D23.16, ' |qns|_max: ', D23.16,' |emp|_max: ', D23.16) 148 186 !
Note: See TracChangeset
for help on using the changeset viewer.