source: LMDZ6/trunk/libf/dyn3d/dynetat0.F90 @ 4125

Last change on this file since 4125 was 4124, checked in by dcugnet, 3 years ago

Remove solsym, ok_isotopes (=niso>0), ok_isotrac (=nzone>0)

File size: 9.1 KB
Line 
1SUBROUTINE dynetat0(fichnom,vcov,ucov,teta,q,masse,ps,phis,time)
2!
3!-------------------------------------------------------------------------------
4! Authors: P. Le Van , L.Fairhead
5!-------------------------------------------------------------------------------
6! Purpose: Initial state reading.
7!-------------------------------------------------------------------------------
8  USE infotrac,    ONLY: nqtot, tracers, niso, iqiso, iso_indnum, iso_num, tnat, alpha_ideal, iH2O
9  USE strings_mod, ONLY: maxlen, msg, strStack, real2str
10  USE netcdf,      ONLY: NF90_OPEN,  NF90_NOWRITE, NF90_INQ_VARID, &
11                         NF90_CLOSE, NF90_GET_VAR, NF90_NoErr
12  USE readTracFiles_mod, ONLY: new2oldName
13  USE control_mod, ONLY: planet_type
14  USE assert_eq_m, ONLY: assert_eq
15  USE comvert_mod, ONLY: pa,preff
16  USE comconst_mod, ONLY: cpp, daysec, dtvr, g, im, jm, kappa, lllm, omeg, rad
17  USE logic_mod, ONLY: fxyhypb, ysinus
18  USE serre_mod, ONLY: clon, clat, grossismx, grossismy
19  USE temps_mod, ONLY: annee_ref, day_ini, day_ref, itau_dyn, start_time
20  USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
21
22  IMPLICIT NONE
23  include "dimensions.h"
24  include "paramet.h"
25  include "comgeom2.h"
26  include "description.h"
27  include "iniprint.h"
28!===============================================================================
29! Arguments:
30  CHARACTER(LEN=*), INTENT(IN) :: fichnom          !--- FILE NAME
31  REAL, INTENT(OUT) ::  vcov(iip1,jjm, llm)        !--- V COVARIANT WIND
32  REAL, INTENT(OUT) ::  ucov(iip1,jjp1,llm)        !--- U COVARIANT WIND
33  REAL, INTENT(OUT) ::  teta(iip1,jjp1,llm)        !--- POTENTIAL TEMP.
34  REAL, INTENT(OUT) ::     q(iip1,jjp1,llm,nqtot)  !--- TRACERS
35  REAL, INTENT(OUT) :: masse(iip1,jjp1,llm)        !--- MASS PER CELL
36  REAL, INTENT(OUT) ::    ps(iip1,jjp1)            !--- GROUND PRESSURE
37  REAL, INTENT(OUT) ::  phis(iip1,jjp1)            !--- GEOPOTENTIAL
38!===============================================================================
39! Local variables:
40  CHARACTER(LEN=maxlen) :: mesg, var, modname, oldVar
41  INTEGER, PARAMETER :: length=100
42  INTEGER :: iq, fID, vID, idecal, iqParent, iName, iZone, iPhase
43  REAL    :: time, tab_cntrl(length)               !--- RUN PARAMS TABLE
44!-------------------------------------------------------------------------------
45  modname="dynetat0"
46
47!--- Initial state file opening
48  var=fichnom
49  CALL err(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var)
50  CALL get_var1("controle",tab_cntrl)
51
52!!! AS: idecal is a hack to be able to read planeto starts...
53!!!     .... while keeping everything OK for LMDZ EARTH
54  IF(planet_type=="generic") THEN
55    CALL msg('NOTE NOTE NOTE : Planeto-like start files', modname)
56    idecal = 4
57    annee_ref  = 2000
58  ELSE
59    CALL msg('NOTE NOTE NOTE : Earth-like start files', modname)
60    idecal = 5
61    annee_ref  = tab_cntrl(5)
62  END IF
63  im         = tab_cntrl(1)
64  jm         = tab_cntrl(2)
65  lllm       = tab_cntrl(3)
66  day_ref    = tab_cntrl(4)
67  rad        = tab_cntrl(idecal+1)
68  omeg       = tab_cntrl(idecal+2)
69  g          = tab_cntrl(idecal+3)
70  cpp        = tab_cntrl(idecal+4)
71  kappa      = tab_cntrl(idecal+5)
72  daysec     = tab_cntrl(idecal+6)
73  dtvr       = tab_cntrl(idecal+7)
74  etot0      = tab_cntrl(idecal+8)
75  ptot0      = tab_cntrl(idecal+9)
76  ztot0      = tab_cntrl(idecal+10)
77  stot0      = tab_cntrl(idecal+11)
78  ang0       = tab_cntrl(idecal+12)
79  pa         = tab_cntrl(idecal+13)
80  preff      = tab_cntrl(idecal+14)
81!
82  clon       = tab_cntrl(idecal+15)
83  clat       = tab_cntrl(idecal+16)
84  grossismx  = tab_cntrl(idecal+17)
85  grossismy  = tab_cntrl(idecal+18)
86!
87  IF ( tab_cntrl(idecal+19)==1. )  THEN
88    fxyhypb  = .TRUE.
89!   dzoomx   = tab_cntrl(25)
90!   dzoomy   = tab_cntrl(26)
91!   taux     = tab_cntrl(28)
92!   tauy     = tab_cntrl(29)
93  ELSE
94    fxyhypb = .FALSE.
95    ysinus  = tab_cntrl(idecal+22)==1.
96  END IF
97
98  day_ini    = tab_cntrl(30)
99  itau_dyn   = tab_cntrl(31)
100  start_time = tab_cntrl(32)
101
102!-------------------------------------------------------------------------------
103  CALL msg('rad, omeg, g, cpp, kappa = '//TRIM(strStack(real2str([rad,omeg,g,cpp,kappa]))), modname)
104  CALL check_dim(im,iim,'im','im')
105  CALL check_dim(jm,jjm,'jm','jm')
106  CALL check_dim(lllm,llm,'lm','lllm')
107  CALL get_var1("rlonu",rlonu)
108  CALL get_var1("rlatu",rlatu)
109  CALL get_var1("rlonv",rlonv)
110  CALL get_var1("rlatv",rlatv)
111  CALL get_var2("cu"   ,cu)
112  CALL get_var2("cv"   ,cv)
113  CALL get_var2("aire" ,aire)
114  var="temps"
115  IF(NF90_INQ_VARID(fID,var,vID)/=NF90_NoErr) THEN
116    CALL msg('missing field <temps> ; trying with <Time>', modname)
117    var="Time"
118    CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
119  END IF
120  CALL err(NF90_GET_VAR(fID,vID,time),"get",var)
121  CALL get_var2("phisinit",phis)
122  CALL get_var3("ucov",ucov)
123  CALL get_var3("vcov",vcov)
124  CALL get_var3("teta",teta)
125  CALL get_var3("masse",masse)
126  CALL get_var2("ps",ps)
127
128!--- Tracers
129  DO iq=1,nqtot
130    var = tracers(iq)%name
131    oldVar = new2oldName(var)
132    !--------------------------------------------------------------------------------------------------------------------------
133    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr) THEN                                 !=== REGULAR CASE
134      CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",var)
135    !--------------------------------------------------------------------------------------------------------------------------
136    ELSE IF(NF90_INQ_VARID(fID, oldVar, vID) == NF90_NoErr) THEN                         !=== OLD NAME
137      CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to <'//TRIM(oldVar)//'>', modname)
138      CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",oldVar)
139    !--------------------------------------------------------------------------------------------------------------------------
140#ifdef INCA
141    ELSE IF(NF90_INQ_VARID(fID, 'OX',   vID) == NF90_NoErr .AND. var == 'O3') THEN       !=== INCA: OX INSTEAD OF O3
142      CALL msg('Tracer <O3> is missing => initialized to <OX>', modname)
143      CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",'OX')
144    !--------------------------------------------------------------------------------------------------------------------------
145#endif
146    ELSE IF(tracers(iq)%iso_iGroup == iH2O .AND. niso > 0) THEN                          !=== WATER ISOTOPES
147!     iName    = tracers(iq)%iso_iName  ! (next commit)
148      iName    = iso_num(iq)
149      iPhase   = tracers(iq)%iso_iPhase
150      iqParent = tracers(iq)%iqParent
151      IF(tracers(iq)%iso_iZone == 0) THEN
152         CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized with a simplified Rayleigh distillation law.', modname)
153         q(:,:,:,iq) = q(:,:,:,iqParent)*tnat(iName)*(q(:,:,:,iqParent)/30.e-3)**(alpha_ideal(iName)-1.)
154      ELSE
155         CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to its parent isotope concentration.', modname)
156         q(:,:,:,iq) = q(:,:,:,iqiso(iso_indnum(iq),iPhase))
157      END IF
158    !--------------------------------------------------------------------------------------------------------------------------
159    ELSE                                                                                 !=== MISSING: SET TO 0
160      CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to zero', modname)
161      q(:,:,:,iq)=0.
162    !--------------------------------------------------------------------------------------------------------------------------
163    END IF
164  END DO
165
166  CALL err(NF90_CLOSE(fID),"close",fichnom)
167  day_ini=day_ini+INT(time)
168  time=time-INT(time)
169
170
171  CONTAINS
172
173
174SUBROUTINE check_dim(n1,n2,str1,str2)
175  INTEGER,          INTENT(IN) :: n1, n2
176  CHARACTER(LEN=*), INTENT(IN) :: str1, str2
177  CHARACTER(LEN=maxlen) :: s1, s2
178  IF(n1/=n2) THEN
179    s1='value of '//TRIM(str1)//' ='
180    s2=' read in starting file differs from parametrized '//TRIM(str2)//' ='
181    WRITE(mesg,'(10x,a,i4,2x,a,i4)')TRIM(ADJUSTL(s1)),n1,TRIM(ADJUSTL(s2)),n2
182    CALL ABORT_gcm(TRIM(modname),TRIM(mesg),1)
183  END IF
184END SUBROUTINE check_dim
185
186
187SUBROUTINE get_var1(var,v)
188  CHARACTER(LEN=*), INTENT(IN)  :: var
189  REAL,             INTENT(OUT) :: v(:)
190  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
191  CALL err(NF90_GET_VAR(fID,vID,v),"get",var)
192END SUBROUTINE get_var1
193
194
195SUBROUTINE get_var2(var,v)
196  CHARACTER(LEN=*), INTENT(IN)  :: var
197  REAL,             INTENT(OUT) :: v(:,:)
198  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
199  CALL err(NF90_GET_VAR(fID,vID,v),"get",var)
200END SUBROUTINE get_var2
201
202
203SUBROUTINE get_var3(var,v)
204  CHARACTER(LEN=*), INTENT(IN)  :: var
205  REAL,             INTENT(OUT) :: v(:,:,:)
206  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
207  CALL err(NF90_GET_VAR(fID,vID,v),"get",var)
208END SUBROUTINE get_var3
209
210
211SUBROUTINE err(ierr,typ,nam)
212  INTEGER,          INTENT(IN) :: ierr   !--- NetCDF ERROR CODE
213  CHARACTER(LEN=*), INTENT(IN) :: typ    !--- TYPE OF OPERATION
214  CHARACTER(LEN=*), INTENT(IN) :: nam    !--- FIELD/FILE NAME
215  IF(ierr==NF90_NoERR) RETURN
216  SELECT CASE(typ)
217    CASE('inq');   mesg="Field <"//TRIM(nam)//"> is missing"
218    CASE('get');   mesg="Reading failed for <"//TRIM(nam)//">"
219    CASE('open');  mesg="File opening failed for <"//TRIM(nam)//">"
220    CASE('close'); mesg="File closing failed for <"//TRIM(nam)//">"
221  END SELECT
222  CALL ABORT_gcm(TRIM(modname),TRIM(mesg),ierr)
223END SUBROUTINE err
224
225END SUBROUTINE dynetat0
Note: See TracBrowser for help on using the repository browser.