Changeset 12933
- Timestamp:
- 2020-05-15T10:06:25+02:00 (4 years ago)
- Location:
- NEMO/trunk
- Files:
-
- 30 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
NEMO/trunk
- Property svn:externals
-
old new 8 8 9 9 # SETTE 10 ^/utils/CI/sette@12 798sette10 ^/utils/CI/sette@12931 sette
-
- Property svn:externals
-
NEMO/trunk/cfgs/C1D_PAPA/EXPREF/file_def_nemo-oce.xml
r9799 r12933 53 53 <file id="file4" name_suffix="_grid_W" description="ocean W grid variables" > 54 54 <field field_ref="e3w" /> 55 <field field_ref="woce" name="wo" />56 55 <field field_ref="avt" name="difvho" /> 57 56 </file> -
NEMO/trunk/cfgs/C1D_PAPA/EXPREF/namelist_cfg
r12489 r12933 49 49 &namdom ! time and space domain 50 50 !----------------------------------------------------------------------- 51 ln_linssh = .true. ! =T linear free surface ==>> model level are fixed in time 52 ! 51 53 rn_Dt = 360. ! time step for the dynamics and tracer 52 54 / … … 358 360 &namdyn_spg ! surface pressure gradient (default: NO selection) 359 361 !----------------------------------------------------------------------- 360 ln_dynspg_ts = .true. ! split-explicit free surface361 ln_bt_fw = .false. ! Forward integration of barotropic Eqs.362 ln_bt_av = .true. ! Time filtering of barotropic variables363 362 / 364 363 !----------------------------------------------------------------------- -
NEMO/trunk/cfgs/SHARED/namelist_ref
r12530 r12933 1394 1394 &namctl ! Control prints (default: OFF) 1395 1395 !----------------------------------------------------------------------- 1396 sn_cfctl%l_glochk = .FALSE. ! Range sanity checks are local (F) or global (T). Set T for debugging only 1397 sn_cfctl%l_allon = .FALSE. ! IF T activate all options. If F deactivate all unless l_config is T 1398 sn_cfctl%l_config = .TRUE. ! IF .true. then control which reports are written with the following 1399 sn_cfctl%l_runstat = .TRUE. ! switches and which areas produce reports with the proc integer settings. 1400 sn_cfctl%l_trcstat = .FALSE. ! The default settings for the proc integers should ensure 1401 sn_cfctl%l_oceout = .FALSE. ! that all areas report. 1402 sn_cfctl%l_layout = .FALSE. ! 1403 sn_cfctl%l_prtctl = .FALSE. ! 1404 sn_cfctl%l_prttrc = .FALSE. ! 1405 sn_cfctl%l_oasout = .FALSE. ! 1406 sn_cfctl%procmin = 0 ! Minimum area number for reporting [default:0] 1407 sn_cfctl%procmax = 1000000 ! Maximum area number for reporting [default:1000000] 1408 sn_cfctl%procincr = 1 ! Increment for optional subsetting of areas [default:1] 1409 sn_cfctl%ptimincr = 1 ! Timestep increment for writing time step progress info 1410 nn_print = 0 ! level of print (0 no extra print) 1411 nn_ictls = 0 ! start i indice of control sum (use to compare mono versus 1412 nn_ictle = 0 ! end i indice of control sum multi processor runs 1413 nn_jctls = 0 ! start j indice of control over a subdomain) 1414 nn_jctle = 0 ! end j indice of control 1415 nn_isplt = 1 ! number of processors in i-direction 1416 nn_jsplt = 1 ! number of processors in j-direction 1417 ln_timing = .false. ! timing by routine write out in timing.output file 1418 ln_diacfl = .false. ! CFL diagnostics write out in cfl_diagnostics.ascii 1396 sn_cfctl%l_runstat = .TRUE. ! switches and which areas produce reports with the proc integer settings. 1397 sn_cfctl%l_trcstat = .FALSE. ! The default settings for the proc integers should ensure 1398 sn_cfctl%l_oceout = .FALSE. ! that all areas report. 1399 sn_cfctl%l_layout = .FALSE. ! 1400 sn_cfctl%l_prtctl = .FALSE. ! 1401 sn_cfctl%l_prttrc = .FALSE. ! 1402 sn_cfctl%l_oasout = .FALSE. ! 1403 sn_cfctl%procmin = 0 ! Minimum area number for reporting [default:0] 1404 sn_cfctl%procmax = 1000000 ! Maximum area number for reporting [default:1000000] 1405 sn_cfctl%procincr = 1 ! Increment for optional subsetting of areas [default:1] 1406 sn_cfctl%ptimincr = 1 ! Timestep increment for writing time step progress info 1407 nn_print = 0 ! level of print (0 no extra print) 1408 nn_ictls = 0 ! start i indice of control sum (use to compare mono versus 1409 nn_ictle = 0 ! end i indice of control sum multi processor runs 1410 nn_jctls = 0 ! start j indice of control over a subdomain) 1411 nn_jctle = 0 ! end j indice of control 1412 nn_isplt = 1 ! number of processors in i-direction 1413 nn_jsplt = 1 ! number of processors in j-direction 1414 ln_timing = .false. ! timing by routine write out in timing.output file 1415 ln_diacfl = .false. ! CFL diagnostics write out in cfl_diagnostics.ascii 1419 1416 / 1420 1417 !----------------------------------------------------------------------- -
NEMO/trunk/cfgs/WED025/EXPREF/namelist_cfg
r12905 r12933 659 659 &namctl ! Control prints (default: OFF) 660 660 !----------------------------------------------------------------------- 661 sn_cfctl%l_glochk = .FALSE. ! Range sanity checks are local (F) or global (T). Set T for debugging only 662 sn_cfctl%l_allon = .FALSE. ! IF T activate all options. If F deactivate all unless l_config is T 663 sn_cfctl%l_config = .TRUE. ! IF .true. then control which reports are written with the following 664 sn_cfctl%l_runstat = .TRUE. ! switches and which areas produce reports with the proc integer settings. 665 sn_cfctl%l_trcstat = .FALSE. ! The default settings for the proc integers should ensure 666 sn_cfctl%l_oceout = .FALSE. ! that all areas report. 667 sn_cfctl%l_layout = .FALSE. ! 668 sn_cfctl%l_prtctl = .FALSE. ! 669 sn_cfctl%l_prttrc = .FALSE. ! 670 sn_cfctl%l_oasout = .FALSE. ! 671 sn_cfctl%procmin = 0 ! Minimum area number for reporting [default:0] 672 sn_cfctl%procmax = 1000000 ! Maximum area number for reporting [default:1000000] 673 sn_cfctl%procincr = 1 ! Increment for optional subsetting of areas [default:1] 674 sn_cfctl%ptimincr = 1 ! Timestep increment for writing time step progress info 675 nn_print = 0 ! level of print (0 no extra print) 676 nn_ictls = 0 ! start i indice of control sum (use to compare mono versus 677 nn_ictle = 0 ! end i indice of control sum multi processor runs 678 nn_jctls = 0 ! start j indice of control over a subdomain) 679 nn_jctle = 0 ! end j indice of control 680 nn_isplt = 1 ! number of processors in i-direction 681 nn_jsplt = 1 ! number of processors in j-direction 682 ln_timing = .true. ! timing by routine write out in timing.output file 683 ln_diacfl = .false. ! CFL diagnostics write out in cfl_diagnostics.ascii 661 sn_cfctl%l_runstat = .true. ! switches and which areas produce reports with the proc integer settings. 662 ln_timing = .true. ! timing by routine write out in timing.output file 684 663 / 685 664 !----------------------------------------------------------------------- -
NEMO/trunk/src/OCE/C1D/step_c1d.F90
r12740 r12933 56 56 ! 57 57 INTEGER :: jk ! dummy loop indice 58 INTEGER :: indic ! error indicator if < 059 58 !! --------------------------------------------------------------------- 60 61 indic = 0 ! reset to no error condition62 59 IF( kstp == nit000 ) CALL iom_init( "nemo") ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS) 63 60 IF( kstp /= nit000 ) CALL day( kstp ) ! Calendar (day was already called at nit000 in day_init) … … 137 134 ! Control and restarts 138 135 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 139 CALL stp_ctl( kstp, N bb, Nnn, indic)136 CALL stp_ctl( kstp, Nnn ) 140 137 IF( kstp == nit000 ) CALL iom_close( numror ) ! close input ocean restart file 141 138 IF( lrst_oce ) CALL rst_write( kstp, Nbb, Nnn ) ! write output ocean restart file 142 139 ! 143 140 #if defined key_iomput 144 IF( kstp == nitend .OR. indic <0 ) CALL xios_context_finalize() ! needed for XIOS141 IF( kstp == nitend .OR. nstop > 0 ) CALL xios_context_finalize() ! needed for XIOS 145 142 ! 146 143 #endif -
NEMO/trunk/src/OCE/DIA/diawri.F90
r12649 r12933 998 998 CALL iom_close( inum ) 999 999 ENDIF 1000 ! 1000 1001 #endif 1001 1002 1002 END SUBROUTINE dia_wri_state 1003 1003 -
NEMO/trunk/src/OCE/DOM/dom_oce.F90
r12489 r12933 17 17 !!---------------------------------------------------------------------- 18 18 !! Agrif_Root : dummy function used when lk_agrif=F 19 !! Agrif_Fixed : dummy function used when lk_agrif=F 19 20 !! Agrif_CFixed : dummy function used when lk_agrif=F 20 21 !! dom_oce_alloc : dynamical allocation of dom_oce arrays … … 233 234 END FUNCTION Agrif_Root 234 235 236 INTEGER FUNCTION Agrif_Fixed() 237 Agrif_Fixed = 0 238 END FUNCTION Agrif_Fixed 239 235 240 CHARACTER(len=3) FUNCTION Agrif_CFixed() 236 241 Agrif_CFixed = '0' -
NEMO/trunk/src/OCE/ICB/icbrst.F90
r12472 r12933 188 188 ! 189 189 INTEGER :: jn ! dummy loop index 190 INTEGER :: idg ! number of digits 190 191 INTEGER :: ix_dim, iy_dim, ik_dim, in_dim 191 192 CHARACTER(len=256) :: cl_path 192 193 CHARACTER(len=256) :: cl_filename 193 194 CHARACTER(len=256) :: cl_kt 195 CHARACTER(LEN=12 ) :: clfmt ! writing format 194 196 TYPE(iceberg), POINTER :: this 195 197 TYPE(point) , POINTER :: pt … … 213 215 cl_filename = TRIM(cexper)//"_"//TRIM(ADJUSTL(cl_kt))//"_"//TRIM(cn_icbrst_out) 214 216 IF( lk_mpp ) THEN 215 WRITE(cl_filename,'(A,"_",I4.4,".nc")') TRIM(cl_filename), narea-1 217 idg = MAX( INT(LOG10(REAL(jpnij-1,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 218 WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg ! '(a,a,ix.x,a)' 219 WRITE(cl_filename,clfmt) TRIM(cl_filename), '_', narea-1, '.nc' 216 220 ELSE 217 221 WRITE(cl_filename,'(A,".nc")') TRIM(cl_filename) -
NEMO/trunk/src/OCE/ICB/icbtrj.F90
r12489 r12933 62 62 ! 63 63 INTEGER :: iret, iyear, imonth, iday 64 INTEGER :: idg ! number of digits 64 65 REAL(wp) :: zfjulday, zsec 65 66 CHARACTER(len=80) :: cl_filename 67 CHARACTER(LEN=12) :: clfmt ! writing format 66 68 CHARACTER(LEN=20) :: cldate_ini, cldate_end 67 69 TYPE(iceberg), POINTER :: this … … 80 82 81 83 ! define trajectory output name 82 IF ( lk_mpp ) THEN ; WRITE(cl_filename,'("trajectory_icebergs_",A,"-",A,"_",I4.4,".nc")') & 83 & TRIM(ADJUSTL(cldate_ini)), TRIM(ADJUSTL(cldate_end)), narea-1 84 ELSE ; WRITE(cl_filename,'("trajectory_icebergs_",A,"-",A ,".nc")') & 85 & TRIM(ADJUSTL(cldate_ini)), TRIM(ADJUSTL(cldate_end)) 84 cl_filename = 'trajectory_icebergs_'//TRIM(ADJUSTL(cldate_ini))//'-'//TRIM(ADJUSTL(cldate_end)) 85 IF ( lk_mpp ) THEN 86 idg = MAX( INT(LOG10(REAL(jpnij-1,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 87 WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg ! '(a,a,ix.x,a)' 88 WRITE(cl_filename,clfmt) TRIM(cl_filename), '_', narea-1, '.nc' 89 ELSE 90 WRITE(cl_filename,'(A,".nc")') TRIM(cl_filename) 86 91 ENDIF 87 92 IF( lwp .AND. nn_verbose_level >= 0 ) WRITE(numout,'(2a)') 'icebergs, icb_trj_init: creating ',TRIM(cl_filename) -
NEMO/trunk/src/OCE/IOM/in_out_manager.F90
r12377 r12933 100 100 !!---------------------------------------------------------------------- 101 101 TYPE :: sn_ctl !: structure for control over output selection 102 LOGICAL :: l_glochk = .FALSE. !: range sanity checks are local (F) or global (T)103 ! Use global setting for debugging only;104 ! local breaches will still be reported105 ! and stop the code in most cases.106 LOGICAL :: l_allon = .FALSE. !: overall control; activate all following output options107 LOGICAL :: l_config = .FALSE. !: activate/deactivate finer control108 ! Note if l_config is True then sn_cfctl%l_allon is ignored.109 ! Otherwise setting sn_cfctl%l_allon T/F is equivalent to110 ! setting all the following logicals in this structure T/F111 ! and disabling subsetting of processors112 102 LOGICAL :: l_runstat = .FALSE. !: Produce/do not produce run.stat file (T/F) 113 103 LOGICAL :: l_trcstat = .FALSE. !: Produce/do not produce tracer.stat file (T/F) … … 169 159 INTEGER :: no_print = 0 !: optional argument of fld_fill (if present, suppress some control print) 170 160 INTEGER :: nstop = 0 !: error flag (=number of reason for a premature stop run) 161 !$AGRIF_DO_NOT_TREAT 162 INTEGER :: ngrdstop = -1 !: grid number having nstop > 1 163 !$AGRIF_END_DO_NOT_TREAT 171 164 INTEGER :: nwarn = 0 !: warning flag (=number of warning found during the run) 172 165 CHARACTER(lc) :: ctmp1, ctmp2, ctmp3 !: temporary characters 1 to 3 -
NEMO/trunk/src/OCE/IOM/iom_nf90.F90
r12649 r12933 62 62 CHARACTER(LEN=256) :: clinfo ! info character 63 63 CHARACTER(LEN=256) :: cltmp ! temporary character 64 CHARACTER(LEN=12 ) :: clfmt ! writing format 64 65 CHARACTER(LEN=3 ) :: clcomp ! name of component calling iom_nf90_open 66 INTEGER :: idg ! number of digits 65 67 INTEGER :: iln ! lengths of character 66 68 INTEGER :: istop ! temporary storage of nstop … … 109 111 IF( ldwrt ) THEN !* the file should be open in write mode so we create it... 110 112 IF( jpnij > 1 ) THEN 111 WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea-1, '.nc' 113 idg = MAX( INT(LOG10(REAL(jpnij-1,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 114 WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg ! '(a,a,ix.x,a)' 115 WRITE(cltmp,clfmt) cdname(1:iln-1), '_', narea-1, '.nc' 112 116 cdname = TRIM(cltmp) 113 117 ENDIF -
NEMO/trunk/src/OCE/LBC/lib_mpp.F90
r12512 r12933 1112 1112 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cd2, cd3, cd4, cd5 1113 1113 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cd6, cd7, cd8, cd9, cd10 1114 ! 1115 CHARACTER(LEN=8) :: clfmt ! writing format 1116 INTEGER :: inum 1117 INTEGER :: idg ! number of digits 1114 1118 !!---------------------------------------------------------------------- 1115 1119 ! 1116 1120 nstop = nstop + 1 1117 1121 ! 1118 ! force to open ocean.output file if not already opened 1119 IF( numout == 6 ) CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) 1122 IF( numout == 6 ) THEN ! force to open ocean.output file if not already opened 1123 CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) 1124 ELSE 1125 IF( narea > 1 .AND. cd1 == 'STOP' ) THEN ! add an error message in ocean.output 1126 CALL ctl_opn( inum,'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) 1127 WRITE(inum,*) 1128 idg = MAX( INT(LOG10(REAL(jpnij-1,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 1129 WRITE(clfmt, "('(a,i', i1, '.', i1, ')')") idg, idg ! '(a,ix.x)' 1130 WRITE(inum,clfmt) ' ===>>> : see E R R O R in ocean.output_', narea - 1 1131 ENDIF 1132 ENDIF 1120 1133 ! 1121 1134 WRITE(numout,*) … … 1145 1158 WRITE(numout,*) 'huge E-R-R-O-R : immediate stop' 1146 1159 WRITE(numout,*) 1160 CALL FLUSH(numout) 1161 CALL SLEEP(60) ! make sure that all output and abort files are written by all cores. 60s should be enough... 1147 1162 CALL mppstop( ld_abort = .true. ) 1148 1163 ENDIF … … 1207 1222 ! 1208 1223 CHARACTER(len=80) :: clfile 1224 CHARACTER(LEN=10) :: clfmt ! writing format 1209 1225 INTEGER :: iost 1226 INTEGER :: idg ! number of digits 1210 1227 !!---------------------------------------------------------------------- 1211 1228 ! … … 1214 1231 clfile = TRIM(cdfile) 1215 1232 IF( PRESENT( karea ) ) THEN 1216 IF( karea > 1 ) WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1 1233 IF( karea > 1 ) THEN 1234 idg = MAX( INT(LOG10(REAL(jpnij-1,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 1235 WRITE(clfmt, "('(a,a,i', i1, '.', i1, ')')") idg, idg ! '(a,a,ix.x)' 1236 WRITE(clfile, clfmt) TRIM(clfile), '_', karea-1 1237 ENDIF 1217 1238 ENDIF 1218 1239 #if defined key_agrif -
NEMO/trunk/src/OCE/LBC/mpp_loc_generic.h90
r10716 r12933 32 32 REAL(wp) , INTENT( out) :: pmin ! Global minimum of ptab 33 33 INDEX_TYPE(:) ! index of minimum in global frame 34 # if defined key_mpp_mpi35 34 ! 36 35 INTEGER :: ierror, ii, idim … … 56 55 ! 57 56 kindex(1) = mig( ilocs(1) ) 58 # 57 #if defined DIM_2d || defined DIM_3d /* avoid warning when kindex has 1 element */ 59 58 kindex(2) = mjg( ilocs(2) ) 60 # 61 # 59 #endif 60 #if defined DIM_3d /* avoid warning when kindex has 2 elements */ 62 61 kindex(3) = ilocs(3) 63 # 62 #endif 64 63 ! 65 64 DEALLOCATE (ilocs) 66 65 ! 67 66 index0 = kindex(1)-1 ! 1d index starting at 0 68 # 67 #if defined DIM_2d || defined DIM_3d /* avoid warning when kindex has 1 element */ 69 68 index0 = index0 + jpiglo * (kindex(2)-1) 70 # 71 # 69 #endif 70 #if defined DIM_3d /* avoid warning when kindex has 2 elements */ 72 71 index0 = index0 + jpiglo * jpjglo * (kindex(3)-1) 73 # 72 #endif 74 73 END IF 75 74 zain(1,:) = zmin … … 77 76 ! 78 77 IF( ln_timing ) CALL tic_tac(.TRUE., ld_global = .TRUE.) 78 #if defined key_mpp_mpi 79 79 CALL MPI_ALLREDUCE( zain, zaout, 1, MPI_2DOUBLE_PRECISION, MPI_OPERATION ,MPI_COMM_OCE, ierror) 80 #else 81 zaout(:,:) = zain(:,:) 82 #endif 80 83 IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.) 81 84 ! 82 85 pmin = zaout(1,1) 83 86 index0 = NINT( zaout(2,1) ) 84 # 87 #if defined DIM_3d /* avoid warning when kindex has 2 elements */ 85 88 kindex(3) = index0 / (jpiglo*jpjglo) 86 89 index0 = index0 - kindex(3) * (jpiglo*jpjglo) 87 # 88 # 90 #endif 91 #if defined DIM_2d || defined DIM_3d /* avoid warning when kindex has 1 element */ 89 92 kindex(2) = index0 / jpiglo 90 93 index0 = index0 - kindex(2) * jpiglo 91 # 94 #endif 92 95 kindex(1) = index0 93 96 kindex(:) = kindex(:) + 1 ! start indices at 1 94 #else95 kindex = 0 ; pmin = 0.96 WRITE(*,*) 'ROUTINE_LOC: You should not have seen this print! error?'97 #endif98 97 99 98 END SUBROUTINE ROUTINE_LOC -
NEMO/trunk/src/OCE/OBS/obs_grid.F90
r10068 r12933 684 684 & fhistx1, fhistx2, fhisty1, fhisty2 685 685 REAL(wp) :: histtol 686 686 CHARACTER(LEN=26) :: clfmt ! writing format 687 INTEGER :: idg ! number of digits 688 687 689 IF (ln_grid_search_lookup) THEN 688 690 … … 709 711 710 712 IF ( ln_grid_global ) THEN 711 WRITE(cfname, FMT="(A,'_',A)") & 712 & TRIM(cn_gridsearchfile), 'global.nc' 713 WRITE(cfname, FMT="(A,'_',A)") TRIM(cn_gridsearchfile), 'global.nc' 713 714 ELSE 714 WRITE(cfname, FMT="(A,'_',I4.4,'of',I4.4,'by',I4.4,'.nc')") & 715 & TRIM(cn_gridsearchfile), nproc, jpni, jpnj 715 idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 716 ! define the following format: "(a,a,ix.x,a,ix.x,a,ix.x,a)" 717 WRITE(clfmt, "('(a,a,i', i1, '.', i1',a,i', i1, '.', i1',a,i', i1, '.', i1',a)')") idg, idg, idg, idg, idg, idg 718 WRITE(cfname, clfmt ) TRIM(cn_gridsearchfile),'_', nproc,'of', jpni,'by', jpnj,'.nc' 716 719 ENDIF 717 720 -
NEMO/trunk/src/OCE/OBS/obs_write.F90
r12377 r12933 86 86 CHARACTER(LEN=40) :: clfname 87 87 CHARACTER(LEN=10) :: clfiletype 88 CHARACTER(LEN=12) :: clfmt ! writing format 89 INTEGER :: idg ! number of digits 88 90 INTEGER :: ilevel 89 91 INTEGER :: jvar … … 181 183 fbdata%caddname(1) = 'Hx' 182 184 183 WRITE(clfname, FMT="(A,'_fdbk_',I4.4,'.nc')") TRIM(clfiletype), nproc 185 idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 186 WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg ! '(a,a,ix.x,a)' 187 WRITE(clfname,clfmt) TRIM(clfiletype), '_fdbk_', nproc, '.nc' 184 188 185 189 IF(lwp) THEN … … 326 330 CHARACTER(LEN=10) :: clfiletype 327 331 CHARACTER(LEN=12), PARAMETER :: cpname = 'obs_wri_surf' 332 CHARACTER(LEN=12) :: clfmt ! writing format 333 INTEGER :: idg ! number of digits 328 334 INTEGER :: jo 329 335 INTEGER :: ja … … 453 459 fbdata%caddname(1) = 'Hx' 454 460 455 WRITE(clfname, FMT="(A,'_fdbk_',I4.4,'.nc')") TRIM(clfiletype), nproc 461 idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 462 WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg ! '(a,a,ix.x,a)' 463 WRITE(clfname,clfmt) TRIM(clfiletype), '_fdbk_', nproc, '.nc' 456 464 457 465 IF(lwp) THEN -
NEMO/trunk/src/OCE/STO/stopar.F90
r12377 r12933 684 684 !! ** Purpose : read stochastic parameters from restart file 685 685 !!---------------------------------------------------------------------- 686 INTEGER :: jsto, jseed 686 INTEGER :: jsto, jseed 687 INTEGER :: idg ! number of digits 687 688 INTEGER(KIND=8) :: ziseed(4) ! RNG seeds in integer type 688 689 REAL(KIND=8) :: zrseed(4) ! RNG seeds in real type (with same bits to save in restart) 689 690 CHARACTER(LEN=9) :: clsto2d='sto2d_000' ! stochastic parameter variable name 690 691 CHARACTER(LEN=9) :: clsto3d='sto3d_000' ! stochastic parameter variable name 691 CHARACTER(LEN=10) :: clseed='seed0_0000' ! seed variable name 692 CHARACTER(LEN=15) :: clseed='seed0_0000' ! seed variable name 693 CHARACTER(LEN=6) :: clfmt ! writing format 692 694 !!---------------------------------------------------------------------- 693 695 … … 717 719 IF (ln_rstseed) THEN 718 720 ! Get saved state of the random number generator 721 idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 722 WRITE(clfmt, "('(i', i1, '.', i1, ')')") idg, idg ! "(ix.x)" 719 723 DO jseed = 1 , 4 720 WRITE(clseed(5:5) ,'(i1.1)') jseed721 WRITE(clseed(7: 10),'(i4.4)') narea722 CALL iom_get( numstor, clseed , zrseed(jseed) )724 WRITE(clseed(5:5) ,'(i1.1)') jseed 725 WRITE(clseed(7:7+idg-1), clfmt ) narea 726 CALL iom_get( numstor, clseed(1:7+idg-1) , zrseed(jseed) ) 723 727 END DO 724 728 ziseed = TRANSFER( zrseed , ziseed) … … 742 746 INTEGER, INTENT(in) :: kt ! ocean time-step 743 747 !! 744 INTEGER :: jsto, jseed 748 INTEGER :: jsto, jseed 749 INTEGER :: idg ! number of digits 745 750 INTEGER(KIND=8) :: ziseed(4) ! RNG seeds in integer type 746 751 REAL(KIND=8) :: zrseed(4) ! RNG seeds in real type (with same bits to save in restart) … … 749 754 CHARACTER(LEN=9) :: clsto2d='sto2d_000' ! stochastic parameter variable name 750 755 CHARACTER(LEN=9) :: clsto3d='sto3d_000' ! stochastic parameter variable name 751 CHARACTER(LEN=10) :: clseed='seed0_0000' ! seed variable name 756 CHARACTER(LEN=15) :: clseed='seed0_0000' ! seed variable name 757 CHARACTER(LEN=6) :: clfmt ! writing format 752 758 !!---------------------------------------------------------------------- 753 759 … … 771 777 CALL kiss_state( ziseed(1) , ziseed(2) , ziseed(3) , ziseed(4) ) 772 778 zrseed = TRANSFER( ziseed , zrseed) 779 idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 ) ! how many digits to we need to write? min=4, max=9 780 WRITE(clfmt, "('(i', i1, '.', i1, ')')") idg, idg ! "(ix.x)" 773 781 DO jseed = 1 , 4 774 WRITE(clseed(5:5) ,'(i1.1)') jseed775 WRITE(clseed(7: 10),'(i4.4)') narea776 CALL iom_rstput( kt, nitrst, numstow, clseed 782 WRITE(clseed(5:5) ,'(i1.1)') jseed 783 WRITE(clseed(7:7+idg-1), clfmt ) narea 784 CALL iom_rstput( kt, nitrst, numstow, clseed(1:7+idg-1), zrseed(jseed) ) 777 785 END DO 778 786 ! 2D stochastic parameters -
NEMO/trunk/src/OCE/nemogcm.F90
r12641 r12933 186 186 END DO 187 187 ! 188 IF( .NOT. Agrif_Root() ) THEN189 CALL Agrif_ParentGrid_To_ChildGrid()190 IF( ln_diaobs ) CALL dia_obs_wri191 IF( ln_timing ) CALL timing_finalize192 CALL Agrif_ChildGrid_To_ParentGrid()193 ENDIF194 !195 188 # else 196 189 ! … … 237 230 IF( nstop /= 0 .AND. lwp ) THEN ! error print 238 231 WRITE(ctmp1,*) ' ==>>> nemo_gcm: a total of ', nstop, ' errors have been found' 239 CALL ctl_stop( ctmp1 ) 232 IF( ngrdstop > 0 ) THEN 233 WRITE(ctmp9,'(i2)') ngrdstop 234 WRITE(ctmp2,*) ' ==>>> Error detected in Agrif grid '//TRIM(ctmp9) 235 WRITE(ctmp3,*) ' ==>>> look for error messages in '//TRIM(ctmp9)//'_ocean_output* files' 236 CALL ctl_stop( ctmp1, ctmp2, ctmp3 ) 237 ELSE 238 CALL ctl_stop( ctmp1 ) 239 ENDIF 240 240 ENDIF 241 241 ! … … 335 335 ! 336 336 ! finalize the definition of namctl variables 337 IF( sn_cfctl%l_allon ) THEN 338 ! Turn on all options. 339 CALL nemo_set_cfctl( sn_cfctl, .TRUE., .TRUE. ) 340 ! Ensure all processors are active 341 sn_cfctl%procmin = 0 ; sn_cfctl%procmax = 1000000 ; sn_cfctl%procincr = 1 342 ELSEIF( sn_cfctl%l_config ) THEN 343 ! Activate finer control of report outputs 344 ! optionally switch off output from selected areas (note this only 345 ! applies to output which does not involve global communications) 346 IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax ) .OR. & 347 & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) ) & 348 & CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. ) 349 ELSE 350 ! turn off all options. 351 CALL nemo_set_cfctl( sn_cfctl, .FALSE., .TRUE. ) 352 ENDIF 337 IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) & 338 & CALL nemo_set_cfctl( sn_cfctl, .FALSE. ) 353 339 ! 354 340 lwp = (narea == 1) .OR. sn_cfctl%l_oceout ! control of all listing output print … … 534 520 WRITE(numout,*) '~~~~~~~~' 535 521 WRITE(numout,*) ' Namelist namctl' 536 WRITE(numout,*) ' sn_cfctl%l_glochk = ', sn_cfctl%l_glochk537 WRITE(numout,*) ' sn_cfctl%l_allon = ', sn_cfctl%l_allon538 WRITE(numout,*) ' finer control over o/p sn_cfctl%l_config = ', sn_cfctl%l_config539 522 WRITE(numout,*) ' sn_cfctl%l_runstat = ', sn_cfctl%l_runstat 540 523 WRITE(numout,*) ' sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat … … 684 667 685 668 686 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto , for_all)669 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto ) 687 670 !!---------------------------------------------------------------------- 688 671 !! *** ROUTINE nemo_set_cfctl *** 689 672 !! 690 673 !! ** Purpose : Set elements of the output control structure to setto. 691 !! for_all should be .false. unless all areas are to be692 !! treated identically.693 674 !! 694 675 !! ** Method : Note this routine can be used to switch on/off some 695 !! types of output for selected areas but any output types 696 !! that involve global communications (e.g. mpp_max, glob_sum) 697 !! should be protected from selective switching by the 698 !! for_all argument 699 !!---------------------------------------------------------------------- 700 LOGICAL :: setto, for_all 701 TYPE(sn_ctl) :: sn_cfctl 702 !!---------------------------------------------------------------------- 703 IF( for_all ) THEN 704 sn_cfctl%l_runstat = setto 705 sn_cfctl%l_trcstat = setto 706 ENDIF 676 !! types of output for selected areas. 677 !!---------------------------------------------------------------------- 678 TYPE(sn_ctl), INTENT(inout) :: sn_cfctl 679 LOGICAL , INTENT(in ) :: setto 680 !!---------------------------------------------------------------------- 681 sn_cfctl%l_runstat = setto 682 sn_cfctl%l_trcstat = setto 707 683 sn_cfctl%l_oceout = setto 708 684 sn_cfctl%l_layout = setto -
NEMO/trunk/src/OCE/step.F90
r12650 r12933 82 82 !!---------------------------------------------------------------------- 83 83 INTEGER :: ji, jj, jk ! dummy loop indice 84 INTEGER :: indic ! error indicator if < 085 84 !!gm kcall can be removed, I guess 86 85 INTEGER :: kcall ! optional integer argument (dom_vvl_sf_nxt) 87 86 !! --------------------------------------------------------------------- 88 87 #if defined key_agrif 89 IF( nstop > 0 ) return ! avoid to go further if an error was detected during previous time step88 IF( nstop > 0 ) RETURN ! avoid to go further if an error was detected during previous time step (child grid) 90 89 kstp = nit000 + Agrif_Nb_Step() 91 90 Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices … … 115 114 ! update I/O and calendar 116 115 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 117 indic = 0 ! reset to no error condition118 119 116 IF( kstp == nit000 ) THEN ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS) 120 CALL iom_init( cxios_context, ld_closedef=.FALSE. ) ! for model grid (including p assible AGRIF zoom)117 CALL iom_init( cxios_context, ld_closedef=.FALSE. ) ! for model grid (including possible AGRIF zoom) 121 118 IF( lk_diamlr ) CALL dia_mlr_iom_init ! with additional setup for multiple-linear-regression analysis 122 119 CALL iom_init_closedef … … 314 311 Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices 315 312 CALL Agrif_Integrate_ChildGrids( stp ) ! allows to finish all the Child Grids before updating 313 316 314 #endif 317 315 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 318 316 ! Control 319 317 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 320 CALL stp_ctl ( kstp, Nbb, Nnn, indic ) 318 CALL stp_ctl ( kstp, Nnn ) 319 321 320 #if defined key_agrif 322 321 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> … … 326 325 CALL Agrif_update_all( ) ! Update all components 327 326 ENDIF 328 #endif 329 IF( ln_diaobs ) CALL dia_obs ( kstp, Nnn ) ! obs-minus-model (assimilation) diagnostics (call after dynamics update) 327 328 #endif 329 IF( ln_diaobs .AND. nstop == 0 ) CALL dia_obs( kstp, Nnn ) ! obs-minus-model (assimilation) diags (after dynamics update) 330 330 331 331 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> … … 341 341 ! Coupled mode 342 342 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 343 !!gm why lk_oasis and not lk_cpl ???? 344 IF( lk_oasis ) CALL sbc_cpl_snd( kstp, Nbb, Nnn ) ! coupled mode : field exchanges 343 IF( lk_oasis .AND. nstop == 0 ) CALL sbc_cpl_snd( kstp, Nbb, Nnn ) ! coupled mode : field exchanges 345 344 ! 346 345 #if defined key_iomput … … 348 347 ! Finalize contextes if end of simulation or error detected 349 348 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 350 IF( kstp == nitend .OR. indic <0 ) THEN349 IF( kstp == nitend .OR. nstop > 0 ) THEN 351 350 CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF 352 351 IF( lrxios ) CALL iom_context_finalize( crxios_context ) -
NEMO/trunk/src/OCE/stpctl.F90
r12377 r12933 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 … … 33 33 PUBLIC stp_ctl ! routine called by step.F90 34 34 35 INTEGER :: idrun, idtime, idssh, idu, ids1, ids2, idt1, idt2, idc1, idw1, istatus36 LOGICAL :: lsomeoce35 INTEGER :: nrunid ! netcdf file id 36 INTEGER, DIMENSION(8) :: nvarid ! netcdf variable id 37 37 !!---------------------------------------------------------------------- 38 38 !! NEMO/OCE 4.0 , NEMO Consortium (2018) … … 42 42 CONTAINS 43 43 44 SUBROUTINE stp_ctl( kt, K bb, Kmm, kindic)44 SUBROUTINE stp_ctl( kt, Kmm ) 45 45 !!---------------------------------------------------------------------- 46 46 !! *** ROUTINE stp_ctl *** … … 50 50 !! ** Method : - Save the time step in numstp 51 51 !! - Print it each 50 time steps 52 !! - Stop the run IF problem encountered by setting indic=-352 !! - Stop the run IF problem encountered by setting nstop > 0 53 53 !! Problems checked: |ssh| maximum larger than 10 m 54 54 !! |U| maximum larger than 10 m/s … … 57 57 !! ** Actions : "time.step" file = last ocean time-step 58 58 !! "run.stat" file = run statistics 59 !! nstop indicator sheared among all local domain (lk_mpp=T)59 !! nstop indicator sheared among all local domain 60 60 !!---------------------------------------------------------------------- 61 61 INTEGER, INTENT(in ) :: kt ! ocean time-step index 62 INTEGER, INTENT(in ) :: Kbb, Kmm ! ocean time level index 63 INTEGER, INTENT(inout) :: kindic ! error indicator 64 !! 65 INTEGER :: ji, jj, jk ! dummy loop indices 66 INTEGER, DIMENSION(2) :: ih ! min/max loc indices 67 INTEGER, DIMENSION(3) :: iu, is1, is2 ! min/max loc indices 68 REAL(wp) :: zzz ! local real 69 REAL(wp), DIMENSION(9) :: zmax 70 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 71 CHARACTER(len=20) :: clname 72 !!---------------------------------------------------------------------- 73 ! 74 ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 75 ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) 76 ll_wrtruns = ll_colruns .AND. lwm 77 IF( kt == nit000 .AND. lwp ) THEN 78 WRITE(numout,*) 79 WRITE(numout,*) 'stp_ctl : time-stepping control' 80 WRITE(numout,*) '~~~~~~~' 81 ! ! open time.step file 82 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 83 ! ! open run.stat file(s) at start whatever 84 ! ! the value of sn_cfctl%ptimincr 85 IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN 62 INTEGER, INTENT(in ) :: Kmm ! ocean time level index 63 !! 64 INTEGER :: ji ! dummy loop indices 65 INTEGER :: idtime, istatus 66 INTEGER , DIMENSION(9) :: iareasum, iareamin, iareamax 67 INTEGER , DIMENSION(3,4) :: iloc ! min/max loc indices 68 REAL(wp) :: zzz ! local real 69 REAL(wp), DIMENSION(9) :: zmax, zmaxlocal 70 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 71 LOGICAL, DIMENSION(jpi,jpj,jpk) :: llmsk 72 CHARACTER(len=20) :: clname 73 !!---------------------------------------------------------------------- 74 IF( nstop > 0 .AND. ngrdstop > -1 ) RETURN ! stpctl was already called by a child grid 75 ! 76 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 77 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 78 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 79 ! 80 IF( kt == nit000 ) THEN 81 ! 82 IF( lwp ) THEN 83 WRITE(numout,*) 84 WRITE(numout,*) 'stp_ctl : time-stepping control' 85 WRITE(numout,*) '~~~~~~~' 86 ENDIF 87 ! ! open time.step ascii file, done only by 1st subdomain 88 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 89 ! 90 IF( ll_wrtruns ) THEN 91 ! ! open run.stat ascii file, done only by 1st subdomain 86 92 CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 93 ! ! open run.stat.nc netcdf file, done only by 1st subdomain 87 94 clname = 'run.stat.nc' 88 95 IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 89 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun)90 istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime )91 istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh)92 istatus = NF90_DEF_VAR( idrun, 'abs_u_max', NF90_DOUBLE, (/ idtime /), idu)93 istatus = NF90_DEF_VAR( idrun, 's_min', NF90_DOUBLE, (/ idtime /), ids1)94 istatus = NF90_DEF_VAR( idrun, 's_max', NF90_DOUBLE, (/ idtime /), ids2)95 istatus = NF90_DEF_VAR( idrun, 't_min', NF90_DOUBLE, (/ idtime /), idt1)96 istatus = NF90_DEF_VAR( idrun, 't_max', NF90_DOUBLE, (/ idtime /), idt2)96 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 97 istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) 98 istatus = NF90_DEF_VAR( nrunid, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) 99 istatus = NF90_DEF_VAR( nrunid, 'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 100 istatus = NF90_DEF_VAR( nrunid, 's_min', NF90_DOUBLE, (/ idtime /), nvarid(3) ) 101 istatus = NF90_DEF_VAR( nrunid, 's_max', NF90_DOUBLE, (/ idtime /), nvarid(4) ) 102 istatus = NF90_DEF_VAR( nrunid, 't_min', NF90_DOUBLE, (/ idtime /), nvarid(5) ) 103 istatus = NF90_DEF_VAR( nrunid, 't_max', NF90_DOUBLE, (/ idtime /), nvarid(6) ) 97 104 IF( ln_zad_Aimp ) THEN 98 istatus = NF90_DEF_VAR( idrun, 'abs_wi_max', NF90_DOUBLE, (/ idtime /), idw1)99 istatus = NF90_DEF_VAR( idrun, 'Cf_max', NF90_DOUBLE, (/ idtime /), idc1)105 istatus = NF90_DEF_VAR( nrunid, 'Cf_max', NF90_DOUBLE, (/ idtime /), nvarid(7) ) 106 istatus = NF90_DEF_VAR( nrunid,'abs_wi_max',NF90_DOUBLE, (/ idtime /), nvarid(8) ) 100 107 ENDIF 101 istatus = NF90_ENDDEF(idrun) 102 zmax(8:9) = 0._wp ! initialise to zero in case ln_zad_Aimp option is not in use 103 ENDIF 104 ENDIF 105 IF( kt == nit000 ) lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 106 ! 107 IF(lwm .AND. ll_wrtstp) THEN !== current time step ==! ("time.step" file) 108 istatus = NF90_ENDDEF(nrunid) 109 ENDIF 110 ! 111 ENDIF 112 ! 113 ! !== write current time step ==! 114 ! !== done only by 1st subdomain at writting timestep ==! 115 IF( lwm .AND. ll_wrtstp ) THEN 108 116 WRITE ( numstp, '(1x, i8)' ) kt 109 117 REWIND( numstp ) 110 118 ENDIF 111 ! 112 ! !== test of extrema ==! 119 ! !== test of local extrema ==! 120 ! !== done by all processes at every time step ==! 121 llmsk(:,:,1) = ssmask(:,:) == 1._wp 113 122 IF( ll_wd ) THEN 114 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref*tmask(:,:,1) ) ) ! ssh max123 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) ) ! ssh max 115 124 ELSE 116 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) ) ) ! ssh max 117 ENDIF 118 zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ) ) ! velocity max (zonal only) 119 zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! minus salinity max 120 zmax(4) = MAXVAL( ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! salinity max 121 zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! minus temperature max 122 zmax(6) = MAXVAL( ts(:,:,:,jp_tem,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! temperature max 123 zmax(7) = REAL( nstop , wp ) ! stop indicator 124 IF( ln_zad_Aimp ) THEN 125 zmax(8) = MAXVAL( ABS( wi(:,:,:) ) , mask = wmask(:,:,:) == 1._wp ) ! implicit vertical vel. max 126 zmax(9) = MAXVAL( Cu_adv(:,:,:) , mask = tmask(:,:,:) == 1._wp ) ! partitioning coeff. max 127 ENDIF 128 ! 125 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) ), mask = llmsk(:,:,1) ) ! ssh max 126 ENDIF 127 llmsk(:,:,:) = umask(:,:,:) == 1._wp 128 zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ), mask = llmsk ) ! velocity max (zonal only) 129 llmsk(:,:,:) = tmask(:,:,:) == 1._wp 130 zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk ) ! minus salinity max 131 zmax(4) = MAXVAL( ts(:,:,:,jp_sal,Kmm), mask = llmsk ) ! salinity max 132 IF( ll_colruns ) THEN ! following variables are used only in the netcdf file 133 zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm), mask = llmsk ) ! minus temperature max 134 zmax(6) = MAXVAL( ts(:,:,:,jp_tem,Kmm), mask = llmsk ) ! temperature max 135 IF( ln_zad_Aimp ) THEN 136 zmax(7) = MAXVAL( Cu_adv(:,:,:) , mask = llmsk ) ! partitioning coeff. max 137 llmsk(:,:,:) = wmask(:,:,:) == 1._wp 138 zmax(8) = MAXVAL( ABS( wi(:,:,:) ) , mask = llmsk ) ! implicit vertical vel. max 139 ELSE 140 zmax(7:8) = 0._wp 141 ENDIF 142 ELSE 143 zmax(5:8) = 0._wp 144 ENDIF 145 zmax(9) = REAL( nstop, wp ) ! stop indicator 146 ! !== get global extrema ==! 147 ! !== done by all processes if writting run.stat ==! 129 148 IF( ll_colruns ) THEN 149 zmaxlocal(:) = zmax(:) 130 150 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 131 nstop = NINT( zmax(7) ) ! nstop indicator sheared among all local domains 132 ENDIF 133 ! !== run statistics ==! ("run.stat" files) 151 nstop = NINT( zmax(9) ) ! update nstop indicator (now sheared among all local domains) 152 ENDIF 153 ! !== write "run.stat" files ==! 154 ! !== done only by 1st subdomain at writting timestep ==! 134 155 IF( ll_wrtruns ) THEN 135 156 WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4) 136 istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )137 istatus = NF90_PUT_VAR( idrun, idu, (/ zmax(2)/), (/kt/), (/1/) )138 istatus = NF90_PUT_VAR( idrun, ids1, (/-zmax(3)/), (/kt/), (/1/) )139 istatus = NF90_PUT_VAR( idrun, ids2, (/ zmax(4)/), (/kt/), (/1/) )140 istatus = NF90_PUT_VAR( idrun, idt1, (/-zmax(5)/), (/kt/), (/1/) )141 istatus = NF90_PUT_VAR( idrun, idt2, (/ zmax(6)/), (/kt/), (/1/) )157 istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 158 istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 159 istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) ) 160 istatus = NF90_PUT_VAR( nrunid, nvarid(4), (/ zmax(4)/), (/kt/), (/1/) ) 161 istatus = NF90_PUT_VAR( nrunid, nvarid(5), (/-zmax(5)/), (/kt/), (/1/) ) 162 istatus = NF90_PUT_VAR( nrunid, nvarid(6), (/ zmax(6)/), (/kt/), (/1/) ) 142 163 IF( ln_zad_Aimp ) THEN 143 istatus = NF90_PUT_VAR( idrun, idw1, (/ zmax(8)/), (/kt/), (/1/) ) 144 istatus = NF90_PUT_VAR( idrun, idc1, (/ zmax(9)/), (/kt/), (/1/) ) 145 ENDIF 146 IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) 147 IF( kt == nitend ) istatus = NF90_CLOSE(idrun) 164 istatus = NF90_PUT_VAR( nrunid, nvarid(7), (/ zmax(7)/), (/kt/), (/1/) ) 165 istatus = NF90_PUT_VAR( nrunid, nvarid(8), (/ zmax(8)/), (/kt/), (/1/) ) 166 ENDIF 167 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 148 168 END IF 149 ! !== error handling ==! 150 IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. ( & ! domain contains some ocean points, check for sensible ranges 151 & zmax(1) > 20._wp .OR. & ! too large sea surface height ( > 20 m ) 152 & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) 153 & zmax(3) >= 0._wp .OR. & ! negative or zero sea surface salinity 154 & zmax(4) >= 100._wp .OR. & ! too large sea surface salinity ( > 100 ) 155 & zmax(4) < 0._wp .OR. & ! too large sea surface salinity (keep this line for sea-ice) 156 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN ! NaN encounter in the tests 157 IF( lk_mpp .AND. sn_cfctl%l_glochk ) THEN 158 ! have use mpp_max (because sn_cfctl%l_glochk=.T. and distributed) 159 CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,Kmm)) , ssmask(:,:) , zzz, ih ) 160 CALL mpp_maxloc( 'stpctl', ABS(uu(:,:,:,Kmm)) , umask (:,:,:), zzz, iu ) 161 CALL mpp_minloc( 'stpctl', ts(:,:,:,jp_sal,Kmm), tmask (:,:,:), zzz, is1 ) 162 CALL mpp_maxloc( 'stpctl', ts(:,:,:,jp_sal,Kmm), tmask (:,:,:), zzz, is2 ) 169 ! !== error handling ==! 170 ! !== done by all processes at every time step ==! 171 ! 172 IF( zmax(1) > 20._wp .OR. & ! too large sea surface height ( > 20 m ) 173 & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) 174 & zmax(3) >= 0._wp .OR. & ! negative or zero sea surface salinity 175 & zmax(4) >= 100._wp .OR. & ! too large sea surface salinity ( > 100 ) 176 & zmax(4) < 0._wp .OR. & ! too large sea surface salinity (keep this line for sea-ice) 177 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR. & ! NaN encounter in the tests 178 & ABS( zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests 179 ! 180 iloc(:,:) = 0 181 IF( ll_colruns ) THEN ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 182 ! first: close the netcdf file, so we can read it 183 IF( lwm .AND. kt /= nitend ) istatus = NF90_CLOSE(nrunid) 184 ! get global loc on the min/max 185 CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:, Kmm)), ssmask(:,: ), zzz, iloc(1:2,1) ) ! mpp_maxloc ok if mask = F 186 CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:, Kmm)), umask(:,:,:), zzz, iloc(1:3,2) ) 187 CALL mpp_minloc( 'stpctl', ts(:,:,:,jp_sal,Kmm) , tmask(:,:,:), zzz, iloc(1:3,3) ) 188 CALL mpp_maxloc( 'stpctl', ts(:,:,:,jp_sal,Kmm) , tmask(:,:,:), zzz, iloc(1:3,4) ) 189 ! find which subdomain has the max. 190 iareamin(:) = jpnij+1 ; iareamax(:) = 0 ; iareasum(:) = 0 191 DO ji = 1, 9 192 IF( zmaxlocal(ji) == zmax(ji) ) THEN 193 iareamin(ji) = narea ; iareamax(ji) = narea ; iareasum(ji) = 1 194 ENDIF 195 END DO 196 CALL mpp_min( "stpctl", iareamin ) ! min over the global domain 197 CALL mpp_max( "stpctl", iareamax ) ! max over the global domain 198 CALL mpp_sum( "stpctl", iareasum ) ! sum over the global domain 199 ELSE ! find local min and max locations: 200 ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 201 iloc(1:2,1) = MAXLOC( ABS( ssh(:,:, Kmm)), mask = ssmask(:,: ) == 1._wp ) + (/ nimpp - 1, njmpp - 1 /) 202 iloc(1:3,2) = MAXLOC( ABS( uu(:,:,:, Kmm)), mask = umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 203 iloc(1:3,3) = MINLOC( ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 204 iloc(1:3,4) = MAXLOC( ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 205 iareamin(:) = narea ; iareamax(:) = narea ; iareasum(:) = 1 ! this is local information 206 ENDIF 207 ! 208 WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests' 209 CALL wrt_line( ctmp2, kt, '|ssh| max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 210 CALL wrt_line( ctmp3, kt, '|U| max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 211 CALL wrt_line( ctmp4, kt, 'Sal min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 212 CALL wrt_line( ctmp5, kt, 'Sal max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) ) 213 IF( Agrif_Root() ) THEN 214 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort* files' 163 215 ELSE 164 ! find local min and max locations 165 ih(:) = MAXLOC( ABS( ssh(:,:,Kmm) ) ) + (/ nimpp - 1, njmpp - 1 /) 166 iu(:) = MAXLOC( ABS( uu (:,:,:,Kmm) ) ) + (/ nimpp - 1, njmpp - 1, 0 /) 167 is1(:) = MINLOC( ts(:,:,:,jp_sal,Kmm), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 168 is2(:) = MAXLOC( ts(:,:,:,jp_sal,Kmm), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 169 ENDIF 170 171 WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests' 172 WRITE(ctmp2,9100) kt, zmax(1), ih(1) , ih(2) 173 WRITE(ctmp3,9200) kt, zmax(2), iu(1) , iu(2) , iu(3) 174 WRITE(ctmp4,9300) kt, - zmax(3), is1(1), is1(2), is1(3) 175 WRITE(ctmp5,9400) kt, zmax(4), is2(1), is2(2), is2(3) 176 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort.nc file' 177 216 WRITE(ctmp6,*) ' ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 217 ENDIF 218 ! 178 219 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 179 180 IF( .NOT. sn_cfctl%l_glochk ) THEN 181 WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea 182 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp8, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ctmp6 ) 183 ELSE 184 CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6, ' ' ) 185 ENDIF 186 187 kindic = -3 188 ! 189 ENDIF 190 ! 191 9100 FORMAT (' kt=',i8,' |ssh| max: ',1pg11.4,', at i j : ',2i5) 192 9200 FORMAT (' kt=',i8,' |U| max: ',1pg11.4,', at i j k: ',3i5) 193 9300 FORMAT (' kt=',i8,' S min: ',1pg11.4,', at i j k: ',3i5) 194 9400 FORMAT (' kt=',i8,' S max: ',1pg11.4,', at i j k: ',3i5) 220 ! 221 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 222 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 223 ELSE ! only mpi subdomains with errors are here -> STOP now 224 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 225 ENDIF 226 ! 227 IF( nstop == 0 ) nstop = 1 228 ngrdstop = Agrif_Fixed() 229 ! 230 ENDIF 231 ! 195 232 9500 FORMAT(' it :', i8, ' |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16) 196 233 ! 197 234 END SUBROUTINE stp_ctl 235 236 237 SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax ) 238 !!---------------------------------------------------------------------- 239 !! *** ROUTINE wrt_line *** 240 !! 241 !! ** Purpose : write information line 242 !! 243 !!---------------------------------------------------------------------- 244 CHARACTER(len=*), INTENT( out) :: cdline 245 CHARACTER(len=*), INTENT(in ) :: cdprefix 246 REAL(wp), INTENT(in ) :: pval 247 INTEGER, DIMENSION(3), INTENT(in ) :: kloc 248 INTEGER, INTENT(in ) :: kt, ksum, kmin, kmax 249 ! 250 CHARACTER(len=80) :: clsuff 251 CHARACTER(len=9 ) :: clkt, clsum, clmin, clmax 252 CHARACTER(len=9 ) :: cli, clj, clk 253 CHARACTER(len=1 ) :: clfmt 254 CHARACTER(len=4 ) :: cl4 ! needed to be able to compile with Agrif, I don't know why 255 INTEGER :: ifmtk 256 !!---------------------------------------------------------------------- 257 WRITE(clkt , '(i9)') kt 258 259 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij ,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 260 !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF 261 cl4 = '(i'//clfmt//')' ; WRITE(clsum, cl4) ksum 262 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij-1,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 263 cl4 = '(i'//clfmt//')' ; WRITE(clmin, cl4) kmin-1 264 WRITE(clmax, cl4) kmax-1 265 ! 266 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1 ! how many digits to we need to write jpiglo? (we decide max = 9) 267 cl4 = '(i'//clfmt//')' ; WRITE(cli, cl4) kloc(1) ! this is ok with AGRIF 268 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1 ! how many digits to we need to write jpjglo? (we decide max = 9) 269 cl4 = '(i'//clfmt//')' ; WRITE(clj, cl4) kloc(2) ! this is ok with AGRIF 270 ! 271 IF( ksum == 1 ) THEN ; WRITE(clsuff,9100) TRIM(clmin) 272 ELSE ; WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax) 273 ENDIF 274 IF(kloc(3) == 0) THEN 275 ifmtk = INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 276 clk = REPEAT(' ', ifmtk) ! create the equivalent in blank string 277 WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff) 278 ELSE 279 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 280 !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF 281 cl4 = '(i'//clfmt//')' ; WRITE(clk, cl4) kloc(3) ! this is ok with AGRIF 282 WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), TRIM(clk), TRIM(clsuff) 283 ENDIF 284 ! 285 9100 FORMAT('MPI rank ', a) 286 9200 FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a) 287 9300 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j ', a, ' ', a, ' ', a, ' ', a) 288 9400 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a) 289 ! 290 END SUBROUTINE wrt_line 291 198 292 199 293 !!====================================================================== -
NEMO/trunk/src/OFF/nemogcm.F90
r12843 r12933 92 92 !! Madec, 2008, internal report, IPSL. 93 93 !!---------------------------------------------------------------------- 94 INTEGER :: istp , indic! time step index94 INTEGER :: istp ! time step index 95 95 !!---------------------------------------------------------------------- 96 96 … … 132 132 IF( .NOT.ln_linssh ) CALL dta_dyn_sf_interp( istp, Nnn ) ! calculate now grid parameters 133 133 #endif 134 CALL stp_ctl ( istp , indic )! Time loop: control and print134 CALL stp_ctl ( istp ) ! Time loop: control and print 135 135 istp = istp + 1 136 136 END DO … … 229 229 ! 230 230 ! finalize the definition of namctl variables 231 IF( sn_cfctl%l_allon ) THEN 232 ! Turn on all options. 233 CALL nemo_set_cfctl( sn_cfctl, .TRUE., .TRUE. ) 234 ! Ensure all processors are active 235 sn_cfctl%procmin = 0 ; sn_cfctl%procmax = 1000000 ; sn_cfctl%procincr = 1 236 ELSEIF( sn_cfctl%l_config ) THEN 237 ! Activate finer control of report outputs 238 ! optionally switch off output from selected areas (note this only 239 ! applies to output which does not involve global communications) 240 IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax ) .OR. & 241 & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) ) & 242 & CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. ) 243 ELSE 244 ! turn off all options. 245 CALL nemo_set_cfctl( sn_cfctl, .FALSE., .TRUE. ) 246 ENDIF 231 IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) & 232 & CALL nemo_set_cfctl( sn_cfctl, .FALSE. ) 247 233 ! 248 234 lwp = (narea == 1) .OR. sn_cfctl%l_oceout ! control of all listing output print … … 373 359 WRITE(numout,*) '~~~~~~~~' 374 360 WRITE(numout,*) ' Namelist namctl' 375 WRITE(numout,*) ' sn_cfctl%l_glochk = ', sn_cfctl%l_glochk376 WRITE(numout,*) ' sn_cfctl%l_allon = ', sn_cfctl%l_allon377 WRITE(numout,*) ' finer control over o/p sn_cfctl%l_config = ', sn_cfctl%l_config378 361 WRITE(numout,*) ' sn_cfctl%l_runstat = ', sn_cfctl%l_runstat 379 362 WRITE(numout,*) ' sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat … … 511 494 END SUBROUTINE nemo_alloc 512 495 513 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto , for_all)496 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto ) 514 497 !!---------------------------------------------------------------------- 515 498 !! *** ROUTINE nemo_set_cfctl *** 516 499 !! 517 500 !! ** Purpose : Set elements of the output control structure to setto. 518 !! for_all should be .false. unless all areas are to be 519 !! treated identically. 520 !! 501 !! 521 502 !! ** Method : Note this routine can be used to switch on/off some 522 !! types of output for selected areas but any output types 523 !! that involve global communications (e.g. mpp_max, glob_sum) 524 !! should be protected from selective switching by the 525 !! for_all argument 526 !!---------------------------------------------------------------------- 527 LOGICAL :: setto, for_all 528 TYPE(sn_ctl) :: sn_cfctl 529 !!---------------------------------------------------------------------- 530 IF( for_all ) THEN 531 sn_cfctl%l_runstat = setto 532 sn_cfctl%l_trcstat = setto 533 ENDIF 503 !! types of output for selected areas. 504 !!---------------------------------------------------------------------- 505 TYPE(sn_ctl), INTENT(inout) :: sn_cfctl 506 LOGICAL , INTENT(in ) :: setto 507 !!---------------------------------------------------------------------- 508 sn_cfctl%l_runstat = setto 509 sn_cfctl%l_trcstat = setto 534 510 sn_cfctl%l_oceout = setto 535 511 sn_cfctl%l_layout = setto … … 561 537 562 538 563 SUBROUTINE stp_ctl( kt , kindic)539 SUBROUTINE stp_ctl( kt ) 564 540 !!---------------------------------------------------------------------- 565 541 !! *** ROUTINE stp_ctl *** … … 572 548 !!---------------------------------------------------------------------- 573 549 INTEGER, INTENT(in ) :: kt ! ocean time-step index 574 INTEGER, INTENT(inout) :: kindic ! indicator of solver convergence575 550 !!---------------------------------------------------------------------- 576 551 ! -
NEMO/trunk/src/SAO/nemogcm.F90
r12641 r12933 158 158 ! 159 159 ! finalize the definition of namctl variables 160 IF( sn_cfctl%l_allon ) THEN 161 ! Turn on all options. 162 CALL nemo_set_cfctl( sn_cfctl, .TRUE., .TRUE. ) 163 ! Ensure all processors are active 164 sn_cfctl%procmin = 0 ; sn_cfctl%procmax = 1000000 ; sn_cfctl%procincr = 1 165 ELSEIF( sn_cfctl%l_config ) THEN 166 ! Activate finer control of report outputs 167 ! optionally switch off output from selected areas (note this only 168 ! applies to output which does not involve global communications) 169 IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax ) .OR. & 170 & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) ) & 171 & CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. ) 172 ELSE 173 ! turn off all options. 174 CALL nemo_set_cfctl( sn_cfctl, .FALSE., .TRUE. ) 175 ENDIF 160 IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) & 161 & CALL nemo_set_cfctl( sn_cfctl, .FALSE. ) 176 162 ! 177 163 lwp = (narea == 1) .OR. sn_cfctl%l_oceout ! control of all listing output print … … 270 256 WRITE(numout,*) '~~~~~~~~' 271 257 WRITE(numout,*) ' Namelist namctl' 272 WRITE(numout,*) ' sn_cfctl%l_glochk = ', sn_cfctl%l_glochk273 WRITE(numout,*) ' sn_cfctl%l_allon = ', sn_cfctl%l_allon274 WRITE(numout,*) ' finer control over o/p sn_cfctl%l_config = ', sn_cfctl%l_config275 258 WRITE(numout,*) ' sn_cfctl%l_runstat = ', sn_cfctl%l_runstat 276 259 WRITE(numout,*) ' sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat … … 410 393 END SUBROUTINE nemo_alloc 411 394 412 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto , for_all)395 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto ) 413 396 !!---------------------------------------------------------------------- 414 397 !! *** ROUTINE nemo_set_cfctl *** 415 398 !! 416 399 !! ** Purpose : Set elements of the output control structure to setto. 417 !! for_all should be .false. unless all areas are to be418 !! treated identically.419 400 !! 420 401 !! ** Method : Note this routine can be used to switch on/off some 421 !! types of output for selected areas but any output types 422 !! that involve global communications (e.g. mpp_max, glob_sum) 423 !! should be protected from selective switching by the 424 !! for_all argument 425 !!---------------------------------------------------------------------- 426 LOGICAL :: setto, for_all 427 TYPE(sn_ctl) :: sn_cfctl 428 !!---------------------------------------------------------------------- 429 IF( for_all ) THEN 430 sn_cfctl%l_runstat = setto 431 sn_cfctl%l_trcstat = setto 432 ENDIF 402 !! types of output for selected areas. 403 !!---------------------------------------------------------------------- 404 TYPE(sn_ctl), INTENT(inout) :: sn_cfctl 405 LOGICAL , INTENT(in ) :: setto 406 !!---------------------------------------------------------------------- 407 sn_cfctl%l_runstat = setto 408 sn_cfctl%l_trcstat = setto 433 409 sn_cfctl%l_oceout = setto 434 410 sn_cfctl%l_layout = setto -
NEMO/trunk/src/SAS/diawri.F90
r12649 r12933 138 138 !! Each nn_write time step, output the instantaneous or mean fields 139 139 !!---------------------------------------------------------------------- 140 !!141 140 INTEGER, INTENT( in ) :: kt ! ocean time-step index 142 INTEGER, INTENT( in ) :: Kmm ! ocean time level index141 INTEGER, INTENT( in ) :: Kmm ! ocean time level index 143 142 !! 144 143 LOGICAL :: ll_print = .FALSE. ! =T print and flush numout … … 462 461 CALL iom_close( inum ) 463 462 ENDIF 464 #endif 465 463 ! 464 #endif 466 465 END SUBROUTINE dia_wri_state 467 466 -
NEMO/trunk/src/SAS/nemogcm.F90
r12641 r12933 126 126 END DO 127 127 ! 128 IF( .NOT. Agrif_Root() ) THEN129 CALL Agrif_ParentGrid_To_ChildGrid()130 IF( ln_timing ) CALL timing_finalize131 CALL Agrif_ChildGrid_To_ParentGrid()132 ENDIF133 !134 128 #else 135 129 ! … … 166 160 IF( nstop /= 0 .AND. lwp ) THEN ! error print 167 161 WRITE(ctmp1,*) ' ==>>> nemo_gcm: a total of ', nstop, ' errors have been found' 168 CALL ctl_stop( ctmp1 ) 162 IF( ngrdstop > 0 ) THEN 163 WRITE(ctmp9,'(i2)') ngrdstop 164 WRITE(ctmp2,*) ' ==>>> Error detected in Agrif grid '//TRIM(ctmp9) 165 WRITE(ctmp3,*) ' ==>>> look for error messages in '//TRIM(ctmp9)//'_ocean_output* files' 166 CALL ctl_stop( ctmp1, ctmp2, ctmp3 ) 167 ELSE 168 CALL ctl_stop( ctmp1 ) 169 ENDIF 169 170 ENDIF 170 171 ! … … 275 276 ! 276 277 ! finalize the definition of namctl variables 277 IF( sn_cfctl%l_allon ) THEN 278 ! Turn on all options. 279 CALL nemo_set_cfctl( sn_cfctl, .TRUE., .TRUE. ) 280 ! Ensure all processors are active 281 sn_cfctl%procmin = 0 ; sn_cfctl%procmax = 1000000 ; sn_cfctl%procincr = 1 282 ELSEIF( sn_cfctl%l_config ) THEN 283 ! Activate finer control of report outputs 284 ! optionally switch off output from selected areas (note this only 285 ! applies to output which does not involve global communications) 286 IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax ) .OR. & 287 & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) ) & 288 & CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. ) 289 ELSE 290 ! turn off all options. 291 CALL nemo_set_cfctl( sn_cfctl, .FALSE., .TRUE. ) 292 ENDIF 278 IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) & 279 & CALL nemo_set_cfctl( sn_cfctl, .FALSE. ) 293 280 ! 294 281 lwp = (narea == 1) .OR. sn_cfctl%l_oceout ! control of all listing output print … … 408 395 WRITE(numout,*) '~~~~~~~~' 409 396 WRITE(numout,*) ' Namelist namctl' 410 WRITE(numout,*) ' sn_cfctl%l_glochk = ', sn_cfctl%l_glochk411 WRITE(numout,*) ' sn_cfctl%l_allon = ', sn_cfctl%l_allon412 WRITE(numout,*) ' finer control over o/p sn_cfctl%l_config = ', sn_cfctl%l_config413 397 WRITE(numout,*) ' sn_cfctl%l_runstat = ', sn_cfctl%l_runstat 414 398 WRITE(numout,*) ' sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat … … 552 536 END SUBROUTINE nemo_alloc 553 537 554 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto , for_all)538 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto ) 555 539 !!---------------------------------------------------------------------- 556 540 !! *** ROUTINE nemo_set_cfctl *** 557 541 !! 558 542 !! ** Purpose : Set elements of the output control structure to setto. 559 !! for_all should be .false. unless all areas are to be560 !! treated identically.561 543 !! 562 544 !! ** Method : Note this routine can be used to switch on/off some 563 !! types of output for selected areas but any output types 564 !! that involve global communications (e.g. mpp_max, glob_sum) 565 !! should be protected from selective switching by the 566 !! for_all argument 567 !!---------------------------------------------------------------------- 568 LOGICAL :: setto, for_all 569 TYPE(sn_ctl) :: sn_cfctl 570 !!---------------------------------------------------------------------- 571 IF( for_all ) THEN 572 sn_cfctl%l_runstat = setto 573 sn_cfctl%l_trcstat = setto 574 ENDIF 545 !! types of output for selected areas. 546 !!---------------------------------------------------------------------- 547 TYPE(sn_ctl), INTENT(inout) :: sn_cfctl 548 LOGICAL , INTENT(in ) :: setto 549 !!---------------------------------------------------------------------- 550 sn_cfctl%l_runstat = setto 551 sn_cfctl%l_trcstat = setto 575 552 sn_cfctl%l_oceout = setto 576 553 sn_cfctl%l_layout = setto -
NEMO/trunk/src/SAS/step.F90
r12650 r12933 74 74 !! -2- Outputs and diagnostics 75 75 !!---------------------------------------------------------------------- 76 INTEGER :: indic ! error indicator if < 077 !! ---------------------------------------------------------------------78 76 79 77 #if defined key_agrif 80 IF( nstop > 0 ) return ! avoid to go further if an error was detected during previous time step78 IF( nstop > 0 ) RETURN ! avoid to go further if an error was detected during previous time step (child grid) 81 79 kstp = nit000 + Agrif_Nb_Step() 82 80 Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices 83 IF 84 IF ( Agrif_Root() .and. lwp) Write(*,*) '---'85 IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp, 'int tstep',Agrif_NbStepint()81 IF( lk_agrif_debug ) THEN 82 IF( Agrif_Root() .and. lwp) WRITE(*,*) '---' 83 IF(lwp) WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint() 86 84 ENDIF 87 88 IF ( kstp == (nit000 + 1) ) lk_agrif_fstep = .FALSE. 89 85 IF( kstp == nit000 + 1 ) lk_agrif_fstep = .FALSE. 90 86 # if defined key_iomput 91 87 IF( Agrif_Nbstepint() == 0 ) CALL iom_swap( cxios_context ) 92 88 # endif 93 89 #endif 94 indic = 0 ! although indic is not changed in stp_ctl95 ! need to keep the same interface96 90 IF( kstp == nit000 ) CALL iom_init( cxios_context ) ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS) 97 91 IF( kstp /= nit000 ) CALL day( kstp ) ! Calendar (day was already called at nit000 in day_init) … … 112 106 ! AGRIF recursive integration 113 107 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 114 CALL Agrif_Integrate_ChildGrids( stp ) 115 #endif 108 CALL Agrif_Integrate_ChildGrids( stp ) 116 109 110 #endif 117 111 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 118 112 ! Control 119 113 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 120 CALL stp_ctl( kstp, indic ) 121 IF( indic < 0 ) THEN 122 CALL ctl_stop( 'step: indic < 0' ) 123 CALL dia_wri_state( Nnn, 'output.abort' ) 124 ENDIF 114 CALL stp_ctl( kstp, Nnn ) 115 125 116 #if defined key_agrif 126 117 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> … … 132 123 #endif 133 124 ENDIF 125 134 126 #endif 135 127 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> … … 141 133 ! Coupled mode 142 134 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 143 IF( lk_oasis ) CALL sbc_cpl_snd( kstp, Nbb, Nnn )! coupled mode : field exchanges if OASIS-coupled ice135 IF( lk_oasis .AND. nstop == 0 ) CALL sbc_cpl_snd( kstp, Nbb, Nnn ) ! coupled mode : field exchanges if OASIS-coupled ice 144 136 145 137 #if defined key_iomput … … 152 144 lrst_oce = .FALSE. 153 145 ENDIF 154 IF( kstp == nitend .OR. indic <0 ) THEN155 146 IF( kstp == nitend .OR. nstop > 0 ) THEN 147 CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF 156 148 ENDIF 157 149 #endif -
NEMO/trunk/src/SAS/stpctl.F90
r12377 r12933 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 USE in_out_manager ! I/O manager 24 25 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 25 26 USE lib_mpp ! distributed memory computing 26 27 ! 27 28 USE netcdf ! NetCDF library 28 29 IMPLICIT NONE … … 31 32 PUBLIC stp_ctl ! routine called by step.F90 32 33 33 INTEGER :: idrun, idtime, idssh, idu, ids, istatus34 LOGICAL :: lsomeoce34 INTEGER :: nrunid ! netcdf file id 35 INTEGER, DIMENSION(3) :: nvarid ! netcdf variable id 35 36 !!---------------------------------------------------------------------- 36 37 !! NEMO/SAS 4.0 , NEMO Consortium (2018) … … 38 39 !! Software governed by the CeCILL license (see ./LICENSE) 39 40 !!---------------------------------------------------------------------- 40 41 41 CONTAINS 42 42 43 SUBROUTINE stp_ctl( kt, kindic)43 SUBROUTINE stp_ctl( kt, Kmm ) 44 44 !!---------------------------------------------------------------------- 45 45 !! *** ROUTINE stp_ctl *** … … 49 49 !! ** Method : - Save the time step in numstp 50 50 !! - Print it each 50 time steps 51 !! - Stop the run IF problem encountered by setting nstop > 0 52 !! Problems checked: ice thickness maximum > 100 m 53 !! ice velocity maximum > 10 m/s 54 !! min ice temperature < -100 degC 51 55 !! 52 56 !! ** Actions : "time.step" file = last ocean time-step 53 57 !! "run.stat" file = run statistics 54 !! 55 !!---------------------------------------------------------------------- 56 INTEGER, INTENT( in ) :: kt ! ocean time-step index 57 INTEGER, INTENT( inout ) :: kindic ! indicator of solver convergence 58 !! 59 REAL(wp), DIMENSION(3) :: zmax 60 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 61 CHARACTER(len=20) :: clname 62 !!---------------------------------------------------------------------- 63 ! 64 ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 65 ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) 66 ll_wrtruns = ll_colruns .AND. lwm 67 IF( kt == nit000 .AND. lwp ) THEN 68 WRITE(numout,*) 69 WRITE(numout,*) 'stp_ctl : time-stepping control' 70 WRITE(numout,*) '~~~~~~~' 71 ! ! open time.step file 72 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 73 ! ! open run.stat file(s) at start whatever 74 ! ! the value of sn_cfctl%ptimincr 75 IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN 58 !! nstop indicator sheared among all local domain 59 !!---------------------------------------------------------------------- 60 INTEGER, INTENT(in ) :: kt ! ocean time-step index 61 INTEGER, INTENT(in ) :: Kmm ! ocean time level index 62 !! 63 INTEGER :: ji ! dummy loop indices 64 INTEGER :: idtime, istatus 65 INTEGER , DIMENSION(4) :: iareasum, iareamin, iareamax 66 INTEGER , DIMENSION(3,3) :: iloc ! min/max loc indices 67 REAL(wp) :: zzz ! local real 68 REAL(wp), DIMENSION(4) :: zmax, zmaxlocal 69 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 70 LOGICAL, DIMENSION(jpi,jpj) :: llmsk 71 CHARACTER(len=20) :: clname 72 !!---------------------------------------------------------------------- 73 IF( nstop > 0 .AND. ngrdstop > -1 ) RETURN ! stpctl was already called by a child grid 74 ! 75 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 76 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 77 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 78 ! 79 IF( kt == nit000 ) THEN 80 ! 81 IF( lwp ) THEN 82 WRITE(numout,*) 83 WRITE(numout,*) 'stp_ctl : time-stepping control' 84 WRITE(numout,*) '~~~~~~~' 85 ENDIF 86 ! ! open time.step ascii file, done only by 1st subdomain 87 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 88 ! 89 IF( ll_wrtruns ) THEN 90 ! ! open run.stat ascii file, done only by 1st subdomain 76 91 CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 92 ! ! open run.stat.nc netcdf file, done only by 1st subdomain 77 93 clname = 'run.stat.nc' 78 94 IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 79 istatus = NF90_CREATE( 'run.stat.nc', NF90_CLOBBER, idrun ) 80 istatus = NF90_DEF_DIM( idrun, 'time' , NF90_UNLIMITED, idtime ) 81 istatus = NF90_DEF_VAR( idrun, 'vt_i_max' , NF90_DOUBLE, (/ idtime /), idssh ) 82 istatus = NF90_DEF_VAR( idrun, 'abs_u_max', NF90_DOUBLE, (/ idtime /), idu ) 83 istatus = NF90_DEF_VAR( idrun, 'tm_i_min' , NF90_DOUBLE, (/ idtime /), ids ) 84 istatus = NF90_ENDDEF(idrun) 85 ENDIF 86 ENDIF 87 IF( kt == nit000 ) lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 88 ! 89 IF(lwm .AND. ll_wrtstp) THEN !== current time step ==! ("time.step" file) 95 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 96 istatus = NF90_DEF_DIM( nrunid, 'time' , NF90_UNLIMITED, idtime ) 97 istatus = NF90_DEF_VAR( nrunid, 'vt_i_max' , NF90_DOUBLE, (/ idtime /), nvarid(1) ) 98 istatus = NF90_DEF_VAR( nrunid, 'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 99 istatus = NF90_DEF_VAR( nrunid, 'tm_i_min' , NF90_DOUBLE, (/ idtime /), nvarid(3) ) 100 istatus = NF90_ENDDEF(nrunid) 101 ENDIF 102 ! 103 ENDIF 104 ! 105 ! !== write current time step ==! 106 ! !== done only by 1st subdomain at writting timestep ==! 107 IF( lwm .AND. ll_wrtstp ) THEN 90 108 WRITE ( numstp, '(1x, i8)' ) kt 91 109 REWIND( numstp ) 92 110 ENDIF 93 ! !== test of extrema ==! 111 ! !== test of local extrema ==! 112 ! !== done by all processes at every time step ==! 113 llmsk(:,:) = tmask(:,:,1) == 1._wp 114 zmax(1) = MAXVAL( vt_i (:,:) , mask = llmsk ) ! max ice thickness 115 zmax(2) = MAXVAL( ABS( u_ice(:,:) ) , mask = llmsk ) ! max ice velocity (zonal only) 116 zmax(3) = MAXVAL( -tm_i (:,:) + 273.15_wp, mask = llmsk ) ! min ice temperature 117 zmax(4) = REAL( nstop, wp ) ! stop indicator 118 ! !== get global extrema ==! 119 ! !== done by all processes if writting run.stat ==! 94 120 IF( ll_colruns ) THEN 95 zmax(1) = MAXVAL( vt_i (:,:) ) ! max ice thickness 96 zmax(2) = MAXVAL( ABS( u_ice(:,:) ) ) ! max ice velocity (zonal only) 97 zmax(3) = MAXVAL( -tm_i (:,:)+273.15_wp , mask = ssmask(:,:) == 1._wp ) ! min ice temperature 98 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 121 zmaxlocal(:) = zmax(:) 122 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 123 nstop = NINT( zmax(4) ) ! update nstop indicator (now sheared among all local domains) 124 ENDIF 125 ! !== write "run.stat" files ==! 126 ! !== done only by 1st subdomain at writting timestep ==! 127 IF( ll_wrtruns ) THEN 128 WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3) 129 istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 130 istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 131 istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) ) 132 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 99 133 END IF 100 ! !== run statistics ==! ("run.stat" file) 101 IF( ll_wrtruns ) THEN 102 WRITE(numrun,9500) kt, zmax(1), zmax(2), - zmax(3) 103 istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) ) 104 istatus = NF90_PUT_VAR( idrun, idu, (/ zmax(2)/), (/kt/), (/1/) ) 105 istatus = NF90_PUT_VAR( idrun, ids, (/-zmax(3)/), (/kt/), (/1/) ) 106 IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) 107 IF( kt == nitend ) istatus = NF90_CLOSE(idrun) 108 END IF 134 ! !== error handling ==! 135 ! !== done by all processes at every time step ==! 136 ! 137 IF( zmax(1) > 100._wp .OR. & ! too large ice thickness maximum ( > 100 m) 138 & zmax(2) > 10._wp .OR. & ! too large ice velocity ( > 10 m/s) 139 & zmax(3) > 101._wp .OR. & ! too cold ice temperature ( < -100 degC) 140 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR. & ! NaN encounter in the tests 141 & ABS( zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests 142 ! 143 iloc(:,:) = 0 144 IF( ll_colruns ) THEN ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 145 ! first: close the netcdf file, so we can read it 146 IF( lwm .AND. kt /= nitend ) istatus = NF90_CLOSE(nrunid) 147 ! get global loc on the min/max 148 CALL mpp_maxloc( 'stpctl', vt_i(:,:) , tmask(:,:,1), zzz, iloc(1:2,1) ) ! mpp_maxloc ok if mask = F 149 CALL mpp_maxloc( 'stpctl',ABS( u_ice(:,:) ) , tmask(:,:,1), zzz, iloc(1:2,2) ) 150 CALL mpp_minloc( 'stpctl', tm_i(:,:) - 273.15_wp, tmask(:,:,1), zzz, iloc(1:2,3) ) 151 ! find which subdomain has the max. 152 iareamin(:) = jpnij+1 ; iareamax(:) = 0 ; iareasum(:) = 0 153 DO ji = 1, 4 154 IF( zmaxlocal(ji) == zmax(ji) ) THEN 155 iareamin(ji) = narea ; iareamax(ji) = narea ; iareasum(ji) = 1 156 ENDIF 157 END DO 158 CALL mpp_min( "stpctl", iareamin ) ! min over the global domain 159 CALL mpp_max( "stpctl", iareamax ) ! max over the global domain 160 CALL mpp_sum( "stpctl", iareasum ) ! sum over the global domain 161 ELSE ! find local min and max locations: 162 ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 163 iloc(1:2,1) = MAXLOC( vt_i(:,:) , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 164 iloc(1:2,2) = MAXLOC( ABS( u_ice(:,:) ) , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 165 iloc(1:2,3) = MINLOC( tm_i(:,:) - 273.15_wp, mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 166 iareamin(:) = narea ; iareamax(:) = narea ; iareasum(:) = 1 ! this is local information 167 ENDIF 168 ! 169 WRITE(ctmp1,*) ' stp_ctl: ice_thick > 100 m or |ice_vel| > 10 m/s or ice_temp < -100 degC or NaN encounter in the tests' 170 CALL wrt_line( ctmp2, kt, 'ice_thick max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 171 CALL wrt_line( ctmp3, kt, '|ice_vel| max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 172 CALL wrt_line( ctmp4, kt, 'ice_temp min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 173 IF( Agrif_Root() ) THEN 174 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort* files' 175 ELSE 176 WRITE(ctmp6,*) ' ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 177 ENDIF 178 ! 179 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 180 ! 181 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 182 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 183 ELSE ! only mpi subdomains with errors are here -> STOP now 184 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 185 ENDIF 186 ! 187 IF( nstop == 0 ) nstop = 1 188 ngrdstop = Agrif_Fixed() 189 ! 190 ENDIF 109 191 ! 110 192 9500 FORMAT(' it :', i8, ' vt_i_max: ', D23.16, ' |u|_max: ', D23.16,' tm_i_min: ', D23.16) 111 193 ! 112 194 END SUBROUTINE stp_ctl 195 196 197 SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax ) 198 !!---------------------------------------------------------------------- 199 !! *** ROUTINE wrt_line *** 200 !! 201 !! ** Purpose : write information line 202 !! 203 !!---------------------------------------------------------------------- 204 CHARACTER(len=*), INTENT( out) :: cdline 205 CHARACTER(len=*), INTENT(in ) :: cdprefix 206 REAL(wp), INTENT(in ) :: pval 207 INTEGER, DIMENSION(3), INTENT(in ) :: kloc 208 INTEGER, INTENT(in ) :: kt, ksum, kmin, kmax 209 ! 210 CHARACTER(len=80) :: clsuff 211 CHARACTER(len=9 ) :: clkt, clsum, clmin, clmax 212 CHARACTER(len=9 ) :: cli, clj, clk 213 CHARACTER(len=1 ) :: clfmt 214 CHARACTER(len=4 ) :: cl4 ! needed to be able to compile with Agrif, I don't know why 215 INTEGER :: ifmtk 216 !!---------------------------------------------------------------------- 217 WRITE(clkt , '(i9)') kt 218 219 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij ,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 220 !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF 221 cl4 = '(i'//clfmt//')' ; WRITE(clsum, cl4) ksum 222 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij-1,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 223 cl4 = '(i'//clfmt//')' ; WRITE(clmin, cl4) kmin-1 224 WRITE(clmax, cl4) kmax-1 225 ! 226 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1 ! how many digits to we need to write jpiglo? (we decide max = 9) 227 cl4 = '(i'//clfmt//')' ; WRITE(cli, cl4) kloc(1) ! this is ok with AGRIF 228 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1 ! how many digits to we need to write jpjglo? (we decide max = 9) 229 cl4 = '(i'//clfmt//')' ; WRITE(clj, cl4) kloc(2) ! this is ok with AGRIF 230 ! 231 IF( ksum == 1 ) THEN ; WRITE(clsuff,9100) TRIM(clmin) 232 ELSE ; WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax) 233 ENDIF 234 IF(kloc(3) == 0) THEN 235 ifmtk = INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 236 clk = REPEAT(' ', ifmtk) ! create the equivalent in blank string 237 WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff) 238 ELSE 239 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 240 !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF 241 cl4 = '(i'//clfmt//')' ; WRITE(clk, cl4) kloc(3) ! this is ok with AGRIF 242 WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), TRIM(clk), TRIM(clsuff) 243 ENDIF 244 ! 245 9100 FORMAT('MPI rank ', a) 246 9200 FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a) 247 9300 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j ', a, ' ', a, ' ', a, ' ', a) 248 9400 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a) 249 ! 250 END SUBROUTINE wrt_line 251 113 252 114 253 !!====================================================================== -
NEMO/trunk/tests/CANAL/MY_SRC/stpctl.F90
r12740 r12933 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 … … 33 33 PUBLIC stp_ctl ! routine called by step.F90 34 34 35 INTEGER :: idrun, idtime, idssh, idu, ids1, ids2, idt1, idt2, idc1, idw1, istatus36 LOGICAL :: lsomeoce35 INTEGER :: nrunid ! netcdf file id 36 INTEGER, DIMENSION(8) :: nvarid ! netcdf variable id 37 37 !!---------------------------------------------------------------------- 38 38 !! NEMO/OCE 4.0 , NEMO Consortium (2018) … … 42 42 CONTAINS 43 43 44 SUBROUTINE stp_ctl( kt, K bb, Kmm, kindic)44 SUBROUTINE stp_ctl( kt, Kmm ) 45 45 !!---------------------------------------------------------------------- 46 46 !! *** ROUTINE stp_ctl *** … … 50 50 !! ** Method : - Save the time step in numstp 51 51 !! - Print it each 50 time steps 52 !! - Stop the run IF problem encountered by setting indic=-352 !! - Stop the run IF problem encountered by setting nstop > 0 53 53 !! Problems checked: |ssh| maximum larger than 10 m 54 54 !! |U| maximum larger than 10 m/s … … 57 57 !! ** Actions : "time.step" file = last ocean time-step 58 58 !! "run.stat" file = run statistics 59 !! nstop indicator sheared among all local domain (lk_mpp=T)59 !! nstop indicator sheared among all local domain 60 60 !!---------------------------------------------------------------------- 61 61 INTEGER, INTENT(in ) :: kt ! ocean time-step index 62 INTEGER, INTENT(in ) :: Kbb, Kmm ! ocean time level index 63 INTEGER, INTENT(inout) :: kindic ! error indicator 64 !! 65 INTEGER :: ji, jj, jk ! dummy loop indices 66 INTEGER, DIMENSION(2) :: ih ! min/max loc indices 67 INTEGER, DIMENSION(3) :: iu, is1, is2 ! min/max loc indices 68 REAL(wp) :: zzz ! local real 69 REAL(wp), DIMENSION(9) :: zmax 70 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 71 CHARACTER(len=20) :: clname 72 !!---------------------------------------------------------------------- 73 ! 74 ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 75 ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) 76 ll_wrtruns = ll_colruns .AND. lwm 77 IF( kt == nit000 .AND. lwp ) THEN 78 WRITE(numout,*) 79 WRITE(numout,*) 'stp_ctl : time-stepping control' 80 WRITE(numout,*) '~~~~~~~' 81 ! ! open time.step file 82 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 83 ! ! open run.stat file(s) at start whatever 84 ! ! the value of sn_cfctl%ptimincr 85 IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN 62 INTEGER, INTENT(in ) :: Kmm ! ocean time level index 63 !! 64 INTEGER :: ji ! dummy loop indices 65 INTEGER :: idtime, istatus 66 INTEGER , DIMENSION(9) :: iareasum, iareamin, iareamax 67 INTEGER , DIMENSION(3,4) :: iloc ! min/max loc indices 68 REAL(wp) :: zzz ! local real 69 REAL(wp), DIMENSION(9) :: zmax, zmaxlocal 70 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 71 LOGICAL, DIMENSION(jpi,jpj,jpk) :: llmsk 72 CHARACTER(len=20) :: clname 73 !!---------------------------------------------------------------------- 74 IF( nstop > 0 .AND. ngrdstop > -1 ) RETURN ! stpctl was already called by a child grid 75 ! 76 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 77 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 78 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 79 ! 80 IF( kt == nit000 ) THEN 81 ! 82 IF( lwp ) THEN 83 WRITE(numout,*) 84 WRITE(numout,*) 'stp_ctl : time-stepping control' 85 WRITE(numout,*) '~~~~~~~' 86 ENDIF 87 ! ! open time.step ascii file, done only by 1st subdomain 88 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 89 ! 90 IF( ll_wrtruns ) THEN 91 ! ! open run.stat ascii file, done only by 1st subdomain 86 92 CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 93 ! ! open run.stat.nc netcdf file, done only by 1st subdomain 87 94 clname = 'run.stat.nc' 88 95 IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 89 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun)90 istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime )91 istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh)92 istatus = NF90_DEF_VAR( idrun, 'abs_u_max', NF90_DOUBLE, (/ idtime /), idu)93 istatus = NF90_DEF_VAR( idrun, 's_min', NF90_DOUBLE, (/ idtime /), ids1)94 istatus = NF90_DEF_VAR( idrun, 's_max', NF90_DOUBLE, (/ idtime /), ids2)95 istatus = NF90_DEF_VAR( idrun, 't_min', NF90_DOUBLE, (/ idtime /), idt1)96 istatus = NF90_DEF_VAR( idrun, 't_max', NF90_DOUBLE, (/ idtime /), idt2)96 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 97 istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) 98 istatus = NF90_DEF_VAR( nrunid, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) 99 istatus = NF90_DEF_VAR( nrunid, 'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 100 istatus = NF90_DEF_VAR( nrunid, 's_min', NF90_DOUBLE, (/ idtime /), nvarid(3) ) 101 istatus = NF90_DEF_VAR( nrunid, 's_max', NF90_DOUBLE, (/ idtime /), nvarid(4) ) 102 istatus = NF90_DEF_VAR( nrunid, 't_min', NF90_DOUBLE, (/ idtime /), nvarid(5) ) 103 istatus = NF90_DEF_VAR( nrunid, 't_max', NF90_DOUBLE, (/ idtime /), nvarid(6) ) 97 104 IF( ln_zad_Aimp ) THEN 98 istatus = NF90_DEF_VAR( idrun, 'abs_wi_max', NF90_DOUBLE, (/ idtime /), idw1)99 istatus = NF90_DEF_VAR( idrun, 'Cf_max', NF90_DOUBLE, (/ idtime /), idc1)105 istatus = NF90_DEF_VAR( nrunid, 'Cf_max', NF90_DOUBLE, (/ idtime /), nvarid(7) ) 106 istatus = NF90_DEF_VAR( nrunid,'abs_wi_max',NF90_DOUBLE, (/ idtime /), nvarid(8) ) 100 107 ENDIF 101 istatus = NF90_ENDDEF(idrun) 102 zmax(8:9) = 0._wp ! initialise to zero in case ln_zad_Aimp option is not in use 103 ENDIF 104 ENDIF 105 IF( kt == nit000 ) lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 106 ! 107 IF(lwm .AND. ll_wrtstp) THEN !== current time step ==! ("time.step" file) 108 istatus = NF90_ENDDEF(nrunid) 109 ENDIF 110 ! 111 ENDIF 112 ! 113 ! !== write current time step ==! 114 ! !== done only by 1st subdomain at writting timestep ==! 115 IF( lwm .AND. ll_wrtstp ) THEN 108 116 WRITE ( numstp, '(1x, i8)' ) kt 109 117 REWIND( numstp ) 110 118 ENDIF 111 ! 112 ! !== test of extrema ==! 119 ! !== test of local extrema ==! 120 ! !== done by all processes at every time step ==! 121 llmsk(:,:,1) = ssmask(:,:) == 1._wp 113 122 IF( ll_wd ) THEN 114 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref*tmask(:,:,1) ) ) ! ssh max123 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) ) ! ssh max 115 124 ELSE 116 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) ) ) ! ssh max 117 ENDIF 118 zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ) ) ! velocity max (zonal only) 119 zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! minus salinity max 120 zmax(4) = MAXVAL( ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! salinity max 121 zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! minus temperature max 122 zmax(6) = MAXVAL( ts(:,:,:,jp_tem,Kmm) , mask = tmask(:,:,:) == 1._wp ) ! temperature max 123 zmax(7) = REAL( nstop , wp ) ! stop indicator 124 IF( ln_zad_Aimp ) THEN 125 zmax(8) = MAXVAL( ABS( wi(:,:,:) ) , mask = wmask(:,:,:) == 1._wp ) ! implicit vertical vel. max 126 zmax(9) = MAXVAL( Cu_adv(:,:,:) , mask = tmask(:,:,:) == 1._wp ) ! partitioning coeff. max 127 ENDIF 128 ! 125 zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) ), mask = llmsk(:,:,1) ) ! ssh max 126 ENDIF 127 llmsk(:,:,:) = umask(:,:,:) == 1._wp 128 zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ), mask = llmsk ) ! velocity max (zonal only) 129 llmsk(:,:,:) = tmask(:,:,:) == 1._wp 130 zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk ) ! minus salinity max 131 zmax(4) = MAXVAL( ts(:,:,:,jp_sal,Kmm), mask = llmsk ) ! salinity max 132 IF( ll_colruns ) THEN ! following variables are used only in the netcdf file 133 zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm), mask = llmsk ) ! minus temperature max 134 zmax(6) = MAXVAL( ts(:,:,:,jp_tem,Kmm), mask = llmsk ) ! temperature max 135 IF( ln_zad_Aimp ) THEN 136 zmax(7) = MAXVAL( Cu_adv(:,:,:) , mask = llmsk ) ! partitioning coeff. max 137 llmsk(:,:,:) = wmask(:,:,:) == 1._wp 138 zmax(8) = MAXVAL( ABS( wi(:,:,:) ) , mask = llmsk ) ! implicit vertical vel. max 139 ELSE 140 zmax(7:8) = 0._wp 141 ENDIF 142 ELSE 143 zmax(5:8) = 0._wp 144 ENDIF 145 zmax(9) = REAL( nstop, wp ) ! stop indicator 146 ! !== get global extrema ==! 147 ! !== done by all processes if writting run.stat ==! 129 148 IF( ll_colruns ) THEN 149 zmaxlocal(:) = zmax(:) 130 150 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 131 nstop = NINT( zmax(7) ) ! nstop indicator sheared among all local domains 132 ENDIF 133 ! !== run statistics ==! ("run.stat" files) 151 nstop = NINT( zmax(9) ) ! update nstop indicator (now sheared among all local domains) 152 ENDIF 153 ! !== write "run.stat" files ==! 154 ! !== done only by 1st subdomain at writting timestep ==! 134 155 IF( ll_wrtruns ) THEN 135 156 WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4) 136 istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )137 istatus = NF90_PUT_VAR( idrun, idu, (/ zmax(2)/), (/kt/), (/1/) )138 istatus = NF90_PUT_VAR( idrun, ids1, (/-zmax(3)/), (/kt/), (/1/) )139 istatus = NF90_PUT_VAR( idrun, ids2, (/ zmax(4)/), (/kt/), (/1/) )140 istatus = NF90_PUT_VAR( idrun, idt1, (/-zmax(5)/), (/kt/), (/1/) )141 istatus = NF90_PUT_VAR( idrun, idt2, (/ zmax(6)/), (/kt/), (/1/) )157 istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 158 istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 159 istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) ) 160 istatus = NF90_PUT_VAR( nrunid, nvarid(4), (/ zmax(4)/), (/kt/), (/1/) ) 161 istatus = NF90_PUT_VAR( nrunid, nvarid(5), (/-zmax(5)/), (/kt/), (/1/) ) 162 istatus = NF90_PUT_VAR( nrunid, nvarid(6), (/ zmax(6)/), (/kt/), (/1/) ) 142 163 IF( ln_zad_Aimp ) THEN 143 istatus = NF90_PUT_VAR( idrun, idw1, (/ zmax(8)/), (/kt/), (/1/) ) 144 istatus = NF90_PUT_VAR( idrun, idc1, (/ zmax(9)/), (/kt/), (/1/) ) 145 ENDIF 146 IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) 147 IF( kt == nitend ) istatus = NF90_CLOSE(idrun) 164 istatus = NF90_PUT_VAR( nrunid, nvarid(7), (/ zmax(7)/), (/kt/), (/1/) ) 165 istatus = NF90_PUT_VAR( nrunid, nvarid(8), (/ zmax(8)/), (/kt/), (/1/) ) 166 ENDIF 167 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 148 168 END IF 149 ! !== error handling ==! 150 IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. ( & ! domain contains some ocean points, check for sensible ranges 151 & zmax(1) > 20._wp .OR. & ! too large sea surface height ( > 20 m ) 152 & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) 153 !!$ & zmax(3) >= 0._wp .OR. & ! negative or zero sea surface salinity 154 !!$ & zmax(4) >= 100._wp .OR. & ! too large sea surface salinity ( > 100 ) 155 !!$ & zmax(4) < 0._wp .OR. & ! too large sea surface salinity (keep this line for sea-ice) 156 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN ! NaN encounter in the tests 157 IF( lk_mpp .AND. sn_cfctl%l_glochk ) THEN 158 ! have use mpp_max (because sn_cfctl%l_glochk=.T. and distributed) 159 CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,Kmm)) , ssmask(:,:) , zzz, ih ) 160 CALL mpp_maxloc( 'stpctl', ABS(uu(:,:,:,Kmm)) , umask (:,:,:), zzz, iu ) 161 CALL mpp_minloc( 'stpctl', ts(:,:,:,jp_sal,Kmm), tmask (:,:,:), zzz, is1 ) 162 CALL mpp_maxloc( 'stpctl', ts(:,:,:,jp_sal,Kmm), tmask (:,:,:), zzz, is2 ) 169 ! !== error handling ==! 170 ! !== done by all processes at every time step ==! 171 ! 172 IF( zmax(1) > 20._wp .OR. & ! too large sea surface height ( > 20 m ) 173 & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) 174 !!$ & zmax(3) >= 0._wp .OR. & ! negative or zero sea surface salinity 175 !!$ & zmax(4) >= 100._wp .OR. & ! too large sea surface salinity ( > 100 ) 176 !!$ & zmax(4) < 0._wp .OR. & ! too large sea surface salinity (keep this line for sea-ice) 177 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR. & ! NaN encounter in the tests 178 & ABS( zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests 179 ! 180 iloc(:,:) = 0 181 IF( ll_colruns ) THEN ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 182 ! first: close the netcdf file, so we can read it 183 IF( lwm .AND. kt /= nitend ) istatus = NF90_CLOSE(nrunid) 184 ! get global loc on the min/max 185 CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:, Kmm)), ssmask(:,: ), zzz, iloc(1:2,1) ) ! mpp_maxloc ok if mask = F 186 CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:, Kmm)), umask(:,:,:), zzz, iloc(1:3,2) ) 187 CALL mpp_minloc( 'stpctl', ts(:,:,:,jp_sal,Kmm) , tmask(:,:,:), zzz, iloc(1:3,3) ) 188 CALL mpp_maxloc( 'stpctl', ts(:,:,:,jp_sal,Kmm) , tmask(:,:,:), zzz, iloc(1:3,4) ) 189 ! find which subdomain has the max. 190 iareamin(:) = jpnij+1 ; iareamax(:) = 0 ; iareasum(:) = 0 191 DO ji = 1, 9 192 IF( zmaxlocal(ji) == zmax(ji) ) THEN 193 iareamin(ji) = narea ; iareamax(ji) = narea ; iareasum(ji) = 1 194 ENDIF 195 END DO 196 CALL mpp_min( "stpctl", iareamin ) ! min over the global domain 197 CALL mpp_max( "stpctl", iareamax ) ! max over the global domain 198 CALL mpp_sum( "stpctl", iareasum ) ! sum over the global domain 199 ELSE ! find local min and max locations: 200 ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 201 iloc(1:2,1) = MAXLOC( ABS( ssh(:,:, Kmm)), mask = ssmask(:,: ) == 1._wp ) + (/ nimpp - 1, njmpp - 1 /) 202 iloc(1:3,2) = MAXLOC( ABS( uu(:,:,:, Kmm)), mask = umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 203 iloc(1:3,3) = MINLOC( ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 204 iloc(1:3,4) = MAXLOC( ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 205 iareamin(:) = narea ; iareamax(:) = narea ; iareasum(:) = 1 ! this is local information 206 ENDIF 207 ! 208 WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests' 209 CALL wrt_line( ctmp2, kt, '|ssh| max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 210 CALL wrt_line( ctmp3, kt, '|U| max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 211 CALL wrt_line( ctmp4, kt, 'Sal min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 212 CALL wrt_line( ctmp5, kt, 'Sal max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) ) 213 IF( Agrif_Root() ) THEN 214 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort* files' 163 215 ELSE 164 ! find local min and max locations 165 ih(:) = MAXLOC( ABS( ssh(:,:,Kmm) ) ) + (/ nimpp - 1, njmpp - 1 /) 166 iu(:) = MAXLOC( ABS( uu (:,:,:,Kmm) ) ) + (/ nimpp - 1, njmpp - 1, 0 /) 167 is1(:) = MINLOC( ts(:,:,:,jp_sal,Kmm), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 168 is2(:) = MAXLOC( ts(:,:,:,jp_sal,Kmm), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 169 ENDIF 170 171 WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests' 172 WRITE(ctmp2,9100) kt, zmax(1), ih(1) , ih(2) 173 WRITE(ctmp3,9200) kt, zmax(2), iu(1) , iu(2) , iu(3) 174 WRITE(ctmp4,9300) kt, - zmax(3), is1(1), is1(2), is1(3) 175 WRITE(ctmp5,9400) kt, zmax(4), is2(1), is2(2), is2(3) 176 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort.nc file' 177 216 WRITE(ctmp6,*) ' ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 217 ENDIF 218 ! 178 219 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 179 180 IF( .NOT. sn_cfctl%l_glochk ) THEN 181 WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea 182 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp8, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ctmp6 ) 183 ELSE 184 CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6, ' ' ) 185 ENDIF 186 187 kindic = -3 188 ! 189 ENDIF 190 ! 191 9100 FORMAT (' kt=',i8,' |ssh| max: ',1pg11.4,', at i j : ',2i5) 192 9200 FORMAT (' kt=',i8,' |U| max: ',1pg11.4,', at i j k: ',3i5) 193 9300 FORMAT (' kt=',i8,' S min: ',1pg11.4,', at i j k: ',3i5) 194 9400 FORMAT (' kt=',i8,' S max: ',1pg11.4,', at i j k: ',3i5) 220 ! 221 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 222 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 223 ELSE ! only mpi subdomains with errors are here -> STOP now 224 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 225 ENDIF 226 ! 227 IF( nstop == 0 ) nstop = 1 228 ngrdstop = Agrif_Fixed() 229 ! 230 ENDIF 231 ! 195 232 9500 FORMAT(' it :', i8, ' |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16) 196 233 ! 197 234 END SUBROUTINE stp_ctl 235 236 237 SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax ) 238 !!---------------------------------------------------------------------- 239 !! *** ROUTINE wrt_line *** 240 !! 241 !! ** Purpose : write information line 242 !! 243 !!---------------------------------------------------------------------- 244 CHARACTER(len=*), INTENT( out) :: cdline 245 CHARACTER(len=*), INTENT(in ) :: cdprefix 246 REAL(wp), INTENT(in ) :: pval 247 INTEGER, DIMENSION(3), INTENT(in ) :: kloc 248 INTEGER, INTENT(in ) :: kt, ksum, kmin, kmax 249 ! 250 CHARACTER(len=80) :: clsuff 251 CHARACTER(len=9 ) :: clkt, clsum, clmin, clmax 252 CHARACTER(len=9 ) :: cli, clj, clk 253 CHARACTER(len=1 ) :: clfmt 254 CHARACTER(len=4 ) :: cl4 ! needed to be able to compile with Agrif, I don't know why 255 INTEGER :: ifmtk 256 !!---------------------------------------------------------------------- 257 WRITE(clkt , '(i9)') kt 258 259 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij ,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 260 !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF 261 cl4 = '(i'//clfmt//')' ; WRITE(clsum, cl4) ksum 262 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij-1,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 263 cl4 = '(i'//clfmt//')' ; WRITE(clmin, cl4) kmin-1 264 WRITE(clmax, cl4) kmax-1 265 ! 266 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1 ! how many digits to we need to write jpiglo? (we decide max = 9) 267 cl4 = '(i'//clfmt//')' ; WRITE(cli, cl4) kloc(1) ! this is ok with AGRIF 268 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1 ! how many digits to we need to write jpjglo? (we decide max = 9) 269 cl4 = '(i'//clfmt//')' ; WRITE(clj, cl4) kloc(2) ! this is ok with AGRIF 270 ! 271 IF( ksum == 1 ) THEN ; WRITE(clsuff,9100) TRIM(clmin) 272 ELSE ; WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax) 273 ENDIF 274 IF(kloc(3) == 0) THEN 275 ifmtk = INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 276 clk = REPEAT(' ', ifmtk) ! create the equivalent in blank string 277 WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff) 278 ELSE 279 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 280 !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF 281 cl4 = '(i'//clfmt//')' ; WRITE(clk, cl4) kloc(3) ! this is ok with AGRIF 282 WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), TRIM(clk), TRIM(clsuff) 283 ENDIF 284 ! 285 9100 FORMAT('MPI rank ', a) 286 9200 FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a) 287 9300 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j ', a, ' ', a, ' ', a, ' ', a) 288 9400 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a) 289 ! 290 END SUBROUTINE wrt_line 291 198 292 199 293 !!====================================================================== -
NEMO/trunk/tests/STATION_ASF/EXPREF/launch_sasf.sh
r12615 r12933 34 34 35 35 if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled nemo.exe found into ${NEMO_DIR}/tests/STATION_ASF/BLD/bin !"; exit; fi 36 37 echo 38 echo " *** Using the following NEMO executable:" 39 echo " ${NEMO_EXE} " 40 echo 41 36 42 37 43 NEMO_EXPREF="${NEMO_DIR}/tests/STATION_ASF/EXPREF" -
NEMO/trunk/tests/STATION_ASF/MY_SRC/nemogcm.F90
r12641 r12933 184 184 ! 185 185 ! finalize the definition of namctl variables 186 IF( sn_cfctl%l_allon ) THEN 187 ! Turn on all options. 188 CALL nemo_set_cfctl( sn_cfctl, .TRUE., .TRUE. ) 189 ! Ensure all processors are active 190 sn_cfctl%procmin = 0 ; sn_cfctl%procmax = 1000000 ; sn_cfctl%procincr = 1 191 ELSEIF( sn_cfctl%l_config ) THEN 192 ! Activate finer control of report outputs 193 ! optionally switch off output from selected areas (note this only 194 ! applies to output which does not involve global communications) 195 IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax ) .OR. & 196 & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) ) & 197 & CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. ) 198 ELSE 199 ! turn off all options. 200 CALL nemo_set_cfctl( sn_cfctl, .FALSE., .TRUE. ) 201 ENDIF 186 IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) & 187 & CALL nemo_set_cfctl( sn_cfctl, .FALSE. ) 202 188 ! 203 189 lwp = (narea == 1) .OR. sn_cfctl%l_oceout ! control of all listing output print … … 308 294 WRITE(numout,*) '~~~~~~~~' 309 295 WRITE(numout,*) ' Namelist namctl' 310 WRITE(numout,*) ' sn_cfctl%l_glochk = ', sn_cfctl%l_glochk311 WRITE(numout,*) ' sn_cfctl%l_allon = ', sn_cfctl%l_allon312 WRITE(numout,*) ' finer control over o/p sn_cfctl%l_config = ', sn_cfctl%l_config313 296 WRITE(numout,*) ' sn_cfctl%l_runstat = ', sn_cfctl%l_runstat 314 297 WRITE(numout,*) ' sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat … … 446 429 447 430 448 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto , for_all)431 SUBROUTINE nemo_set_cfctl(sn_cfctl, setto ) 449 432 !!---------------------------------------------------------------------- 450 433 !! *** ROUTINE nemo_set_cfctl *** 451 434 !! 452 435 !! ** Purpose : Set elements of the output control structure to setto. 453 !! for_all should be .false. unless all areas are to be454 !! treated identically.455 436 !! 456 437 !! ** Method : Note this routine can be used to switch on/off some 457 !! types of output for selected areas but any output types 458 !! that involve global communications (e.g. mpp_max, glob_sum) 459 !! should be protected from selective switching by the 460 !! for_all argument 461 !!---------------------------------------------------------------------- 462 LOGICAL :: setto, for_all 463 TYPE(sn_ctl) :: sn_cfctl 464 !!---------------------------------------------------------------------- 465 IF( for_all ) THEN 466 sn_cfctl%l_runstat = setto 467 sn_cfctl%l_trcstat = setto 468 ENDIF 438 !! types of output for selected areas. 439 !!---------------------------------------------------------------------- 440 TYPE(sn_ctl), INTENT(inout) :: sn_cfctl 441 LOGICAL , INTENT(in ) :: setto 442 !!---------------------------------------------------------------------- 443 sn_cfctl%l_runstat = setto 444 sn_cfctl%l_trcstat = setto 469 445 sn_cfctl%l_oceout = setto 470 446 sn_cfctl%l_layout = setto -
NEMO/trunk/tests/STATION_ASF/MY_SRC/stpctl.F90
r12254 r12933 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 :: idrun, idtime, idtau, idqns, idemp, istatus34 LOGICAL :: lsomeoce33 INTEGER :: nrunid ! netcdf file id 34 INTEGER, DIMENSION(3) :: nvarid ! netcdf variable id 35 35 !!---------------------------------------------------------------------- 36 36 !! NEMO/SAS 4.0 , NEMO Consortium (2018) … … 40 40 CONTAINS 41 41 42 SUBROUTINE stp_ctl( kt, K bb, Kmm, kindic)42 SUBROUTINE stp_ctl( kt, Kmm ) 43 43 !!---------------------------------------------------------------------- 44 44 !! *** ROUTINE stp_ctl *** 45 !! 45 !! 46 46 !! ** Purpose : Control the run 47 47 !! 48 48 !! ** Method : - Save the time step in numstp 49 49 !! - Print it each 50 time steps 50 !! - 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 51 54 !! 52 55 !! ** Actions : "time.step" file = last ocean time-step 53 56 !! "run.stat" file = run statistics 54 !! nstop indicator sheared among all local domain (lk_mpp=T)57 !! nstop indicator sheared among all local domain 55 58 !!---------------------------------------------------------------------- 56 59 INTEGER, INTENT(in ) :: kt ! ocean time-step index 57 INTEGER, INTENT(in ) :: Kbb, Kmm ! ocean time level index 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 ) 66 ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) 67 ll_wrtruns = ll_colruns .AND. lwm 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 73 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 74 ! ! open run.stat file(s) at start whatever 75 ! ! the value of sn_cfctl%ptimincr 76 IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN 60 INTEGER, INTENT(in ) :: Kmm ! ocean time level index 61 !! 62 INTEGER :: ji ! dummy loop indices 63 INTEGER :: idtime, istatus 64 INTEGER , DIMENSION(4) :: iareasum, iareamin, iareamax 65 INTEGER , DIMENSION(3,3) :: iloc ! min/max loc indices 66 REAL(wp) :: zzz ! local real 67 REAL(wp), DIMENSION(4) :: zmax, zmaxlocal 68 LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns 69 LOGICAL, DIMENSION(jpi,jpj) :: llmsk 70 CHARACTER(len=20) :: clname 71 !!---------------------------------------------------------------------- 72 IF( nstop > 0 .AND. ngrdstop > -1 ) RETURN ! stpctl was already called by a child grid 73 ! 74 ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 75 ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 76 ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 77 ! 78 IF( kt == nit000 ) THEN 79 ! 80 IF( lwp ) THEN 81 WRITE(numout,*) 82 WRITE(numout,*) 'stp_ctl : time-stepping control' 83 WRITE(numout,*) '~~~~~~~' 84 ENDIF 85 ! ! open time.step ascii file, done only by 1st subdomain 86 IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 87 ! 88 IF( ll_wrtruns ) THEN 89 ! ! open run.stat ascii file, done only by 1st subdomain 77 90 CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 91 ! ! open run.stat.nc netcdf file, done only by 1st subdomain 78 92 clname = 'run.stat.nc' 79 93 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 ! 90 IF(lwm .AND. ll_wrtstp) THEN !== current time step ==! ("time.step" file) 94 istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 95 istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) 96 istatus = NF90_DEF_VAR( nrunid, 'tau_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) 97 istatus = NF90_DEF_VAR( nrunid, 'qns_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 98 istatus = NF90_DEF_VAR( nrunid, 'emp_max', NF90_DOUBLE, (/ idtime /), nvarid(3) ) 99 istatus = NF90_ENDDEF(nrunid) 100 ENDIF 101 ! 102 ENDIF 103 ! 104 ! !== write current time step ==! 105 ! !== done only by 1st subdomain at writting timestep ==! 106 IF( lwm .AND. ll_wrtstp ) THEN 91 107 WRITE ( numstp, '(1x, i8)' ) kt 92 108 REWIND( numstp ) 93 109 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 ! 110 ! !== test of local extrema ==! 111 ! !== done by all processes at every time step ==! 112 llmsk(:,:) = tmask(:,:,1) == 1._wp 113 zmax(1) = MAXVAL( taum(:,:) , mask = llmsk ) ! max wind stress module 114 zmax(2) = MAXVAL( ABS( qns(:,:) ) , mask = llmsk ) ! max non-solar heat flux 115 zmax(3) = MAXVAL( ABS( emp(:,:) ) , mask = llmsk ) ! max E-P 116 zmax(4) = REAL( nstop, wp ) ! stop indicator 117 ! !== get global extrema ==! 118 ! !== done by all processes if writting run.stat ==! 100 119 IF( ll_colruns ) THEN 120 zmaxlocal(:) = zmax(:) 101 121 CALL mpp_max( "stpctl", zmax ) ! max over the global domain 102 nstop = NINT( zmax(3) ) ! nstop indicator sheared among all local domains 103 ENDIF 104 ! !== run statistics ==! ("run.stat" files) 122 nstop = NINT( zmax(4) ) ! update nstop indicator (now sheared among all local domains) 123 ENDIF 124 ! !== write "run.stat" files ==! 125 ! !== done only by 1st subdomain at writting timestep ==! 105 126 IF( ll_wrtruns ) THEN 106 127 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) 128 istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 129 istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 130 istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/ zmax(3)/), (/kt/), (/1/) ) 131 IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 112 132 END IF 113 ! !== error handling ==! 114 IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. ( & ! domain contains some ocean points, check for sensible ranges 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 120 !! We are 1D so no need to find a spatial location of the rogue point. 121 133 ! !== error handling ==! 134 ! !== done by all processes at every time step ==! 135 ! 136 IF( zmax(1) > 5._wp .OR. & ! too large wind stress ( > 5 N/m^2 ) 137 & zmax(2) > 2000._wp .OR. & ! too large non-solar heat flux ( > 2000 W/m^2 ) 138 & zmax(3) > 1.E-3_wp .OR. & ! too large net freshwater flux ( > 1.E-3 kg/m^2/s ) 139 & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR. & ! NaN encounter in the tests 140 & ABS( zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests 141 ! 142 iloc(:,:) = 0 143 IF( ll_colruns ) THEN ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 144 ! first: close the netcdf file, so we can read it 145 IF( lwm .AND. kt /= nitend ) istatus = NF90_CLOSE(nrunid) 146 ! get global loc on the min/max 147 CALL mpp_maxloc( 'stpctl', taum(:,:) , tmask(:,:,1), zzz, iloc(1:2,1) ) ! mpp_maxloc ok if mask = F 148 CALL mpp_maxloc( 'stpctl',ABS( qns(:,:) ), tmask(:,:,1), zzz, iloc(1:2,2) ) 149 CALL mpp_minloc( 'stpctl',ABS( emp(:,:) ), tmask(:,:,1), zzz, iloc(1:2,3) ) 150 ! find which subdomain has the max. 151 iareamin(:) = jpnij+1 ; iareamax(:) = 0 ; iareasum(:) = 0 152 DO ji = 1, 4 153 IF( zmaxlocal(ji) == zmax(ji) ) THEN 154 iareamin(ji) = narea ; iareamax(ji) = narea ; iareasum(ji) = 1 155 ENDIF 156 END DO 157 CALL mpp_min( "stpctl", iareamin ) ! min over the global domain 158 CALL mpp_max( "stpctl", iareamax ) ! max over the global domain 159 CALL mpp_sum( "stpctl", iareasum ) ! sum over the global domain 160 ELSE ! find local min and max locations: 161 ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 162 iloc(1:2,1) = MAXLOC( taum(:,:) , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 163 iloc(1:2,2) = MAXLOC( ABS( qns(:,:) ), mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 164 iloc(1:2,3) = MINLOC( ABS( emp(:,:) ), mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 165 iareamin(:) = narea ; iareamax(:) = narea ; iareasum(:) = 1 ! this is local information 166 ENDIF 167 ! 122 168 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 169 CALL wrt_line( ctmp2, kt, '|tau| max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 170 CALL wrt_line( ctmp3, kt, '|qns| max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 171 CALL wrt_line( ctmp4, kt, 'emp max', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 172 IF( Agrif_Root() ) THEN 173 WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort* files' 174 ELSE 175 WRITE(ctmp6,*) ' ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 176 ENDIF 177 ! 126 178 CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file 127 128 IF( .NOT. sn_cfctl%l_glochk ) THEN129 WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea130 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' )131 ELSE132 CALL ctl_stop( ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' )133 ENDIF134 135 kindic = -3179 ! 180 IF( ll_colruns .or. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files 181 IF(lwp) CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 182 ELSE ! only mpi subdomains with errors are here -> STOP now 183 CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 184 ENDIF 185 ! 186 IF( nstop == 0 ) nstop = 1 187 ngrdstop = Agrif_Fixed() 136 188 ! 137 189 ENDIF … … 140 192 ! 141 193 END SUBROUTINE stp_ctl 194 195 196 SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax ) 197 !!---------------------------------------------------------------------- 198 !! *** ROUTINE wrt_line *** 199 !! 200 !! ** Purpose : write information line 201 !! 202 !!---------------------------------------------------------------------- 203 CHARACTER(len=*), INTENT( out) :: cdline 204 CHARACTER(len=*), INTENT(in ) :: cdprefix 205 REAL(wp), INTENT(in ) :: pval 206 INTEGER, DIMENSION(3), INTENT(in ) :: kloc 207 INTEGER, INTENT(in ) :: kt, ksum, kmin, kmax 208 ! 209 CHARACTER(len=80) :: clsuff 210 CHARACTER(len=9 ) :: clkt, clsum, clmin, clmax 211 CHARACTER(len=9 ) :: cli, clj, clk 212 CHARACTER(len=1 ) :: clfmt 213 CHARACTER(len=4 ) :: cl4 ! needed to be able to compile with Agrif, I don't know why 214 INTEGER :: ifmtk 215 !!---------------------------------------------------------------------- 216 WRITE(clkt , '(i9)') kt 217 218 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij ,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 219 !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF 220 cl4 = '(i'//clfmt//')' ; WRITE(clsum, cl4) ksum 221 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij-1,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) 222 cl4 = '(i'//clfmt//')' ; WRITE(clmin, cl4) kmin-1 223 WRITE(clmax, cl4) kmax-1 224 ! 225 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1 ! how many digits to we need to write jpiglo? (we decide max = 9) 226 cl4 = '(i'//clfmt//')' ; WRITE(cli, cl4) kloc(1) ! this is ok with AGRIF 227 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1 ! how many digits to we need to write jpjglo? (we decide max = 9) 228 cl4 = '(i'//clfmt//')' ; WRITE(clj, cl4) kloc(2) ! this is ok with AGRIF 229 ! 230 IF( ksum == 1 ) THEN ; WRITE(clsuff,9100) TRIM(clmin) 231 ELSE ; WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax) 232 ENDIF 233 IF(kloc(3) == 0) THEN 234 ifmtk = INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 235 clk = REPEAT(' ', ifmtk) ! create the equivalent in blank string 236 WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff) 237 ELSE 238 WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) 239 !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF 240 cl4 = '(i'//clfmt//')' ; WRITE(clk, cl4) kloc(3) ! this is ok with AGRIF 241 WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), TRIM(clk), TRIM(clsuff) 242 ENDIF 243 ! 244 9100 FORMAT('MPI rank ', a) 245 9200 FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a) 246 9300 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j ', a, ' ', a, ' ', a, ' ', a) 247 9400 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a) 248 ! 249 END SUBROUTINE wrt_line 250 142 251 143 252 !!======================================================================
Note: See TracChangeset
for help on using the changeset viewer.