Changeset 14318 for NEMO/trunk/tests/STATION_ASF/MY_SRC/stpctl.F90
- Timestamp:
- 2021-01-20T11:49:35+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/trunk/tests/STATION_ASF/MY_SRC/stpctl.F90
r14072 r14318 31 31 PUBLIC stp_ctl ! routine called by step.F90 32 32 33 INTEGER :: nrunid ! netcdf file id 34 INTEGER, DIMENSION(3) :: nvarid ! netcdf variable id 33 INTEGER, PARAMETER :: jpvar = 3 34 INTEGER :: nrunid ! netcdf file id 35 INTEGER, DIMENSION(jpvar) :: nvarid ! netcdf variable id 35 36 !!---------------------------------------------------------------------- 36 37 !! NEMO/SAS 4.0 , NEMO Consortium (2018) … … 59 60 INTEGER, INTENT(in ) :: Kmm ! ocean time level index 60 61 !! 62 INTEGER, PARAMETER :: jptst = 3 61 63 INTEGER :: ji ! dummy loop indices 62 64 INTEGER :: idtime, istatus 63 INTEGER , DIMENSION(4) :: iareasum, iareamin, iareamax 64 INTEGER , DIMENSION(3,3) :: iloc ! min/max loc indices 65 REAL(wp) :: zzz ! local real 66 REAL(wp), DIMENSION(4) :: zmax, zmaxlocal 65 INTEGER , DIMENSION(jptst) :: iareasum, iareamin, iareamax 66 INTEGER , DIMENSION(3,jptst) :: iloc ! min/max loc indices 67 REAL(wp) :: zzz ! local real 68 REAL(wp), DIMENSION(jpvar+1) :: zmax 69 REAL(wp), DIMENSION(jptst) :: zmaxlocal 67 70 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce 68 71 LOGICAL, DIMENSION(jpi,jpj) :: llmsk … … 122 125 zmax(2) = MAXVAL( ABS( qns(:,:) ), mask = llmsk ) ! max non-solar heat flux 123 126 zmax(3) = MAXVAL( ABS( emp(:,:) ), mask = llmsk ) ! max E-P 124 zmax( 4) = REAL( nstop, wp )! stop indicator127 zmax(jpvar+1) = REAL( nstop, wp ) ! stop indicator 125 128 ! 126 129 ! !== get global extrema ==! 127 130 ! !== done by all processes if writting run.stat ==! 128 131 IF( ll_colruns ) THEN 129 zmaxlocal(:) = zmax( :)130 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 131 nstop = NINT( zmax( 4) )! update nstop indicator (now sheared among all local domains)132 zmaxlocal(:) = zmax(1:jptst) 133 CALL mpp_max( "stpctl", zmax ) ! max over the global domain: ok even of ll_0oce = .true. 134 nstop = NINT( zmax(jpvar+1) ) ! update nstop indicator (now sheared among all local domains) 132 135 ELSE 133 136 ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow. 134 IF( ll_0oce ) zmax(1:3) = 0._wp ! default "valid" values... 135 ENDIF 136 ! !== error handling ==! 137 IF( ll_0oce ) zmax(1:jptst) = 0._wp ! default "valid" values... 138 ENDIF 137 139 ! !== write "run.stat" files ==! 138 140 ! !== done only by 1st subdomain at writting timestep ==! 139 141 IF( ll_wrtruns ) THEN 140 WRITE(numrun,9500) kt, zmax(1 ), zmax(2), zmax(3)141 DO ji = 1, 3142 WRITE(numrun,9500) kt, zmax(1:jptst) 143 DO ji = 1, jpvar 142 144 istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) ) 143 145 END DO 144 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid)146 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 145 147 END IF 146 148 ! !== error handling ==! 147 149 ! !== done by all processes at every time step ==! 148 150 ! 149 IF( zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 )150 & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2 )151 & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( > 1.E-3 kg/m^2/s )152 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR. & ! NaN encounter in the tests153 & ABS( zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests151 IF( zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 ) 152 & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2 ) 153 & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( > 1.E-3 kg/m^2/s ) 154 & ISNAN( SUM(zmax(1:jptst)) ) .OR. & ! NaN encounter in the tests 155 & ABS( SUM(zmax(1:jptst)) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests 154 156 ! 155 157 iloc(:,:) = 0 … … 163 165 ! find which subdomain has the max. 164 166 iareamin(:) = jpnij+1 ; iareamax(:) = 0 ; iareasum(:) = 0 165 DO ji = 1, 4167 DO ji = 1, jptst 166 168 IF( zmaxlocal(ji) == zmax(ji) ) THEN 167 169 iareamin(ji) = narea ; iareamax(ji) = narea ; iareasum(ji) = 1 … … 176 178 iloc(1:2,2) = MAXLOC( ABS( qns(:,:) ), mask = llmsk ) 177 179 iloc(1:2,3) = MINLOC( ABS( emp(:,:) ), mask = llmsk ) 178 DO ji = 1, 3! local domain indices ==> global domain indices, excluding halos180 DO ji = 1, jptst ! local domain indices ==> global domain indices, excluding halos 179 181 iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /) 180 182 END DO … … 195 197 ! 196 198 IF( ll_colruns .OR. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 197 IF(lwp) THEN 198 CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 199 ELSE 200 nstop = MAX(1, nstop) ! make sure nstop > 0 (automatically done when calling ctl_stop) 199 IF(lwp) THEN ; CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 200 ELSE ; nstop = MAX(1, nstop) ! make sure nstop > 0 (automatically done when calling ctl_stop) 201 201 ENDIF 202 202 ELSE ! only mpi subdomains with errors are here -> STOP now … … 239 239 240 240 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij ,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 241 !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF241 !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF 242 242 cl4 = '(i'//clfmt//')' ; WRITE(clsum, cl4) ksum 243 243 WRITE(clfmt, '(i1)') INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 244 244 cl4 = '(i'//clfmt//')' ; WRITE(clmin, cl4) kmin-1 245 WRITE(clmax, cl4) kmax-1245 WRITE(clmax, cl4) kmax-1 246 246 ! 247 247 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1 ! how many digits to we need to write jpiglo? (we decide max = 9) … … 259 259 ELSE 260 260 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 261 !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF261 !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF 262 262 cl4 = '(i'//clfmt//')' ; WRITE(clk, cl4) kloc(3) ! this is ok with AGRIF 263 263 WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), TRIM(clk), TRIM(clsuff)
Note: See TracChangeset
for help on using the changeset viewer.