-
Notifications
You must be signed in to change notification settings - Fork 0
/
MetFields_mod.f90
1135 lines (1032 loc) · 39.6 KB
/
MetFields_mod.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module MetFields_mod
use Config_module, only : USES,USE_WRF_MET_NAMES,NPROC, PBL
use MPI_Groups_mod , only : MPI_BYTE, MPI_DOUBLE_PRECISION, MPI_REAL8, MPI_INTEGER, MPI_LOGICAL, &
MPI_COMM_CALC, MPI_COMM_WORLD, MPI_COMM_SUB, MPISTATUS, &
IERROR, ME_MPI, NPROC_MPI, largeLIMAX,largeLJMAX, share, share_logical
use Par_mod , only : me
implicit none
private
!----------------- basic met fields ----------------------------------!
! Here we declare the meteorological fields used in the model !
!
! Horizonal alignments....
! Placement of q(i,j), u(i,j), v(i,j)
!
! --------------- --------------- --------------- ---------------
! | | | | |
! | | | | |
! u03 q13 u13 q23 u23 q33 u33 q43 u43 ... u(LIMAX,3)
! | | | | |
! | | | | |
! -----v12------- -----v22------- ------v32------ -----v42-------
! | | | | |
! | | | | |
! u02 q12 u12 q22 u22 q32 u32 q42 u42
! | | | | |
! | | | | |
! -----v11------- -----v21------- ------v31------ -----v41-------
! | | | | |
! | | | | |
! u01 q11 u11 q21 u21 q31 u31 q41 u41
! | | | | |
! | | | | |
! -----v10------- -----v20------- ------v30------ -----v40-------
!
!---------------------------------------------------------------------!
!
!
! Vertical levels: z_mid, z_bnd, sigma_mid, sigma_bnd
!=============================================================================
!* "mid" and "bnd" are used as suffixes on z and sigma as shown in
!* the sketch below. "bnd" is the boundary between two layers and
!* "mid" the midddle of the layer. The numbering of layers starts
!* from 1 at the surface.
!*
!*
!*
!* ---------------------------
!*
!*
!* - - - - - - - - - - - - KMAX_MID -1
!*
!*
!* -------------------------- KMAX_BDN-1 (z_bnd) (sigma_bnd)
!*
!*
!* - - - - - - - - - KMAX_MID(old kmax2) = 20 (z_mid) (sigma_mid) (old z2)
!*
!* ------------------------ KMAX_BND = 21 (z_bnd) (old z1)
!* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ surface \\\\\\\\\\\\\\\\
!*
! RESULT FROM ONE TEST
!Tested zm3d (=zm) which is sometimes used against
!z_mid. Seems almost identical. Diff in exner functions maybe?
! z_bnd z_mid zm3d
! DEBUG_Z 2 1 16276.2359 15244.9023 15244.7131
! DEBUG_Z 2 2 14319.8682 13536.3354 13531.2981
! DEBUG_Z 2 3 12815.7707 12185.9090 12177.9740
! DEBUG_Z 2 4 11598.2202 11011.4342 11004.0286
! DEBUG_Z 2 5 10461.1309 9792.2354 9788.6193
! DEBUG_Z 2 6 9168.4701 8431.0622 8430.8546
! DEBUG_Z 2 7 7747.1534 7010.9878 7013.5860
! DEBUG_Z 2 8 6324.9278 5696.2857 5700.0226
! DEBUG_Z 2 9 5103.2253 4595.6436 4598.2893
! DEBUG_Z 2 10 4110.6562 3690.7686 3692.3391
! DEBUG_Z 2 11 3286.0770 2933.6493 2934.3594
! DEBUG_Z 2 12 2591.8972 2296.1632 2296.2730
! DEBUG_Z 2 13 2007.7924 1761.4943 1761.6936
! DEBUG_Z 2 14 1520.4434 1316.9528 1317.4565
! DEBUG_Z 2 15 1116.9477 950.9995 951.4678
! DEBUG_Z 2 16 787.3321 655.5900 655.8842
! DEBUG_Z 2 17 525.1633 424.5627 424.7443
! DEBUG_Z 2 18 324.8232 253.9725 254.0498
! DEBUG_Z 2 19 183.6019 137.4135 137.4284
! DEBUG_Z 2 20 91.3017 45.6234 45.6146
! Vertical level geopotential heights:
real,public, save, allocatable,&
dimension(:,:,:) :: z_bnd ! height of full layers. Updated each timestep
real,public, save,allocatable, &
dimension(:,:,:) :: z_mid ! height of half layers. Updated each METSTEP
! Two sets of Met. fields are read in, and a linear interpolation is made
! between these two points in time. NMET == 2 (two points in time)
! note u_xmj, v_xmi are not "real" m/s wind speeds
! - they are actually divided by the mapping factor in the perpendicular direction).
!
real,target,public, save,allocatable, dimension(:,:,:,:) :: u_xmj
real,target,public, save,allocatable, dimension(:,:,:,:) :: v_xmi
real,target,allocatable,public, dimension(:,:,:,:) :: q
real,target,public, save,allocatable, dimension(:,:,:,:) :: &
th & ! Potential teperature ( deg. k )
! ,q & ! Specific humidity
,roa & ! kg/m3
,cw_met ! cloudwater from meteo file (not always defined!)
real,target,public, save,allocatable, dimension(:,:,:,:) :: &
EtaKz &! vertical diffusivity in Eta coords
,SigmaKz &! vertical diffusivity in sigma coords
,Etadot &! vertical velocity, Eta coords, Pa/s
,Kz_met ! vertical diffusivity in sigma coordinates from meteorology
real,target,public, save,allocatable, dimension(:,:,:,:) :: rain! used only by wrf met
real,target,public, save,allocatable, dimension(:,:) :: irainc! used only by wrf met
real,target,public, save,allocatable, dimension(:,:) :: irainnc! used only by wrf met
! since pr,cc3d,cc3dmax,cnvuf,cnvdf used only for 1 time layer - define without NMET
real,target,public, save,allocatable, dimension(:,:,:) :: &
pr & ! Precipitation in mm/s "passing" the layer
,cc3d & ! 3-d cloud cover (cc3d),
,cc3dmax & ! and maximum for layers above a given layer
,lwc & !liquid water content
! QUERY - should xksig be MID, not BND? Is it needed at all?
,Kz_m2s ! estimated Kz, in intermediate sigma levels, m2/s
real,target,public, save,allocatable, dimension(:,:,:) :: &
cnvuf & ! convective_updraft_flux (kg/s/m2)
,cnvdf ! convective_downdraft_flux (kg/s/m2)
! We don't need to calculate u,v for RiB, Kz for all layer in future maybe
! Still, for safety we let this extent to K=1 for now
real,target,public, save,allocatable, dimension(:,:,:) :: &
u_mid & ! wind u-compnent, m/s (real, not projected)
,v_mid ! wind v-compnent, m/s
real,target,public,save,allocatable, dimension(:,:,:) :: &
tau ! surf. stress N/m^2
! Surface fields, interpolated:
real,target,public, save,allocatable, dimension(:,:,:) :: &
ps &! Surface pressure Pa
,t2_nwp & ! Temp 2 m deg. K
,pbl_nwp & ! Planetary boundary layer height (m)
,fh & ! surf.flux.sens.heat W/m^2
,fl & ! latent heat flux W/m^2
! ,tau & ! surf. stress N/m^2
! These fields only available for EMEP/PARLAM from 2002 on
,rh2m & ! RH at 2m
,SoilWater_uppr & ! Shallow (Upper 7.2cm in PARLAM)
,SoilWater_deep & ! Deep (Next 6x7cm in PARLAM), converted to relative value
,sdepth & ! Snowdepth, m
,ice_nwp & ! QUERY why real?
,sst & ! SST Sea Surface Temprature- ONLY from 2002 in PARLAM
,ws_10m ! wind speed 10m
real,target,public, save,allocatable, dimension(:,:) :: &
u_ref & ! wind speed m/s at 45m (real, not projected)
,rho_surf & ! Surface density
,surface_precip & ! Surface precip mm/hr
,convective_precip & ! Convective precip mm/hr
,Tpot2m & ! Potential temp at 2m
,ustar_nwp & ! friction velocity m/s ustar^2 = tau/roa
,pzpbl & ! stores H(ABL) for averaging and plotting purposes, m
,pwp & ! Permanent Wilting Point
,fc & ! Field Capacity
,invL_nwp & ! inverse of the Monin-Obuhkov length
,model_surf_elevation! height above sea level of model surface. NB: can differ from physical value
! temporary placement of solar radiation variations QUERY?
real,target, public,allocatable, dimension(:,:), save:: &
zen & ! Zenith angle (degrees)
,coszen & ! cos of zenith angle
,PARdbh & ! PAR, direct beam on horizontal surface, W/m2 !WN17
,PARdif & ! PAR, diffuse, W/m2 !WN17
,fCloud & ! cloud atten. factor (0-1), for Weiss&Norman approach !WN17
,Idiffuse & ! diffuse solar radiation (W/m^2)
,Idirect ! total direct solar radiation (W/m^2)
integer, parameter ::Nspecial2d = 0
real,target, public,allocatable, dimension(:,:,:), save:: &
special2d
integer, parameter ::Nspecial3d = 0
real,target, public,allocatable, dimension(:,:,:,:), save:: &
special3d
integer, public, save :: ix_special2d(Nspecial2d),ix_special3d(Nspecial3d)
real,target,public, save,allocatable, dimension(:,:) :: & !st-dust
clay_frac & ! clay fraction (%) in the soil
,sand_frac ! sand fraction (%) in the soil
real,target,public, save,allocatable, dimension(:,:) :: &
surface_precip_old !precip from previous step for making differences (wrf)
! Different NWP outputs for soil water are possible. We can currently
! cope with two:
character(len=10), public, save :: SoilWaterSource="IFS" ! IFS or PARLAM
real,target,public, save, allocatable,dimension(:,:) :: &
fSW ! fSW= f(relative extractable water) = (sw-swmin)/(swFC-swmin)
real,target, public, dimension(:,:), save,allocatable ::&
xwf ! extension of water fraction, save after 1st call
integer, parameter, public :: NEXTEND = 2 ! no. box to side of (i,j)
integer, public, save :: Nhh & ! number of field stored per 24 hours
,nhour_first ! time of the first meteo stored
! Logical flags, used to determine if some met fields are present in the
! input or not:
logical, target, public, save :: &
foundustar= .false. & ! Used for MM5-type, where u_xmj* but not tau
,foundcc3d = .false. & ! false if no cc3d in metdata
,foundSST= .false. & ! false if no SeaSurfaceT in metdata
,foundSoilWater_uppr= .false. & ! false if no SW-shallow
,foundSoilWater_deep= .false. & ! false if no SW-deep
,foundrh2m= .false. & ! false if no relative_humidity_2m in metdata
,foundtau= .false. & ! false if no surface_stress in metdata
,foundsdepth= .false. & ! false if no snow_flag depth in metdata
,foundHmix= .false.& ! false if no PBL height found
,foundice= .false. & ! false if no ice_nwp coverage (%) in metdata
,foundKz_met= .false. & ! false if no Kz from meteorology
,foundconv= .false. & ! false if convection not found or not used
! Introduced for FUTURE NH3, but also sea-salt
,foundws10_met= .false. & ! false if no u10 from meteorology
,foundu10_met= .false. & ! false if no u10 from meteorology
,foundv10_met= .false. & ! false if no v10 from meteorology
,foundprecip= .false. & ! false if no precipitationfrom meteorology
,foundcloudwater= .false.& !false if no cloudwater found
,foundSMI1= .true.& ! false if no Soil Moisture Index level 1 (shallow)
,foundSMI3= .true.& ! false if no Soil Moisture Index level 3 (deep)
,foundrain= .false.& ! false if no rain found or used
,foundirainnc= .false. &! false if no irainnc found or used
,foundirainc= .false. &! false if no irainc found or used
,foundinvL= .false. &! false if topography file found.
,foundtopo= .false. ! false if topography file found.
!NB: the value of model_surf_elevation will be set to default value based on surface pressure anyway
! specific indices of met
integer, public, save :: ix_u_xmj,ix_v_xmi, ix_q, ix_th, ix_cc3d, ix_pr, &
ix_cw_met, ix_cnvuf, ix_cnvdf, ix_Kz_met, ix_roa, ix_SigmaKz, ix_EtaKz,&
ix_Etadot, ix_cc3dmax, ix_lwc, ix_Kz_m2s, ix_u_mid, ix_v_mid, ix_ps, &
ix_t2_nwp, ix_rh2m, ix_fh, ix_fl, ix_tau, ix_ustar_nwp, ix_sst, &
ix_SoilWater_uppr, ix_SoilWater_deep, ix_sdepth, ix_ice_nwp, ix_ws_10m,&
ix_surface_precip, ix_uw, ix_ue, ix_vs, ix_vn, ix_convective_precip, &
ix_rain,ix_irainc,ix_irainnc, ix_elev, ix_invL, ix_pblnwp
type, public :: metfield
character(len = 100) :: name = 'empty' !name as defined in external meteo file
character(len = 100) :: unit = 'notset' !unit required by the model
character(len = 100) :: validity = 'notset' !special conditions set by the external meteo file
integer :: dim = 3 !number of dimension (2 for 2D, 3 for 3D)
integer :: frequency =3 ! How many hours between two fields
logical :: time_interpolate = .true. ! Interpolate in time
logical :: read_meteo = .false. ! The field will be looked for in the external meteo file
logical :: needed= .true. ! The field must be present in the external meteo file
logical, pointer :: found => null() ! The field has been found in the external meteo file
!note that it is not allowed in fortran to define a target in a derived type
real, pointer :: field(:,:,:,:) => null() !actual values for the fields; must be pointed to
integer :: zsize = 1 ! field, size of third index
integer :: msize = 1 ! field, size of fourth index
real, pointer, dimension(:,:,:)::field_shared
logical, pointer :: ready ! The field must be present in the external meteo file
logical, pointer :: copied ! The field must be present in the external meteo file
end type metfield
logical, public,save, target::ready=.false.,copied=.false.
integer, public, parameter :: NmetfieldsMax=100 !maxnumber of metfields
type(metfield), public :: met(NmetfieldsMax) !To put the metfields that need systematic treatment
type(metfield), public :: derivmet(20) !DSA15 To put the metfields derived from NWP, eg for output
logical, target :: metfieldfound(NmetfieldsMax)=.false. !default for met(ix)%found
integer, public, save :: Nmetfields! number of fields defined in met
integer, public, save :: N3Dmetfields! number of 3D fields defined in met
real,target, public,save,allocatable, dimension(:,:,:) :: uw,ue
real,target, public,save,allocatable, dimension(:,:,:) :: vs,vn
logical, public :: WRF_MET_CORRECTIONS = .false.
logical, public :: MET_SHORT = .true.!metfields are stored as "short" (integer*2 and scaling)
logical, public :: MET_C_GRID = .false.!true if u and v wind fields are in a C-staggered, larger grid.
logical, public :: MET_REVERSE_K = .false.!set true if met fields are stored with lowest k at surface
logical, public :: found_wrf_bucket = .false.
real, public :: wrf_bucket = 0.0 !constant used to define precipitation
integer, public :: Nshared_2d
integer, public :: Nshared_3d
public :: Alloc_MetFields !allocate arrays
contains
subroutine Alloc_MetFields(LIMAX,LJMAX,KMAX_MID,KMAX_BND,NMET)
!allocate MetFields arrays arrays
implicit none
integer, intent(in) ::LIMAX,LJMAX,KMAX_MID,KMAX_BND,NMET
integer ::ix,i,j,n,data_shape(3),xsize
do ix=1,NmetfieldsMax
met(ix)%found => metfieldfound(ix)!default target
if(.not. associated(met(ix)%ready))met(ix)%ready=>ready
if(.not. associated(met(ix)%copied))met(ix)%copied=>copied
end do
ix=1
met(ix)%name = 'u_wind'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(u_xmj(0:LIMAX,1:LJMAX,KMAX_MID,NMET))
u_xmj=0.0
met(ix)%field(0:LIMAX,1:LJMAX,1:KMAX_MID,1:NMET) => u_xmj
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_u_xmj=ix
ix=ix+1
met(ix)%name = 'v_wind'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(v_xmi(1:LIMAX,0:LJMAX,KMAX_MID,NMET))
v_xmi=0.0
met(ix)%field(1:LIMAX,0:LJMAX,1:KMAX_MID,1:NMET) => v_xmi
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_v_xmi=ix
ix=ix+1
met(ix)%name = 'specific_humidity' ! kg/kg
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(q(LIMAX,LJMAX,KMAX_MID,NMET))
q=0.0
met(ix)%field => q
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_q=ix
ix=ix+1
met(ix)%name = 'potential_temperature'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(th(LIMAX,LJMAX,KMAX_MID,NMET))
th=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:NMET) => th
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_th=ix
ix=ix+1
met(ix)%name = '3D_cloudcover'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundcc3d
allocate(cc3d(LIMAX,LJMAX,KMAX_MID))
cc3d=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => cc3d
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_cc3d=ix
ix=ix+1
met(ix)%name = 'precipitation'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundprecip
allocate(pr(LIMAX,LJMAX,KMAX_MID))
pr=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => pr
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_pr=ix
ix=ix+1
met(ix)%name = 'cloudwater'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found => foundcloudwater
allocate(cw_met(LIMAX,LJMAX,KMAX_MID,NMET))
cw_met=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:NMET) => cw_met
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_cw_met=ix
ix=ix+1
met(ix)%name = 'convective_updraft_flux'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = USES%CONVECTION
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(cnvuf(LIMAX,LJMAX,KMAX_BND))
cnvuf=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_BND,1:1) => cnvuf
met(ix)%zsize = KMAX_BND
met(ix)%msize = 1
ix_cnvuf=ix
ix=ix+1
met(ix)%name = 'convective_downdraft_flux'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = USES%CONVECTION
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(cnvdf(LIMAX,LJMAX,KMAX_BND))
cnvdf=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_BND,1:1) => cnvdf
met(ix)%zsize = KMAX_BND
met(ix)%msize = 1
ix_cnvdf=ix
ix=ix+1
met(ix)%name = 'eddy_diffusion_coefficient'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundKz_met
allocate(Kz_met(LIMAX,LJMAX,KMAX_BND,NMET))
Kz_met=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_BND,1:NMET) => Kz_met
met(ix)%zsize = KMAX_BND
met(ix)%msize = NMET
ix_Kz_met=ix
ix=ix+1
met(ix)%name = 'air_density'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(roa(LIMAX,LJMAX,KMAX_MID,NMET))
roa=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:NMET) => roa
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_roa=ix
ix=ix+1
met(ix)%name = 'Kz_sigmacoordinates'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(SigmaKz(LIMAX,LJMAX,KMAX_BND,NMET))
SigmaKz=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_BND,1:NMET) => SigmaKz
met(ix)%zsize = KMAX_BND
met(ix)%msize = NMET
ix_SigmaKz=ix
ix=ix+1
met(ix)%name = 'Kz_Etacoordinates'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(EtaKz(LIMAX,LJMAX,KMAX_BND,NMET))
EtaKz=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_BND,1:NMET) => EtaKz
met(ix)%zsize = KMAX_BND
met(ix)%msize = NMET
ix_EtaKz=ix
ix=ix+1
met(ix)%name = 'etadot'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(Etadot(LIMAX,LJMAX,KMAX_BND,NMET))
Etadot=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_BND,1:NMET) => Etadot
met(ix)%zsize = KMAX_BND
met(ix)%msize = NMET
ix_Etadot=ix
ix=ix+1
met(ix)%name = 'max_cloudcover'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(cc3dmax(LIMAX,LJMAX,KMAX_MID))
cc3dmax=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => cc3dmax
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_cc3dmax=ix
ix=ix+1
met(ix)%name = 'cloud_liquid_water'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(lwc(LIMAX,LJMAX,KMAX_MID))
lwc=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => lwc
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_lwc=ix
ix=ix+1
met(ix)%name = 'Kz'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(Kz_m2s(LIMAX,LJMAX,KMAX_MID))
Kz_m2s=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => Kz_m2s
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_Kz_m2s=ix
ix=ix+1
met(ix)%name = 'u_wind_3D'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(u_mid(LIMAX,LJMAX,KMAX_MID))
u_mid=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => u_mid
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_u_mid=ix
ix=ix+1
met(ix)%name = 'v_wind_3D'
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(v_mid(LIMAX,LJMAX,KMAX_MID))
v_mid=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => v_mid
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_v_mid=ix
N3Dmetfields=ix
! write(*,*)'number of 3D metfields: ',N3Dmetfields
!________________________________________________________________
! 2D fields
ix=ix+1
met(ix)%name = 'surface_pressure'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(ps(LIMAX,LJMAX,NMET))
ps=1.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => ps
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_ps=ix
!NWPHMIX
ix=ix+1
met(ix)%name = 'PBLH' ! GLOBAL05
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
! If we ask for this, we need it.
if ( PBL%HmixMethod == 'NWP' ) then
met(ix)%needed = .true.
met(ix)%needed = .false. ! DS testing
met(ix)%found => foundHmix
pbl_nwp=0.0
else
met(ix)%needed = .false.
met(ix)%found = .false.
end if
allocate(pbl_nwp(LIMAX,LJMAX,NMET))
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => pbl_nwp
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_pblnwp=ix
!NWPHMIX
ix=ix+1
met(ix)%name = 'temperature_2m'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(t2_nwp(LIMAX,LJMAX,NMET))
t2_nwp=1.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => t2_nwp
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_t2_nwp=ix
ix=ix+1
met(ix)%name = 'relative_humidity_2m'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundrh2m
allocate(rh2m(LIMAX,LJMAX,NMET))
rh2m=1.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => rh2m
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_rh2m=ix
ix=ix+1
met(ix)%name = 'surface_flux_sensible_heat'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(fh(LIMAX,LJMAX,NMET))
fh=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => fh
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_fh=ix
ix=ix+1
met(ix)%name = 'surface_flux_latent_heat'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(fl(LIMAX,LJMAX,NMET))
fl=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => fl
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_fl=ix
ix=ix+1
met(ix)%name = 'surface_stress'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundtau
allocate(tau(LIMAX,LJMAX,NMET))
tau=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => tau
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_tau=ix
ix=ix+1
met(ix)%name = 'ustar_nwp'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(ustar_nwp(LIMAX,LJMAX))
ustar_nwp=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:1) => ustar_nwp
met(ix)%zsize = 1
met(ix)%msize = 1
ix_ustar_nwp=ix
ix=ix+1
met(ix)%name = 'sea_surface_temperature'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundSST
allocate(sst(LIMAX,LJMAX,NMET))
sst=1.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => sst
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_sst=ix
ix=ix+1
met(ix)%name = 'SMI1'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = USES%SOILWATER
met(ix)%read_meteo = USES%SOILWATER
met(ix)%needed = .false.
met(ix)%found => foundSoilWater_uppr
allocate(SoilWater_uppr(LIMAX,LJMAX,NMET))
SoilWater_uppr=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => SoilWater_uppr
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_SoilWater_uppr=ix
ix=ix+1
met(ix)%name = 'SMI3'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = USES%SOILWATER
met(ix)%read_meteo = USES%SOILWATER
met(ix)%needed = .false.
met(ix)%found => foundSoilWater_deep
allocate(SoilWater_deep(LIMAX,LJMAX,NMET))
SoilWater_deep=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => SoilWater_deep
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_SoilWater_deep=ix
ix=ix+1
met(ix)%name = 'snow_depth'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundsdepth
allocate(sdepth(LIMAX,LJMAX,NMET))
sdepth=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => sdepth
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_sdepth=ix
ix=ix+1
met(ix)%name = 'fraction_of_ice'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundice
allocate(ice_nwp(LIMAX,LJMAX,NMET))
ice_nwp=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => ice_nwp
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_ice_nwp=ix
ix=ix+1
met(ix)%name = 'u10'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .true.
met(ix)%needed = .false.
met(ix)%found => foundws10_met
allocate(ws_10m(LIMAX,LJMAX,NMET))
ws_10m=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:NMET) => ws_10m
met(ix)%zsize = 1
met(ix)%msize = NMET
ix_ws_10m=ix
ix=ix+1
met(ix)%name = 'invL_nwp'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found => foundinvL
allocate(invL_nwp(LIMAX,LJMAX))
invL_nwp=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:1) => invL_nwp
met(ix)%zsize = 1
met(ix)%msize = 1
ix_invL=ix
ix=ix+1
met(ix)%name = 'large_scale_precipitations'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
allocate(surface_precip(LIMAX,LJMAX))
surface_precip=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:1) => surface_precip
met(ix)%zsize = 1
met(ix)%msize = 1
ix_surface_precip=ix
ix=ix+1
met(ix)%name = 'convective_precipitations'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(convective_precip(LIMAX,LJMAX))
convective_precip=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:1) => convective_precip
met(ix)%zsize = 1
met(ix)%msize = 1
ix_convective_precip=ix
ix=ix+1
met(ix)%name = 'topography'!NB: as used in the met model; can differ from physical in mountainous areas.
met(ix)%dim = 2
met(ix)%frequency = 100000!constant
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.!read once only the first time
met(ix)%needed = .false.
met(ix)%found => foundtopo
allocate(model_surf_elevation(LIMAX,LJMAX))
model_surf_elevation=0.0
met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:1) => model_surf_elevation
met(ix)%zsize = 1
met(ix)%msize = 1
ix_elev=ix
ix=ix+1
met(ix)%name = 'neigbors_wind-uw'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(uw(LJMAX,KMAX_MID,NMET))
uw=0.0
met(ix)%field(1:1,1:LJMAX,1:KMAX_MID,1:NMET) => uw
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_uw=ix
ix=ix+1
met(ix)%name = 'neigbors_wind-ue'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(ue(LJMAX,KMAX_MID,NMET))
ue=0.0
met(ix)%field(1:1,1:LJMAX,1:KMAX_MID,1:NMET) => ue
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_ue=ix
ix=ix+1
met(ix)%name = 'neigbors_wind-vs'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(vs(LIMAX,KMAX_MID,NMET))
vs=0.0
met(ix)%field(1:LIMAX,1:1,1:KMAX_MID,1:NMET) => vs
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_vs=ix
ix=ix+1
met(ix)%name = 'neigbors_wind-vn'
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .true.
met(ix)%read_meteo = .false.
met(ix)%needed = .true.
met(ix)%found = .false.
allocate(vn(LIMAX,KMAX_MID,NMET))
vn=0.0
met(ix)%field(1:LIMAX,1:1,1:KMAX_MID,1:NMET) => vn
met(ix)%zsize = KMAX_MID
met(ix)%msize = NMET
ix_vn=ix
!can be used to output any 2d field, using 'MET2D'
do n = 1, Nspecial2d
ix=ix+1
write(met(ix)%name,fmt='(A,I0)')'special2d',n
met(ix)%dim = 2
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
if(n==1)then
allocate(special2d(LIMAX,LJMAX,Nspecial2d))
special2d=0.0
endif
! met(ix)%field(1:LIMAX,1:LJMAX,1:1,1:1) => special2d(1:LIMAX,1:LJMAX,n)
!Since the syntax above is not allowed, we move the adress of the pointer, instead of the target
met(ix)%field(1:LIMAX,1:LJMAX,1-(n-1):1-(n-1),1:1) => special2d
met(ix)%zsize = 1
met(ix)%msize = 1
ix_special2d(n)=ix
enddo
!can be used to output any 2d field, using 'MET2D'
do n = 1, Nspecial3d
ix=ix+1
write(met(ix)%name,fmt='(A,I0)')'special3d',n
met(ix)%dim = 3
met(ix)%frequency = 3
met(ix)%time_interpolate = .false.
met(ix)%read_meteo = .false.
met(ix)%needed = .false.
met(ix)%found = .false.
if(n==1)then
allocate(special3d(LIMAX,LJMAX,KMAX_MID,Nspecial3d))
special3d=0.0
endif
! met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1:1) => special3d(1:LIMAX,1:LJMAX,1:KMAX_MID,n)
!Since the syntax above is not allowed, we move the adress of the pointer, instead of the target
met(ix)%field(1:LIMAX,1:LJMAX,1:KMAX_MID,1-(n-1):1-(n-1)) => special3d
met(ix)%zsize = KMAX_MID
met(ix)%msize = 1
ix_special3d(n)=ix
enddo
if(USE_WRF_MET_NAMES)then
WRF_MET_CORRECTIONS = .true.
MET_C_GRID = .true.
MET_SHORT = .false. !metfields are stored as "float"
MET_REVERSE_K = .true.!reverse k coordinates when reading
!names used in WRF metfiles
!3D
met(ix_u_xmj)%name = 'U'
met(ix_v_xmi)%name = 'V'
met(ix_q)%name = 'QVAPOR'