New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
diadimg.F90 in trunk/NEMO/OPA_SRC/DIA – NEMO

source: trunk/NEMO/OPA_SRC/DIA/diadimg.F90 @ 460

Last change on this file since 460 was 460, checked in by opalod, 18 years ago

nemo_v1_update_051:RB: update diagnostics routines following the new coordinate definition (gdept -> gdept_0)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1MODULE diadimg
2   !!======================================================================
3   !!                     ***  MODULE  diadimg  ***
4   !! Ocean diagnostics :  write ocean output files in dimg direct access format (mpp)
5   !!=====================================================================
6# if defined key_dimgout
7   !!----------------------------------------------------------------------
8   !! * Modules used
9   USE oce             ! ocean dynamics and tracers
10   USE dom_oce         ! ocean space and time domain
11   USE in_out_manager  ! I/O manager
12   USE daymod          ! calendar
13
14   IMPLICIT NONE
15   PRIVATE
16
17   !! * Accessibility
18   PUBLIC dia_wri_dimg            ! called by trd_mld (eg)
19
20   !! * Substitutions
21#  include "domzgr_substitute.h90"
22   !!----------------------------------------------------------------------
23   !!   OPA 9.0 , LOCEAN-IPSL (2005)
24   !! $Header$
25   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
26   !!----------------------------------------------------------------------
27
28CONTAINS
29
30  SUBROUTINE dia_wri_dimg(cd_name, cd_text, ptab, klev, cd_type , ksubi )
31    !!-------------------------------------------------------------------------
32    !!        *** ROUTINE dia_wri_dimg ***
33    !!
34    !! ** Purpose : write ptab in the dimg file cd_name, with comment cd_text.
35    !!       ptab has klev x 2D fields
36    !!
37    !! ** Action :
38    !!       Define header variables from the config parameters
39    !!       Open the dimg file on unit inum = 14 ( IEEE I4R4 file )
40    !!       Write header on record 1
41    !!       Write ptab on the following klev records
42    !!
43    !! History :
44    !!   03-12 (J.M. Molines ) : Original. Replace ctlopn, writn2d
45    !!---------------------------------------------------------------------------
46    !! * Arguments
47    CHARACTER(len=*),INTENT(in) ::   &
48         &                            cd_name,  &  ! dimg file name
49         &                            cd_text      ! comment to write on record #1
50    INTEGER, INTENT(in) ::            klev         ! number of level in ptab to write
51    REAL(wp),INTENT(in), DIMENSION(:,:,:) :: ptab  ! 3D array to write
52    CHARACTER(LEN=1),INTENT(in) ::    cd_type      ! either 'T', 'W' or '2' , depending on the vertical
53    !                                              ! grid for ptab. 2 stands for 2D file
54    INTEGER, INTENT(in), OPTIONAL, DIMENSION(klev) :: ksubi 
55
56    !! * Local declarations
57    INTEGER :: jk, jn           ! dummy loop indices
58    INTEGER :: irecl4,             &    ! record length in bytes
59         &       inum,             &    ! logical unit (set to 14)
60         &       irec                   ! current record to be written
61    REAL(sp)                    :: zdx,zdy,zspval,zwest,ztimm
62    REAL(sp)                    :: zsouth
63    REAL(sp),DIMENSION(jpi,jpj) :: z42d        ! 2d temporary workspace (sp)
64    REAL(sp),DIMENSION(jpk)     :: z4dep       ! vertical level (sp)
65
66    CHARACTER(LEN=4) :: clver='@!01'
67    !!---------------------------------------------------------------------------
68
69    !! * Initialisations
70
71    irecl4 = MAX(jpi*jpj*sp , 84+18*sp + (jpk+8)*jpnij*sp  )
72    inum = 14
73
74    zspval=0.0_sp    ! special values on land
75    !  the 'numerical' grid is described. The geographical one is in a grid file
76    zdx=1._sp
77    zdy=1._sp
78    zsouth=njmpp * 1._sp
79    zwest=nimpp * 1._sp
80    !  time in days since the historical begining of the run (nit000 = 0 )
81    ztimm=adatrj
82
83    SELECT CASE ( cd_type )
84
85    CASE ( 'T')
86       z4dep(:)=gdept_0(:)
87
88    CASE ( 'W' )
89       z4dep(:)=gdepw_0(:)
90
91    CASE ( '2' )
92       z4dep(1:klev) =(/(jk, jk=1,klev)/)
93
94    CASE ( 'I' )
95       z4dep(1:klev) = ksubi(1:klev)
96
97    CASE DEFAULT
98       IF(lwp) WRITE(numout,*) ' E R R O R : bad cd_type in dia_wri_dimg '
99       STOP 'dia_wri_dimg'
100
101    END SELECT
102
103    !! * Open file
104    OPEN (inum, FILE=cd_name, FORM='UNFORMATTED', ACCESS='DIRECT', RECL=irecl4 )
105
106    !! * Write header on record #1
107    IF(lwp) WRITE(inum,REC=1 ) clver, cd_text, irecl4, &
108         &     jpi,jpj, klev*jpnij, 1 , 1 ,            &
109         &     zwest, zsouth, zdx, zdy, zspval,  &
110         &     (z4dep(1:klev),jn=1,jpnij),       &
111         &     ztimm,                            &
112         &     narea, jpnij,jpiglo,jpjglo,jpizoom, jpjzoom,    &    ! extension to dimg for mpp output
113         &     nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt  !
114
115    !! * Write klev levels
116    IF ( cd_type == 'I' ) THEN
117
118       DO jk = 1, klev
119          irec =1 + klev * (narea -1) + jk
120          z42d(:,:) = ptab(:,:,ksubi(jk))
121          WRITE(inum,REC=irec)  z42d(:,:)
122       END DO
123    ELSE
124       DO jk = 1, klev
125          irec =1 + klev * (narea -1) + jk
126          z42d(:,:) = ptab(:,:,jk)
127          WRITE(inum,REC=irec)  z42d(:,:)
128       END DO
129    ENDIF
130
131    !! * Close the file
132    CLOSE(inum)
133
134  END SUBROUTINE dia_wri_dimg
135
136#  else
137   !!----------------------------------------------------------------------
138   !!   Default option :                                       Empty module
139   !!----------------------------------------------------------------------
140CONTAINS
141
142   SUBROUTINE dia_wri_dimg( cd_name, cd_exper, ptab, klev, cd_type )
143      REAL, DIMENSION(:,:,:) :: ptab
144      INTEGER :: klev
145      CHARACTER(LEN=80) :: cd_name, cd_exper,cd_type
146      WRITE(*,*) ' This print must never occur ', cd_name, cd_exper,ptab, klev, cd_type
147      WRITE(*,*) ' this routine is here just for compilation '
148   END SUBROUTINE dia_wri_dimg
149# endif
150   !!======================================================================
151END MODULE diadimg
Note: See TracBrowser for help on using the repository browser.