Skip to content

Commit e25e529

Browse files
authored
Merge pull request #33 from SmithJos13/feature_sch2cice
added import states from CICE to schism cap
2 parents 771a954 + 65d1b38 commit e25e529

File tree

1 file changed

+261
-8
lines changed

1 file changed

+261
-8
lines changed

src/schism/schism_nuopc_cap.F90

+261-8
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,81 @@ subroutine InitializeAdvertise(comp, importState, exportState, clock, rc)
384384
call NUOPC_FieldDictionaryAddIfNeeded("ocean_mask", "1", localrc)
385385
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
386386

387+
388+
!>---------------------------------------------------------------------------------
389+
!> Adding CICE fields to ufs_fd
390+
!>---------------------------------------------------------------------------------
391+
392+
call NUOPC_FieldDictionaryAddIfNeeded("Si_uvel", "m s-1", localrc)
393+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
394+
395+
call NUOPC_FieldDictionaryAddIfNeeded("Si_vvel", "m s-1", localrc)
396+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
397+
398+
call NUOPC_FieldDictionaryAddIfNeeded("Fioi_taux", "N m-2", localrc)
399+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
400+
401+
call NUOPC_FieldDictionaryAddIfNeeded("Fioi_tauy", "N m-2", localrc)
402+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
403+
404+
call NUOPC_FieldDictionaryAddIfNeeded("Si_vsno", "m3", localrc)
405+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
406+
407+
call NUOPC_FieldDictionaryAddIfNeeded("Si_vice", "m3", localrc)
408+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
409+
410+
call NUOPC_FieldDictionaryAddIfNeeded("Fioi_meltw", "kg m-1", localrc)
411+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
412+
413+
call NUOPC_FieldDictionaryAddIfNeeded("Fioi_salt", "kg m-1", localrc)
414+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
415+
416+
call NUOPC_FieldDictionaryAddIfNeeded("Fioi_melth", "W m-2", localrc)
417+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
418+
419+
call NUOPC_FieldDictionaryAddIfNeeded("Fioi_swpen", "W m-2", localrc)
420+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
421+
422+
!>---------------------------------------------------------------------------------
423+
!>---------------------------------------------------------------------------------
424+
425+
426+
!>---------------------------------------------------------------------------------
427+
!> Adertizing CICE states
428+
!>---------------------------------------------------------------------------------
429+
call NUOPC_Advertise(importState, "sea_surface_height_above_sea_level", rc=localrc)
430+
!> ice-vel xy-dir -----------------------------------------------------------------
431+
call NUOPC_Advertise(importState, "Si_uvel", rc=localrc)
432+
call NUOPC_Advertise(importState, "Si_vvel", rc=localrc)
433+
434+
!> ice-to-ocn stress xy-dir -------------------------------------------------------
435+
call NUOPC_Advertise(importState, "Fioi_taux", rc=localrc)
436+
call NUOPC_Advertise(importState, "Fioi_tauy", rc=localrc)
437+
438+
!> Volume_of_snow -----------------------------------------------------------------
439+
call NUOPC_Advertise(importState, "Si_vsno", rc=localrc)
440+
441+
!> Volume_of_ice ------------------------------------------------------------------
442+
call NUOPC_Advertise(importState, "Si_vice", rc=localrc)
443+
444+
!> ice_fraction -------------------------------------------------------------------
445+
call NUOPC_Advertise(importState, "Si_ifrac", rc=localrc)
446+
447+
!> Melt_water_flux ----------------------------------------------------------------
448+
call NUOPC_Advertise(importState, "Fioi_meltw", rc=localrc)
449+
450+
!> Salinity_flux -----------------------------------------------------------------
451+
call NUOPC_Advertise(importState, "Fioi_salt", rc=localrc)
452+
453+
!> Heat_flux_ice_to_ocn -----------------------------------------------------------
454+
call NUOPC_Advertise(importState, "Fioi_melth", rc=localrc)
455+
456+
!> Pen_shortwave_rad_through_ice --------------------------------------------------
457+
call NUOPC_Advertise(importState, "Fioi_swpen", rc=localrc)
458+
459+
!>---------------------------------------------------------------------------------
460+
!>---------------------------------------------------------------------------------
461+
387462
! for coupling to ATM/DATM
388463
call NUOPC_Advertise(importState, "air_pressure_at_sea_level", rc=localrc)
389464
call NUOPC_Advertise(importState, "inst_zonal_wind_height10m", rc=localrc)
@@ -508,12 +583,6 @@ subroutine InitializeRealize(comp, importState, exportState, clock, rc)
508583
rc = ESMF_SUCCESS
509584
localrc= ESMF_SUCCESS
510585

511-
!<<<<<<< HEAD
512-
!=======
513-
!> @todo move addSchismMesh back to schism_esmf_util to share with ESMF cap
514-
!> call addSchismMesh(comp, ownedNodes=ownedNodes, foreignNodes=foreignNodes, rc=localrc)
515-
!call addSchismMesh(comp, localrc)
516-
!>>>>>>> a9a0ce0 (Use MeshCreate instead off add Mesh)
517586
if (meshloc == ESMF_MESHLOC_NODE) then
518587
call SCHISM_MeshCreateNode(comp, rc=localrc)
519588
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
@@ -617,6 +686,65 @@ subroutine InitializeRealize(comp, importState, exportState, clock, rc)
617686
name="inst_prec_rate", field=field, rc=localrc)
618687
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
619688

689+
!>------------------------------------------------------------
690+
!> Adding CICE vars to import state
691+
!>------------------------------------------------------------
692+
693+
!> Ice_velocity ----------------------------------------------
694+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
695+
name="Si_uvel", field=field, rc=localrc)
696+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
697+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
698+
name="Si_vvel", field=field, rc=localrc)
699+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
700+
701+
!> Ice_to_ocean_stress ---------------------------------------
702+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
703+
name="Fioi_taux", field=field, rc=localrc)
704+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
705+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
706+
name="Fioi_tauy", field=field, rc=localrc)
707+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
708+
709+
!> Volume of snow --------------------------------------------
710+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
711+
name="Si_vsno", field=field, rc=localrc)
712+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
713+
714+
!> Volume of ice ---------------------------------------------
715+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
716+
name="Si_vice", field=field, rc=localrc)
717+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
718+
719+
!> ---- ice_fraction -----------------------------------------
720+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
721+
name="Si_ifrac", field=field, rc=localrc)
722+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
723+
724+
!> Melt_water_flux -------------------------------------------
725+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
726+
name="Fioi_meltw", field=field, rc=localrc)
727+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
728+
729+
!> Salinity_flux ---------------------------------------------
730+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
731+
name="Fioi_salt", field=field, rc=localrc)
732+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
733+
734+
!> Heat_flux_ice_to_ocn --------------------------------------
735+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
736+
name="Fioi_melth", field=field, rc=localrc)
737+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
738+
739+
!> Pen_shortwave_rad_through_ice -----------------------------
740+
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
741+
name="Fioi_swpen", field=field, rc=localrc)
742+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
743+
744+
!>------------------------------------------------------------
745+
!>------------------------------------------------------------
746+
747+
620748
!> Wave parameters, for now we only have those from the WW3DATA cap in
621749
!> NOAA's CoastalApp.
622750
call SCHISM_StateFieldCreateRealize(comp, state=importState, &
@@ -1073,7 +1201,7 @@ end subroutine SCHISM_Export
10731201
#define ESMF_METHOD "SCHISM_Import"
10741202
subroutine SCHISM_Import(comp, importState, clock, rc)
10751203

1076-
use schism_glbl , only: RADFLAG, windx2, windy2, pr2
1204+
use schism_glbl , only: RADFLAG, windx2, windy2, pr2, npa
10771205
use schism_glbl , only: airt2,shum2,srad,hradd,fluxprc
10781206
use schism_esmf_util, only: SCHISM_StateImportWaveTensor
10791207
use schism_esmf_util, only: SCHISM_StateImportWave3dVortex
@@ -1086,7 +1214,23 @@ subroutine SCHISM_Import(comp, importState, clock, rc)
10861214
type(ESMF_State) , intent(inout) :: importState
10871215
type(ESMF_Clock) , intent(in) :: clock
10881216
integer , intent(inout) :: rc
1089-
1217+
!>---------------------------------------------------
1218+
! Creating vars to dump cice fields to
1219+
!>---------------------------------------------------
1220+
real(ESMF_KIND_R8), allocatable, save, target :: uvice(:)
1221+
real(ESMF_KIND_R8), allocatable, save, target :: vvice(:)
1222+
real(ESMF_KIND_R8), allocatable, save, target :: taux(:)
1223+
real(ESMF_KIND_R8), allocatable, save, target :: tauy(:)
1224+
real(ESMF_KIND_R8), allocatable, save, target :: vsno(:)
1225+
real(ESMF_KIND_R8), allocatable, save, target :: vice(:)
1226+
real(ESMF_KIND_R8), allocatable, save, target :: aice(:)
1227+
real(ESMF_KIND_R8), allocatable, save, target :: ifresh_flux(:)
1228+
real(ESMF_KIND_R8), allocatable, save, target :: isalt_flux(:)
1229+
real(ESMF_KIND_R8), allocatable, save, target :: iheat_flux(:)
1230+
real(ESMF_KIND_R8), allocatable, save, target :: isw_pen(:)
1231+
!>---------------------------------------------------
1232+
!>---------------------------------------------------
1233+
10901234
!> Local variables
10911235
type(ESMF_Time) :: currTime
10921236
type(type_InternalStateWrapper) :: internalState
@@ -1158,6 +1302,115 @@ subroutine SCHISM_Import(comp, importState, clock, rc)
11581302
call SCHISM_StateUpdate(importState, 'inst_prec_rate', fluxprc, &
11591303
isPtr=isDataPtr, rc=localrc)
11601304
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1305+
1306+
!>-------------------------------------------------------
1307+
!> Allocated vars to dump import to
1308+
!>-------------------------------------------------------
1309+
1310+
if (.not. allocated(uvice)) then
1311+
allocate(uvice(npa))
1312+
uvice(:) =0.0d0
1313+
end if
1314+
if (.not. allocated(vvice)) then
1315+
allocate(vvice(npa))
1316+
vvice(:) =0.0d0
1317+
end if
1318+
if (.not. allocated(taux)) then
1319+
allocate(taux(npa))
1320+
taux(:) =0.0d0
1321+
end if
1322+
if (.not. allocated(tauy)) then
1323+
allocate(tauy(npa))
1324+
tauy(:) =0.0d0
1325+
end if
1326+
if (.not. allocated(vsno)) then
1327+
allocate(vsno(npa))
1328+
vsno(:) =0.0d0
1329+
end if
1330+
if (.not. allocated(vice)) then
1331+
allocate(vice(npa))
1332+
vice(:) =0.0d0
1333+
end if
1334+
if (.not. allocated(aice)) then
1335+
allocate(aice(npa))
1336+
aice(:) =0.0d0
1337+
end if
1338+
if (.not. allocated(ifresh_flux)) then
1339+
allocate(ifresh_flux(npa))
1340+
ifresh_flux(:) =0.0d0
1341+
end if
1342+
if (.not. allocated(isalt_flux)) then
1343+
allocate(isalt_flux(npa))
1344+
isalt_flux(:) =0.0d0
1345+
end if
1346+
if (.not. allocated(iheat_flux)) then
1347+
allocate(iheat_flux(npa))
1348+
iheat_flux(:) =0.0d0
1349+
end if
1350+
if (.not. allocated(isw_pen)) then
1351+
allocate(isw_pen(npa))
1352+
isw_pen(:) =0.0d0
1353+
end if
1354+
1355+
!>-------------------------------------------------------
1356+
!>-------------------------------------------------------
1357+
1358+
!>-------------------------------------------------------
1359+
!> Importing CICE vars into schism
1360+
!>-------------------------------------------------------
1361+
!> u-direction ------------------------------------------
1362+
call SCHISM_StateUpdate(importState, 'Si_uvel', uvice, &
1363+
isPtr=isDataPtr, rc=localrc)
1364+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1365+
!> v-direction ------------------------------------------
1366+
call SCHISM_StateUpdate(importState, 'Si_vvel', vvice, &
1367+
isPtr=isDataPtr, rc=localrc)
1368+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1369+
!> ice-stress x-direction -------------------------------
1370+
call SCHISM_StateUpdate(importState, 'Fioi_taux', taux, &
1371+
isPtr=isDataPtr, rc=localrc)
1372+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1373+
!> ice-stress x-direction -------------------------------
1374+
call SCHISM_StateUpdate(importState, 'Fioi_tauy', tauy, &
1375+
isPtr=isDataPtr, rc=localrc)
1376+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1377+
!> Volume of snow ---------------------------------------
1378+
call SCHISM_StateUpdate(importState, 'Si_vsno', vsno, &
1379+
isPtr=isDataPtr, rc=localrc)
1380+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1381+
1382+
!> Volume of ice ----------------------------------------
1383+
call SCHISM_StateUpdate(importState, 'Si_vice', vice, &
1384+
isPtr=isDataPtr, rc=localrc)
1385+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1386+
1387+
!> ice_fraction -----------------------------------------
1388+
call SCHISM_StateUpdate(importState, 'Si_ifrac', aice, &
1389+
isPtr=isDataPtr, rc=localrc)
1390+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1391+
1392+
!> Melt_water_flux --------------------------------------
1393+
call SCHISM_StateUpdate(importState, 'Fioi_meltw', ifresh_flux, &
1394+
isPtr=isDataPtr, rc=localrc)
1395+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1396+
1397+
!> Melt_water_flux --------------------------------------
1398+
call SCHISM_StateUpdate(importState, 'Fioi_salt', isalt_flux, &
1399+
isPtr=isDataPtr, rc=localrc)
1400+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1401+
1402+
!> Heat_flux_ice_to_ocn ---------------------------------
1403+
call SCHISM_StateUpdate(importState, 'Fioi_melth', iheat_flux, &
1404+
isPtr=isDataPtr, rc=localrc)
1405+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1406+
1407+
!> Heat_flux_ice_to_ocn --------------------------------
1408+
call SCHISM_StateUpdate(importState, 'Fioi_swpen', isw_pen, &
1409+
isPtr=isDataPtr, rc=localrc)
1410+
_SCHISM_LOG_AND_FINALIZE_ON_ERROR_(rc)
1411+
1412+
!>-------------------------------------------------------
1413+
!>-------------------------------------------------------
11611414

11621415
!> Write fields on import state for debugging
11631416
if (debug_level > 0) then

0 commit comments

Comments
 (0)