[216] | 1 | MODULE 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 |
---|
[1953] | 12 | USE daymod ! calendar |
---|
[216] | 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 | !!---------------------------------------------------------------------- |
---|
[247] | 23 | !! OPA 9.0 , LOCEAN-IPSL (2005) |
---|
[1953] | 24 | !! $Header$ |
---|
[247] | 25 | !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt |
---|
[216] | 26 | !!---------------------------------------------------------------------- |
---|
| 27 | |
---|
| 28 | CONTAINS |
---|
| 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 : |
---|
[1581] | 44 | !! 03-12 (J.M. Molines ) : Original. Replace ctl_opn, writn2d |
---|
[216] | 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 |
---|
[1953] | 59 | & inum, & ! logical unit (set to 14) |
---|
| 60 | & irec, & ! current record to be written |
---|
| 61 | & irecend ! record number where nclit... are stored |
---|
[216] | 62 | REAL(sp) :: zdx,zdy,zspval,zwest,ztimm |
---|
| 63 | REAL(sp) :: zsouth |
---|
| 64 | REAL(sp),DIMENSION(jpi,jpj) :: z42d ! 2d temporary workspace (sp) |
---|
| 65 | REAL(sp),DIMENSION(jpk) :: z4dep ! vertical level (sp) |
---|
| 66 | |
---|
[631] | 67 | CHARACTER(LEN=80) :: clname ! name of file in case of dimgnnn |
---|
| 68 | CHARACTER(LEN=4) :: clver='@!01' ! dimg string identifier |
---|
[216] | 69 | !!--------------------------------------------------------------------------- |
---|
| 70 | |
---|
| 71 | !! * Initialisations |
---|
| 72 | |
---|
[1953] | 73 | irecl4 = MAX(jpi*jpj*sp , 84+(18+1+jpk)*sp ) |
---|
[216] | 74 | |
---|
| 75 | zspval=0.0_sp ! special values on land |
---|
| 76 | ! the 'numerical' grid is described. The geographical one is in a grid file |
---|
| 77 | zdx=1._sp |
---|
| 78 | zdy=1._sp |
---|
| 79 | zsouth=njmpp * 1._sp |
---|
| 80 | zwest=nimpp * 1._sp |
---|
| 81 | ! time in days since the historical begining of the run (nit000 = 0 ) |
---|
| 82 | ztimm=adatrj |
---|
| 83 | |
---|
| 84 | SELECT CASE ( cd_type ) |
---|
| 85 | |
---|
| 86 | CASE ( 'T') |
---|
[460] | 87 | z4dep(:)=gdept_0(:) |
---|
[216] | 88 | |
---|
| 89 | CASE ( 'W' ) |
---|
[460] | 90 | z4dep(:)=gdepw_0(:) |
---|
[216] | 91 | |
---|
| 92 | CASE ( '2' ) |
---|
| 93 | z4dep(1:klev) =(/(jk, jk=1,klev)/) |
---|
| 94 | |
---|
| 95 | CASE ( 'I' ) |
---|
| 96 | z4dep(1:klev) = ksubi(1:klev) |
---|
| 97 | |
---|
| 98 | CASE DEFAULT |
---|
| 99 | IF(lwp) WRITE(numout,*) ' E R R O R : bad cd_type in dia_wri_dimg ' |
---|
| 100 | STOP 'dia_wri_dimg' |
---|
| 101 | |
---|
| 102 | END SELECT |
---|
| 103 | |
---|
[631] | 104 | IF ( ln_dimgnnn ) THEN |
---|
[1953] | 105 | irecl4 = MAX(jpi*jpj*sp , 84+(18+jpk)*sp + 8*jpnij*sp ) |
---|
[631] | 106 | WRITE(clname,'(a,a,i3.3)') TRIM(cd_name),'.',narea |
---|
[1953] | 107 | CALL ctl_opn(inum, clname,'UNKNOWN','UNFORMATTED','DIRECT',irecl4,numout,lwp) |
---|
[631] | 108 | WRITE(inum,REC=1 ) clver, cd_text, irecl4, & |
---|
| 109 | & jpi,jpj, klev, 1 , 1 , & |
---|
| 110 | & zwest, zsouth, zdx, zdy, zspval, & |
---|
| 111 | & z4dep(1:klev), & |
---|
| 112 | & ztimm, & |
---|
| 113 | & narea, jpnij,jpiglo,jpjglo,jpizoom, jpjzoom, & ! extension to dimg for mpp output |
---|
| 114 | & nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt ! |
---|
[216] | 115 | |
---|
[631] | 116 | !! * Write klev levels |
---|
| 117 | IF ( cd_type == 'I' ) THEN |
---|
[216] | 118 | |
---|
[631] | 119 | DO jk = 1, klev |
---|
| 120 | irec =1 + jk |
---|
| 121 | z42d(:,:) = ptab(:,:,ksubi(jk)) |
---|
| 122 | WRITE(inum,REC=irec) z42d(:,:) |
---|
| 123 | END DO |
---|
| 124 | ELSE |
---|
| 125 | DO jk = 1, klev |
---|
| 126 | irec =1 + jk |
---|
| 127 | z42d(:,:) = ptab(:,:,jk) |
---|
| 128 | WRITE(inum,REC=irec) z42d(:,:) |
---|
| 129 | END DO |
---|
| 130 | ENDIF |
---|
| 131 | ELSE |
---|
[1953] | 132 | clver='@!03' ! dimg string identifier |
---|
| 133 | ! note that version @!02 is optimized with respect to record length. |
---|
| 134 | ! The vertical dep variable is reduced to klev instead of klev*jpnij : |
---|
| 135 | ! this is OK for jpnij < 181 (jpk=46) |
---|
| 136 | ! for more processors, irecl4 get huge and that's why we switch to '@!03': |
---|
| 137 | ! In this case we just add an extra integer to the standard dimg structure, |
---|
| 138 | ! which is a record number where the arrays nlci etc... starts (1 per record) |
---|
| 139 | |
---|
[631] | 140 | !! Standard dimgproc (1 file per variable, all procs. write to this file ) |
---|
| 141 | !! * Open file |
---|
[1953] | 142 | CALL ctl_opn(inum, cd_name,'UNKNOWN','UNFORMATTED','DIRECT',irecl4,numout,lwp) |
---|
[216] | 143 | |
---|
[631] | 144 | !! * Write header on record #1 |
---|
[1953] | 145 | irecend=1 + klev*jpnij |
---|
[631] | 146 | IF(lwp) WRITE(inum,REC=1 ) clver, cd_text, irecl4, & |
---|
[1953] | 147 | & jpi,jpj, klev, 1 , 1 , & |
---|
[631] | 148 | & zwest, zsouth, zdx, zdy, zspval, & |
---|
[1953] | 149 | & z4dep(1:klev), & |
---|
[631] | 150 | & ztimm, & |
---|
[1953] | 151 | & narea, jpnij,jpiglo,jpjglo,jpizoom, jpjzoom, irecend |
---|
| 152 | IF (lwp ) THEN |
---|
| 153 | WRITE(inum,REC=irecend + 1 ) nlcit |
---|
| 154 | WRITE(inum,REC=irecend + 2 ) nlcjt |
---|
| 155 | WRITE(inum,REC=irecend + 3 ) nldit |
---|
| 156 | WRITE(inum,REC=irecend + 4 ) nldjt |
---|
| 157 | WRITE(inum,REC=irecend + 5 ) nleit |
---|
| 158 | WRITE(inum,REC=irecend + 6 ) nlejt |
---|
| 159 | WRITE(inum,REC=irecend + 7 ) nimppt |
---|
| 160 | WRITE(inum,REC=irecend + 8 ) njmppt |
---|
| 161 | ENDIF |
---|
| 162 | ! & ! extension to dimg for mpp output |
---|
| 163 | ! & nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt ! |
---|
[631] | 164 | |
---|
| 165 | !! * Write klev levels |
---|
| 166 | IF ( cd_type == 'I' ) THEN |
---|
| 167 | |
---|
| 168 | DO jk = 1, klev |
---|
| 169 | irec =1 + klev * (narea -1) + jk |
---|
| 170 | z42d(:,:) = ptab(:,:,ksubi(jk)) |
---|
| 171 | WRITE(inum,REC=irec) z42d(:,:) |
---|
| 172 | END DO |
---|
| 173 | ELSE |
---|
| 174 | DO jk = 1, klev |
---|
| 175 | irec =1 + klev * (narea -1) + jk |
---|
| 176 | z42d(:,:) = ptab(:,:,jk) |
---|
| 177 | WRITE(inum,REC=irec) z42d(:,:) |
---|
| 178 | END DO |
---|
| 179 | ENDIF |
---|
[216] | 180 | ENDIF |
---|
| 181 | |
---|
| 182 | !! * Close the file |
---|
| 183 | CLOSE(inum) |
---|
| 184 | |
---|
| 185 | END SUBROUTINE dia_wri_dimg |
---|
| 186 | |
---|
| 187 | # else |
---|
| 188 | !!---------------------------------------------------------------------- |
---|
| 189 | !! Default option : Empty module |
---|
| 190 | !!---------------------------------------------------------------------- |
---|
| 191 | CONTAINS |
---|
| 192 | |
---|
| 193 | SUBROUTINE dia_wri_dimg( cd_name, cd_exper, ptab, klev, cd_type ) |
---|
| 194 | REAL, DIMENSION(:,:,:) :: ptab |
---|
| 195 | INTEGER :: klev |
---|
| 196 | CHARACTER(LEN=80) :: cd_name, cd_exper,cd_type |
---|
| 197 | WRITE(*,*) ' This print must never occur ', cd_name, cd_exper,ptab, klev, cd_type |
---|
| 198 | WRITE(*,*) ' this routine is here just for compilation ' |
---|
| 199 | END SUBROUTINE dia_wri_dimg |
---|
| 200 | # endif |
---|
| 201 | !!====================================================================== |
---|
| 202 | END MODULE diadimg |
---|