source: LMDZ6/trunk/libf/dyn3dmem/dynredem_loc.f90 @ 5403

Last change on this file since 5403 was 5285, checked in by abarral, 7 weeks ago

As discussed internally, remove generic ONLY: ... for new _mod_h modules

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 10.3 KB
RevLine 
[2299]1SUBROUTINE dynredem0_loc(fichnom,iday_end,phis)
[1632]2!
[2299]3!-------------------------------------------------------------------------------
4! Write the NetCDF restart file (initialization).
5!-------------------------------------------------------------------------------
[5281]6  USE comgeom_mod_h
[2299]7  USE IOIPSL
8  USE parallel_lmdz
9  USE mod_hallo
[4063]10  USE strings_mod, ONLY: maxlen
11  USE infotrac, ONLY: nqtot, tracers
[5084]12  USE netcdf, ONLY: NF90_CREATE, NF90_DEF_DIM, NF90_INQ_VARID, NF90_GLOBAL,    &
[3803]13                    NF90_CLOSE,  NF90_PUT_ATT, NF90_UNLIMITED, NF90_CLOBBER,   &
14                    NF90_64BIT_OFFSET
[2299]15  USE dynredem_mod, ONLY: cre_var, put_var, err, modname, fil
[4172]16  USE comvert_mod,  ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs,&
17                          aps,bps,pseudoalt
[2597]18  USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
[2603]19  USE logic_mod, ONLY: fxyhypb, ysinus
[2598]20  USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy, &
21                       taux,tauy
[2601]22  USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itaufin, start_time
[2622]23  USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
[2598]24
[5271]25  USE dimensions_mod, ONLY: iim, jjm, llm, ndm
[5285]26  USE paramet_mod_h
[5281]27  USE comgeom_mod_h
[5282]28  USE iniprint_mod_h
[5281]29  IMPLICIT NONE
[5271]30
[5282]31  !===============================================================================
[2299]32! Arguments:
33  CHARACTER(LEN=*), INTENT(IN) :: fichnom          !--- FILE NAME
[5281]34  INTEGER,          INTENT(IN) :: iday_end         !---
[2299]35  REAL,             INTENT(IN) :: phis(ijb_u:ije_u)!--- GROUND GEOPOTENTIAL
36!===============================================================================
37! Local variables:
[4172]38  INTEGER :: iq
[2299]39  INTEGER, PARAMETER :: length=100
40  REAL    :: tab_cntrl(length)                     !--- RUN PARAMETERS TABLE
41  REAL    :: phis_glo(ip1jmp1)
42!   For NetCDF:
[4046]43  CHARACTER(LEN=maxlen) :: unites
[2299]44  INTEGER :: indexID
45  INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID
[4172]46  INTEGER :: sID, sigID, nID, timID
[2299]47  INTEGER :: yyears0, jjour0, mmois0
[4172]48  REAL    :: zjulian, hours
[2299]49!===============================================================================
50  modname='dynredem0'; fil=fichnom
51  CALL Gather_field_u(phis,phis_glo,1)
52  IF(mpi_rank/=0) RETURN
[1632]53
[2299]54  CALL ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian)
55  CALL ju2ymds(zjulian, yyears0, mmois0, jjour0, hours)
[1632]56
[5267]57
[2299]58  tab_cntrl(:)  = 0.
59  tab_cntrl(1)  = REAL(iim)
60  tab_cntrl(2)  = REAL(jjm)
61  tab_cntrl(3)  = REAL(llm)
62  tab_cntrl(4)  = REAL(day_ref)
63  tab_cntrl(5)  = REAL(annee_ref)
64  tab_cntrl(6)  = rad
65  tab_cntrl(7)  = omeg
66  tab_cntrl(8)  = g
67  tab_cntrl(9)  = cpp
68  tab_cntrl(10) = kappa
69  tab_cntrl(11) = daysec
70  tab_cntrl(12) = dtvr
71  tab_cntrl(13) = etot0
72  tab_cntrl(14) = ptot0
73  tab_cntrl(15) = ztot0
74  tab_cntrl(16) = stot0
75  tab_cntrl(17) = ang0
76  tab_cntrl(18) = pa
77  tab_cntrl(19) = preff
[1632]78
[5281]79!    .....    parameters for zoom    ......
[2299]80  tab_cntrl(20) = clon
81  tab_cntrl(21) = clat
82  tab_cntrl(22) = grossismx
83  tab_cntrl(23) = grossismy
84!
85  IF ( fxyhypb )   THEN
86    tab_cntrl(24) = 1.
87    tab_cntrl(25) = dzoomx
88    tab_cntrl(26) = dzoomy
89    tab_cntrl(27) = 0.
90    tab_cntrl(28) = taux
91    tab_cntrl(29) = tauy
92  ELSE
93    tab_cntrl(24) = 0.
94    tab_cntrl(25) = dzoomx
95    tab_cntrl(26) = dzoomy
96    tab_cntrl(27) = 0.
97    tab_cntrl(28) = 0.
98    tab_cntrl(29) = 0.
99    IF( ysinus )  tab_cntrl(27) = 1.
100  END IF
101  tab_cntrl(30) = REAL(iday_end)
102  tab_cntrl(31) = REAL(itau_dyn + itaufin)
103! start_time: start_time of simulation (not necessarily 0.)
104  tab_cntrl(32) = start_time
[1632]105
[2299]106!--- File creation
[3803]107  CALL err(NF90_CREATE(fichnom,IOR(NF90_CLOBBER,NF90_64BIT_OFFSET),nid))
[1632]108
[2299]109!--- Some global attributes
110  CALL err(NF90_PUT_ATT(nid,NF90_GLOBAL,"title","Fichier demarrage dynamique"))
[1632]111
[2299]112!--- Dimensions
113  CALL err(NF90_DEF_DIM(nid,"index", length, indexID))
114  CALL err(NF90_DEF_DIM(nid,"rlonu", iip1,   rlonuID))
115  CALL err(NF90_DEF_DIM(nid,"rlatu", jjp1,   rlatuID))
116  CALL err(NF90_DEF_DIM(nid,"rlonv", iip1,   rlonvID))
117  CALL err(NF90_DEF_DIM(nid,"rlatv", jjm,    rlatvID))
118  CALL err(NF90_DEF_DIM(nid,"sigs",  llm,        sID))
119  CALL err(NF90_DEF_DIM(nid,"sig",   llmp1,    sigID))
120  CALL err(NF90_DEF_DIM(nid,"temps", NF90_UNLIMITED, timID))
[1632]121
[2299]122!--- Define and save invariant fields
123  CALL put_var(nid,"controle","Parametres de controle" ,[indexID],tab_cntrl)
124  CALL put_var(nid,"rlonu"   ,"Longitudes des points U",[rlonuID],rlonu)
125  CALL put_var(nid,"rlatu"   ,"Latitudes des points U" ,[rlatuID],rlatu)
126  CALL put_var(nid,"rlonv"   ,"Longitudes des points V",[rlonvID],rlonv)
127  CALL put_var(nid,"rlatv"   ,"Latitudes des points V" ,[rlatvID],rlatv)
128  CALL put_var(nid,"nivsigs" ,"Numero naturel des couches s"    ,[sID]  ,nivsigs)
129  CALL put_var(nid,"nivsig"  ,"Numero naturel des couches sigma",[sigID],nivsig)
130  CALL put_var(nid,"ap"      ,"Coefficient A pour hybride"      ,[sigID],ap)
131  CALL put_var(nid,"bp"      ,"Coefficient B pour hybride"      ,[sigID],bp)
132  CALL put_var(nid,"presnivs",""                                ,[sID]  ,presnivs)
133! covariant <-> contravariant <-> natural conversion coefficients
134  CALL put_var(nid,"cu","Coefficient de passage pour U",[rlonuID,rlatuID],cu)
135  CALL put_var(nid,"cv","Coefficient de passage pour V",[rlonvID,rlatvID],cv)
136  CALL put_var(nid,"aire","Aires de chaque maille"     ,[rlonvID,rlatuID],aire)
137  CALL put_var(nid,"phisinit","Geopotentiel au sol"    ,[rlonvID,rlatuID],phis_glo)
[1632]138
[2299]139!--- Define fields saved later
[4172]140  WRITE(unites,"('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") &
[2299]141               yyears0,mmois0,jjour0
142  CALL cre_var(nid,"temps","Temps de simulation",[timID],unites)
143  CALL cre_var(nid,"ucov" ,"Vitesse U"  ,[rlonuID,rlatuID,sID,timID])
144  CALL cre_var(nid,"vcov" ,"Vitesse V"  ,[rlonvID,rlatvID,sID,timID])
145  CALL cre_var(nid,"teta" ,"Temperature",[rlonvID,rlatuID,sID,timID])
146  DO iq=1,nqtot
[4046]147    CALL cre_var(nid,tracers(iq)%name,tracers(iq)%longName,[rlonvID,rlatuID,sID,timID])
[2299]148  END DO
149  CALL cre_var(nid,"masse","Masse d air"    ,[rlonvID,rlatuID,sID,timID])
150  CALL cre_var(nid,"ps"   ,"Pression au sol",[rlonvID,rlatuID    ,timID])
151  CALL err(NF90_CLOSE (nid))
[1632]152
[2299]153  WRITE(lunout,*)TRIM(modname)//': iim,jjm,llm,iday_end',iim,jjm,llm,iday_end
154  WRITE(lunout,*)TRIM(modname)//': rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa
[1632]155
[2299]156END SUBROUTINE dynredem0_loc
157!
158!-------------------------------------------------------------------------------
[1632]159
160
[2299]161!-------------------------------------------------------------------------------
162!
163SUBROUTINE dynredem1_loc(fichnom,time,vcov,ucov,teta,q,masse,ps)
164!
165!-------------------------------------------------------------------------------
166! Purpose: Write the NetCDF restart file (append).
167!-------------------------------------------------------------------------------
168  USE parallel_lmdz
169  USE mod_hallo
[4063]170  USE strings_mod, ONLY: maxlen
[4389]171  USE infotrac, ONLY: nqtot, tracers, type_trac
[2299]172  USE control_mod
[5084]173  USE netcdf,   ONLY: NF90_OPEN,  NF90_NOWRITE, NF90_GET_VAR, NF90_INQ_VARID,  &
[2299]174                      NF90_CLOSE, NF90_WRITE,   NF90_PUT_VAR, NF90_NoErr
175  USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, &
176                          err, modname, fil, msg
[2601]177  USE temps_mod, ONLY: itau_dyn, itaufin
[5281]178
[5271]179  USE dimensions_mod, ONLY: iim, jjm, llm, ndm
[5285]180  USE paramet_mod_h
[5282]181  USE iniprint_mod_h
[5271]182IMPLICIT NONE
183
[5272]184
[5282]185  !===============================================================================
[2299]186! Arguments:
187  CHARACTER(LEN=*), INTENT(IN) :: fichnom              !-- FILE NAME
188  REAL, INTENT(IN)    ::  time                         !-- TIME
189  REAL, INTENT(IN)    ::  vcov(ijb_v:ije_v,llm)        !-- V COVARIANT WIND
190  REAL, INTENT(IN)    ::  ucov(ijb_u:ije_u,llm)        !-- U COVARIANT WIND
191  REAL, INTENT(IN)    ::  teta(ijb_u:ije_u,llm)        !-- POTENTIAL TEMPERATURE
192  REAL, INTENT(INOUT) ::     q(ijb_u:ije_u,llm,nqtot)  !-- TRACERS
193  REAL, INTENT(IN)    :: masse(ijb_u:ije_u,llm)        !-- MASS PER CELL
194  REAL, INTENT(IN)    ::    ps(ijb_u:ije_u)            !-- GROUND PRESSURE
195!===============================================================================
196! Local variables:
[4172]197  INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac
[2299]198  INTEGER, SAVE :: nb=0
199  INTEGER, PARAMETER :: length=100
200  REAL               :: tab_cntrl(length) ! tableau des parametres du run
[4046]201  CHARACTER(LEN=maxlen) :: var, dum
[2299]202  LOGICAL            :: lread_inca
203!===============================================================================
[1632]204
[2299]205!$OMP MASTER
206  IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++
207  modname='dynredem1_loc'; fil=fichnom
208  CALL err(NF90_OPEN(fil,NF90_WRITE,nid),"open",fil)
[1632]209
[2299]210!--- Write/extend time coordinate
211  nb = nb + 1
212  var="temps"
213  CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var)
214  CALL err(NF90_PUT_VAR(nid,vID,[time]),"put",var)
215  WRITE(lunout,*)TRIM(modname)//": Saving for ", nb, time
[1632]216
[2299]217!--- Rewrite control table (itaufin undefined in dynredem0)
218  var="controle"
219  CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var)
220  CALL err(NF90_GET_VAR(nid,vID,tab_cntrl),"get",var)
221  tab_cntrl(31)=DBLE(itau_dyn + itaufin)
222  CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var)
223  CALL err(NF90_PUT_VAR(nid,vID,tab_cntrl),"put",var)
224  END IF               !++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[1632]225!$OMP END MASTER
226
[2299]227!--- Save fields
228  CALL dynredem_write_u(nid,"ucov" ,ucov ,llm)
229  CALL dynredem_write_v(nid,"vcov" ,vcov ,llm)
230  CALL dynredem_write_u(nid,"teta" ,teta ,llm)
231  CALL dynredem_write_u(nid,"masse",masse,llm)
232  CALL dynredem_write_u(nid,"ps"   ,ps   ,1)
[1632]233
[2299]234!--- Tracers in file "start_trac.nc" (added by Anne)
[2584]235  lread_inca=.FALSE.
[1632]236!$OMP MASTER
[2584]237  fil="start_trac.nc"
[4389]238  IF(ANY(type_trac == ['inca','inco'])) INQUIRE(FILE=fil,EXIST=lread_inca)
[2299]239  IF(lread_inca) CALL err(NF90_OPEN(fil,NF90_NOWRITE,nid_trac),"open")
[1632]240!$OMP END MASTER
241!$OMP BARRIER
242
[2299]243!--- Save tracers
[4046]244  DO iq=1,nqtot; var=TRIM(tracers(iq)%name); ierr=-1
[2299]245    IF(lread_inca) THEN                  !--- Possibly read from "start_trac.nc"
[1632]246!$OMP MASTER     
[2299]247      fil="start_trac.nc"
248      ierr=NF90_INQ_VARID(nid_trac,var,vID_trac)
249      dum='inq'; IF(ierr==NF90_NoErr) dum='fnd'
250      WRITE(lunout,*)msg(dum,var)
[1632]251!$OMP END MASTER
252!$OMP BARRIER
[2299]253      IF(ierr==NF90_NoErr) CALL dynredem_read_u(nid_trac,var,q(:,:,iq),llm)
254    END IF
255    fil=fichnom
256    CALL dynredem_write_u(nid,var,q(:,:,iq),llm)
257  END DO
[1632]258
259!$OMP MASTER
[2299]260  IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++
261  CALL err(NF90_CLOSE(nid),"close")
262  fil="start_trac.nc"
263  IF(lread_inca) CALL err(NF90_CLOSE(nid_trac),"close")
264  END IF               !++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[1632]265!$OMP END MASTER
266
[2299]267END SUBROUTINE dynredem1_loc
268
Note: See TracBrowser for help on using the repository browser.