MODULE trcdia !!====================================================================== !! *** MODULE trcdia *** !! TOP : Output of passive tracers !!====================================================================== !! History : - ! 1995-01 (M. Levy) Original code !! - ! 1998-01 (C. Levy) NETCDF format using ioipsl interface !! - ! 1999-01 (M.A. Foujols) adapted for passive tracer !! - ! 1999-09 (M.A. Foujols) split into three parts !! 1.0 ! 2005-03 (O. Aumont, A. El Moussaoui) F90 !! ! 2008-05 (C. Ethe re-organization) !!---------------------------------------------------------------------- #if defined key_top && ! defined key_iomput !!---------------------------------------------------------------------- !! 'key_top' TOP models !!---------------------------------------------------------------------- !! trc_dia : main routine of output passive tracer !! trcdit_wr : outputs of concentration fields !! trcdid_wr : outputs of dvection-diffusion trends !! trcdii_wr : outputs of additional 2D/3D diagnostics !! trcdib_wr : outputs of biological fields !!---------------------------------------------------------------------- USE dom_oce ! ocean space and time domain variables USE oce_trc USE trc USE trp_trc USE trdmld_trc_oce, ONLY : luttrd USE dianam ! build name of file (routine) USE in_out_manager ! I/O manager USE lib_mpp USE ioipsl IMPLICIT NONE PRIVATE PUBLIC trc_dia INTEGER :: nit5 !: id for tracer output file INTEGER :: ndepit5 !: id for depth mesh INTEGER :: nhorit5 !: id for horizontal mesh INTEGER :: ndimt50 !: number of ocean points in index array INTEGER :: ndimt51 !: number of ocean points in index array REAL(wp) :: xjulian !: ???? not DOCTOR ! INTEGER , DIMENSION (jpij*jpk) :: ndext50 !: integer arrays for ocean 3D index INTEGER , DIMENSION (jpij) :: ndext51 !: integer arrays for ocean surface index # if defined key_trc_diaadd INTEGER :: nitd !: id for additional array output file INTEGER :: ndepitd !: id for depth mesh INTEGER :: nhoritd !: id for horizontal mesh # endif # if defined key_trc_diatrd INTEGER , DIMENSION (jptra) :: nit6 !: id for additional array output file INTEGER , DIMENSION (jptra) :: ndepit6 !: id for depth mesh INTEGER , DIMENSION (jptra) :: nhorit6 !: id for horizontal mesh # endif # if defined key_trc_diabio INTEGER :: nitb !: id. for additional array output file INTEGER :: ndepitb !: id for depth mesh INTEGER :: nhoritb !: id for horizontal mesh # endif !! * Substitutions # include "top_substitute.h90" !!---------------------------------------------------------------------- !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) !! $Id$ !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) !!---------------------------------------------------------------------- CONTAINS SUBROUTINE trc_dia( kt ) !!--------------------------------------------------------------------- !! *** ROUTINE trc_dia *** !! !! ** Purpose : output passive tracers fields !!--------------------------------------------------------------------- INTEGER, INTENT( in ) :: kt INTEGER :: kindic !!--------------------------------------------------------------------- CALL trcdit_wr( kt, kindic ) ! outputs for tracer concentration CALL trcdid_wr( kt, kindic ) ! outputs for dynamical trends CALL trcdii_wr( kt, kindic ) ! outputs for additional arrays CALL trcdib_wr( kt, kindic ) ! outputs for biological trends ! END SUBROUTINE trc_dia SUBROUTINE trcdit_wr( kt, kindic ) !!---------------------------------------------------------------------- !! *** ROUTINE trcdit_wr *** !! !! ** Purpose : Standard output of passive tracer : concentration fields !! !! ** Method : At the beginning of the first time step (nit000), define all !! the NETCDF files and fields for concentration of passive tracer !! !! At each time step call histdef to compute the mean if necessary !! Each nwritetrc time step, output the instantaneous or mean fields !! !! IF kindic <0, output of fields before the model interruption. !! IF kindic =0, time step loop !! IF kindic >0, output of fields before the time step loop !!---------------------------------------------------------------------- INTEGER, INTENT( in ) :: kt ! ocean time-step INTEGER, INTENT( in ) :: kindic ! indicator of abnormal termination !! INTEGER :: jn LOGICAL :: ll_print = .FALSE. CHARACTER (len=40) :: clhstnam, clop #if defined key_off_tra INTEGER :: inum = 11 ! temporary logical unit #endif CHARACTER (len=20) :: cltra, cltrau CHARACTER (len=80) :: cltral REAL(wp) :: zsto, zout, zdt INTEGER :: iimi, iima, ijmi, ijma, ipk, it, itmod !!---------------------------------------------------------------------- ! Initialisation ! -------------- ! local variable for debugging ll_print = .FALSE. ! change it to true for more control print ll_print = ll_print .AND. lwp ! Define frequency of output and means zdt = rdt IF( ln_mskland ) THEN ; clop = "only(x)" ! put 1.e+20 on land (very expensive!!) ELSE ; clop = "x" ! no use of the mask value (require less cpu time) ENDIF # if defined key_diainstant zsto = nwritetrc * rdt clop = "inst("//TRIM(clop)//")" # else zsto = zdt clop = "ave("//TRIM(clop)//")" # endif zout = nwritetrc * zdt ! Define indices of the horizontal output zoom and vertical limit storage iimi = 1 ; iima = jpi ijmi = 1 ; ijma = jpj ipk = jpk ! define time axis itmod = kt - nittrc000 + 1 it = kt ! Define NETCDF files and fields at beginning of first time step ! -------------------------------------------------------------- IF(ll_print)WRITE(numout,*)'trcdit_wr kt=',kt,' kindic ',kindic IF( kt == nittrc000 ) THEN ! Compute julian date from starting date of the run CALL ymds2ju( nyear, nmonth, nday, rdt, xjulian ) xjulian = xjulian - adatrj ! set calendar origin to the beginning of the experiment IF(lwp)WRITE(numout,*)' ' IF(lwp)WRITE(numout,*)' Date 0 used :', nittrc000 & & ,' YEAR ', nyear, ' MONTH ', nmonth, ' DAY ', nday & & ,'Julian day : ', xjulian IF(lwp) WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma, & & ' limit storage in depth = ', ipk #if defined key_off_tra ! WRITE root name in date.file for use by postpro IF(lwp) THEN CALL dia_nam( clhstnam, nwritetrc,' ' ) CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) WRITE(inum,*) clhstnam CLOSE(inum) ENDIF #endif ! Define the NETCDF files for passive tracer concentration CALL dia_nam( clhstnam, nwritetrc, 'ptrc_T' ) IF(lwp)WRITE(numout,*)" Name of NETCDF file ", clhstnam ! Horizontal grid : glamt and gphit CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & nittrc000-ndttrc, xjulian, zdt, nhorit5, nit5 , domain_id=nidom) ! Vertical grid for tracer : gdept CALL histvert( nit5, 'deptht', 'Vertical T levels', 'm', ipk, gdept_0, ndepit5) ! Index of ocean points in 3D and 2D (surface) CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndext50, ndimt50 ) CALL wheneq( jpi*jpj , tmask, 1, 1., ndext51, ndimt51 ) ! Declare all the output fields as NETCDF variables 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( nit5, cltra, cltral, cltrau, jpi, jpj, nhorit5, & & ipk, 1, ipk, ndepit5, 32, clop, zsto, zout ) ENDIF END DO ! end netcdf files header CALL histend( nit5 ) IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdit_wr' IF( ll_print ) CALL FLUSH(numout ) ENDIF ! Start writing the tracer concentrations ! --------------------------------------- IF( lwp .AND. MOD( itmod, nwritetrc ) == 0 ) THEN WRITE(numout,*) 'trcdit_wr : write NetCDF passive tracer concentrations at ', kt, 'time-step' WRITE(numout,*) '~~~~~~~~~ ' ENDIF DO jn = 1, jptra cltra = ctrcnm(jn) ! short title for tracer IF( lutsav(jn) ) CALL histwrite( nit5, cltra, it, trn(:,:,:,jn), ndimt50, ndext50 ) END DO ! close the file ! -------------- IF( kt == nitend .OR. kindic < 0 ) CALL histclo( nit5 ) ! END SUBROUTINE trcdit_wr # if defined key_trc_diatrd SUBROUTINE trcdid_wr( kt, kindic ) !!---------------------------------------------------------------------- !! *** ROUTINE trcdid_wr *** !! !! ** Purpose : output of passive tracer : advection-diffusion trends !! !! ** Method : At the beginning of the first time step (nit000), define all !! the NETCDF files and fields for concentration of passive tracer !! !! At each time step call histdef to compute the mean if necessary !! Each nwritetrd time step, output the instantaneous or mean fields !! !! IF kindic <0, output of fields before the model interruption. !! IF kindic =0, time step loop !! IF kindic >0, output of fields before the time step loop !!---------------------------------------------------------------------- INTEGER, INTENT( in ) :: kt ! ocean time-step INTEGER, INTENT( in ) :: kindic ! indicator of abnormal termination !! LOGICAL :: ll_print = .FALSE. CHARACTER (len=40) :: clhstnam, clop CHARACTER (len=20) :: cltra, cltrau CHARACTER (len=80) :: cltral CHARACTER (len=10) :: csuff INTEGER :: jn, jl INTEGER :: iimi, iima, ijmi, ijma, ipk, it, itmod REAL(wp) :: zsto, zout, zdt !!---------------------------------------------------------------------- ! 0. Initialisation ! ----------------- ! local variable for debugging ll_print = .FALSE. ll_print = ll_print .AND. lwp ! ! Define frequency of output and means zdt = rdt IF( ln_mskland ) THEN ; clop = "only(x)" ! put 1.e+20 on land (very expensive!!) ELSE ; clop = "x" ! no use of the mask value (require less cpu time) ENDIF # if defined key_diainstant zsto = nwritetrd * rdt clop = "inst("//TRIM(clop)//")" # else zsto = zdt clop = "ave("//TRIM(clop)//")" # endif zout = nwritetrd * zdt ! Define indices of the horizontal output zoom and vertical limit storage iimi = 1 ; iima = jpi ijmi = 1 ; ijma = jpj ipk = jpk ! define time axis itmod = kt - nittrc000 + 1 it = kt ! Define the NETCDF files (one per tracer) IF( ll_print ) WRITE(numout,*) 'trcdid kt=', kt, ' kindic ', kindic IF( kt == nittrc000 ) THEN DO jn = 1, jptra ! IF( luttrd(jn) ) THEN ! Define the file for dynamical trends - one per each tracer IF required IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma, & & ' limit storage in depth = ', ipk csuff='DY_'//ctrcnm(jn) CALL dia_nam( clhstnam, nwritetrd, csuff ) IF(lwp)WRITE(numout,*) " Name of NETCDF file for dynamical trends", & & " of tracer number : ",clhstnam CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & nittrc000-ndttrc, xjulian, zdt, nhorit6(jn), & & nit6(jn) , domain_id=nidom ) ! Vertical grid for tracer trend - one per each tracer IF needed CALL histvert( nit6(jn), 'deptht', 'Vertical T levels', 'm', ipk, gdept_0, ndepit6(jn) ) END IF END DO ! Declare all the output fields as NETCDF variables ! trends for tracer concentrations DO jn = 1, jptra IF( luttrd(jn) ) THEN DO jl = 1, jpdiatrc IF( jl == 1 ) THEN ! short and long title for x advection for tracer WRITE (cltra,'("XAD_",16a)') ctrcnm(jn) WRITE (cltral,'("X advective trend for ",58a)') & & ctrcnl(jn)(1:58) END IF IF( jl == 2 ) THEN ! short and long title for y advection for tracer WRITE (cltra,'("YAD_",16a)') ctrcnm(jn) WRITE (cltral,'("Y advective trend for ",58a)') & & ctrcnl(jn)(1:58) END IF IF( jl == 3 ) THEN ! short and long title for Z advection for tracer WRITE (cltra,'("ZAD_",16a)') ctrcnm(jn) WRITE (cltral,'("Z advective trend for ",58a)') & & ctrcnl(jn)(1:58) END IF IF( jl == 4 ) THEN ! short and long title for X diffusion for tracer WRITE (cltra,'("XDF_",16a)') ctrcnm(jn) WRITE (cltral,'("X diffusion trend for ",58a)') & & ctrcnl(jn)(1:58) END IF IF( jl == 5 ) THEN ! short and long title for Y diffusion for tracer WRITE (cltra,'("YDF_",16a)') ctrcnm(jn) WRITE (cltral,'("Y diffusion trend for ",58a)') & & ctrcnl(jn)(1:58) END IF IF( jl == 6 ) THEN ! short and long title for Z diffusion for tracer WRITE (cltra,'("ZDF_",16a)') ctrcnm(jn) WRITE (cltral,'("Z diffusion trend for ",58a)') & & ctrcnl(jn)(1:58) END IF # if defined key_trcldf_eiv IF( jl == 7 ) THEN ! short and long title for x gent velocity for tracer WRITE (cltra,'("XGV_",16a)') ctrcnm(jn) WRITE (cltral,'("X gent velocity trend for ",53a)') & & ctrcnl(jn)(1:53) END IF IF( jl == 8 ) THEN ! short and long title for y gent velocity for tracer WRITE (cltra,'("YGV_",16a)') ctrcnm(jn) WRITE (cltral,'("Y gent velocity trend for ",53a)') & & ctrcnl(jn)(1:53) END IF IF( jl == 9 ) THEN ! short and long title for Z gent velocity for tracer WRITE (cltra,'("ZGV_",16a)') ctrcnm(jn) WRITE (cltral,'("Z gent velocity trend for ",53a)') & & ctrcnl(jn)(1:53) END IF # endif # if defined key_trcdmp IF( jl == jpdiatrc - 1 ) THEN ! last trends for tracer damping : short and long title WRITE (cltra,'("TDM_",16a)') ctrcnm(jn) WRITE (cltral,'("Tracer damping trend for ",55a)') & & ctrcnl(jn)(1:55) END IF # endif IF( jl == jpdiatrc ) THEN ! last trends for tracer damping : short and long title WRITE (cltra,'("SBC_",16a)') ctrcnm(jn) WRITE (cltral,'("Surface boundary flux ",58a)') & & ctrcnl(jn)(1:58) END IF CALL FLUSH( numout ) cltrau = ctrcun(jn) ! UNIT for tracer /trends CALL histdef( nit6(jn), cltra, cltral, cltrau, jpi,jpj, & & nhorit6(jn), ipk, 1, ipk, ndepit6(jn), 32, clop , & & zsto,zout ) END DO END IF END DO ! CLOSE netcdf Files DO jn = 1, jptra IF( luttrd(jn) ) CALL histend( nit6(jn) ) END DO IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdid' IF(ll_print) CALL FLUSH(numout ) ! ENDIF ! SOME diagnostics to DO first time ! Start writing data ! --------------------- ! trends for tracer concentrations IF( lwp .AND. MOD( itmod, nwritetrd ) == 0 ) THEN WRITE(numout,*) 'trcdid_wr : write NetCDF dynamical trends at ', kt, 'time-step' WRITE(numout,*) '~~~~~~ ' ENDIF DO jn = 1, jptra IF( luttrd(jn) ) THEN DO jl = 1, jpdiatrc ! short titles IF( jl == 1) WRITE (cltra,'("XAD_",16a)') ctrcnm(jn) ! x advection for tracer IF( jl == 2) WRITE (cltra,'("YAD_",16a)') ctrcnm(jn) ! z advection for tracer IF( jl == 3) WRITE (cltra,'("ZAD_",16a)') ctrcnm(jn) ! z advection for tracer IF( jl == 4) WRITE (cltra,'("XDF_",16a)') ctrcnm(jn) ! x diffusion for tracer IF( jl == 5) WRITE (cltra,'("YDF_",16a)') ctrcnm(jn) ! y diffusion for tracer IF( jl == 6) WRITE (cltra,'("ZDF_",16a)') ctrcnm(jn) ! z diffusion for tracer # if defined key_trcldf_eiv IF( jl == 7) WRITE (cltra,'("XGV_",16a)') ctrcnm(jn) ! x gent velocity for tracer IF( jl == 8) WRITE (cltra,'("YGV_",16a)') ctrcnm(jn) ! y gent velocity for tracer IF( jl == 9) WRITE (cltra,'("ZGV_",16a)') ctrcnm(jn) ! z gent velocity for tracer # endif # if defined key_trcdmp IF( jl == jpdiatrc - 1 ) WRITE (cltra,'("TDM_",16a)') ctrcnm(jn) ! damping # endif IF( jl == jpdiatrc ) WRITE (cltra,'("SBC_",a)') ctrcnm(jn) ! surface boundary conditions ! CALL histwrite(nit6(jn), cltra, it, trtrd(:,:,:,ikeep(jn),jl),ndimt50, ndext50) END DO END IF END DO ! Closing all files ! ----------------- IF( kt == nitend .OR. kindic < 0 ) THEN DO jn = 1, jptra IF( luttrd(jn) ) CALL histclo( nit6(jn) ) END DO ENDIF ! END SUBROUTINE trcdid_wr # else SUBROUTINE trcdid_wr( kt, kindic ) ! Dummy routine INTEGER, INTENT ( in ) :: kt, kindic END SUBROUTINE trcdid_wr # endif #if defined key_trc_diaadd SUBROUTINE trcdii_wr( kt, kindic ) !!---------------------------------------------------------------------- !! *** ROUTINE trcdii_wr *** !! !! ** Purpose : output of passive tracer : additional 2D and 3D arrays !! !! ** Method : At the beginning of the first time step (nit000), define all !! the NETCDF files and fields for concentration of passive tracer !! !! At each time step call histdef to compute the mean if necessary !! Each nwritedia time step, output the instantaneous or mean fields !! !! IF kindic <0, output of fields before the model interruption. !! IF kindic =0, time step loop !! IF kindic >0, output of fields before the time step loop !!---------------------------------------------------------------------- INTEGER, INTENT( in ) :: kt ! ocean time-step INTEGER, INTENT( in ) :: kindic ! indicator of abnormal termination !! LOGICAL :: ll_print = .FALSE. CHARACTER (len=40) :: clhstnam, clop CHARACTER (len=20) :: cltra, cltrau CHARACTER (len=80) :: cltral INTEGER :: jl INTEGER :: iimi, iima, ijmi, ijma, ipk, it, itmod REAL(wp) :: zsto, zout, zdt !!---------------------------------------------------------------------- ! Initialisation ! -------------- ! local variable for debugging ll_print = .FALSE. ll_print = ll_print .AND. lwp ! ! Define frequency of output and means zdt = rdt IF( ln_mskland ) THEN ; clop = "only(x)" ! put 1.e+20 on land (very expensive!!) ELSE ; clop = "x" ! no use of the mask value (require less cpu time) ENDIF # if defined key_diainstant zsto = nwritedia * zdt clop = "inst("//TRIM(clop)//")" # else zsto = zdt clop = "ave("//TRIM(clop)//")" # endif zout = nwritedia * zdt ! Define indices of the horizontal output zoom and vertical limit storage iimi = 1 ; iima = jpi ijmi = 1 ; ijma = jpj ipk = jpk ! define time axis itmod = kt - nittrc000 + 1 it = kt ! 1. Define NETCDF files and fields at beginning of first time step ! ----------------------------------------------------------------- IF( ll_print ) WRITE(numout,*) 'trcdii_wr kt=', kt, ' kindic ', kindic IF( kt == nittrc000 ) THEN ! Define the NETCDF files for additional arrays : 2D or 3D ! Define the T grid file for tracer auxiliary files CALL dia_nam( clhstnam, nwritedia, 'diad_T' ) IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! Define a netcdf FILE for 2d and 3d arrays CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & nittrc000-ndttrc, xjulian, zdt, nhoritd, nitd , domain_id=nidom ) ! Vertical grid for 2d and 3d arrays CALL histvert( nitd, 'deptht', 'Vertical T levels','m', ipk, gdept_0, ndepitd) ! Declare all the output fields as NETCDF variables ! more 3D horizontal arrays 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( nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd, & & ipk, 1, ipk, ndepitd, 32, clop, zsto, zout ) END DO ! more 2D horizontal arrays 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( nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd, & & 1, 1, 1, -99, 32, clop, zsto, zout ) END DO ! TODO: more 2D vertical sections arrays : I or J indice fixed ! CLOSE netcdf Files CALL histend( nitd ) IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdii_wr' IF( ll_print ) CALL FLUSH(numout ) ! ENDIF ! 2. Start writing data ! --------------------- IF( lwp .AND. MOD( itmod, nwritedia ) == 0 ) THEN WRITE(numout,*) 'trcdii_wr : write NetCDF additional arrays at ', kt, 'time-step' WRITE(numout,*) '~~~~~~ ' ENDIF ! more 3D horizontal arrays DO jl = 1, jpdia3d cltra = ctrc3d(jl) ! short title for 3D diagnostic CALL histwrite( nitd, cltra, it, trc3d(:,:,:,jl), ndimt50 ,ndext50) END DO ! more 2D horizontal arrays DO jl = 1, jpdia2d cltra = ctrc2d(jl) ! short title for 2D diagnostic CALL histwrite(nitd, cltra, it, trc2d(:,:,jl), ndimt51 ,ndext51) END DO ! Closing all files ! ----------------- IF( kt == nitend .OR. kindic < 0 ) CALL histclo(nitd) ! END SUBROUTINE trcdii_wr # else SUBROUTINE trcdii_wr( kt, kindic ) ! Dummy routine INTEGER, INTENT ( in ) :: kt, kindic END SUBROUTINE trcdii_wr # endif # if defined key_trc_diabio SUBROUTINE trcdib_wr( kt, kindic ) !!---------------------------------------------------------------------- !! *** ROUTINE trcdib_wr *** !! !! ** Purpose : output of passive tracer : biological fields !! !! ** Method : At the beginning of the first time step (nit000), define all !! the NETCDF files and fields for concentration of passive tracer !! !! At each time step call histdef to compute the mean if necessary !! Each nwritebio time step, output the instantaneous or mean fields !! !! IF kindic <0, output of fields before the model interruption. !! IF kindic =0, time step loop !! IF kindic >0, output of fields before the time step loop !!---------------------------------------------------------------------- !! INTEGER, INTENT( in ) :: kt ! ocean time-step INTEGER, INTENT( in ) :: kindic ! indicator of abnormal termination !! LOGICAL :: ll_print = .FALSE. CHARACTER (len=40) :: clhstnam, clop CHARACTER (len=20) :: cltra, cltrau CHARACTER (len=80) :: cltral INTEGER :: ji, jj, jk, jl INTEGER :: iimi, iima, ijmi, ijma, ipk, it, itmod REAL(wp) :: zsto, zout, zdt !!---------------------------------------------------------------------- ! Initialisation ! -------------- ! local variable for debugging ll_print = .FALSE. ll_print = ll_print .AND. lwp ! Define frequency of output and means zdt = rdt IF( ln_mskland ) THEN ; clop = "only(x)" ! put 1.e+20 on land (very expensive!!) ELSE ; clop = "x" ! no use of the mask value (require less cpu time) ENDIF # if defined key_diainstant zsto = nwritebio * zdt clop = "inst("//TRIM(clop)//")" # else zsto = zdt clop = "ave("//TRIM(clop)//")" # endif zout = nwritebio * zdt ! Define indices of the horizontal output zoom and vertical limit storage iimi = 1 ; iima = jpi ijmi = 1 ; ijma = jpj ipk = jpk ! define time axis itmod = kt - nittrc000 + 1 it = kt ! Define NETCDF files and fields at beginning of first time step ! -------------------------------------------------------------- IF(ll_print) WRITE(numout,*)'trcdib_wr kt=',kt,' kindic ',kindic IF( kt == nittrc000 ) THEN ! Define the NETCDF files for biological trends CALL dia_nam(clhstnam,nwritebio,'biolog') IF(lwp)WRITE(numout,*) " Name of NETCDF file for biological trends ", clhstnam ! Horizontal grid : glamt and gphit CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, & & nittrc000-ndttrc, xjulian, zdt, nhoritb, nitb , domain_id=nidom ) ! Vertical grid for biological trends CALL histvert(nitb, 'deptht', 'Vertical T levels', 'm', ipk, gdept_0, ndepitb) ! Declare all the output fields as NETCDF variables ! biological trends DO jl = 1, jpdiabio cltra = ctrbio(jl) ! short title for biological diagnostic cltral = ctrbil(jl) ! long title for biological diagnostic cltrau = ctrbiu(jl) ! UNIT for biological diagnostic CALL histdef( nitb, cltra, cltral, cltrau, jpi, jpj, nhoritb, & & ipk, 1, ipk, ndepitb, 32, clop, zsto, zout) END DO ! CLOSE netcdf Files CALL histend( nitb ) IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdib_wr' IF(ll_print) CALL FLUSH(numout ) ! ENDIF ! Start writing data ! ------------------ ! biological trends IF( lwp .AND. MOD( itmod, nwritebio ) == 0 ) THEN WRITE(numout,*) 'trcdit_wr : write NetCDF biological trends at ', kt, 'time-step' WRITE(numout,*) '~~~~~~ ' ENDIF DO jl = 1, jpdiabio cltra = ctrbio(jl) ! short title for biological diagnostic CALL histwrite(nitb, cltra, it, trbio(:,:,:,jl), ndimt50,ndext50) END DO ! Closing all files ! ----------------- IF( kt == nitend .OR. kindic < 0 ) CALL histclo( nitb ) ! END SUBROUTINE trcdib_wr # else SUBROUTINE trcdib_wr( kt, kindic ) ! Dummy routine INTEGER, INTENT ( in ) :: kt, kindic END SUBROUTINE trcdib_wr # endif #else !!---------------------------------------------------------------------- !! Dummy module : No passive tracer !!---------------------------------------------------------------------- CONTAINS SUBROUTINE trc_dia( kt ) ! Empty routine INTEGER, INTENT(in) :: kt END SUBROUTINE trc_dia #endif !!====================================================================== END MODULE trcdia