source: LMDZ6/trunk/libf/dyn3d/dynetat0.f90 @ 4054

Last change on this file since 4054 was 4052, checked in by dcugnet, 3 years ago

Fixes for previous commit:

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