source: LMDZ5/branches/AI-cosp/libf/dyn3dmem/dynredem_loc.F90 @ 5444

Last change on this file since 5444 was 2299, checked in by dcugnet, 10 years ago

In dyn3d/:
etat0dyn_netcdf.F90: "startget_dyn3d" syntax slightly simplified.
dynredem.F90: Shortcut routines (put_var*, cre_var,
dynredem_write_*, dynredem_read_u)

modified to match dyn3dmem version and put in

module dyredem_mod.F90.
dynetat0.F90 -> *.f90: Few simplifications (no usage of NC_DOUBLE
needed => no precompilation)

Add tracers initialization in the isotope case

suppressed by accident.
dynredem_mod.F90: Created to mimic dyn3dmem equivalent.

In dyn3dmem/:
dynetat0_loc.F -> *.f90: Converted into fortran 90 to match the dyn3d
version.
dynredem_loc.F -> *.F90: Converted into fortran 90.
dynredem_mod.F90: Add some shortcut routines to match the dyn3d
version.

In phylmd/:
phyredem.F90: Bug fix: nsw instead of nsoilmx was used as
Tsoil second maximum index.

Bug fix: fevap instead of snow was saved for

"SNOW".
etat0phys_netcdf.F90: "filtreg_mod" module usage suppressed.

Local variable rugo computation removed (not

used).

In dynlonlat_phylonlat/:
grid_atob_m.F90 -> *.f90 DOUBLE PRECISION variables usage removed.

Precompilation o longer needed => .F90 extension.

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