MODULE diafoam !!====================================================================== !! *** MODULE diafoam *** !! Ocean diagnostics : write ocean output files for FOAM diagnostics !!===================================================================== #if ! defined key_iomput !! !!---------------------------------------------------------------------- !! * Modules used USE oce ! ocean dynamics and tracers #if defined key_lim3 USE ice_3 ! LIM_3 ice model variables USE lbclnk ! ocean lateral boundary conditions (or mpp link) #endif #if defined key_lim2 USE ice_2 ! LIM_2 ice model variables USE lbclnk ! ocean lateral boundary conditions (or mpp link) #endif #if defined key_cice USE phycst, only: rsmall USE ice_state, only: uvel,vvel,vsno,vice USE sbc_ice, only: naicet USE ice_kinds_mod, only: dbl_kind USE ice_domain, only: distrb_info USE ice_domain_size, only: max_blocks, nx_global, ny_global USE ice_blocks, only: nx_block, ny_block USE ice_gather_scatter USE lbclnk ! ocean lateral boundary conditions (or mpp link) #endif USE dom_oce ! ocean space and time domain USE zdfmxl ! mixed layer USE daymod ! calendar USE dianam ! build name of file (routine) USE in_out_manager ! I/O manager USE insitu_tem, ONLY: insitu_t, theta2t USE sbc_oce ! surface boundary condition: ocean #if defined key_top USE par_trc ! biogeochemical variables USE trc #endif #if defined key_spm USE spm_con, ONLY: Eps0XS #endif USE zdf_oce USE lib_mpp ! MPP library IMPLICIT NONE PRIVATE !! * Accessibility PUBLIC dia_wri_foam ! routines called by step.F90 PUBLIC int_dia_wri_foam_alloc ! routines calles by nemogcm.F90 PUBLIC real_dia_wri_foam_alloc ! routines calles by nemogcm.F90 !! * Module variables INTEGER,DIMENSION(7):: nouttime = (/1,1,1,1,1,1,1/) !the time-stamp for instantaneous diagnostic outputs. INTEGER :: & nid_tmbT, nid_opT, nid_merT, nid_liteT, nid_shelfT, nid_25hmT, nz_T, nh_T, ndim_T, ndim_hT, ndim_tT, & ! grid_T files nid_tmbU, nid_opU, nid_merU, nid_liteU, nid_shelfU, nid_25hmU, nz_U, nh_U, ndim_U, ndim_hU, ndim_tU, & ! grid_U files nid_tmbV, nid_opV, nid_merV, nid_liteV, nid_shelfV, nid_25hmV, nz_V, nh_V, ndim_V, ndim_hV, ndim_tV, & ! grid_V files nid_opW, nid_merW, nid_25hmW, nz_W, nh_W, ndim_W, ndim_hW ! grid_W files INTEGER :: & nid_opcvT ! grid T file INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV, ndex_hW INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_T, ndex_U, ndex_V, ndex_W INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_tT, ndex_tU, ndex_tV INTEGER :: ji, jj, jk REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: ut_ice, vt_ice !: T-point zonal & meridional ice velocity REAL(wp), DIMENSION(3) :: gdept_tmb = (/ 0., 0.5, 1./) #if defined key_cice REAL(wp), PARAMETER :: aice_cutoff = 0.15 #endif !! * variables for calculating 25-hourly means REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: tn_25h, sn_25h, insitu_t_25h REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: sshn_25h, hmld_tref_25h #if defined key_lim3 || defined key_lim2 REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: hsnif_25h, hicif_25h, frld_25h #endif #if defined key_cice REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: naicet_25h #endif #if defined key_spm || key_MOersem REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: trn_25h REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: trc3d_25h REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: trc2d_25h #endif REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: un_25h, vn_25h, wn_25h REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: avt_25h, avmu_25h INTEGER :: cnt_25h !! Substitutions: # include "domzgr_substitute.h90" !!---------------------------------------------------------------------- !! OPA 9.0 , LOCEAN-IPSL (2005) !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt !!---------------------------------------------------------------------- CONTAINS INTEGER FUNCTION int_dia_wri_foam_alloc() !!---------------------------------------------------------------------- INTEGER, DIMENSION(2) :: ierr !!---------------------------------------------------------------------- ! ierr = 0 ! ALLOCATE( ndex_hT(jpi*jpj) , ndex_hU(jpi*jpj) , ndex_hV(jpi*jpj) , ndex_hW(jpi*jpj) , & & ndex_T(jpi*jpj*jpk), ndex_U(jpi*jpj*jpk), ndex_V(jpi*jpj*jpk), ndex_W(jpi*jpj*jpk), & & ndex_tT(jpi*jpj*3) , ndex_tU(jpi*jpj*3) , ndex_tV(jpi*jpj*3) , STAT=ierr(1) ) ! int_dia_wri_foam_alloc = MAXVAL(ierr) IF( lk_mpp ) CALL mpp_sum( int_dia_wri_foam_alloc ) ! END FUNCTION int_dia_wri_foam_alloc INTEGER FUNCTION real_dia_wri_foam_alloc() !!---------------------------------------------------------------------- INTEGER, DIMENSION(2) :: ierr !!---------------------------------------------------------------------- ! ierr = 0 ! ALLOCATE( ut_ice(jpi,jpj), vt_ice(jpi,jpj), tn_25h(jpi,jpj,jpk), sn_25h(jpi,jpj,jpk), & & insitu_t_25h(jpi,jpj,jpk), sshn_25h(jpi,jpj), hmld_tref_25h(jpi,jpj), un_25h(jpi,jpj,jpk), & & vn_25h(jpi,jpj,jpk), wn_25h(jpi,jpj,jpk), avt_25h(jpi,jpj,jpk), avmu_25h(jpi,jpj,jpk), & #if defined key_lim3 || defined key_lim2 & hsnif_25h(jpi,jpj), hicif_25h(jpi,jpj), frld_25h(jpi,jpj), #endif #if defined key_cice & naicet_25h(jpi,jpj), & #endif #if defined key_spm || key_MOersem & trn_25h(jpi,jpj,jpk,jptra), trc3d_25h(jpi,jpj,jpk,jpdia3d), trc2d_25h(jpi,jpj,jpdia2d), & #endif & STAT=ierr(1) ) ! real_dia_wri_foam_alloc = MAXVAL(ierr) IF( lk_mpp ) CALL mpp_sum( real_dia_wri_foam_alloc ) ! END FUNCTION real_dia_wri_foam_alloc !!---------------------------------------------------------------------- !! Default option NetCDF output file !!---------------------------------------------------------------------- !! dia_wri_foam : create the FOAM NetCDF output files !!---------------------------------------------------------------------- SUBROUTINE dia_wri_foam( kt ) !!--------------------------------------------------------------------- !! *** ROUTINE dia_wri_foam *** !! !! ** Purpose : Write diagnostics for FOAM runs !! !! ** Method : At the beginning of the first time step (nn_it000), !! define all the NETCDF files and fields. Seven options, any of !! which can be switched on or off: !! standard FOAM output, !! operational FOAM output, !! Mersea FOAM output, !! FOAM Lite, !! operational FOAM for error covariance, !! output for boundary conditions for Shelf models (UKMO and ESEOO) !! 25hr mean outputs for shelf seas !! Options are !! controlled by respective switches in nn_diafoam array (0=off, >=1=on) !! At each time step call histdef to compute the mean if ncessary !! Each nwrite time step, output the instantaneous or mean fields !! !! History : !! ?.0 ! 07-04 (A. Hines) New routine, developed from dia_wri_foam !!---------------------------------------------------------------------- !! * Modules used USE ioipsl !! * Arguments INTEGER, INTENT( in ) :: kt ! ocean time-step index !! * Local declarations LOGICAL :: ll_print = .FALSE. ! =T print and flush numout LOGICAL :: ll_set CHARACTER (len=40) :: & clhstnam, clop_in, clop_mn, clop_tmb ! temporary names CHARACTER (len=4) :: cnumout INTEGER :: inum = 11 ! temporary logical unit INTEGER :: & iimi, iima, ipk, it, & ! temporary integers ijmi, ijma, idia ! " " REAL(wp) :: & zsto, zout, zmax, & ! temporary scalars zjulian, zdt, zmdi ! " " REAL(wp), DIMENSION(jpi,jpj) :: & zw2d, un_dm, vn_dm ! temporary workspace REAL(wp), DIMENSION(jpi,jpj,jpk) :: & zw3d ! temporary workspace REAL(wp), DIMENSION(jpi,jpj,3) :: & zwtmb ! temporary workspace INTEGER :: & nyear0 , & !: start year nmonth0 , & !: start month nday0 !: start day of the month #if defined key_top CHARACTER (len=20) :: cltra, cltrau CHARACTER (len=80) :: cltral INTEGER :: jn, jl #endif #if defined key_spm ! variables needed to calculate visibility field from sediment fields REAL(wp), DIMENSION(jpi,jpj,jpk) :: vis3d ! derived 3D visibility field REAL(wp) :: epsessX = 0.07d-03 ! attenuation coefficient applied to the sediment (as used in ERSEM) REAL(wp) :: tiny = 1.0d-15 ! to prevent division by zero in visibility calculation #endif !!---------------------------------------------------------------------- ! 0. Initialisation ! ----------------- ! set 25 hour mean sums to zero at first timestep (needs to be reset after each write after 24 hours) IF( kt == nn_it000 .AND. nn_diafoam(7) .GT. 0) THEN cnt_25h = 1 ! sets the first value of sum at timestep 1 (note - should strictly be at timestep zero so before values used where possible) tn_25h(:,:,:) = tsb(:,:,:,jp_tem) sn_25h(:,:,:) = tsb(:,:,:,jp_sal) CALL theta2t insitu_t_25h(:,:,:) = insitu_t(:,:,:) sshn_25h(:,:) = sshb(:,:) hmld_tref_25h(:,:) = hmld_tref(:,:) #if defined key_lim3 || defined key_lim2 hsnif_25h(:,:) = hsnif(:,:) hicif_25h(:,:) = hicif(:,:) frld_25h(:,:) = frld(:,:) #endif # if defined key_cice naicet_25h(:,:) = naicet(:,:,1) #endif un_25h(:,:,:) = ub(:,:,:) vn_25h(:,:,:) = vb(:,:,:) wn_25h(:,:,:) = wn(:,:,:) avt_25h(:,:,:) = avt(:,:,:) avmu_25h(:,:,:) = avmu(:,:,:) IF(lwp) THEN WRITE(numout,*) 'dia_wri_foam: Calculating 25-hour means at timestep',kt WRITE(numout,*) '~~~~~~~~~~~~' ENDIF ENDIF #if defined key_spm || defined key_MOersem IF( kt == nn_it000*ndttrc .AND. nn_diafoam(7) .GT. 0) THEN trn_25h(:,:,:,:) = trn(:,:,:,:) trc3d_25h(:,:,:,:) = trc3d(:,:,:,:) trc2d_25h(:,:,:) = trc2d(:,:,:) IF(lwp) THEN WRITE(numout,*) 'dia_wri_foam: initialize TOP variables at nn_it000*ndddtrc', nn_it000*ndttrc WRITE(numout,*) '~~~~~~~~~~~~' ENDIF ENDIF #endif ! local variable for debugging ll_print = ll_print .AND. lwp ! Define frequency of output and means zdt = rdt IF( nacc == 1 ) zdt = rdtmin clop_in = "inst(x)" clop_mn = "ave(x)" clop_tmb= "inst(only(x))" zsto = zdt zmax = ( nitend - nn_it000 + 1 ) * zdt ! Define indices of the horizontal output zoom and vertical limit storage iimi = 1 ; iima = jpi ijmi = 1 ; ijma = jpj ipk = jpk IF (nn_it000 .le. 0) CALL ctl_stop( 'dia_wri_foam: nn_it000 must be greater than 0 in namelist namrun' ) ! define time axis it = kt - nn_it000 + 1 ! setup reference date values to be at the start of the run nyear0 = ndate0 / 10000 nmonth0 = ( ndate0 - (nyear0 * 10000) ) / 100 nday0 = ndate0 - (nyear0 * 10000) - ( nmonth0 * 100 ) ! 1. Define NETCDF files and fields at beginning of first time step ! ----------------------------------------------------------------- IF(ll_print) WRITE(numout,*) 'dia_wri_foam kt = ', kt ll_set = .false. DO idia = 1, 7 IF (nn_diafoam(idia) .GT. 0) THEN IF (MOD(kt-1,nn_diafoam(idia)) == 0) ll_set = .true. ENDIF END DO IF( ll_set ) THEN IF(lwp) THEN WRITE(numout,*) 'dia_wri_foam : write FOAM diagnostics to NetCDF on timestep: ',kt WRITE(numout,*) '~~~~~~~~~~~~ ' ENDIF ! Define the NETCDF files (one per grid) ! Compute julian date from starting date of the run CALL ymds2ju( nyear0, nmonth0, nday0, 0.e0, zjulian ) IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'Date 0 used :', nn_it000, ' YEAR ', nyear, & & ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian IF(lwp) WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma, & ' limit storage in depth = ', ipk ! Define grid index arrays ! Index of ocean points CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndex_T , ndim_T ) ! volume CALL wheneq( jpi*jpj , tmask, 1, 1., ndex_hT, ndim_hT ) ! surface CALL wheneq( jpi*jpj*3 , tmask, 1, 1., ndex_tT, ndim_tT ) ! Top, middle, bottom ! CALL wheneq( jpi*jpj*ipk, umask, 1, 1., ndex_U , ndim_U ) ! volume CALL wheneq( jpi*jpj , umask, 1, 1., ndex_hU, ndim_hU ) ! surface CALL wheneq( jpi*jpj*3 , umask, 1, 1., ndex_tU, ndim_tU ) ! Top, middle, bottom ! CALL wheneq( jpi*jpj*ipk, vmask, 1, 1., ndex_V , ndim_V ) ! volume CALL wheneq( jpi*jpj , vmask, 1, 1., ndex_hV, ndim_hV ) ! surface CALL wheneq( jpi*jpj*3 , vmask, 1, 1., ndex_tV, ndim_tV ) ! Top, middle, bottom ! #if ! key_shelf_OPER && key_shelf CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndex_W , ndim_W ) ! volume CALL wheneq( jpi*jpj , tmask, 1, 1., ndex_hW, ndim_hW ) ! surface #endif ! Definitions for top,middle,bottom FOAM output streams IF( nn_diafoam(1) .GT. 0 .AND. kt == nn_it000 ) THEN ! Output all times in one file IF(lwp) WRITE(numout,*) "Top,Middle,Bottom FOAM diagnostics every ",nn_diafoam(1)," timesteps." zout = nn_diafoam(1) * zdt ! Define the instantaneous output files clhstnam=TRIM(cexper)//'.shelftmb.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt and gphit & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_T, nid_tmbT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_tmbT, "deptht", "Vertical T tmb levels", & ! Vertical grid: gdept_tmb & "non dimensional", 3, gdept_tmb, nz_T, pdirect='down' ) ! Define the U grid FILE ( nid_tmbU ) clhstnam=TRIM(cexper)//'.shelftmb.grid_U' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu and gphiu & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_U, nid_tmbU, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_tmbU, "depthu", "Vertical U tmb levels", & ! Vertical grid: gdept_tmb & "non dimensional", 3, gdept_tmb, nz_U, pdirect='down' ) ! Define the V grid FILE ( nid_tmbV ) clhstnam=TRIM(cexper)//'.shelftmb.grid_V' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv and gphiv & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_V, nid_tmbV, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_tmbV, "depthv", "Vertical V tmb levels", & ! Vertical grid : gdept_tmb & "non dimensional", 3, gdept_tmb, nz_V, pdirect='down' ) ! Declare all the output fields as NETCDF variables CALL histdef( nid_tmbT, "votemper", "TMB Temperature" , "C" , & ! tmb temp & jpi, jpj, nh_T, 3 , 1, 3 , nz_T , 32, clop_tmb, zout, zout ) CALL histdef( nid_tmbT, "vosaline", "TMB Salinity" , "PSU" , & ! tmb sal & jpi, jpj, nh_T, 3 , 1, 3 , nz_T , 32, clop_tmb, zout, zout ) CALL histdef( nid_tmbT, "sossheig", "Sea Surface Height" , "m" , & ! ssh & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_tmb, zout, zout ) CALL histdef( nid_tmbT, "sotrefml", "T criterion Mixed Layer Depth" , "m" , & ! hmld_tref & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_tmb, zout, zout ) #if defined key_lim3 || defined key_lim2 CALL histdef( nid_tmbT, "isnowthi", "Snow thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_tmb, zout, zout ) CALL histdef( nid_tmbT, "iicethic", "Ice thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_tmb, zout, zout ) #endif #if defined key_lim3 || defined key_lim2 || defined key_cice CALL histdef( nid_tmbT, "iiceconc", "Ice concentration" , "%" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_tmb, zout, zout ) #endif #if defined key_spm CALL histdef( nid_tmbT, "vovisible", "TMB Visibility" , "m" , & ! tmb visibility & jpi, jpj, nh_T, 3 , 1, 3 , nz_T , 32, clop_tmb, zout, zout ) #endif CALL histend( nid_tmbT, snc4chunks=snc4set ) ! ! !!! nid_U : 3D CALL histdef( nid_tmbU, "vobtcrtx", "Barotropic zonal Current" , "m/s" , & ! barotropic u & jpi, jpj, nh_U, 1, 1, 1, -99 , 32, clop_tmb, zout, zout ) CALL histdef( nid_tmbU, "vozocrtx", "TMB Zonal Current" , "m/s" , & ! tmb un & jpi, jpj, nh_U, 3, 1, 3, nz_U, 32, clop_tmb, zout, zout ) CALL histend( nid_tmbU, snc4chunks=snc4set ) ! ! !!! nid_V : 3D CALL histdef( nid_tmbV, "vobtcrty", "Barotropic meridional Current" , "m/s" , & ! barotropic v & jpi, jpj, nh_V, 1, 1, 1, -99 , 32, clop_tmb, zout, zout ) CALL histdef( nid_tmbV, "vomecrty", "TMB Meridional Current" , "m/s" , & ! tmb vn & jpi, jpj, nh_V, 3, 1, 3, nz_V, 32, clop_tmb, zout, zout ) CALL histend( nid_tmbV, snc4chunks=snc4set ) ! ENDIF ! Definitions for operational FOAM output streams IF( nn_diafoam(2) .GT. 0) THEN !This stream now outputs separate files for each output time. IF (MOD(kt-1,nn_diafoam(2)) == 0 ) THEN IF(lwp) WRITE(numout,*) "FOAM operational diagnostics every ",nn_diafoam(2)," timesteps." zout = nn_diafoam(2) * zdt ! Define the instantaneous output files WRITE(cnumout,'(i4.4)') nouttime(2) clhstnam=TRIM(cexper)//'.'//cnumout//'.diaopfoam.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_T, nid_opT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_opT, "deptht", "Vertical T levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_T, pdirect='down' ) ! Define the U grid FILE ( nid_opU ) clhstnam=TRIM(cexper)//'.'//cnumout//'.diaopfoam.grid_U' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_U, nid_opU, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_opU, "depthu", "Vertical U levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_U, pdirect='down' ) ! Define the V grid FILE ( nid_opV ) clhstnam=TRIM(cexper)//'.'//cnumout//'.diaopfoam.grid_V' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_V, nid_opV, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_opV, "depthv", "Vertical V levels", & ! Vertical grid : gdept_0 & "m", ipk, gdept_0, nz_V, pdirect='down' ) #if ! key_shelf_OPER && key_shelf ! Define the W grid FILE ( nid_opW ) clhstnam=TRIM(cexper)//'.'//cnumout//'.diaopfoam.grid_W' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_W, nid_opW, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_opW, "depthw", "Vertical W levels", & ! Vertical grid : gdepw_0 & "m", ipk, gdepw_0, nz_W, pdirect='down' ) #endif ! Declare all the output fields as NETCDF variables CALL histdef( nid_opT, "votemper", "Temperature" , "C" , & ! tsn(:,:,:,jp_tem) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_opT, "votempis", "In-situ Temperature" , "C" , & ! insitu_t & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_opT, "vosaline", "Salinity" , "PSU" , & & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) ! CALL histdef( nid_opT, "sossheig", "Sea Surface Height" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) ! CALL histdef( nid_opT, "sokaraml", "Kara Mixed Layer Depth" , "m" , & ! & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) ! #if defined key_lim3 || defined key_lim2 || defined key_cice CALL histdef( nid_opT, "isnowthi", "Snow thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_opT, "iicethic", "Ice thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_opT, "iiceconc", "Ice concentration" , "%" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) #endif #if defined key_spm || key_MOersem ! output main tracers DO jn = 1, jptra IF( lutsav(jn) ) THEN cltra = ctrcnm(jn) ! short title for tracer cltral = ctrcnl(jn) ! long title for tracer cltrau = ctrcun(jn) ! UNIT for tracer CALL histdef( nid_opT, cltra, cltral, cltrau, & & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) ENDIF END DO ! more 3D horizontal arrays from diagnostics DO jl = 1, jpdia3d cltra = ctrc3d(jl) ! short title for 3D diagnostic cltral = ctrc3l(jl) ! long title for 3D diagnostic cltrau = ctrc3u(jl) ! UNIT for 3D diagnostic CALL histdef( nid_opT, cltra, cltral, cltrau, jpi, jpj, nh_T, & & ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) END DO ! more 2D horizontal arrays from diagnostics DO jl = 1, jpdia2d cltra = ctrc2d(jl) ! short title for 2D diagnostic cltral = ctrc2l(jl) ! long title for 2D diagnostic cltrau = ctrc2u(jl) ! UNIT for 2D diagnostic CALL histdef( nid_opT, cltra, cltral, cltrau, jpi, jpj, nh_T, & & 1, 1, 1, -99, 32, clop_in, zout, zout ) END DO #endif CALL histend( nid_opT, snc4chunks=snc4set ) ! CALL histdef( nid_opU, "vozocrtx", "Zonal Current" , "m/s" , & ! un & jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop_in, zout, zout ) CALL histend( nid_opU, snc4chunks=snc4set ) ! CALL histdef( nid_opV, "vomecrty", "Meridional Current" , "m/s" , & ! vn & jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop_in, zout, zout ) CALL histend( nid_opV, snc4chunks=snc4set ) ! #if ! key_shelf_OPER && key_shelf CALL histdef( nid_opW, "vovecrtz", "Vertical Velocity" , "m/s" , & ! wn & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_in, zout, zout ) CALL histdef( nid_opW, "votkeavt", "Vertical Eddy Diffusivity" , "m2/s" , & ! avt & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_in, zout, zout ) CALL histdef( nid_opW, "votkeavm", "Vertical Eddy Viscosity" , "m2/s" , & ! avmu & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_in, zout, zout ) CALL histend( nid_opW, snc4chunks=snc4set ) #endif ENDIF ENDIF ! Definitions for Mersea FOAM output streams IF( nn_diafoam(3) .GT. 0 .AND. kt == nn_it000 ) THEN !output all to one file IF(lwp) WRITE(numout,*) "FOAM Mersea diagnostics every ",nn_diafoam(3)," timesteps" zout = nn_diafoam(3) * zdt ! Define the Mersea daily mean output files clhstnam=TRIM(cexper)//'.mersea.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & 0, zjulian, zdt, nh_T, nid_merT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_merT, "deptht", "Vertical T levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_T, pdirect='down' ) ! Define the U grid FILE ( nid_merU ) clhstnam=TRIM(cexper)//'.mersea.grid_U' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & 0, zjulian, zdt, nh_U, nid_merU, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_merU, "depthu", "Vertical U levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_U, pdirect='down' ) ! Define the V grid FILE ( nid_merV ) clhstnam=TRIM(cexper)//'.mersea.grid_V' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & 0, zjulian, zdt, nh_V, nid_merV, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_merV, "depthv", "Vertical V levels", & ! Vertical grid : gdept_0 & "m", ipk, gdept_0, nz_V, pdirect='down' ) ! Define the W grid FILE ( nid_merW ) clhstnam=TRIM(cexper)//'.mersea.grid_W' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & 0, zjulian, zdt, nh_W, nid_merW, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_merW, "depthw", "Vertical W levels", & ! Vertical grid : gdepw_0 & "m", ipk, gdepw_0, nz_W, pdirect='down' ) ! Declare all the output fields as NETCDF variables CALL histdef( nid_merT, "votemper", "Temperature" , "C" , & ! tsn(:,:,1,jp_tem) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_mn, zsto, zout ) CALL histdef( nid_merT, "vosaline", "Salinity" , "PSU" , & ! tsn(:,:,1,jp_sal) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_mn, zsto, zout ) CALL histdef( nid_merT, "sossheig", "Sea Surface Height" , "m" , & ! ssh & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zsto, zout ) CALL histdef( nid_merT, "somxl010", "Mixed Layer Depth 0.01" , "m" , & ! hmlp & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zsto, zout ) ! CALL histdef( nid_merT, "sokaraml", "Kara Mixed Layer Depth" , "m" , & ! hmld_kara ! & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zsto, zout ) CALL histdef( nid_merT, "so_thflx", "Total heat flux" , "W m-2" , & ! total heat flux & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zsto, zout ) CALL histdef( nid_merT, "so_shflx", "Solar heat flux" , "W m-2" , & ! solar heat flux & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zsto, zout ) CALL histdef( nid_merT, "so_evmpr", "Evaporation minus precipitation" , "kg m-2 s-1", & ! E-P & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zsto, zout ) #if defined key_lim3 || defined key_lim2 || defined key_cice CALL histdef( nid_merT, "iiceconc", "Ice concentration" , "%" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zout, zout ) CALL histdef( nid_merT, "isnowthi", "Snow thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zout, zout ) CALL histdef( nid_merT, "iicethic", "Ice thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zout, zout ) CALL histdef( nid_merT, "itzocrtx", "Ice zonal current" , "m/s" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zout, zout ) CALL histdef( nid_merT, "itmecrty", "Ice meridional current" , "m/s" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_mn, zout, zout ) #endif CALL histend( nid_merT, snc4chunks=snc4set ) ! !!! nid_U : 3D CALL histdef( nid_merU, "vozocrtx", "Zonal Current" , "m/s" , & ! un & jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop_mn, zsto, zout ) CALL histdef( nid_merU, "sozowind", "Zonal wind stress" , "Pa" , & ! wind stress & jpi, jpj, nh_U, 1, 1, 1, -99, 32, clop_mn, zsto, zout ) CALL histend( nid_merU, snc4chunks=snc4set ) ! !!! nid_V : 3D CALL histdef( nid_merV, "vomecrty", "Meridional Current" , "m/s" , & ! vn & jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop_mn, zsto, zout ) CALL histdef( nid_merV, "somewind", "Meridional wind stress" , "Pa" , & ! wind stress & jpi, jpj, nh_V, 1, 1, 1, -99, 32, clop_mn, zsto, zout ) CALL histend( nid_merV, snc4chunks=snc4set ) ! CALL histdef( nid_merW, "vovecrtz", "Vertical Velocity" , "m/s" , & ! wn & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_mn, zsto, zout ) CALL histend( nid_merW, snc4chunks=snc4set ) ENDIF ! Definitions for ORCA025 FOAM output streams IF( nn_diafoam(4) .GT. 0 .AND. kt == nn_it000 ) THEN !Output all in one file IF(lwp) WRITE(numout,*) "FOAM-LITE diagnostics every ",nn_diafoam(4)," timesteps" #if defined key_cice IF(lwp) WRITE(numout,*) "aice_cutoff is ",aice_cutoff #endif IF(lwp) CALL flush(numout) zout = nn_diafoam(4) * zdt ! Define the instantaneous output files clhstnam=TRIM(cexper)//'.foamlite.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_T, nid_liteT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_liteT, "deptht", "Vertical T levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_T, pdirect='down' ) ! Define the U grid FILE ( nid_liteU ) clhstnam=TRIM(cexper)//'.foamlite.grid_U' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_U, nid_liteU, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_liteU, "depthu", "Vertical U levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_U, pdirect='down' ) ! Define the V grid FILE ( nid_liteV ) clhstnam=TRIM(cexper)//'.foamlite.grid_V' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_V, nid_liteV, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_liteV, "depthv", "Vertical V levels", & ! Vertical grid : gdept_0 & "m", ipk, gdept_0, nz_V, pdirect='down' ) ! Declare all the output fields as NETCDF variables CALL histdef( nid_liteT, "sosstsst", "Sea Surface temperature" , "C" , & ! sst & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_liteT, "sosaline", "Sea Surface Salinity" , "PSU" , & ! sss & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_liteT, "sossheig", "Sea Surface Height" , "m" , & ! ssh & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) #if defined key_lim3 || defined key_lim2 || defined key_cice CALL histdef( nid_liteT, "iiceconc", "Ice concentration" , "%" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_liteT, "iicethic", "Ice thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) #endif ! CALL histdef( nid_liteT, "sokaraml", "Kara Mixed Layer Depth" , "m" , & ! & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histend( nid_liteT, snc4chunks=snc4set ) ! !!! nid_V : 3D CALL histdef( nid_liteU, "sozocrtx", "Zonal Surface Current" , "m/s" , & ! un(jk=1) & jpi, jpj, nh_U, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histend( nid_liteU, snc4chunks=snc4set ) ! !!! nid_V : 3D CALL histdef( nid_liteV, "somecrty", "Meridional Surface Current" , "m/s" , & ! vn(jk=1) & jpi, jpj, nh_V, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histend( nid_liteV, snc4chunks=snc4set ) ENDIF IF( nn_diafoam(5) .GT. 0) THEN !This stream now outputs separate files for each output time. IF (MOD(kt-1,nn_diafoam(5)) == 0) THEN IF(lwp) WRITE(numout,*) "FOAM operational diagnostics for covariance calcs every ",nn_diafoam(5)," timesteps." zout = nn_diafoam(5) * zdt ! Define the instantaneous output files WRITE(cnumout,'(i4.4)')nouttime(5) clhstnam=TRIM(cexper)//'.'//cnumout//'.diaopcvfoam.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_T, nid_opcvT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_opcvT, "deptht", "Vertical T levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_T, pdirect='down' ) ! Declare all the output fields as NETCDF variables CALL histdef( nid_opcvT, "votemper", "Temperature" , "C" , & ! tsn(:,:,:,jp_tem) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_opcvT, "vosaline", "Salinity" , "PSU" , & & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) ! CALL histdef( nid_opcvT, "sossheig", "Sea Surface Height" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) ! #if defined key_lim3 || defined key_lim2 || defined key_cice CALL histdef( nid_opcvT, "iiceconc", "Ice concentration" , "%" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) #endif CALL histend( nid_opcvT, snc4chunks=snc4set ) ! ENDIF ENDIF ! Definitions for output for Shelf boundary conditions (UKMO and ESEOO) IF( nn_diafoam(6) .GT. 0 .AND. kt == nn_it000 ) THEN !Output all in one file IF(lwp) WRITE(numout,*) "Output for Shelf Seas boundary conditions every ",nn_diafoam(6)," timesteps" zout = nn_diafoam(6) * zdt ! Define the instantaneous output files clhstnam=TRIM(cexper)//'.shelfbc.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_T, nid_shelfT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_shelfT, "deptht", "Vertical T levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_T, pdirect='down' ) ! Define the U grid FILE ( nid_shelfU ) clhstnam=TRIM(cexper)//'.shelfbc.grid_U' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_U, nid_shelfU, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_shelfU, "depthu", "Vertical U levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_U, pdirect='down' ) ! Define the V grid FILE ( nid_shelfV ) clhstnam=TRIM(cexper)//'.shelfbc.grid_V' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_V, nid_shelfV, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_shelfV, "depthv", "Vertical V levels", & ! Vertical grid : gdept_0 & "m", ipk, gdept_0, nz_V, pdirect='down' ) ! Declare all the output fields as NETCDF variables CALL histdef( nid_shelfT, "votemper", "Temperature" , "C" , & ! tsn(:,:,:,jp_tem) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_shelfT, "vosaline", "Salinity" , "PSU" , & ! tsn(:,:,:,jp_sal) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_shelfT, "sossheig", "Sea Surface Height" , "m" , & ! ssh & jpi, jpj, nh_T, 1, 1, 1, -99 , 32, clop_in, zout, zout ) CALL histdef( nid_shelfU, "vobtcrtx", "Barotropic zonal Current" , "m/s" , & ! baratropic u & jpi, jpj, nh_U, 1, 1, 1, -99 , 32, clop_in, zout, zout ) CALL histdef( nid_shelfU, "vozocrtx", "Zonal Current" , "m/s" , & ! baraclinic u & jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop_in, zout, zout ) CALL histdef( nid_shelfV, "vobtcrty", "Barotropic meridional Current" , "m/s" , & ! baratropic v & jpi, jpj, nh_V, 1, 1, 1, -99 , 32, clop_in, zout, zout ) CALL histdef( nid_shelfV, "vomecrty", "Meridional Current" , "m/s" , & ! baraclinic v & jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop_in, zout, zout ) CALL histend( nid_shelfT, snc4chunks=snc4set ) CALL histend( nid_shelfU, snc4chunks=snc4set ) CALL histend( nid_shelfV, snc4chunks=snc4set ) ! ENDIF ! Definitions for 25 hour mean output streams (at the end of the routine as previous file is open at start) IF( nn_diafoam(7) .GT. 0) THEN !This stream now outputs separate files for each output time. IF (kt .eq. nn_it000) THEN IF(lwp) WRITE(numout,*) "FOAM 25 hour mean diagnostics every ",nn_diafoam(7)*24," timesteps." zout = nn_diafoam(7) * zdt ! Define the instantaneous output files WRITE(cnumout,'(i4.4)')nouttime(7) clhstnam=TRIM(cexper)//'.25hourm.grid_T' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_T, nid_25hmT, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_25hmT, "deptht", "Vertical T levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_T, pdirect='down' ) ! Define the U grid FILE ( nid_25hmU ) clhstnam=TRIM(cexper)//'.25hourm.grid_U' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_U, nid_25hmU, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_25hmU, "depthu", "Vertical U levels", & ! Vertical grid: gdept_0 & "m", ipk, gdept_0, nz_U, pdirect='down' ) ! Define the V grid FILE ( nid_25hmV ) clhstnam=TRIM(cexper)//'.25hourm.grid_V' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_V, nid_25hmV, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_25hmV, "depthv", "Vertical V levels", & ! Vertical grid : gdept_0 & "m", ipk, gdept_0, nz_V, pdirect='down' ) #if ! key_shelf_OPER && key_shelf ! Define the W grid FILE ( nid_25hmW ) clhstnam=TRIM(cexper)//'.25hourm.grid_W' IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & kt-1, zjulian, zdt, nh_W, nid_25hmW, domain_id=nidom, snc4chunks=snc4set ) CALL histvert( nid_25hmW, "depthw", "Vertical W levels", & ! Vertical grid : gdepw_0 & "m", ipk, gdepw_0, nz_W, pdirect='down' ) #endif ! Declare all the output fields as NETCDF variables CALL histdef( nid_25hmT, "votemper", "Temperature" , "C" , & ! tsn(:,:,:,jp_tem) & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_25hmT, "votempis", "In-situ Temperature" , "C" , & ! insitu_t & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) CALL histdef( nid_25hmT, "vosaline", "Salinity" , "PSU" , & & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) ! CALL histdef( nid_25hmT, "sossheig", "Sea Surface Height" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_25hmT, "sotrefml", "T criterion Mixed Layer Depth" , "m" , & ! hmld_tref & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) ! #if defined key_lim3 || defined key_lim2 CALL histdef( nid_25hmT, "isnowthi", "Snow thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) CALL histdef( nid_25hmT, "iicethic", "Ice thickness" , "m" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) #endif #if defined key_lim3 || defined key_lim2 || defined key_cice CALL histdef( nid_25hmT, "iiceconc", "Ice concentration" , "%" , & & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop_in, zout, zout ) #endif #if defined key_spm || key_MOersem ! output biogeochemical variables: ! output main tracers DO jn = 1, jptra IF( lutsav(jn) ) THEN cltra = ctrcnm(jn) ! short title for tracer cltral = ctrcnl(jn) ! long title for tracer cltrau = ctrcun(jn) ! UNIT for tracer CALL histdef( nid_25hmT, cltra, cltral, cltrau, & & jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) ENDIF END DO ! more 3D horizontal arrays from diagnostics DO jl = 1, jpdia3d cltra = ctrc3d(jl) ! short title for 3D diagnostic cltral = ctrc3l(jl) ! long title for 3D diagnostic cltrau = ctrc3u(jl) ! UNIT for 3D diagnostic CALL histdef( nid_25hmT, cltra, cltral, cltrau, jpi, jpj, nh_T, & & ipk, 1, ipk, nz_T, 32, clop_in, zout, zout ) END DO ! more 2D horizontal arrays from diagnostics DO jl = 1, jpdia2d cltra = ctrc2d(jl) ! short title for 2D diagnostic cltral = ctrc2l(jl) ! long title for 2D diagnostic cltrau = ctrc2u(jl) ! UNIT for 2D diagnostic CALL histdef( nid_25hmT, cltra, cltral, cltrau, jpi, jpj, nh_T, & & 1, 1, 1, -99, 32, clop_in, zout, zout ) END DO #endif CALL histend( nid_25hmT, snc4chunks=snc4set ) ! CALL histdef( nid_25hmU, "vozocrtx", "Zonal Current" , "m/s" , & ! un & jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop_in, zout, zout ) CALL histend( nid_25hmU, snc4chunks=snc4set ) ! CALL histdef( nid_25hmV, "vomecrty", "Meridional Current" , "m/s" , & ! vn & jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop_in, zout, zout ) CALL histend( nid_25hmV, snc4chunks=snc4set ) ! #if ! key_shelf_OPER && key_shelf CALL histdef( nid_25hmW, "vovecrtz", "Vertical Velocity" , "m/s" , & ! wn & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_in, zout, zout ) CALL histdef( nid_25hmW, "votkeavt", "Vertical Eddy Diffusivity" , "m2/s" , & ! avt & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_in, zout, zout ) CALL histdef( nid_25hmW, "votkeavm", "Vertical Eddy Viscosity" , "m2/s" , & ! avmu & jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop_in, zout, zout ) CALL histend( nid_25hmW, snc4chunks=snc4set ) #endif ENDIF ENDIF IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization on timestep: ',kt IF(ll_print) CALL FLUSH(numout ) ENDIF !lset ! 2. Start writing data ! --------------------- ! mask the fields with a missing data indicator (not a long-term fix) zmdi = missing_val IF(lwp) WRITE(numout,*) 'nn_diafoam is ',nn_diafoam(:) ! Write data for Top, Middle, Bottom FOAM output stream IF( nn_diafoam(1) .GT. 0 ) THEN IF(lwp .AND. MOD( kt, nn_diafoam(1) ) == 0 ) THEN WRITE(numout,*) 'dia_wri_foam : Writing Top,Middle,Bottom FOAM diagnostics at ',kt,' time-step' ENDIF ! write tracers (instantaneous) CALL calc_tmb( tsn(:,:,:,jp_tem), zwtmb) CALL histwrite( nid_tmbT, "votemper", it, zwtmb , ndim_tT , ndex_tT ) ! tmb temperature CALL calc_tmb( tsn(:,:,:,jp_sal), zwtmb) CALL histwrite( nid_tmbT, "vosaline", it, zwtmb , ndim_tT , ndex_tT ) ! tmb salinity zw2d(:,:) = sshn(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface height zw2d(:,:) = hmld_tref(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "sotrefml", it, zw2d , ndim_hT, ndex_hT ) ! mixed layer #if defined key_lim3 || defined key_lim2 ! Write ice model variables (instantaneous) zw2d(:,:) = hsnif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = hicif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = (1.0-frld(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concentration #endif #if defined key_cice ! Write ice model variables (instantaneous) zw2d(:,:) = 0.0 CALL cice2nemo(vsno(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GE. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! snow thickness zw2d(:,:) = 0.0 CALL cice2nemo(vice(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GT. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = 0.0 WHERE(naicet(:,:,1) .GE. aice_cutoff) zw2d(:,:) = (naicet(:,:,1))*tmask(:,:,1) zw2d(:,:) = zw2d(:,:) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_tmbT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concentration #endif #if defined key_spm ! Derive visibility fields from sediment fields (1.0d3 converts g/m^3 to mg/m^3) DO jk = 1, jpkm1 vis3d(:,:,jk) = 1.7_wp / (1.0d3_wp*(tiny + trn(:,:,jk,1) + trn(:,:,jk,2))*epsessX + eps0xs(:,:)) ENDDO ! Write visibility CALL calc_tmb( vis3d, zwtmb) CALL histwrite( nid_tmbT, "vovisible", it, zwtmb , ndim_tT , ndex_tT ) ! top, middle, bottom visibility #endif ! Write velocities (instantaneous) CALL calc_tmb( un, zwtmb) CALL histwrite( nid_tmbU, "vozocrtx", it, zwtmb , ndim_tU , ndex_tU ) ! top, middle, bottom i-current CALL calc_tmb( vn, zwtmb) CALL histwrite( nid_tmbV, "vomecrty", it, zwtmb , ndim_tV , ndex_tV ) ! top, middle, bottom j-current ! Calculate depth-mean currents. un_dm(:,:) = 0.0 vn_dm(:,:) = 0.0 ! vertical sum IF( lk_vopt_loop ) THEN ! vector opt., forced unroll DO jk = 1, jpkm1 DO ji = 1, jpij un_dm(ji,1) = un_dm(ji,1) + fse3u(ji,1,jk) * un(ji,1,jk) vn_dm(ji,1) = vn_dm(ji,1) + fse3v(ji,1,jk) * vn(ji,1,jk) END DO END DO ELSE ! No vector opt. DO jk = 1, jpkm1 un_dm(:,:) = un_dm(:,:) + fse3u(:,:,jk) * un(:,:,jk) vn_dm(:,:) = vn_dm(:,:) + fse3v(:,:,jk) * vn(:,:,jk) END DO ENDIF un_dm(:,:) = un_dm(:,:) * hur(:,:) * umask(:,:,1) + zmdi*(1.0-umask(:,:,1)) vn_dm(:,:) = vn_dm(:,:) * hvr(:,:) * vmask(:,:,1) + zmdi*(1.0-vmask(:,:,1)) CALL histwrite( nid_tmbU, "vobtcrtx", it, un_dm , ndim_hU , ndex_hU ) ! i-depth-mean-current CALL histwrite( nid_tmbV, "vobtcrty", it, vn_dm , ndim_hV , ndex_hV ) ! j-depth-mean-current ENDIF ! Write data for operational FOAM output streams IF( nn_diafoam(2) .GT. 0 ) THEN IF(lwp .AND. MOD( kt, nn_diafoam(2) ) == 0 ) THEN WRITE(numout,*) 'dia_wri_foam : Writing Operational FOAM diagnostics at ',kt,' time-step' ENDIF ! write tracers (instantaneous) zw3d(:,:,:) = tsn(:,:,:,jp_tem)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opT, "votemper", it, zw3d , ndim_T , ndex_T ) ! potential temperature CALL theta2t ! calculate insitu temp zw3d(:,:,:) = insitu_t(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opT, "votempis", it, zw3d , ndim_T , ndex_T ) ! temperature zw3d(:,:,:) = tsn(:,:,:,jp_sal)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opT, "vosaline", it, zw3d , ndim_T , ndex_T ) ! salinity zw2d(:,:) = sshn(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface ! zw2d(:,:) = hmld_kara(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) ! CALL histwrite( nid_opT, "sokaraml", it, zw2d , ndim_hT, ndex_hT ) ! mixed layer #if defined key_lim3 || defined key_lim2 ! Write ice model variables (instantaneous) zw2d(:,:) = hsnif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = hicif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = (1.0-frld(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concetration #endif #if defined key_cice ! Write ice model variables (instantaneous) zw2d(:,:) = 0.0 CALL cice2nemo(vsno(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GT. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = 0.0 CALL cice2nemo(vice(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GT. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = 0.0 WHERE(naicet(:,:,1) .GE. aice_cutoff) zw2d(:,:) = (naicet(:,:,1))*tmask(:,:,1) zw2d(:,:) = zw2d(:,:) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concentration #endif #if defined key_spm || key_MOersem ! output main tracers DO jn = 1, jptra cltra = ctrcnm(jn) ! short title for tracer zw3d(:,:,:) = trn(:,:,:,jn)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) IF( lutsav(jn) ) CALL histwrite( nid_opT, cltra, it, zw3d , ndim_T , ndex_T ) ! temperature END DO ! more 3D horizontal arrays from diagnostics DO jl = 1, jpdia3d cltra = ctrc3d(jl) ! short title for 3D diagnostic zw3d(:,:,:) = trc3d(:,:,:,jl)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opT, cltra, it, zw3d , ndim_T , ndex_T ) END DO ! more 2D horizontal arrays from diagnostics DO jl = 1, jpdia2d cltra = ctrc2d(jl) ! short title for 2D diagnostic zw2d(:,:) = trc2d(:,:,jl)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite(nid_opT, cltra, it, zw2d , ndim_hT ,ndex_hT) END DO #endif ! Write velocities (instantaneous) zw3d(:,:,:) = un(:,:,:)*umask(:,:,:) + zmdi*(1.0-umask(:,:,:)) CALL histwrite( nid_opU, "vozocrtx", it, zw3d , ndim_U , ndex_U ) ! i-current zw3d(:,:,:) = vn(:,:,:)*vmask(:,:,:) + zmdi*(1.0-vmask(:,:,:)) CALL histwrite( nid_opV, "vomecrty", it, zw3d , ndim_V , ndex_V ) ! j-current #if ! key_shelf_OPER && key_shelf zw3d(:,:,:) = wn(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opW, "vomecrtz", it, zw3d , ndim_W , ndex_W ) ! k-current zw3d(:,:,:) = avt(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opW, "votkeavt", it, zw3d , ndim_W , ndex_W ) ! k-current zw3d(:,:,:) = avmu(:,:,:)*umask(:,:,:) + zmdi*(1.0-umask(:,:,:)) CALL histwrite( nid_opW, "votkeavm", it, zw3d , ndim_W , ndex_W ) ! k-current #endif ENDIF ! Write data for Mersea FOAM output streams IF( nn_diafoam(3) .GT. 0 ) THEN IF(lwp .AND. MOD( kt, nn_diafoam(3) ) == 0 ) THEN WRITE(numout,*) 'dia_wri_foam : Writing MERSEA FOAM diagnostics at ',kt,' time-step' ENDIF ! write tracers (daily means) zw3d(:,:,:) = tsn(:,:,:,jp_tem)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_merT, "votemper", it, zw3d , ndim_T , ndex_T ) ! temperature zw3d(:,:,:) = tsn(:,:,:,jp_sal)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_merT, "vosaline", it, zw3d , ndim_T , ndex_T ) ! salinity zw2d(:,:) = sshn(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface height zw2d(:,:) = hmlp(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "somxl010", it, zw2d , ndim_hT, ndex_hT ) ! mixed layer depth ! zw2d(:,:) = hmld_kara(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) ! CALL histwrite( nid_merT, "sokaraml", it, zw2d , ndim_hT, ndex_hT ) ! mixed layer depth zw2d(:,:) = (qns(:,:) + qsr(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "so_thflx", it, zw2d , ndim_hT, ndex_hT ) ! total heat flux zw2d(:,:) = qsr(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "so_shflx", it, zw2d , ndim_hT, ndex_hT ) ! solar heat flux zw2d(:,:) = emp(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "so_evmpr", it, zw2d , ndim_hT, ndex_hT ) ! E-P #if defined key_lim3 || defined key_lim2 ! Write ice model variables (daily means) zw2d(:,:) = hsnif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = hicif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = (1.0-frld(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concetration DO jj = 2, jpjm1 DO ji = 2, jpim1 ut_ice(ji,jj) = 0.5 * ( u_ice(ji,jj) + u_ice(ji-1,jj-1) ) vt_ice(ji,jj) = 0.5 * ( v_ice(ji,jj) + v_ice(ji-1,jj-1) ) END DO END DO CALL lbc_lnk( ut_ice(:,:), 'T', 1. ) CALL lbc_lnk( vt_ice(:,:), 'T', 1. ) zw2d(:,:) = ut_ice(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "itzocrtx", it, zw2d , ndim_hT, ndex_hT ) ! ice zonal current zw2d(:,:) = vt_ice(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "itmecrty", it, zw2d , ndim_hT, ndex_hT ) ! ice meridional current #endif #if defined key_cice ! Write ice model variables (daily means) zw2d(:,:) = 0.0 CALL cice2nemo(vsno(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GT. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = 0.0 CALL cice2nemo(vice(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GT. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = 0.0 WHERE(naicet(:,:,1) .GE. aice_cutoff) zw2d(:,:) = (naicet(:,:,1))*tmask(:,:,1) zw2d(:,:) = zw2d(:,:) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concetration ! Use zw3d(:,:,1:4) as temporary work space for the two ice velocities. zw3d(:,:,:) = 0.0 CALL cice2nemo(uvel(:,:,1), zw3d(:,:,1),'F', -1. ) CALL cice2nemo(vvel(:,:,1), zw3d(:,:,2),'F', -1. ) ! Interpolate from F-points to T-points DO jj = 2, jpjm1 DO ji = 2, jpim1 zw3d(ji,jj,3) = 0.25 * ( zw3d(ji,jj,1) + zw3d(ji-1,jj,1) + zw3d(ji,jj-1,1) + zw3d(ji-1,jj-1,1) ) zw3d(ji,jj,4) = 0.25 * ( zw3d(ji,jj,2) + zw3d(ji-1,jj,2) + zw3d(ji,jj-1,2) + zw3d(ji-1,jj-1,2) ) END DO END DO CALL lbc_lnk( zw3d(:,:,3), 'T', 1. ) CALL lbc_lnk( zw3d(:,:,4), 'T', 1. ) WHERE(naicet(:,:,1) .GE. aice_cutoff) zw3d(:,:,5) = zw3d(:,:,3)*tmask(:,:,1) zw3d(:,:,5) = zw3d(:,:,5) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "itzocrtx", it, zw3d(:,:,5) , ndim_hT, ndex_hT ) ! ice zonal current WHERE(naicet(:,:,1) .GE. aice_cutoff) zw3d(:,:,6) = zw3d(:,:,4)*tmask(:,:,1) zw3d(:,:,6) = zw3d(:,:,6) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merT, "itmecrty", it, zw3d(:,:,6) , ndim_hT, ndex_hT ) ! ice meridional current #endif ! Write velocities (daily means) zw3d(:,:,:) = un(:,:,:)*umask(:,:,:) + zmdi*(1.0-umask(:,:,:)) CALL histwrite( nid_merU, "vozocrtx", it, zw3d , ndim_U , ndex_U ) ! i-current zw2d(:,:) = utau(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merU, "sozowind", it, zw2d , ndim_U , ndex_U ) ! zonal wind stress zw3d(:,:,:) = vn(:,:,:)*vmask(:,:,:) + zmdi*(1.0-vmask(:,:,:)) CALL histwrite( nid_merV, "vomecrty", it, zw3d , ndim_V , ndex_V ) ! j-current zw2d(:,:) = vtau(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_merV, "somewind", it, zw2d , ndim_U , ndex_U ) ! meridional wind stress zw3d(:,:,:) = wn(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_merW, "vovecrtz", it, zw3d , ndim_T , ndex_T ) ! vert. current ENDIF ! Write data for ORCA025 FOAM output streams IF( nn_diafoam(4) .GT. 0 ) THEN IF(lwp .AND. MOD( kt, nn_diafoam(4) ) == 0 ) THEN WRITE(numout,*) 'dia_wri_foam : Writing FOAM Lite diagnostics at ',kt,' time-step' ENDIF ! write tracers (daily means) zw2d(:,:) = tsn(:,:,1,jp_tem)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "sosstsst", it, zw2d , ndim_T , ndex_T ) ! surface temperature zw2d(:,:) = tsn(:,:,1,jp_sal)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "sosaline", it, zw2d , ndim_T , ndex_T ) ! surface salinity zw2d(:,:) = sshn(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface height #if defined key_lim3 || defined key_lim2 zw2d(:,:) = hicif(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = (1.0-frld(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concentration #endif #if defined key_cice zw2d(:,:) = 0.0 CALL cice2nemo(vice(:,:,1), zw2d, 'T', 1. ) WHERE(naicet(:,:,1) .GE. aice_cutoff) zw2d(:,:) = zw2d(:,:)/naicet(:,:,1) WHERE(naicet(:,:,1) .LT. aice_cutoff) zw2d(:,:) = 0.0 zw2d(:,:) = zw2d(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = 0.0 WHERE(naicet(:,:,1) .GE. aice_cutoff) zw2d(:,:) = (naicet(:,:,1))*tmask(:,:,1) zw2d(:,:) = zw2d(:,:) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_liteT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concentration #endif ! zw2d(:,:) = hmld_kara(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) ! CALL histwrite( nid_liteT, "sokaraml", it, zw2d , ndim_hT, ndex_hT ) ! mixed layer ! Write velocities (daily means) zw2d(:,:) = un(:,:,1)*umask(:,:,1) + zmdi*(1.0-umask(:,:,1)) CALL histwrite( nid_liteU, "sozocrtx", it, zw2d , ndim_U , ndex_U ) ! surface i-current zw2d(:,:) = vn(:,:,1)*vmask(:,:,1) + zmdi*(1.0-vmask(:,:,1)) CALL histwrite( nid_liteV, "somecrty", it, zw2d , ndim_V , ndex_V ) ! j-current ENDIF ! Write data for operational FOAM output streams IF( nn_diafoam(5) .GT. 0 ) THEN IF(lwp .AND. MOD( kt, nn_diafoam(5) ) == 0 ) THEN WRITE(numout,*) 'dia_wri_foam : Writing Operational FOAM diagnostics for covariance calcs at ',kt,' time-step' ENDIF ! write tracers (instantaneous) zw3d(:,:,:) = tsn(:,:,:,jp_tem)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opcvT, "votemper", it, zw3d , ndim_T , ndex_T ) ! temperature zw3d(:,:,:) = tsn(:,:,:,jp_sal)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_opcvT, "vosaline", it, zw3d , ndim_T , ndex_T ) ! salinity zw2d(:,:) = sshn(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opcvT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface #if defined key_lim3 || defined key_lim2 ! Write ice model variables (instantaneous) zw2d(:,:) = (1.0-frld(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opcvT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concetration #endif #if defined key_cice ! Write ice model variables (instantaneous) WHERE(naicet(:,:,1) .GT. aice_cutoff) zw2d(:,:) = (naicet(:,:,1))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_opcvT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concetration #endif ENDIF ! Write data for Shelf Seas boundary conditions IF( nn_diafoam(6) .GT. 0 ) THEN IF( lwp .AND. MOD( kt, nn_diafoam(6) ) == 0 ) THEN WRITE(numout,*) 'dia_wri_foam : Writing output for Shelf Seas boundary conditions at ',kt,' time-step' ENDIF ! write tracers (instantaneous) zw3d(:,:,:) = tsn(:,:,:,jp_tem)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_shelfT, "votemper", it, zw3d , ndim_T , ndex_T ) ! temperature zw3d(:,:,:) = tsn(:,:,:,jp_sal)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_shelfT, "vosaline", it, zw3d , ndim_T , ndex_T ) ! salinity zw2d(:,:) = sshn(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_shelfT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface zw3d(:,:,:) = un(:,:,:)*umask(:,:,:) + zmdi*(1.0-umask(:,:,:)) CALL histwrite( nid_shelfU, "vozocrtx", it, zw3d , ndim_U , ndex_U ) ! baraclinic u zw3d(:,:,:) = vn(:,:,:)*vmask(:,:,:) + zmdi*(1.0-vmask(:,:,:)) CALL histwrite( nid_shelfV, "vomecrty", it, zw3d , ndim_V , ndex_V ) ! baraclinic v ! Calculate depth-mean currents. un_dm(:,:) = 0.0 vn_dm(:,:) = 0.0 ! vertical sum IF( lk_vopt_loop ) THEN ! vector opt., forced unroll DO jk = 1, jpkm1 DO ji = 1, jpij un_dm(ji,1) = un_dm(ji,1) + fse3u(ji,1,jk) * un(ji,1,jk) vn_dm(ji,1) = vn_dm(ji,1) + fse3v(ji,1,jk) * vn(ji,1,jk) END DO END DO ELSE ! No vector opt. DO jk = 1, jpkm1 un_dm(:,:) = un_dm(:,:) + fse3u(:,:,jk) * un(:,:,jk) vn_dm(:,:) = vn_dm(:,:) + fse3v(:,:,jk) * vn(:,:,jk) END DO ENDIF un_dm(:,:) = un_dm(:,:) * hur(:,:) * umask(:,:,1) + zmdi*(1.0-umask(:,:,1)) vn_dm(:,:) = vn_dm(:,:) * hvr(:,:) * vmask(:,:,1) + zmdi*(1.0-vmask(:,:,1)) CALL histwrite( nid_shelfU, "vobtcrtx", it, un_dm , ndim_hU , ndex_hU ) ! i-depth-mean-current CALL histwrite( nid_shelfV, "vobtcrty", it, vn_dm , ndim_hV , ndex_hV ) ! j-depth-mean-current ENDIF ! Calculate 25 hourly means for tidal cycle averages IF( nn_diafoam(7) .GT. 0 ) THEN IF( MOD( kt, nn_diafoam(7) ) == 0 ) THEN IF (lwp) THEN WRITE(numout,*) 'dia_wri_foam : Summing instantaneous hourly FOAM diagnostics at timestep ',kt WRITE(numout,*) '~~~~~~~~~~~~ ' ENDIF tn_25h(:,:,:) = tn_25h(:,:,:) + tsn(:,:,:,jp_tem) sn_25h(:,:,:) = sn_25h(:,:,:) + tsn(:,:,:,jp_sal) CALL theta2t insitu_t_25h(:,:,:) = insitu_t_25h(:,:,:) + insitu_t(:,:,:) sshn_25h(:,:) = sshn_25h(:,:) + sshn (:,:) hmld_tref_25h(:,:) = hmld_tref_25h(:,:) + hmld_tref(:,:) #if defined key_lim3 || defined key_lim2 hsnif_25h(:,:) = hsnif_25h(:,:) + hsnif(:,:) hicif_25h(:,:) = hicif_25h(:,:) + hicif(:,:) frld_25h(:,:) = frld_25h(:,:) + frld(:,:) #endif # if defined key_cice naicet_25h(:,:) = naicet_25h(:,:) + naicet(:,:,1) #endif #if defined key_spm || defined key_MOersem trn_25h(:,:,:,:) = trn_25h(:,:,:,:) + trn (:,:,:,:) trc3d_25h(:,:,:,:) = trc3d_25h(:,:,:,:) + trc3d(:,:,:,:) trc2d_25h(:,:,:) = trc2d_25h(:,:,:) + trc2d(:,:,:) #endif un_25h(:,:,:) = un_25h(:,:,:) + un(:,:,:) vn_25h(:,:,:) = vn_25h(:,:,:) + vn(:,:,:) wn_25h(:,:,:) = wn_25h(:,:,:) + wn(:,:,:) avt_25h(:,:,:) = avt_25h(:,:,:) + avt(:,:,:) avmu_25h(:,:,:) = avmu_25h(:,:,:) + avmu(:,:,:) cnt_25h = cnt_25h + 1 IF (lwp) THEN WRITE(numout,*) 'dia_wri_foam : Summed the following number of hourly values so far',cnt_25h ENDIF ENDIF ! MOD( kt, nn_diafoam(7) ) == 0 ! Write data for 25 hour mean output streams IF( cnt_25h .EQ. 25 .AND. MOD( kt, nn_diafoam(7) * 24) == 0 .AND. kt .NE. nn_it000 ) THEN IF(lwp) THEN WRITE(numout,*) 'dia_wri_foam : Writing 25 hour mean FOAM diagnostics at timestep', kt WRITE(numout,*) '~~~~~~~~~~~~ ' ENDIF tn_25h(:,:,:) = tn_25h(:,:,:) / 25.0_wp sn_25h(:,:,:) = sn_25h(:,:,:) / 25.0_wp insitu_t_25h(:,:,:) = insitu_t_25h(:,:,:) / 25.0_wp sshn_25h(:,:) = sshn_25h(:,:) / 25.0_wp hmld_tref_25h(:,:) = hmld_tref_25h(:,:) / 25.0_wp #if defined key_lim3 || defined key_lim2 hsnif_25h(:,:) = hsnif_25h(:,:) / 25.0_wp hicif_25h(:,:) = hicif_25h(:,:) / 25.0_wp frld_25h(:,:) = frld_25h(:,:) / 25.0_wp #endif # if defined key_cice naicet_25h(:,:) = naicet_25h(:,:) / 25.0_wp #endif #if defined key_spm || defined key_MOersem trn_25h(:,:,:,:) = trn_25h(:,:,:,:) / 25.0_wp trc3d_25h(:,:,:,:) = trc3d_25h(:,:,:,:) / 25.0_wp trc2d_25h(:,:,:) = trc2d_25h(:,:,:) / 25.0_wp #endif un_25h(:,:,:) = un_25h(:,:,:) / 25.0_wp vn_25h(:,:,:) = vn_25h(:,:,:) / 25.0_wp wn_25h(:,:,:) = wn_25h(:,:,:) / 25.0_wp avt_25h(:,:,:) = avt_25h(:,:,:) / 25.0_wp avmu_25h(:,:,:) = avmu_25h(:,:,:) / 25.0_wp IF (lwp) WRITE(numout,*) 'dia_wri_foam : Mean calculated by dividing 25 hour sums and writing output' ! write tracers (instantaneous) zw3d(:,:,:) = tn_25h(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_25hmT, "votemper", it, zw3d , ndim_T , ndex_T ) ! potential temperature CALL theta2t ! calculate insitu temp zw3d(:,:,:) = insitu_t_25h(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_25hmT, "votempis", it, zw3d , ndim_T , ndex_T ) ! in-situ temperature zw3d(:,:,:) = sn_25h(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_25hmT, "vosaline", it, zw3d , ndim_T , ndex_T ) ! salinity zw2d(:,:) = sshn_25h(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_25hmT, "sossheig", it, zw2d , ndim_hT, ndex_hT ) ! sea surface zw2d(:,:) = hmld_tref_25h(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_25hmT, "sotrefml", it, zw2d , ndim_hT, ndex_hT ) ! mixed layer #if defined key_lim3 || defined key_lim2 ! Write ice model variables (instantaneous) zw2d(:,:) = hsnif_25h(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_25hmT, "isnowthi", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = hicif_25h(:,:)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_25hmT, "iicethic", it, zw2d , ndim_hT, ndex_hT ) ! ice thickness zw2d(:,:) = (1.0-frld_25h(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_25hmT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concetration #endif #if defined key_cice zw2d(:,:) = (naicet_25h(:,:))*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite( nid_25hmT, "iiceconc", it, zw2d , ndim_hT, ndex_hT ) ! ice concentration #endif #if defined key_spm || key_MOersem ! output biogeochemical variables: ! output main tracers DO jn = 1, jptra cltra = ctrcnm(jn) ! short title for tracer zw3d(:,:,:) = trn_25h(:,:,:,jn)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) IF( lutsav(jn) ) CALL histwrite( nid_25hmT, cltra, it, zw3d , ndim_T , ndex_T ) ! temperature END DO ! more 3D horizontal arrays from diagnostics DO jl = 1, jpdia3d cltra = ctrc3d(jl) ! short title for 3D diagnostic zw3d(:,:,:) = trc3d_25h(:,:,:,jl)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_25hmT, cltra, it, zw3d , ndim_T , ndex_T ) END DO ! more 2D horizontal arrays from diagnostics DO jl = 1, jpdia2d cltra = ctrc2d(jl) ! short title for 2D diagnostic zw2d(:,:) = trc2d_25h(:,:,jl)*tmask(:,:,1) + zmdi*(1.0-tmask(:,:,1)) CALL histwrite(nid_25hmT, cltra, it, zw2d , ndim_hT ,ndex_hT) END DO #endif ! Write velocities (instantaneous) zw3d(:,:,:) = un_25h(:,:,:)*umask(:,:,:) + zmdi*(1.0-umask(:,:,:)) CALL histwrite( nid_25hmU, "vozocrtx", it, zw3d , ndim_U , ndex_U ) ! i-current zw3d(:,:,:) = vn_25h(:,:,:)*vmask(:,:,:) + zmdi*(1.0-vmask(:,:,:)) CALL histwrite( nid_25hmV, "vomecrty", it, zw3d , ndim_V , ndex_V ) ! j-current #if ! key_shelf_OPER && key_shelf zw3d(:,:,:) = wn_25h(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_25hmW, "vovecrtz", it, zw3d , ndim_W , ndex_W ) ! k-current zw3d(:,:,:) = avt_25h(:,:,:)*tmask(:,:,:) + zmdi*(1.0-tmask(:,:,:)) CALL histwrite( nid_25hmW, "votkeavt", it, zw3d , ndim_W , ndex_W ) ! k-current zw3d(:,:,:) = avmu_25h(:,:,:)*umask(:,:,:) + zmdi*(1.0-umask(:,:,:)) CALL histwrite( nid_25hmW, "votkeavm", it, zw3d , ndim_W , ndex_W ) ! k-current #endif ! After the write reset the values to cnt=1 and sum values equal current value tn_25h(:,:,:) = tsn(:,:,:,jp_tem) sn_25h(:,:,:) = tsn(:,:,:,jp_sal) CALL theta2t insitu_t_25h(:,:,:) = insitu_t(:,:,:) sshn_25h(:,:) = sshn (:,:) hmld_tref_25h(:,:) = hmld_tref(:,:) #if defined key_lim3 || defined key_lim2 hsnif_25h(:,:) = hsnif(:,:) hicif_25h(:,:) = hicif(:,:) frld_25h(:,:) = frld(:,:) #endif # if defined key_cice naicet_25h(:,:) = naicet(:,:,1) #endif #if defined key_spm || defined key_MOersem trn_25h(:,:,:,:) = trn (:,:,:,:) trc3d_25h(:,:,:,:) = trc3d(:,:,:,:) trc2d_25h(:,:,:) = trc2d(:,:,:) #endif un_25h(:,:,:) = un(:,:,:) vn_25h(:,:,:) = vn(:,:,:) wn_25h(:,:,:) = wn(:,:,:) avt_25h(:,:,:) = avt(:,:,:) avmu_25h(:,:,:) = avmu(:,:,:) cnt_25h = 1 IF (lwp) WRITE(numout,*) 'dia_wri_foam : After 25hr mean write, reset sum to current value and cnt_25h to one for overlapping average',cnt_25h ENDIF ! cnt_25h .EQ. 25 .AND. MOD( kt, nn_diafoam(7) * 24) == 0 .AND. kt .NE. nn_it000 ENDIF ! 3. Synchronise and close all files ! --------------------------------------- ! Sync and close top,middle,bottom output streams IF( nn_diafoam(1) .GT. 0 ) THEN CALL histsync( nid_tmbT ) CALL histsync( nid_tmbU ) CALL histsync( nid_tmbV ) IF( kt == nitend ) THEN CALL histclo( nid_tmbT ) CALL histclo( nid_tmbU ) CALL histclo( nid_tmbV ) ENDIF ENDIF ! Sync and close operational output streams IF( nn_diafoam(2) .GT. 0) THEN CALL histsync( nid_opT ) CALL histsync( nid_opU ) CALL histsync( nid_opV ) #if ! key_shelf_OPER && key_shelf CALL histsync( nid_opW ) #endif IF (MOD(kt,nn_diafoam(2)) == 0 ) THEN CALL histclo( nid_opT ) CALL histclo( nid_opU ) CALL histclo( nid_opV ) #if ! key_shelf_OPER && key_shelf CALL histclo( nid_opW ) #endif nouttime(2) = nouttime(2) + 1 ENDIF ENDIF ! Sync and close Mersea output streams IF( nn_diafoam(3) .GT. 0 ) THEN CALL histsync( nid_merT ) CALL histsync( nid_merU ) CALL histsync( nid_merV ) CALL histsync( nid_merW ) IF( kt == nitend ) THEN CALL histclo( nid_merT ) CALL histclo( nid_merU ) CALL histclo( nid_merV ) CALL histclo( nid_merW ) ENDIF ENDIF ! Sync and close FOAM LITE output streams IF( nn_diafoam(4) .GT. 0 ) THEN CALL histsync( nid_liteT ) CALL histsync( nid_liteU ) CALL histsync( nid_liteV ) IF( kt == nitend ) THEN CALL histclo( nid_liteT ) CALL histclo( nid_liteU ) CALL histclo( nid_liteV ) ENDIF ENDIF ! Sync and close operational output for covariances streams IF( nn_diafoam(5) .GT. 0) THEN CALL histsync( nid_opcvT ) IF (MOD(kt,nn_diafoam(5)) == 0 ) THEN CALL histclo( nid_opcvT ) nouttime(5) = nouttime(5) + 1 ENDIF ENDIF ! Sync and close shelfbc output streams IF( nn_diafoam(6) .GT. 0 ) THEN CALL histsync( nid_shelfT ) CALL histsync( nid_shelfU ) CALL histsync( nid_shelfV ) IF( kt == nitend ) THEN CALL histclo( nid_shelfT ) CALL histclo( nid_shelfU ) CALL histclo( nid_shelfV ) ENDIF ENDIF ! Sync and close 25 hour mean output streams IF( nn_diafoam(7) .GT. 0 ) THEN CALL histsync( nid_25hmT ) CALL histsync( nid_25hmU ) CALL histsync( nid_25hmV ) #if ! key_shelf_OPER && key_shelf CALL histsync( nid_25hmW ) #endif IF (kt == nitend ) THEN IF (lwp) WRITE(numout,*) 'dia_wri_foam : Closing 25hr mean files' CALL histclo( nid_25hmT ) CALL histclo( nid_25hmU ) CALL histclo( nid_25hmV ) #if ! key_shelf_OPER && key_shelf CALL histclo( nid_25hmW ) #endif nouttime(7) = nouttime(7) + 1 ENDIF ENDIF END SUBROUTINE dia_wri_foam SUBROUTINE calc_tmb( infield,outtmb) ! Routine to map 3d field to top, middle, bottom IMPLICIT NONE ! Routine arguments REAL(wp), DIMENSION(jpi, jpj, jpk), INTENT(IN ) :: infield ! Input 3d field and mask REAL(wp), DIMENSION(jpi, jpj, 3 ), INTENT( OUT) :: outtmb ! Output top, middle, bottom ! Local variables INTEGER :: ji,jj,jk ! Dummy loop indices ! Calculate top outtmb(:,:,1) = infield(:,:,1) ! Calculate middle DO ji = 1,jpi DO jj = 1,jpj jk = mbathy(ji,jj)/2 outtmb(ji,jj,2) = infield(ji,jj,jk) END DO END DO ! Calculate bottom DO ji = 1,jpi DO jj = 1,jpj jk = mbathy(ji,jj) - 1 outtmb(ji,jj,3) = infield(ji,jj,jk) END DO END DO END SUBROUTINE calc_tmb #if defined key_cice SUBROUTINE cice2nemo ( pc, pn, cd_type, psgn ) !!--------------------------------------------------------------------- !! *** ROUTINE cice2nemo *** !! ** Purpose : Transfer field in CICE array to field in NEMO array, !! automatically dealing with scattter/gather between !! different processors and blocks !! ** Method : A. Gather CICE blocks (pc) into global array (pcg) !! B. Map pcg into NEMO global array (png) !! C. Scatter png into NEMO field (pn) for each processor !! D. Ensure all haloes are filled in pn !!--------------------------------------------------------------------- CHARACTER(len=1), INTENT( in ) :: & cd_type ! nature of pn grid-point ! ! = T or F gridpoints REAL(wp), INTENT( in ) :: & psgn ! control of the sign change ! ! =-1 , the sign is modified following the type of b.c. used ! ! = 1 , no sign change REAL(wp), DIMENSION(jpi,jpj) :: pn REAL(wp), DIMENSION(jpi,jpj,jpnij) :: png real (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc INTEGER :: ji, jj, jn ! dummy loop indices ! A. Gather CICE blocks (pc) into global array (pcg) call gather_global(pcg, pc, 0, distrb_info) ! B. Map pcg into NEMO global array (png) ! Need to make sure this is robust to changes in NEMO halo rows.... ! (may be OK but not spent much time thinking about it) IF (nproc==0) THEN png(:,:,:)=0.0 DO jn=1,jpnij DO jj=1,nlcjt(jn)-1 DO ji=2,nlcit(jn)-1 png(ji,jj,jn)=pcg(ji+nimppt(jn)-2,jj+njmppt(jn)-1) ENDDO ENDDO ENDDO ENDIF ! C. Scatter png into NEMO field (pn) for each processor IF ( jpnij > 1) THEN CALL mppsync CALL mppscatter (png,0,pn) CALL mppsync ELSE pn(:,:)=png(:,:,1) ENDIF ! D. Ensure all haloes are filled in pn CALL lbc_lnk( pn , cd_type, psgn ) END SUBROUTINE cice2nemo #endif !!====================================================================== #else !! !! Dia FOAM does not have IOM PUT functionality !! CONTAINS SUBROUTINE dia_wri_foam( ) END SUBROUTINE dia_wri_foam INTEGER FUNCTION int_dia_wri_foam_alloc( ) END FUNCTION int_dia_wri_foam_alloc REAL FUNCTION real_dia_wri_foam_alloc( ) END FUNCTION real_dia_wri_foam_alloc #endif ! ending IOM PUT precompile if statement END MODULE diafoam