forked from HYCOM/HYCOM-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhycom_couple.F
1451 lines (1135 loc) · 36.4 KB
/
hycom_couple.F
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 hycom_couple
use mod_xc ! HYCOM communication interface
use mod_cb_arrays
implicit none
integer idim_size,jdim_size
integer, dimension(:,:,:), allocatable :: deBList
real, dimension(:,:), allocatable :: lon_e
real, dimension(:,:), allocatable :: lat_e
real, dimension(:,:), allocatable :: mask_e
real, dimension(:,:), allocatable :: lon_q
real, dimension(:,:), allocatable :: lat_q
contains
c===================================================
subroutine hycom_couple_init(nPets,rc)
implicit none
real, allocatable, dimension(:,:) :: tmx
real*4, allocatable, dimension(:,:) :: alon,alat
real*4, allocatable, dimension(:,:) :: qlon,qlat
real, allocatable, dimension(:,:) :: tmp_e
integer i,j,rc
integer nPets
if(mnproc.eq.1) print *,"hycom_couple_init called..."
rc=0
c---------------------
c grid size
idim_size=itdm
jdim_size=jtdm
c-----------------------
c deBlockList
c directly from HYCOM
# ifdef ESPC_COUPLE
IF (.not.allocated(deBList)) THEN
allocate ( deBList(2,2,nPets ) )
END IF
c should be something like the following
c do ij=1,nPets
c deBList(1,1,ij)=1+i0
c deBList(2,1,ij)=1+j0
c deBList(1,2,ij)=ii+i0
c deBList(2,2,ij)=jj+j0
c enddo
do i=1,nPets
deBList(1,1,i)=deBlockList(1,1,i)
deBList(2,1,i)=deBlockList(2,1,i)
deBList(1,2,i)=deBlockList(1,2,i)
deBList(2,2,i)=deBlockList(2,2,i)
enddo
if(mnproc.eq.1) then
print *,'itdm,jtdm=',itdm,jtdm
print *,'hycom,deBList BL11 BL21 BL12 BL22'
do i =1,nPets
write(*,555)i,deBList(1,1,i),deBList(2,1,i),
& deBList(1,2,i),deBList(2,2,i),
& deBList(1,2,i)-deBList(1,1,i)+1,
& deBList(2,2,i)-deBList(2,1,i)+1
enddo
endif
555 format(I4,4I8,3x,2I8)
# endif
c-----------------------
c lat/lon/mask
if(mnproc.eq.1) then
allocate(lon_e(itdm,jtdm))
allocate(lat_e(itdm,jtdm))
allocate(mask_e(itdm,jtdm))
allocate(lon_q(itdm,jtdm))
allocate(lat_q(itdm,jtdm))
else
allocate(lon_e(1,1))
allocate(lat_e(1,1))
allocate(mask_e(1,1))
allocate(lon_q(1,1))
allocate(lat_q(1,1))
endif
allocate(tmp_e(itdm,jtdm))
if(mnproc.eq.1) print *,'readHycomLatLon check0...'
c for plon -> lon_e
c for plat -> lat_e
c get and return lons, lats to all nodes
c vland=-99999.9 !data void marker
allocate(tmx(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy))
c lon
cx lon_e(:,:)=9999.
cx call xcaget(lon_e,plon,1)
call xcaget(tmp_e,plon,1)
if(mnproc.eq.1) lon_e(:,:)=tmp_e(:,:)
if(mnproc.eq.1) then
do j=1,jtdm
do i=1,itdm
if(lon_e(i,j) .ge. 360) then
lon_e(i,j)=lon_e(i,j)-360.
else
lon_e(i,j)=lon_e(i,j)
endif
enddo
enddo
endif
c lat
cx lat_e(:,:)=9999.
cx call xcaget(lat_e,plat,1)
call xcaget(tmp_e,plat,1)
if(mnproc.eq.1) lat_e(:,:)=tmp_e(:,:)
c sea/land mask
tmx(:,:)=0.
do j= 1,jj
do i= 1,ii
tmx(i,j) = ishlf(i,j)
cx tmx(i,j) = ip(i,j)
enddo
enddo
mask_e(:,:)=0.
cx call xcaget(mask_e,tmx,1)
call xcaget(tmp_e,tmx,1)
if(mnproc.eq.1) mask_e(:,:)=tmp_e(:,:)
if(mnproc.eq.1) then
allocate(alon(itdm,jtdm))
allocate(alat(itdm,jtdm))
allocate(qlon(itdm,jtdm))
allocate(qlat(itdm,jtdm))
else
allocate(alon(1,1))
allocate(alat(1,1))
allocate(qlon(1,1))
allocate(qlat(1,1))
endif
if(mnproc.eq.1) then
print *,'readHycomLatLon check...'
c read hycom regional.grid.a
c call readHycomLatLon(alat,alon,itdm,jtdm)
call readHycomLatLon(alat,alon,qlat,qlon,itdm,jtdm)
do j=1,jtdm
do i=1,itdm
if(lon_e(i,j).eq.0 .and. lat_e(i,j).eq.0) then
lon_e(i,j)=alon(i,j)
lat_e(i,j)=alat(i,j)
endif
lon_q(i,j)=qlon(i,j)
lat_q(i,j)=qlat(i,j)
enddo
enddo
endif
c vland=0.0 !restore to default
if(allocated(tmx)) deallocate(tmx)
if(allocated(alon)) deallocate(alon)
if(allocated(alat)) deallocate(alat)
if(allocated(qlon)) deallocate(qlon)
if(allocated(qlat)) deallocate(qlat)
if(allocated(tmp_e)) deallocate(tmp_e)
if(mnproc.eq.1) print *,"hycom_couple_init, end..."
return
end subroutine hycom_couple_init
c===================================================
subroutine set_hycom_import_flag(k,fieldName)
c use ocn_couple_impexp
c use mod_cb_arrays
implicit none
integer k
character(len=30) fieldName
if(mnproc.eq.1) print *,
& "set_hycom_import_flag start...,k,name=",k,fieldName
if(k.eq.1) then
cpl_taux=.false.
cpl_tauy=.false.
cpl_u10=.false.
cpl_v10=.false.
cpl_wndspd=.false.
cpl_ustara=.false.
cpl_airtmp=.false.
cpl_vapmix=.false.
cpl_swflx_net=.false.
cpl_lwflx_net=.false.
cpl_swflx_net2down=.false.
cpl_lwflx_net2down=.false.
cpl_swflxd=.false.
cpl_lwflxd=.false.
cpl_mslprs=.false.
cpl_precip=.false.
cpl_surtmp=.false.
cpl_seatmp=.false.
cpl_sbhflx=.false.
cpl_lthflx=.false.
cpl_sic=.false.
cpl_sitx=.false.
cpl_sity=.false.
cpl_siqs=.false.
cpl_sifh=.false.
cpl_sifs=.false.
cpl_sifw=.false.
cpl_sit=.false.
cpl_sih=.false.
cpl_siu=.false.
cpl_siv=.false.
endif
if(fieldName .eq. 'taux10' ) then
cpl_taux=.true.
else if(fieldName .eq. 'tauy10' ) then
cpl_tauy=.true.
if (.not.cpl_taux) then
if(mnproc.eq.1) print *,"error - tauy before taux"
call xcstop('(set_hycom_import_flag)')
stop '(set_hycom_import_flag)'
endif !error
else if(fieldName .eq. 'u10' ) then
cpl_u10=.true.
else if(fieldName .eq. 'v10' ) then
cpl_v10=.true.
if (.not.cpl_u10) then
if(mnproc.eq.1) print *,"error - v10 before u10"
call xcstop('(set_hycom_import_flag)')
stop '(set_hycom_import_flag)'
endif !error
else if(fieldName .eq. 'wndspd10' ) then
cpl_wndspd=.true.
else if(fieldName .eq. 'ustara10' ) then
cpl_ustara=.true.
else if(fieldName .eq. 'airtmp' ) then
cpl_airtmp=.true.
elseif(fieldName .eq. 'airhum' ) then
cpl_vapmix=.true.
else if(fieldName .eq. 'swflx_net' ) then
cpl_swflx_net=.true.
else if(fieldName .eq. 'lwflx_net' ) then
cpl_lwflx_net=.true.
else if(fieldName .eq. 'swflx_net2down' ) then
cpl_swflx_net2down=.true.
else if(fieldName .eq. 'lwflx_net2down' ) then
cpl_lwflx_net2down=.true.
else if(fieldName .eq. 'swflxd' ) then
cpl_swflxd=.true.
else if(fieldName .eq. 'lwflxd' ) then
cpl_lwflxd=.true.
else if(fieldName .eq. 'mslprs' ) then
cpl_mslprs=.true.
else if(fieldName .eq. 'prcp' ) then
cpl_precip=.true.
else if(fieldName .eq. 'gt' ) then
cpl_surtmp=.true.
cpl_seatmp=.true.
else if(fieldName .eq. 'sbhflx' ) then
cpl_sbhflx=.true.
else if(fieldName .eq. 'lthflx' ) then
cpl_lthflx=.true.
else if(fieldName .eq. 'sic' ) then
c import ice concentration
cpl_sic=.true.
else if(fieldName .eq. 'sitx' ) then
c import ice x-stress
cpl_sitx=.true.
else if(fieldName .eq. 'sity' ) then
c import ice y-stress
cpl_sity=.true.
else if(fieldName .eq. 'siqs' ) then
c import solar thru grid cell ave.
cpl_siqs=.true.
else if(fieldName .eq. 'sifh' ) then
c import freeze, melt, H. Flux
cpl_sifh=.true.
else if(fieldName .eq. 'sifs' ) then
c import salt flux
cpl_sifs=.true.
else if(fieldName .eq. 'sifw' ) then
c import water flux
cpl_sifw=.true.
else if(fieldName .eq. 'sit_sfc' ) then
c import sea ice temperature
cpl_sit=.true.
else if(fieldName .eq. 'sih' ) then
c import sea ice thickness
cpl_sih=.true.
else if(fieldName .eq. 'siu' ) then
c import sea ice x-velocity
cpl_siu=.true.
else if(fieldName .eq. 'siv' ) then
c import sea ice y-velocity
cpl_siv=.true.
endif !if fieldName
if(mnproc.eq.1) print *,"import_hycom end..."
return
end subroutine set_hycom_import_flag
c====================================================
subroutine export_from_hycom_deb(tlb,tub,expData,
& fieldName,show_minmax)
c use mod_xc ! HYCOM communication interface
c use mod_cb_arrays
implicit none
c
c integer k
c real mgrid(ii,jj)
integer tlb(2),tub(2)
real expData(tlb(1):tub(1),tlb(2):tub(2))
character(len=30) fieldName
real, allocatable, dimension(:,:) :: ocn_msk
real, allocatable, dimension(:,:) :: field_tmp
real, allocatable, dimension(:,:) :: tmx
integer i,j,jja
logical show_minmax
! (1+i0,ii+i0) could be the subset of (tlb(1),tub(1))
! (1+j0,jja+j0) == (tlb(2),tub(2))
c
if(mnproc.eq.1) print *,"export_from_hycom_deb start..."
c print *,"idm,jdm,nbdy,ii,jj=",mnproc,idm,jdm,nbdy,ii,jj
call export_from_hycom_tiled(util2,fieldName) !can't use util1
#if defined(ARCTIC)
c --- Arctic (tripole) domain, top row is replicated (ignore it)
jja = min( jj, jtdm-1-j0 )
#else
jja = jj
#endif
if(fieldName .eq. 'sst' ) then
do j=1,jj
do i= 1,ii
#ifndef ESPC_NOCANONICAL_CONVERT
c canonical unit conversion: sst (C) -> (K)
util2(i,j) = util2(i,j)+273.15d0
#endif
enddo
enddo
endif
expData(:,:)=0.
do j=1,jja
do i=1,ii
c mgrid(i,j)=util2(i,j)
expData(i+i0,j+j0)=util2(i,j)
enddo
enddo
if(show_minmax) then
if(mnproc.eq.1) then
allocate(ocn_msk(itdm,jtdm))
allocate(field_tmp(itdm,jtdm))
else
allocate(ocn_msk(1,1))
allocate(field_tmp(1,1))
endif
allocate(tmx(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy))
c sea/land mask
tmx(:,:)=0.
do j= 1,jja
do i= 1,ii
tmx(i,j) = ishlf(i,j)
cx tmx(i,j) = ip(i,j)
enddo
enddo
call xcaget(ocn_msk,tmx,1)
c call xcsync(no_flush)
tmx(:,:)=0.
do j= 1,jja
do i= 1,ii
tmx(i,j) = expData(i+i0,j+j0)
enddo
enddo
call xcaget(field_tmp,tmx,1)
c call xcsync(no_flush)
if(mnproc.eq.1) then
write(*,992)trim(fieldName),
& maxval(field_tmp,MASK=ocn_msk.eq.1 ),
& minval(field_tmp,MASK=ocn_msk.eq.1 ),
& sum(field_tmp,MASK=ocn_msk.eq.1 )/
& count(ocn_msk.eq.1 )
992 format('export_from_hycom_deb,max,min,mean=',A10,3E23.15)
c write(*,992) trim(fieldName),maxval(mgrid),minval(mgrid)
c 992 format('export_from_hycom,max,min=',A10,2E12.4)
print *,"export_from_hycom_deb end..."
endif
c test check pang
call xcaget(ocn_msk,pang,1)
if(mnproc.eq.1) then
print *,'export_from_hycom pang, min,max=',
& minval(ocn_msk),maxval(ocn_msk)
endif
if(allocated(ocn_msk)) deallocate(ocn_msk)
if(allocated(field_tmp)) deallocate(field_tmp)
if(allocated(tmx)) deallocate(tmx)
endif
if(mnproc.eq.1) print *,"export_from_hycom_deb end..."
return
end subroutine export_from_hycom_deb
c==================================================
subroutine import_to_hycom_deb(tlb,tub,impData,
& fieldName,show_minmax,data_init_flag)
c use mod_xc ! HYCOM communication interface
c use ocn_couple_impexp
c use mod_cb_arrays
implicit none
c include 'common_blocks.h'
c
character(len=30) fieldName
c integer k
integer tlb(2),tub(2)
real impData(tlb(1):tub(1),tlb(2):tub(2))
c
integer i,j,mcnt
real uij,vij
real, allocatable, dimension(:,:) :: ocn_msk
real, allocatable, dimension(:,:) :: field_tmp
real, allocatable, dimension(:,:) :: tmx
real, parameter :: sstmin = -1.8
real, parameter :: sstmax = 35.0
integer ierr
logical show_minmax
integer jja
real albw,degtorad
logical data_init_flag
! (1+i0,ii+i0) could be the subset of (tlb(1),tub(1))
! (1+j0,jja+j0) == (tlb(2),tub(2))
c if(mnproc.eq.1) print *,"import_to_hycom_deb start...,k,name=",k,
c & fieldName
c if(k.eq.1 .and. mnproc.eq.1) print *,"w0,w1..=",
c & w0,w1,w2,w3
#if defined(ARCTIC)
c --- Arctic (tripole) domain, top row is replicated (ignore it)
jja = min( jj, jtdm-1-j0 )
#else
jja = jj
#endif
if(show_minmax) then
cjc-01262014
if(mnproc.eq.1) then
allocate(ocn_msk(itdm,jtdm))
allocate(field_tmp(itdm,jtdm))
else
allocate(ocn_msk(1,1))
allocate(field_tmp(1,1))
endif
allocate(tmx(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy))
c sea/land mask
tmx(:,:)=0.
do j= 1,jja
do i= 1,ii
tmx(i,j) = ishlf(i,j)
cx tmx(i,j) = ip(i,j)
enddo
enddo
call xcaget(ocn_msk,tmx,1)
c call xcsync(no_flush)
tmx(:,:)=0.
do j= 1,jja
do i= 1,ii
! tmx(i,j) = mgrid(i,j)
tmx(i,j) = impData(i+i0,j+j0)
enddo
enddo
call xcaget(field_tmp,tmx,1)
c call mpi_barrier(mpi_comm_hycom,ierr)
c call xcsync(no_flush)
if(mnproc.eq.1) then
write(*,992)trim(fieldName),
& maxval(field_tmp,MASK=ocn_msk.eq.1 ),
& minval(field_tmp,MASK=ocn_msk.eq.1 ),
& sum(field_tmp,MASK=ocn_msk.eq.1 )/
& count(ocn_msk.eq.1 )
c 992 format('import_to_hycom_deb,max,min,mean=',A10,3E12.4)
992 format('import_to_hycom_deb,max,min,mean=',A10,3E23.15)
endif
if(allocated(ocn_msk)) deallocate(ocn_msk)
if(allocated(field_tmp)) deallocate(field_tmp)
if(allocated(tmx)) deallocate(tmx)
endif
c==> import from atm
c=================================================
if(fieldName .eq. 'taux10' ) then
c import xstress: Pa
do j=1,jja
do i=1,ii
! taux(i,j,l0)=mgrid(i,j)
if(ishlf(i,j).eq.1) then
taux(i,j,l0)=impData(i+i0,j+j0)
else
taux(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila(taux(1-nbdy,1-nbdy,l0),1,1, halo_pv)
#endif
call xctilr(taux(1-nbdy,1-nbdy,l0),1,1, nbdy,nbdy, halo_pv)
c---
c=================================================
else if(fieldName .eq. 'tauy10' ) then
c import ystress: Pa
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
tauy(i,j,l0)=impData(i+i0,j+j0)
else
tauy(i,j,l0)=0.
endif
enddo
enddo
do j=1,jja
do i=1,ii
uij = taux(i,j,l0)
vij = tauy(i,j,l0)
c rotate to (x,y)ward
taux(i,j,l0)=cos(pang(i,j))*uij + sin(pang(i,j))*vij
tauy(i,j,l0)=cos(pang(i,j))*vij - sin(pang(i,j))*uij
enddo !i
enddo !j
#if defined(ARCTIC)
call xctila(taux(1-nbdy,1-nbdy,l0),1,1, halo_pv)
call xctila(tauy(1-nbdy,1-nbdy,l0),1,1, halo_pv)
#endif
call xctilr(taux(1-nbdy,1-nbdy,l0),1,1, nbdy,nbdy, halo_pv)
call xctilr(tauy(1-nbdy,1-nbdy,l0),1,1, nbdy,nbdy, halo_pv)
c---
c=================================================
else if(fieldName .eq. 'u10' ) then
c import u wind at 10m height: ms-1
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
taux(i,j,l0)=impData(i+i0,j+j0)
else
taux(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila(taux(1-nbdy,1-nbdy,l0),1,1, halo_pv)
#endif
call xctilr(taux(1-nbdy,1-nbdy,l0),1,1, nbdy,nbdy, halo_pv)
c---
c=================================================
else if(fieldName .eq. 'v10' ) then
c import v wind at 10m height: ms-1
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
tauy(i,j,l0)=impData(i+i0,j+j0)
else
tauy(i,j,l0)=0.
endif
enddo
enddo
do j=1,jja
do i=1,ii
uij = taux(i,j,l0)
vij = tauy(i,j,l0)
c rotate to (x,y)ward
taux(i,j,l0)=cos(pang(i,j))*uij + sin(pang(i,j))*vij
tauy(i,j,l0)=cos(pang(i,j))*vij - sin(pang(i,j))*uij
enddo !i
enddo !j
#if defined(ARCTIC)
call xctila(taux(1-nbdy,1-nbdy,l0),1,1, halo_pv)
call xctila(tauy(1-nbdy,1-nbdy,l0),1,1, halo_pv)
#endif
call xctilr(taux(1-nbdy,1-nbdy,l0),1,1, nbdy,nbdy, halo_pv)
call xctilr(tauy(1-nbdy,1-nbdy,l0),1,1, nbdy,nbdy, halo_pv)
c---
c=================================================
else if(fieldName .eq. 'wndspd10' ) then
c import wind speed: m s-1
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
wndspd(i,j,l0)=impData(i+i0,j+j0)
else
wndspd(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( wndspd(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'ustara10' ) then
c import friction speed: m s-1
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
ustara(i,j,l0)=impData(i+i0,j+j0)
else
ustara(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( ustara(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'airtmp' ) then
c cpl_airtmp=.true.
c import air temperature
c canonical unit conversion: airtmp (K) -> (C)
do j=1,jja
do i=1,ii
impData(i+i0,j+j0)=impData(i+i0,j+j0)-273.15
enddo
enddo
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
airtmp(i,j,l0)=impData(i+i0,j+j0)
else
airtmp(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( airtmp(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
elseif(fieldName .eq. 'airhum' ) then
c import specific humidity: kg kg-1
c convert from specific humidity to mixing ratio
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
!!Alex flxflg.eq.4 => mixing ratio
vapmix(i,j,l0)=impData(i+i0,j+j0)/(1.-impData(i+i0,j+j0))
!!Alex flxflg.eq.5 => specific humidity
if (flxflg.eq.5) vapmix(i,j,l0)=impData(i+i0,j+j0)
else
vapmix(i,j,l0)=0.01
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( vapmix(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'swflx_net' ) then
c import sw flux: w m-2
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
swflx(i,j,l0)=impData(i+i0,j+j0)
else
swflx(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( swflx(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'swflx_net2down'
& .or. fieldName .eq. 'swflxd' ) then
c import downward sw flux: w m-2
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
swflx(i,j,l0)=impData(i+i0,j+j0)
else
swflx(i,j,l0)=0.
endif
enddo
enddo
if (albflg.ne.0) then !swflx is Qswdn
c --- use the same method as on forfun.F
c --- convert swflx to net shortwave into the ocean
c --- shortwave through sea ice is handled separately
if (albflg.eq.1) then
do j=1,jja
do i=1,ii
c if(ishlf(i,j).eq.1) then
swflx(i,j,l0) = swflx(i,j,l0)*(1.0-0.09) !NAVGEM albedo
c else
c swflx(i,j,l0) = 0.
c endif
enddo
enddo
else !albflg.eq.2
degtorad = 4.d0*atan(1.d0)/180.d0
do j=1,jja
do i=1,ii
c --- latitudinally-varying ocean albedo (Large and Yeager, 2009)
c --- 5.8% at the equator and 8% at the poles
albw = ( 0.069 - 0.011*cos(2.0*degtorad*plat(i,j) ) )
c if(ishlf(i,j).eq.1) then
swflx(i,j,l0) = swflx(i,j,l0)*(1.0-albw)
c else
c swflx(i,j,l0) = 0.
c endif
enddo
enddo
endif !albflg
endif
#if defined(ARCTIC)
call xctila( swflx(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'lwflx_net' ) then
c import lw flux: w m-2
c canonical unit conversion: lwflx_net (upward) -> (downward)
do j=1,jja
do i=1,ii
impData(i+i0,j+j0)=impData(i+i0,j+j0)*(-1.)
enddo
enddo
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
radflx(i,j,l0)=impData(i+i0,j+j0)
else
radflx(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( radflx(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'lwflx_net2down'
& .or. fieldName .eq. 'lwflxd' ) then
c import downward lw flux: w m-2
c +ve into ocean
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
radflx(i,j,l0)=impData(i+i0,j+j0)
else
radflx(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( radflx(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'prcp' ) then
c import precip: m s-1
c canonical unit conversion: prcp (kg_m-2_s-1)-> m_s-1
do j=1,jja
do i=1,ii
impData(i+i0,j+j0)=impData(i+i0,j+j0)*(0.001)
enddo
enddo
do j=1,jja
do i=1,ii
if(ishlf(i,j).eq.1) then
precip(i,j,l0)=impData(i+i0,j+j0)
else
precip(i,j,l0)=0.
endif
enddo
enddo
#if defined(ARCTIC)
call xctila( precip(1-nbdy,1-nbdy,l0),1,1,halo_ps)
#endif
c---
c=================================================
else if(fieldName .eq. 'gt' ) then
c canonical unit conversion: gt (K) -> (C)
do j=1,jja
do i=1,ii
impData(i+i0,j+j0)=impData(i+i0,j+j0)-273.15
enddo
enddo