-
Notifications
You must be signed in to change notification settings - Fork 3
/
kid_a_setup_20180125.diff
1383 lines (1228 loc) · 58.3 KB
/
kid_a_setup_20180125.diff
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
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/namelists/1D_input.nml kid_a_setup/namelists/1D_input.nml
--- kid_a_original_20180125_setup/namelists/1D_input.nml 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/namelists/1D_input.nml 2020-05-18 14:57:20.438479586 +0200
@@ -3,6 +3,5 @@
! comment out this call (in namelists.nml) and use this file to input
! the value.
&namelistToUse
-fileIn='namelists/1D.nml'
-fileOut='output/1D_out.nc'
+fileIn='namelists/kida_icmw1D_libcloud_lgr.nml'
/
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/namelists/SC_2D_input.nml kid_a_setup/namelists/SC_2D_input.nml
--- kid_a_original_20180125_setup/namelists/SC_2D_input.nml 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/namelists/SC_2D_input.nml 2020-05-18 14:57:20.438479586 +0200
@@ -3,6 +3,6 @@
! comment out this call (in namelists.nml) and use this file to input
! the value.
&namelistToUse
-fileIn='namelists/SC_2D.nml'
+fileIn='namelists/kida_icmwSC_2D_libcloud_lgr.nml'
fileOut='output/SC_2D_out.nc'
/
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/namelists/WMO_CASE1_input.nml kid_a_setup/namelists/WMO_CASE1_input.nml
--- kid_a_original_20180125_setup/namelists/WMO_CASE1_input.nml 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/namelists/WMO_CASE1_input.nml 2020-05-18 14:57:20.438479586 +0200
@@ -3,6 +3,6 @@
! comment out this call (in namelists.nml) and use this file to input
! the value.
&namelistToUse
-fileIn='namelists/WMO_CASE1.nml'
+fileIn='namelists/kida_SC_2D_libcloud_lgr.nml'
fileOut='output/WMO_CASE1_out.nc'
/
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/src/common_physics.f90 kid_a_setup/src/common_physics.f90
--- kid_a_original_20180125_setup/src/common_physics.f90 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/src/common_physics.f90 2020-05-18 14:57:20.438479586 +0200
@@ -22,6 +22,10 @@
Interface qisaturation
module procedure qisaturation_sp, qisaturation_dp
end Interface
+
+ Interface psaturation
+ module procedure psaturation_sp, psaturation_dp
+ end Interface
contains
@@ -81,6 +85,31 @@
END FUNCTION Qsaturation_dp
+ REAL(SP) FUNCTION Psaturation_sp (T)
+ IMPLICIT NONE
+ ! Tetens formula
+ !
+ real(sp), INTENT (IN) :: T
+ ! Temperature in Kelvin
+ real(sp), PARAMETER::tk0c = 273.15, mul = 0.61078, num_mul = 17.27, den_add = 237.3
+
+ psaturation_sp = mul * EXP (num_mul * (T - tk0c) / ((T-tk0c) + den_add))
+
+ END FUNCTION Psaturation_sp
+
+ REAL(DP) FUNCTION Psaturation_dp (T)
+ IMPLICIT NONE
+ ! Tetens formula
+ !
+ real(dp), INTENT (IN) :: T
+ ! Temperature in Kelvin
+ ! return pressure in hPa
+ real(dp), PARAMETER::tk0c = 273.15, mul = 6.1078, num_mul = 17.27, den_add = 237.3
+
+ psaturation_dp = mul * EXP (num_mul * (T - tk0c) / ((T-tk0c) + den_add))
+
+ END FUNCTION Psaturation_dp
+
REAL(SP) FUNCTION QIsaturation_sp (T, p)
IMPLICIT NONE
!
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/src/compiler_options.inc kid_a_setup/src/compiler_options.inc
--- kid_a_original_20180125_setup/src/compiler_options.inc 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/src/compiler_options.inc 2020-05-18 14:57:20.438479586 +0200
@@ -56,7 +56,7 @@
LNCDF=-L$(NCPATH)/lib -lnetcdff -lnetcdf
LDFLAGS=$(INCDF) $(LNCDF)
-EXECUTABLE=$(MODEL)_$(CASE).exe
+SHARED_LIB=$(MODEL)_$(CASE).so
F2PY=/usr/local/cdat/bin/f2py
F2PY_OPTS=--fcompiler-exec=$(COMPILER) $(LDFLAGS)
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/src/derived_fields.f90 kid_a_setup/src/derived_fields.f90
--- kid_a_original_20180125_setup/src/derived_fields.f90 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/src/derived_fields.f90 2020-05-18 14:57:20.438479586 +0200
@@ -13,7 +13,7 @@
Use column_variables
Use interpolation, only: interpolate, make_wgrid, make_vgrid &
,interpolate_x
- Use physconst, only : r_on_cp, g, p0, pi
+ Use physconst, only : r_on_cp, g, p0, pi, R, Rw
Use switches, only : icase
Implicit none
@@ -28,11 +28,19 @@
integer :: k,j
TdegK(:,:)=exner(:,:)*theta(:,:)
+ ! calc partial pressure of druy air
pmb(:,:)=.01*p0*exner(:,:)**(1./r_on_cp)
+ ! add partial pressure of water vapor
+!! do j = 1,nx
+!! pmb(:, :) = pmb(:, :) + p0*exner(:,:)**(1./r_on_cp-1.)/ &
+!! (R*theta(:, :)) * qv(:, :) * Rw
+! ! p = p_d + rho_d * q_v * R_v * T
+! pmb(:, :) = pmb(:, :) + pmb(:,:) / R * qv(:, :) * Rw
+!! end do
! If we need a staggered grid in vertical...
- if (icase /= 650) then
+ if (icase /= 650 .OR. icase /= 101) then
call make_wgrid(z,z_half)
if ( nx > 1 ) then
! If we need a staggered grid in horizontal
diff -ruN '--exclude=mphys_libcloud_lgr.f90' '--exclude=kida_icmwSC_2D_libcloud_lgr.nml' '--exclude=SC_2D_libcloud_lgr.nml' '--exclude=*~' '--exclude=*.mod' '--exclude=*.o' '--exclude=bin' '--exclude=4A_code' '--exclude=UM_source' '--exclude=.includes' '--exclude=case.used' '--exclude=output*' '--exclude=gmon.out' '--exclude=*.orig*' '--exclude=*rej*' '--exclude=*.out' '--exclude=kida_icmw1D_libcloud_lgr.nml' '--exclude=ICMW_SC_input.nml' '--exclude=.*' '--exclude=out' kid_a_original_20180125_setup/src/diagnostics.f90 kid_a_setup/src/diagnostics.f90
--- kid_a_original_20180125_setup/src/diagnostics.f90 2017-11-10 14:43:55.000000000 +0100
+++ kid_a_setup/src/diagnostics.f90 2020-05-18 14:57:20.442479571 +0200
@@ -14,13 +14,15 @@
Use parameters
Use column_variables
Use runtime
- Use physconst, only: r_on_cp, p0
- Use common_physics, only : qsaturation, qisaturation
+ Use physconst, only: r_on_cp, p0, R, Rw
+ Use common_physics, only : qsaturation, qisaturation, psaturation
Use header_data
Use switches, only: l_diverge
Use namelists, only: KiD_outdir, KiD_outfile, fileNameOut
+ use iso_c_binding, only: c_int, c_float, c_char
+
Implicit none
type, public :: dgID
@@ -390,13 +392,28 @@
!RH liquid
do k=1,nz
if (z(k) < 20000.)then
+! approx RH=qv/qvs
field(k)= 100.*qv(k,nx)/ &
qsaturation(TdegK(k,nx),pmb(k,nx))
+! exact RH = pv/pvs = rhod * qv * Rv * T / pvs
+! = pd / (T * Rd) * qv * Rv * T / pvs
+! = p0 * Ex^(cp/Rd) / Rd * qv * Rv / pvs
+! field(k)= p0*exner(k,nx)**(1./r_on_cp) / R * &
+! qv(k,nx) * Rw / &
+! psaturation(TdegK(k,nx))
else
field(k)=unset_real
end if
end do
call save_dg(field(:)*field_mask(:,nx), 'RH', i_dgtime, units, dims)
+ do k=1,nz
+ if (z(k) < 20000.)then
+ field(k)= psaturation(TdegK(k,nx))
+ else
+ field(k)=unset_real
+ end if
+ end do
+ call save_dg(field(:)*field_mask(:,nx), 'psat', i_dgtime, units, dims)
!RH ice
do k=1,nz
@@ -468,6 +485,10 @@
write (unit=6,fmt='(T3, i3, a)') int(100*i_dgtime&
&/float(maxn_dgtimes)), '% completed...'
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+call write_diagnostics !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
end subroutine save_diagnostics_1d
subroutine save_diagnostics_2d
@@ -838,13 +859,15 @@
deallocate(field_bin_r)
n_dgtimes=i_dgtime
-
! Write out progress indicator in 2% chunks.
if ( mod( int(100*i_dgtime/float(maxn_dgtimes)), 2) < &
mod( int(100*(i_dgtime-1)/float(maxn_dgtimes)), 2) ) &
write (unit=6,fmt='(T3, i3, a)') int(100*i_dgtime&
&/float(maxn_dgtimes)), '% completed...'
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+call write_diagnostics !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end subroutine save_diagnostics_2d
subroutine allocate_dgs_1DTS(dgStore)
@@ -858,13 +881,13 @@
if (nx == 1) then
maxn_dgtimes=max(maxn_dgtimes, int(n_dgtimes*dt/dg_dt)+1)
- allocate(dgStore%data(nz, maxn_dgtimes))
+ allocate(dgStore%data(nz, 2)) !!!!
dgStore%data=unset_real
else
maxn_dgtimes=max(maxn_dgtimes, int(n_dgtimes*dt/dg_dt)+1)
- allocate(dgStore%data(1:nx, maxn_dgtimes))
+ allocate(dgStore%data(1:nx, 2)) !!!!
dgStore%data=unset_real
endif
@@ -880,7 +903,7 @@
n_dgtimes = n_times - n_offset
maxn_dgtimes=max(maxn_dgtimes, int(n_dgtimes*dt/dg_dt)+1)
- allocate(dgStore%data(nz, 1:nx, maxn_dgtimes))
+ allocate(dgStore%data(nz, 1:nx, 2)) !!!!
dgStore%data=unset_real
end subroutine allocate_dgs_2DTS
@@ -894,7 +917,7 @@
n_dgtimes = n_times - n_offset
maxn_dgtimes=max(maxn_dgtimes, int(n_dgtimes*dt/dg_dt)+1)
- allocate(dgStore%data(nz, max_nbins, maxn_dgtimes))
+ allocate(dgStore%data(nz, max_nbins, 2)) !!!!
dgStore%data=unset_real
end subroutine allocate_dgs_bindgs
@@ -908,7 +931,7 @@
n_dgtimes = n_times - n_offset
maxn_dgtimes=max(maxn_dgtimes, int(n_dgtimes*dt/dg_dt)+1)
- allocate(dgStore%data(nz, nx, max_nbins, maxn_dgtimes))
+ allocate(dgStore%data(nz, nx, max_nbins, 2)) !!!!
dgStore%data=unset_real
end subroutine allocate_dgs_bindgs_2d
@@ -922,7 +945,7 @@
n_dgtimes = n_times - n_offset
maxn_dgtimes=max(maxn_dgtimes, int(n_dgtimes*dt/dg_dt)+1)
- allocate(dgStore%data(maxn_dgtimes))
+ allocate(dgStore%data(2)) !!!!
dgStore%data=unset_real
end subroutine allocate_dgs_ScalarTS
@@ -968,11 +991,25 @@
end subroutine getUniqueId
+ subroutine save_dg_1d_sp_c( &
+ field, nx, nz, &
+ name, namelen, &
+ units, unitslen, &
+ itime &
+ )
+ integer(c_int), intent(in), value :: nx, nz, itime, namelen, unitslen
+ real(c_float), intent(in) :: field(nz, nx)
+ character(namelen) :: name
+ character(unitslen) :: units
+
+ call save_dg_1d_sp(field(:,1), name, itime, units, "x")
+ end subroutine
+
subroutine save_dg_1d_sp(field, name, itime, units, dim, longname)
real(sp), intent(in) :: field(:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables for column diagnostics
@@ -1019,6 +1056,9 @@
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,itime)=field(:)
end subroutine save_dg_1d_sp
@@ -1029,7 +1069,7 @@
integer, intent(in) :: ks, ke ! start and end of range
real(sp), intent(in) :: field(:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1074,6 +1114,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(ks:ke,itime)=field(ks:ke)
end subroutine save_dg_1d_range_sp
@@ -1084,7 +1127,7 @@
integer, intent(in) :: k ! index of value to input
real(sp), intent(in) :: value
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1128,16 +1171,34 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(k,itime)=value
end subroutine save_dg_1d_point_sp
+
+ subroutine save_dg_2d_sp_c( &
+ field, nx, nz, &
+ name, namelen, &
+ units, unitslen, &
+ itime &
+ )
+ integer(c_int), intent(in), value :: nx, nz, itime, namelen, unitslen
+ real(c_float), intent(in) :: field(nz, nx)
+ character(namelen) :: name
+ character(unitslen) :: units
+
+ call save_dg_2d_sp(field, name, itime, units, "z,x")
+ end subroutine
+
subroutine save_dg_2d_sp(field, name, itime, units, &
dim, longname)
real(sp), intent(in) :: field(:,:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1146,6 +1207,7 @@
character(max_char_len):: cunits, cdim, clongname
integer :: ivar
+
if (.not. l_dgstep) return
! We're assuming diagnostics are instant for now
@@ -1182,6 +1244,9 @@
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,:,itime)=field(:,:)
end subroutine save_dg_2d_sp
@@ -1192,7 +1257,7 @@
integer, intent(in) :: k ,l! indices of value to input
real(sp), intent(in) :: value
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1236,15 +1301,33 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(k,l,itime)=value
end subroutine save_dg_2d_point_sp
+ subroutine save_dg_scalar_sp_c( &
+ scalar, &
+ name, namelen, &
+ units, unitslen, &
+ itime &
+ )
+ integer(c_int), intent(in), value :: itime, namelen, unitslen
+ real(c_float), intent(in), value :: scalar
+ character(namelen) :: name
+ character(unitslen) :: units
+
+ call save_dg_scalar_sp(scalar, name, itime, units, "x")
+ end subroutine
+
+
subroutine save_dg_scalar_sp(value, name, itime, units, dim, longname)
real(sp), intent(in) :: value
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1285,6 +1368,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(itime)=value
end subroutine save_dg_scalar_sp
@@ -1293,7 +1379,7 @@
real(dp), intent(in) :: field(:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1338,6 +1424,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,itime)=field(:)
end subroutine save_dg_1d_dp
@@ -1348,7 +1437,7 @@
integer, intent(in) :: ks, ke ! start and end of range
real(dp), intent(in) :: field(:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1393,6 +1482,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(ks:ke,itime)=field(ks:ke)
end subroutine save_dg_1d_range_dp
@@ -1403,7 +1495,7 @@
integer, intent(in) :: k ! index of value to input
real(dp), intent(in) :: value
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1447,6 +1539,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(k,itime)=value
end subroutine save_dg_1d_point_dp
@@ -1456,7 +1551,7 @@
real(dp), intent(in) :: field(:,:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1500,6 +1595,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,:,itime)=field(:,:)
end subroutine save_dg_2d_dp
@@ -1510,7 +1608,7 @@
integer, intent(in) :: k ,l! indices of value to input
real(dp), intent(in) :: value
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1554,6 +1652,9 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(k,l,itime)=value
end subroutine save_dg_2d_point_dp
@@ -1563,7 +1664,7 @@
real(dp), intent(in) :: value
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1604,17 +1705,34 @@
dg(ivar)%dim=trim(cdim)
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(itime)=value
end subroutine save_dg_scalar_dp
+ subroutine save_dg_1d_bin_sp_c( &
+ field, nb, nx, nz, &
+ name, namelen, &
+ units, unitslen, &
+ itime &
+ )
+ integer(c_int), intent(in), value :: nb, nx, nz, itime, namelen, unitslen
+ real(c_float), intent(in) :: field(nz, nx, nb)
+ character(namelen) :: name
+ character(unitslen) :: units
+
+ call save_dg_bin_sp(field(:, 1, :), name, itime, units, "x,b")
+ end subroutine
+
subroutine save_dg_bin_sp(field, name, itime, units, &
dim, longname)
real(sp), intent(in) :: field(:,:)
character(*), intent(in) :: name
!character(*), intent(in) :: bin
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1659,6 +1777,9 @@
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,:,itime)=field(:,:)
end subroutine save_dg_bin_sp
@@ -1669,7 +1790,7 @@
real(dp), intent(in) :: field(:,:)
character(*), intent(in) :: name
!character(*), intent(in) :: bin
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1714,16 +1835,33 @@
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,:,itime)=field(:,:)
end subroutine save_dg_bin_dp
+ subroutine save_dg_2d_bin_sp_c( &
+ field, nb, nx, nz, &
+ name, namelen, &
+ units, unitslen, &
+ itime &
+ )
+ integer(c_int), intent(in), value :: nb, nx, nz, itime, namelen, unitslen
+ real(c_float), intent(in) :: field(nz, nx, nb)
+ character(namelen) :: name
+ character(unitslen) :: units
+
+ call save_dg_2d_bin_sp(field, name, itime, units, "z,x,b")
+ end subroutine
+
subroutine save_dg_2d_bin_sp(field, name, itime, units, &
dim, longname)
real(sp), intent(in) :: field(:,:,:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1768,6 +1906,9 @@
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,:,:,itime)=field(:,:,:)
end subroutine save_dg_2d_bin_sp
@@ -1777,7 +1918,7 @@
real(dp), intent(in) :: field(:,:,:)
character(*), intent(in) :: name
- integer, intent(in) :: itime
+ integer, value :: itime !!!!
character(*), intent(in), optional :: units, dim, longname
!local variables
@@ -1822,10 +1963,26 @@
dg(ivar)%longname=trim(clongname)
end if
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (itime .gt. 1) itime = 2 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dg(ivar)%data(:,:,:,itime)=field(:,:,:)
end subroutine save_dg_2d_bin_dp
+ subroutine save_binData_sp_c(&
+ field, nb, &
+ name, namelen, &
+ units, unitslen &
+ )
+ integer(c_int), intent(in), value :: nb, namelen, unitslen
+ real(c_float), intent(in) :: field(nb)
+ character(namelen) :: name
+ character(unitslen) :: units
+
+ call save_binData_sp(field, name, units)
+ end subroutine
+
subroutine save_binData_sp(field, name, units, &
longname)
! Save the bin data (e.g. sizes or masses)
@@ -1912,7 +2069,7 @@
end subroutine save_binData_dp
- subroutine write_diagnostics
+ recursive subroutine write_diagnostics !!!!
Use netcdf
Use switches, only : icase
@@ -1924,15 +2081,35 @@
integer :: ivar, itmp=1, offset=3, n_dgs, k, iq, tim, ibin
character(4) :: char4
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+integer, save :: ncid !!!!
+integer :: vid, itime !!!!
+logical, save :: init = .false. !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
! netcdf variables
- integer :: status, ncid, zid, xid, timeid, binsid
+ integer :: status, zid, xid, timeid, binsid !!!!
integer :: tzdim(2), txdim(2), tzldim(3), tzxdim(3), tzxbindim(4) &
,dim, dim2d(2), dim3d(3), dim4d(4)
integer, allocatable :: varid(:)
- real, allocatable :: field3d(:,:,:)
- real, allocatable :: field4d(:,:,:,:)
-
- write(6,*) 'Integration complete.'
+ real, allocatable :: field1d(:) !!!!
+ real, allocatable :: field2d(:,:) !!!!
+ real, allocatable :: field3d(:,:) !!!!
+ real, allocatable :: field4d(:,:,:) !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (i_dgtime .eq. 1) return !!!!
+ !!!!
+if ((i_dgtime .eq. 2) .and. (init .eqv. .false.)) then !!!!
+ init = .true. !!!!
+ call write_diagnostics !!!!
+endif !!!!
+ !!!!
+itime = 2 !!!!
+ !!!!
+if (init) then !!!!
+ itime = 1 !!!!
+ i_dgtime = 1 !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (fileNameOut=='')then
write(char4,'(I4.4)')icase
@@ -1990,7 +2167,7 @@
status=nf90_put_att(ncid, nf90_global, 'references', references)
status=nf90_put_att(ncid, nf90_global, 'comments', comments)
- status=nf90_def_dim(ncid, 'time', int(n_dgtimes, kind=incdfp), timeid)
+ status=nf90_def_dim(ncid, 'time', NF90_UNLIMITED, timeid) !!!!
call check_ncstatus(status)
status=nf90_def_dim(ncid, 'z', int(nz, kind=incdfp), zid)
call check_ncstatus(status)
@@ -1999,11 +2176,11 @@
status=nf90_def_dim(ncid, 'x', int(nx, kind=incdfp), xid)
call check_ncstatus(status)
- tzdim=(/ timeid, zid /)
- txdim=(/ timeid, xid /)
- tzldim=(/ timeid, binsid, zid /)
- tzxdim=(/ timeid, xid, zid /)
- tzxbindim=(/ timeid, binsid, xid, zid /)
+ tzdim=(/ zid, timeid /) !!!!
+ txdim=(/ xid, timeid /) !!!!
+ tzldim=(/ binsid, zid, timeid /) !!!!
+ tzxdim=(/ xid, zid, timeid /) !!!!
+ tzxbindim=(/ binsid, xid, zid, timeid /) !!!!
! Do the dim variables
n_dgs=2
@@ -2063,7 +2240,13 @@
deallocate(varid)
! Do scalars (including time)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
n_dgs=ID_Scalars%nids
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
allocate(varid(n_dgs))
status=nf90_redef(ncid)
dim=timeid
@@ -2084,25 +2267,48 @@
status=nf90_enddef(ncid)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do ivar=1,n_dgs
- status=nf90_put_var(ncid, varid(ivar), &
- scalars(ivar)%data(1:n_dgtimes))
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ name=scalars(ivar)%name !!!!
+ call sanitize(name) !!!!
+ status=nf90_inq_varid(ncid, name, vid) !!!!
+ call check_ncstatus(status) !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ status=nf90_put_var(ncid, vid, & !!!!
+ scalars(ivar)%data(itime), start=(/i_dgtime/))!!!!
call check_ncstatus(status)
end do
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
deallocate(varid)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
+ !!!!
+write(6,*) 'Writing data @ i_dgtime=', i_dgtime !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (nx == 1) then
-
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!! nx == 1 case not finished! !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Do the instantaneous diags (1D)
n_dgs=ID_instant_column%nids
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
allocate(varid(n_dgs))
status=nf90_redef(ncid)
dim2d=tzdim
do ivar=1,n_dgs
-
status=nf90_def_var(ncid, instant_column(ivar)%name &
, nf90_float, dim2d, varid(ivar))
call check_ncstatus(status)
@@ -2115,17 +2321,35 @@
end do
status=nf90_enddef(ncid)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
do ivar=1,n_dgs
- status=nf90_put_var(ncid, varid(ivar), &
- transpose(instant_column(ivar)%data(1:nz,1:n_dgtimes)))
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ name=instant_column(ivar)%name !!!!
+ call sanitize(name) !!!!
+ status=nf90_inq_varid(ncid, name, vid) !!!!
+ call check_ncstatus(status) !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ status=nf90_put_var(ncid, vid, &
+ instant_column(ivar)%data(1:nz,itime), start=(/1,i_dgtime/))
call check_ncstatus(status)
end do
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
deallocate(varid)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Do the instantaneous bin diags (2D)
n_dgs=ID_instant_bindgs%nids
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
allocate(varid(n_dgs))
status=nf90_redef(ncid)
dim3d=tzldim
@@ -2143,18 +2367,29 @@
end do
status=nf90_enddef(ncid)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- allocate(field3d(n_dgtimes, max_nbins, nz))
+!!!! TODO
+ allocate(field3d(max_nbins, nz))
do ivar=1,n_dgs
- do tim=1,n_dgtimes
+!! do tim=1,n_dgtimes
do iq=1, max_nbins
do k = 1,nz
- field3d(tim,iq,k)= instant_bindgs(ivar)%data(k,iq,tim)
+ field3d(iq,k)= instant_bindgs(ivar)%data(k,iq,itime) !!!!
enddo
enddo
- enddo
- status=nf90_put_var(ncid, varid(ivar), field3d)
+!! enddo
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ name=instant_bindgs(ivar)%name !!!!
+ call sanitize(name) !!!!
+ status=nf90_inq_varid(ncid, & !!!!
+ instant_bindgs(ivar)%name, vid) !!!!
+ call check_ncstatus(status) !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ status=nf90_put_var(ncid, vid, field3d, start=(/1,1,i_dgtime/))
call check_ncstatus(status)
@@ -2162,12 +2397,187 @@
deallocate(field3d)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
deallocate(varid)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+!!!!! ------ new try of 1D diag from a copy of the 2d diag ------
+
+ ! Do the instantaneous diags (1D)
+! n_dgs=ID_instant_column%nids
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! allocate(varid(n_dgs))
+! status=nf90_redef(ncid)
+! dim3d=tzldim
+!
+! do ivar=1,n_dgs
+! status=nf90_def_var(ncid, instant_column(ivar)%name &
+! , nf90_float, dim2d, varid(ivar))
+! call check_ncstatus(status)
+! status=nf90_put_att(ncid, varid(ivar), &
+! 'units', instant_column(ivar)%units)
+! status=nf90_put_att(ncid, varid(ivar), &
+! 'dim', instant_column(ivar)%dim)
+! status=nf90_put_att(ncid, varid(ivar), &
+! 'missing_value', unset_real)
+! end do
+!
+! status=nf90_enddef(ncid)
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! allocate(field1d(nz)) !!!!
+!
+! do ivar=1,n_dgs
+!!!!! do tim=1,n_dgtimes !!!!
+! do k = 1,nz
+! field1d(k)= instant_column(ivar)%data(k,itime)
+! enddo
+! !!enddo
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! status=nf90_inq_varid(ncid, & !!!!
+! instant_column(ivar)%name, vid) !!!!
+! call check_ncstatus(status) !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! status=nf90_put_var(ncid, vid, field1d, start=(/1,i_dgtime/)) !!!!
+!
+! call check_ncstatus(status)
+!
+! enddo
+!
+! deallocate(field1d)
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! deallocate(varid)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! ! Do the instantaneous bin micro diags (1D)
+! n_dgs=ID_instant_bindgs%nids
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!if (init) then !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! allocate(varid(n_dgs))
+! status=nf90_redef(ncid)
+! dim4d=tzxbindim
+!
+! do ivar=1,n_dgs
+! status=nf90_def_var(ncid, instant_bindgs(ivar)%name &
+! , nf90_float, dim3d, varid(ivar))
+! call check_ncstatus(status)
+! status=nf90_put_att(ncid, varid(ivar), &
+! 'units', instant_bindgs(ivar)%units)
+! status=nf90_put_att(ncid, varid(ivar), &
+! 'dim', instant_bindgs(ivar)%dim)
+! status=nf90_put_att(ncid, varid(ivar), &
+! 'missing_value', unset_real)
+! end do
+!
+! status=nf90_enddef(ncid)
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!endif !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! allocate(field2d(max_nbins, nz))
+!
+! do ivar=1,n_dgs
+!!!!! do tim=1,n_dgtimes !!!!
+! do ibin= 1,max_nbins
+! do k = 1,nz
+! field2d(ibin,k)= instant_bindgs(ivar)%data(k,ibin,itime) !!!!
+! enddo
+!!!!! enddo !!!!
+! enddo
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! status=nf90_inq_varid(ncid, & !!!!
+! instant_bindgs(ivar)%name, vid) !!!!
+! call check_ncstatus(status) !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! status=nf90_put_var(ncid, vid, field2d(:,:), start=(/1,1,i_dgtime/)) !!!!
+!
+! call check_ncstatus(status)
+!