-
Notifications
You must be signed in to change notification settings - Fork 7
/
hydrodynamic_module.f90
810 lines (636 loc) · 21.8 KB
/
hydrodynamic_module.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
MODULE HYDRO_MOD
! This module handles all the input from the hydrodynamic NetCDF input files.
! It is the only module that interacts with NetCDF input files. It contains
! all the variables read in from the NetCDF files. It also contains all the
! information and variables related to the grid elements.
!
! Created by: Zachary Schlag
! Created on: 07 Aug 2008
! Last Modified on: Feb 2013
! ROMSPath Version: 1.0.1
IMPLICIT NONE
PRIVATE
PUBLIC ::getFileNames
SAVE
!Used for reading in NetCDF variables one time step at a time
INTEGER :: STARTr(4),COUNTr(4),STARTz(3),COUNTz(3)
!These variables keep track of the interpolation method and weights
! INTEGER :: tOK
DOUBLE PRECISION :: t,u,Wgt1,Wgt2,Wgt3,Wgt4
! !The Rho, U, and V nodes that make up the Rho, U, and V element that
! ! the particle is in
! INTEGER, ALLOCATABLE,DIMENSION(:) :: rnode1,rnode2,rnode3,rnode4,unode1,unode2,unode3,unode4,vnode1, &
! vnode2,vnode3,vnode4
!read in zeta,salinity,temperature,vertical diffusivity, and U,V,W velocities
! at hydrodynamic back, center, and forward time
INTEGER, ALLOCATABLE,DIMENSION(:) :: stepf !Keeps track of the forward time step
! !S-Level location variables
! DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:) :: SC,CS,SCW,CSW
! !Depth at each rho node location
! DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:) :: depth
! !Rho, U, and V grid wet elements(four node numbers that make up the element)
! ! (wet means at least 1 node is masked as water)
! INTEGER, ALLOCATABLE, DIMENSION(:,:) :: RE,UE,VE
! !Keeps track of the Rho, U, and V element that each particle is in
! INTEGER, ALLOCATABLE, DIMENSION(:) :: P_r_element,P_u_element,P_v_element
! !For each element, a list containing itself and all the elements that share a
! ! node with that element; used to speed up determining which element the
! ! particle has moved to, if it has moved at all
TYPE HDATA
DOUBLE PRECISION,pointer :: zeta(:,:,:)
DOUBLE PRECISION,pointer :: bustr(:,:,:)
DOUBLE PRECISION,pointer :: bvstr(:,:,:)
DOUBLE PRECISION,pointer :: salt(:,:,:,:)
DOUBLE PRECISION,pointer :: temp(:,:,:,:)
DOUBLE PRECISION,pointer :: AKs(:,:,:,:)
DOUBLE PRECISION,pointer :: U(:,:,:,:)
DOUBLE PRECISION,pointer :: V(:,:,:,:)
DOUBLE PRECISION,pointer :: W(:,:,:,:)
DOUBLE PRECISION,pointer :: time(:)
DOUBLE PRECISION,pointer :: Accelstd_t(:,:,:,:)
DOUBLE PRECISION,pointer :: Vortstd_t(:,:,:,:)
DOUBLE PRECISION,pointer :: Accelustd_w(:,:,:,:)
DOUBLE PRECISION,pointer :: Accelvstd_w(:,:,:,:)
DOUBLE PRECISION,pointer :: Accelwstd_w(:,:,:,:)
#ifdef STOKES
DOUBLE PRECISION,pointer :: SU(:,:,:,:)
DOUBLE PRECISION,pointer :: SV(:,:,:,:)
#endif
#ifdef WETDRY
DOUBLE PRECISION,pointer :: wetdry_mask_u(:,:,:)
DOUBLE PRECISION,pointer :: wetdry_mask_v(:,:,:)
DOUBLE PRECISION,pointer :: wetdry_mask_rho(:,:,:)
#endif
END TYPE HDATA
TYPE (HDATA), allocatable :: HYDRODATA(:)
!Keeps track if the grid has been read in yet or not
! If the grid hasn't been read in, the boundaries can't be made
! LOGICAL :: GRD_SET = .FALSE.
!The concatenated hydrodynamic input file name
CHARACTER(len=200) :: filenm,turbfilenm,wavefilenm
#ifdef STOKES
CHARACTER(len=200) :: stokesfilenm
#endif
character(len=256) :: Iname
!Counters for NetCDF files
!The following procedures have been made public:
! PUBLIC :: initGrid,initHydro,updateHydro,setEle,setEle_all,setInterp, &
! getInterp,interp,WCTS_ITPI,getSlevel,getWlevel,getMask_Rho,getUVxy, &
! getR_ele,getP_r_element,finHydro,initNetCDF,createNetCDF,writeNetCDF
PUBLIC :: updateHydro,HYDRODATA
! &
! getMask_Rho,getUVxy,finHydro,setEle, &
! initNetCDF,createNetCDF,writeNetCDF,MODGRID, &
! getInterp,interp,setInterp,WCTS_ITPI,getSlevel,getWlevel
CONTAINS
SUBROUTINE updateHydro(FIRST,tstep,tind)
!This Subroutine reads in the hydrodynamic information for the first
! iteration
USE PARAM_MOD, ONLY: numpar,xi_rho,eta_rho,s_rho,s_w,suffix,&
prefix,filenum,numdigits,readZeta,constZeta,readSalt,constSalt, &
readTemp,constTemp,readDens,constDens,readU,constU,readV,constV,readW, &
constW,readAks,constAks,Ngrid,xi_u,eta_u,xi_v,eta_v,tdim,t_b,t_c,t_f,&
stokesprefix,TempOffset,WriteBottom,turbstd_v_a_prefix,wavestd_prefix,&
Behavior,Process_VA,Process_WA,time_vname,time_dname
USE netcdf
IMPLICIT NONE
INCLUDE 'netcdf.inc'
INTEGER :: STATUS,NCID,VID,DIMID,dimcount
LOGICAL,INTENT(IN) :: FIRST
INTEGER ,INTENT(IN) :: tstep,tind
INTEGER :: i,j,k,ng
real :: before,after,tdiff
do ng=1,Ngrid
if (FIRST) then
if (ng.eq.1) allocate(HYDRODATA(Ngrid))
!ALLOCATE MODULE VARIABLES
ALLOCATE(HYDRODATA(ng)%zeta(xi_rho(ng),eta_rho(ng),3))
ALLOCATE(HYDRODATA(ng)%bustr(xi_u(ng),eta_u(ng),3))
ALLOCATE(HYDRODATA(ng)%bvstr(xi_v(ng),eta_v(ng),3))
ALLOCATE(HYDRODATA(ng)%salt(xi_rho(ng),eta_rho(ng),s_rho(ng),3))
ALLOCATE(HYDRODATA(ng)%temp(xi_rho(ng),eta_rho(ng),s_rho(ng),3))
ALLOCATE(HYDRODATA(ng)%W(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%AKs(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%U(xi_u(ng),eta_u(ng),s_rho(ng),3))
ALLOCATE(HYDRODATA(ng)%V(xi_v(ng),eta_v(ng),s_rho(ng),3))
ALLOCATE(HYDRODATA(ng)%AKs(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%Accelstd_t(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%Vortstd_t(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%Accelustd_w(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%Accelvstd_w(xi_rho(ng),eta_rho(ng),s_w(ng),3))
ALLOCATE(HYDRODATA(ng)%Accelwstd_w(xi_rho(ng),eta_rho(ng),s_w(ng),3))
#ifdef STOKES
ALLOCATE(HYDRODATA(ng)%SU(xi_u(ng),eta_u(ng),s_rho(ng),3))
ALLOCATE(HYDRODATA(ng)%SV(xi_v(ng),eta_v(ng),s_rho(ng),3))
#endif
#ifdef WETDRY
ALLOCATE(HYDRODATA(ng)%wetdry_mask_u(xi_u(ng),eta_u(ng),3))
ALLOCATE(HYDRODATA(ng)%wetdry_mask_v(xi_v(ng),eta_v(ng),3))
ALLOCATE(HYDRODATA(ng)%wetdry_mask_rho(xi_rho(ng),eta_rho(ng),3))
HYDRODATA(ng)%wetdry_mask_u = 0
HYDRODATA(ng)%wetdry_mask_v = 0
HYDRODATA(ng)%wetdry_mask_rho = 0
#endif
HYDRODATA(ng)%zeta = 0
HYDRODATA(ng)%salt = 0
HYDRODATA(ng)%temp = 0
HYDRODATA(ng)%AKs = 0
HYDRODATA(ng)%U = 0
HYDRODATA(ng)%V = 0
HYDRODATA(ng)%W = 0
HYDRODATA(ng)%Accelstd_t = 0
HYDRODATA(ng)%Vortstd_t = 0
HYDRODATA(ng)%Accelustd_w = 0
HYDRODATA(ng)%Accelvstd_w = 0
HYDRODATA(ng)%Accelwstd_w = 0
endif
! !Open netCDF file
call getFileNames(filenm,prefix(ng),filenum)
call getFileNames(turbfilenm,turbstd_v_a_prefix(ng),filenum)
call getFileNames(wavefilenm,wavestd_prefix(ng),filenum)
#ifdef STOKES
call getFileNames(stokesfilenm,stokesprefix(ng),filenum)
#endif
if (tstep.eq.1)then
write(*,*) "New ROMS File:"
write(*,*) filenm
endif
! Read in data for first three external time steps
STATUS = NF90_OPEN(TRIM(filenm), NF90_NOWRITE, NCID)
if (STATUS .NE. NF90_NOERR) write(*,*) 'Problem NF90_OPEN HYDROFILE'
if (STATUS .NE. NF90_NOERR) write(*,*) NF90_STRERROR(STATUS)
STATUS = NF90_INQ_DIMID(NCID,trim(time_dname),DIMID)
STATUS = NF90_INQUIRE_DIMENSION(NCID,DIMID,len=dimcount)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem with dimid:'
write(*,*) time_dname
write(*,*) NF90_STRERROR(STATUS)
endif
tdim(ng) = dimcount
startz(1)=tstep
countz(1)=1
STATUS = NF90_INQ_VARID(NCID,trim(time_vname),VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem finding time variable:'
write(*,*) trim(time_vname)
write(*,*) NF90_STRERROR(STATUS)
stop
endif
! STATUS = NF90_GET_VAR(NCID,VID,ttime,startz,countz)
if(readZeta)then
! **** Zeta ****
startz(1)=1
startz(2)=1
startz(3)=tstep
countz(1)=xi_rho(ng)
countz(2)=eta_rho(ng)
countz(3)=1
STATUS = NF90_INQ_VARID(NCID,'zeta',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find zeta'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%zeta(:,:,tind),STARTz,COUNTz)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read zeta array 1'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%zeta= constZeta
endif
if(readSalt)then
! **** Salt ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_rho(ng)
countr(2)=eta_rho(ng)
countr(3)=s_rho(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'salt',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find salt'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%salt(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read salt array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%salt = constSalt
endif
if(readTemp)then
! **** Temp ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_rho(ng)
countr(2)=eta_rho(ng)
countr(3)=s_rho(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'temp',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find temp'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%temp(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read temp array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
do i=1,xi_rho(ng)
do j=1,eta_rho(ng)
do k=1,s_rho(ng)
HYDRODATA(ng)%temp(i,j,k,tind)=HYDRODATA(ng)%temp(i,j,k,tind)+TempOffset
enddo
enddo
enddo
else
HYDRODATA(ng)%temp = constTemp
endif
! call CPU_TIME(before)
if(readU)then
! **** U velocity ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_u(ng)
countr(2)=eta_u(ng)
countr(3)=s_rho(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'u',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find u'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%U(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read u array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%U = constU
endif
if(readV)then
! **** V velocity ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_v(ng)
countr(2)=eta_v(ng)
countr(3)=s_rho(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'v',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find v'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%V(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read v array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%V = constV
endif
! call CPU_TIME(after)
! tdiff=after-before
! write(*,*) '****'
! write(*,*) tdiff
if(WriteBottom)then
! **** U stress ****
startr(1)=1
startr(2)=1
startr(3)=tstep
countr(1)=xi_u(ng)
countr(2)=eta_u(ng)
countr(3)=1
STATUS = NF90_INQ_VARID(NCID,'bustr',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find bustr'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%bustr(:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read bustr array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
! **** v stress ****
startr(1)=1
startr(2)=1
startr(3)=tstep
countr(1)=xi_v(ng)
countr(2)=eta_v(ng)
countr(3)=1
STATUS = NF90_INQ_VARID(NCID,'bvstr',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find bvstr'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%bvstr(:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read bvstr array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%bustr = 0.0
HYDRODATA(ng)%bvstr = 0.0
endif
if(readW)then
! **** W velocity ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_rho(ng)
countr(2)=eta_rho(ng)
countr(3)=s_w(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'w',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find w'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%W(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read w array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%W = constW
endif
if(readAks)then
! **** Vertical diffusivity for salt (Aks) ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_rho(ng)
countr(2)=eta_rho(ng)
countr(3)=s_w(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'AKs',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find AKs'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%AKs(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read AKs array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
else
HYDRODATA(ng)%AKs = constAks
endif
#ifdef WETDRY
startz(1)=1
startz(2)=1
startz(3)=tstep
countz(1)=xi_v(ng)
countz(2)=eta_v(ng)
countz(3)=1
STATUS = NF90_INQ_VARID(NCID,'wetdry_mask_v',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find wetdry_mask_v'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%wetdry_mask_v(:,:,tind),STARTz,COUNTz)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read wetdry_mask_v array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
countz(1)=xi_u(ng)
countz(2)=eta_u(ng)
countz(3)=1
STATUS = NF90_INQ_VARID(NCID,'wetdry_mask_u',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find wetdry_mask_u'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%wetdry_mask_u(:,:,tind),STARTz,COUNTz)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read wetdry_mask_u array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
countz(1)=xi_rho(ng)
countz(2)=eta_rho(ng)
countz(3)=1
STATUS = NF90_INQ_VARID(NCID,'wetdry_mask_rho',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find wetdry_mask_rho'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%wetdry_mask_rho(:,:,tind),STARTz,COUNTz)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read wetdry_mask_rho array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
#endif
! !close the dataset and reassign the NCID
STATUS = NF90_CLOSE(NCID)
#ifdef STOKES
! call CPU_TIME(before)
STATUS = NF90_OPEN(TRIM(stokesfilenm), NF90_NOWRITE, NCID)
if (STATUS .NE. NF90_NOERR) write(*,*) 'Problem NF90_OPEN STOKESFILE'
if (STATUS .NE. NF90_NOERR) write(*,*) NF90_STRERROR(STATUS)
! **** STOKES U velocity ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_u(ng)
countr(2)=eta_u(ng)
countr(3)=s_rho(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'ustokes',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find u'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%SU(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read stokes u array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
do i=1,xi_u(ng)
do j=1,eta_u(ng)
do k=1,s_rho(ng)
HYDRODATA(ng)%U(i,j,k,tind)=HYDRODATA(ng)%U(i,j,k,tind)+HYDRODATA(ng)%SU(i,j,k,tind)
enddo
enddo
enddo
! **** STOKES V velocity ****
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_v(ng)
countr(2)=eta_v(ng)
countr(3)=s_rho(ng)
countr(4)=1
STATUS = NF90_INQ_VARID(NCID,'vstokes',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find v'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%SV(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read stokes v array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_CLOSE(NCID)
! call CPU_TIME(after)
! tdiff=after-before
! write(*,*) '^^^'
! write(*,*) tdiff
do i=1,xi_v(ng)
do j=1,eta_v(ng)
do k=1,s_rho(ng)
HYDRODATA(ng)%V(i,j,k,tind)=HYDRODATA(ng)%V(i,j,k,tind)+HYDRODATA(ng)%SV(i,j,k,tind)
enddo
enddo
enddo
#endif
if ((Behavior.EQ.10) .OR. (Process_VA)) then
! call CPU_TIME(before)
startr(1)=1
startr(2)=1
startr(3)=1
startr(4)=tstep
countr(1)=xi_rho(ng)
countr(2)=eta_rho(ng)
countr(3)=s_w(ng)
countr(4)=1
STATUS = NF90_OPEN(TRIM(turbfilenm), NF90_NOWRITE, NCID)
if (STATUS .NE. NF90_NOERR) write(*,*) 'Problem NF90_OPEN turbfilenm'
if (STATUS .NE. NF90_NOERR) write(*,*) NF90_STRERROR(STATUS)
STATUS = NF90_INQ_VARID(NCID,'vortstd_cmpnt_turb',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find vortstd_cmpnt_turb'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%Vortstd_t(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read vortstd_cmpnt_turb array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_INQ_VARID(NCID,'accelstd_cmpnt_turb',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find accelstd_cmpnt_turb'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%Accelstd_t(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read accelstd_cmpnt_turb array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_CLOSE(NCID)
endif
if (Process_WA) then
STATUS = NF90_OPEN(TRIM(wavefilenm), NF90_NOWRITE, NCID)
if (STATUS .NE. NF90_NOERR) write(*,*) 'Problem NF90_OPEN wavefilenm'
if (STATUS .NE. NF90_NOERR) write(*,*) NF90_STRERROR(STATUS)
STATUS = NF90_INQ_VARID(NCID,'accelstd_u_wave',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find accelstd_u_wave'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%Accelustd_w(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read accelstd_u_waves array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_INQ_VARID(NCID,'accelstd_v_wave',VID)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem find accelstd_v_wave'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_GET_VAR(NCID,VID,HYDRODATA(ng)%Accelvstd_w(:,:,:,tind),STARTr,COUNTr)
if (STATUS .NE. NF90_NOERR) then
write(*,*) 'Problem read accelstd_u_waves array'
write(*,*) NF90_STRERROR(STATUS)
stop
endif
STATUS = NF90_CLOSE(NCID)
endif
enddo
END SUBROUTINE updateHydro
SUBROUTINE finHydro()
!This subroutine closes all the module's allocatable variables
IMPLICIT NONE
DEALLOCATE(HYDRODATA)
END SUBROUTINE finHydro
SUBROUTINE getFileNames(filenm,prefix,filenum)
USE PARAM_MOD, ONLY: numdigits,suffix,multifile
IMPLICIT NONE
INTEGER, INTENT(IN) :: filenum
CHARACTER(len=200), INTENT(INOUT) :: filenm,prefix
if (multifile) then
SELECT CASE(numdigits)
CASE(1)
WRITE(filenm,'(A,I1.1,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(2)
WRITE(filenm,'(A,I2.2,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(3)
WRITE(filenm,'(A,I3.3,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(4)
WRITE(filenm,'(A,I4.4,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(5)
WRITE(filenm,'(A,I5.5,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(6)
WRITE(filenm,'(A,I6.6,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(7)
WRITE(filenm,'(A,I7.7,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE(8)
WRITE(filenm,'(A,I8.8,A)') TRIM(prefix),filenum,TRIM(suffix)
CASE DEFAULT
WRITE(*,*) 'Model presently does not support numdigits of ',numdigits
WRITE(*,*) 'Please use numdigit value from 1 to 8'
WRITE(*,*) ' OR modify code in Hydrodynamic module'
STOP
END SELECT
else
filenm=TRIM(prefix)
endif
END SUBROUTINE
END MODULE HYDRO_MOD