LCOV - code coverage report
Current view: top level - cicecore/cicedyn/analysis - ice_history_drag.F90 (source / functions) Hit Total Coverage
Test: 231018-211459:8916b9ff2c:1:quick Lines: 29 95 30.53 %
Date: 2023-10-18 15:30:36 Functions: 2 2 100.00 %

          Line data    Source code
       1             : !=======================================================================
       2             : 
       3             : ! 2013 module for form drag parameters
       4             : ! authors Michel Tsamados, David Schroeder, CPOM
       5             : 
       6             :       module ice_history_drag
       7             : 
       8             :       use ice_kinds_mod
       9             :       use ice_domain_size, only: max_nstrm
      10             :       use ice_constants, only: c0, c1
      11             :       use ice_fileunits, only: nu_nml, nml_filename, &
      12             :           get_fileunit, release_fileunit, nu_diag
      13             :       use ice_exit, only: abort_ice
      14             :       use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted, &
      15             :           icepack_query_parameters
      16             : 
      17             :       implicit none
      18             :       private
      19             :       public :: accum_hist_drag, init_hist_drag_2D
      20             : 
      21             :       !---------------------------------------------------------------
      22             :       ! flags: write to output file if true or histfreq value
      23             :       !---------------------------------------------------------------
      24             : 
      25             :       character (len=max_nstrm), public :: &
      26             :            f_Cdn_atm   = 'x', f_Cdn_ocn     = 'x' , &   ! LCOV_EXCL_LINE
      27             :            f_drag      = 'x'
      28             : 
      29             :       !---------------------------------------------------------------
      30             :       ! namelist variables
      31             :       !---------------------------------------------------------------
      32             : 
      33             :       namelist / icefields_drag_nml /     &
      34             :            f_Cdn_atm,        f_Cdn_ocn       , &   ! LCOV_EXCL_LINE
      35             :            f_drag
      36             : 
      37             :       !---------------------------------------------------------------
      38             :       ! field indices
      39             :       !---------------------------------------------------------------
      40             : 
      41             :       integer (kind=int_kind), dimension(max_nstrm) :: &
      42             :            n_hfreebd        , n_hdraft,   &   ! LCOV_EXCL_LINE
      43             :            n_hridge         , n_distrdg,  &   ! LCOV_EXCL_LINE
      44             :            n_hkeel          , n_dkeel,  &   ! LCOV_EXCL_LINE
      45             :            n_lfloe          , n_dfloe,  &   ! LCOV_EXCL_LINE
      46             :            n_Cdn_atm        , n_Cdn_ocn,   &   ! LCOV_EXCL_LINE
      47             :            n_Cdn_atm_skin   , n_Cdn_atm_floe,  &   ! LCOV_EXCL_LINE
      48             :            n_Cdn_atm_pond   , n_Cdn_atm_rdg,  &   ! LCOV_EXCL_LINE
      49             :            n_Cdn_ocn_skin   , n_Cdn_ocn_floe,   &   ! LCOV_EXCL_LINE
      50             :            n_Cdn_ocn_keel   , n_Cdn_atm_ratio
      51             : 
      52             : !=======================================================================
      53             : 
      54             :       contains
      55             : 
      56             : !=======================================================================
      57             : 
      58             : ! Initialize history files
      59             : ! authors Elizabeth C. Hunke, LANL
      60             : 
      61          37 :       subroutine init_hist_drag_2D
      62             : 
      63             :       use ice_broadcast, only: broadcast_scalar
      64             :       use ice_calendar, only: nstreams
      65             :       use ice_communicate, only: my_task, master_task
      66             :       use ice_history_shared, only: tstr2D, tcstr, define_hist_field
      67             :       use ice_fileunits, only: goto_nml
      68             : 
      69             :       integer (kind=int_kind) :: ns
      70             :       integer (kind=int_kind) :: nml_error ! namelist i/o error flag
      71             :       logical (kind=log_kind) :: formdrag
      72             :       character(len=char_len_long) :: tmpstr2 ! for namelist check
      73             :       character(len=char_len)      :: nml_name ! for namelist check
      74             : 
      75             :       character(len=*), parameter :: subname = '(init_hist_drag_2D)'
      76             : 
      77          37 :       call icepack_query_parameters(formdrag_out=formdrag)
      78          37 :       call icepack_warnings_flush(nu_diag)
      79          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
      80           0 :          file=__FILE__, line=__LINE__)
      81             : 
      82             :       !-----------------------------------------------------------------
      83             :       ! read namelist
      84             :       !-----------------------------------------------------------------
      85             : 
      86          37 :       if (my_task == master_task) then
      87           7 :          nml_name = 'icefields_drag_nml'
      88           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
      89             : 
      90             :          ! open namelist file
      91           7 :          call get_fileunit(nu_nml)
      92           7 :          open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
      93           7 :          if (nml_error /= 0) then
      94             :             call abort_ice(subname//'ERROR: '//trim(nml_name)//' open file '// &
      95             :                trim(nml_filename), &   ! LCOV_EXCL_LINE
      96           0 :                file=__FILE__, line=__LINE__)
      97             :          endif
      98             : 
      99             :          ! go to this namelist
     100           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     101           7 :          if (nml_error /= 0) then
     102             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     103           0 :                file=__FILE__, line=__LINE__)
     104             :          endif
     105             : 
     106             :          ! read namelist
     107           7 :          nml_error =  1
     108          14 :          do while (nml_error > 0)
     109           7 :             read(nu_nml, nml=icefields_drag_nml,iostat=nml_error)
     110             :             ! check if error
     111           7 :             if (nml_error /= 0) then
     112             :                ! backspace and re-read erroneous line
     113           0 :                backspace(nu_nml)
     114           0 :                read(nu_nml,fmt='(A)') tmpstr2
     115             :                call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // &
     116           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     117             :             endif
     118             :          end do
     119             : 
     120           7 :          close(nu_nml)
     121           7 :          call release_fileunit(nu_nml)
     122             :       endif
     123             : 
     124          37 :       call broadcast_scalar (f_Cdn_atm, master_task)
     125          37 :       call broadcast_scalar (f_Cdn_ocn, master_task)
     126          37 :       call broadcast_scalar (f_drag, master_task)
     127             : 
     128          37 :       if (formdrag) then
     129             : 
     130             :       ! 2D variables
     131             : 
     132           0 :       do ns = 1, nstreams
     133             : 
     134           0 :        if (f_drag(1:1) /= 'x') &
     135             :          call define_hist_field(n_hfreebd,"hfreebd","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     136             :             "hfreebd: freeboard",                           &   ! LCOV_EXCL_LINE
     137             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     138           0 :             ns, f_drag)
     139             : 
     140           0 :        if (f_drag(1:1) /= 'x') &
     141             :          call define_hist_field(n_hdraft,"hdraft","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     142             :             "hdraft: draught",                           &   ! LCOV_EXCL_LINE
     143             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     144           0 :             ns, f_drag)
     145             : 
     146           0 :        if (f_drag(1:1) /= 'x') &
     147             :          call define_hist_field(n_hridge,"hridge","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     148             :             "hridge: ridge height",                          &   ! LCOV_EXCL_LINE
     149             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     150           0 :             ns, f_drag)
     151             : 
     152           0 :        if (f_drag(1:1) /= 'x') &
     153             :          call define_hist_field(n_distrdg,"distrdg","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     154             :             "distrdg: distance between ridges",  &   ! LCOV_EXCL_LINE
     155             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     156           0 :             ns, f_drag)
     157             : 
     158           0 :        if (f_drag(1:1) /= 'x') &
     159             :          call define_hist_field(n_hkeel,"hkeel","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     160             :             "hkeel: keel depth",                           &   ! LCOV_EXCL_LINE
     161             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     162           0 :             ns, f_drag)
     163             : 
     164           0 :        if (f_drag(1:1) /= 'x') &
     165             :          call define_hist_field(n_dkeel,"dkeel","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     166             :             "dkeel: distance between keels", &   ! LCOV_EXCL_LINE
     167             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     168           0 :             ns, f_drag)
     169             : 
     170           0 :        if (f_drag(1:1) /= 'x') &
     171             :          call define_hist_field(n_lfloe,"lfloe","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     172             :             "lfloe: floe length",         &   ! LCOV_EXCL_LINE
     173             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     174           0 :             ns, f_drag)
     175             : 
     176           0 :        if (f_drag(1:1) /= 'x') &
     177             :          call define_hist_field(n_dfloe,"dfloe","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     178             :             "dfloe: distance between floes", &   ! LCOV_EXCL_LINE
     179             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     180           0 :             ns, f_drag)
     181             : 
     182           0 :        if (f_Cdn_atm(1:1) /= 'x') &
     183             :          call define_hist_field(n_Cdn_atm,"Cdn_atm","none",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     184             :             "Ca: total ice-atm drag coefficient", &   ! LCOV_EXCL_LINE
     185             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     186           0 :             ns, f_Cdn_atm)
     187             : 
     188           0 :        if (f_Cdn_ocn(1:1) /= 'x') &
     189             :          call define_hist_field(n_Cdn_ocn,"Cdn_ocn","none",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     190             :             "Cdn_ocn: total ice-ocn drag coefficient", &   ! LCOV_EXCL_LINE
     191             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     192           0 :             ns, f_Cdn_ocn)
     193             : 
     194           0 :        if (f_drag(1:1) /= 'x') &
     195             :          call define_hist_field(n_Cdn_atm_skin,"Cdn_atm_skin","none", &   ! LCOV_EXCL_LINE
     196             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     197             :             "Cdn_atm_skin: neutral skin ice-atm drag coefficient", &   ! LCOV_EXCL_LINE
     198             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     199           0 :             ns, f_drag)
     200             : 
     201           0 :        if (f_drag(1:1) /= 'x') &
     202             :          call define_hist_field(n_Cdn_atm_floe,"Cdn_atm_floe","none", &   ! LCOV_EXCL_LINE
     203             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     204             :             "Cdn_atm_floe: neutral floe edge ice-atm drag coefficient", &   ! LCOV_EXCL_LINE
     205             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     206           0 :             ns, f_drag)
     207             : 
     208           0 :        if (f_drag(1:1) /= 'x') &
     209             :          call define_hist_field(n_Cdn_atm_pond,"Cdn_atm_pond","none", &   ! LCOV_EXCL_LINE
     210             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     211             :             "Cdn_atm_pond: neutral pond edge ice-atm drag coefficient", &   ! LCOV_EXCL_LINE
     212             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     213           0 :             ns, f_drag)
     214             : 
     215           0 :        if (f_drag(1:1) /= 'x') &
     216             :          call define_hist_field(n_Cdn_atm_rdg,"Cdn_atm_rdg","none", &   ! LCOV_EXCL_LINE
     217             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     218             :             "Cdn_atm_rdg: neutral ridge ice-atm drag coefficient", &   ! LCOV_EXCL_LINE
     219             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     220           0 :             ns, f_drag)
     221             : 
     222           0 :         if (f_drag(1:1) /= 'x') &
     223             :          call define_hist_field(n_Cdn_ocn_skin,"Cdn_ocn_skin","none", &   ! LCOV_EXCL_LINE
     224             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     225             :             "Cdn_ocn_skin: neutral skin ice-ocn drag coefficient", &   ! LCOV_EXCL_LINE
     226             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     227           0 :             ns, f_drag)
     228             : 
     229           0 :        if (f_drag(1:1) /= 'x') &
     230             :          call define_hist_field(n_Cdn_ocn_floe,"Cdn_ocn_floe","none", &   ! LCOV_EXCL_LINE
     231             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     232             :             "Cdn_ocn_floe: neutral floe edge ice-ocn drag coefficient", &   ! LCOV_EXCL_LINE
     233             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     234           0 :             ns, f_drag)
     235             : 
     236           0 :        if (f_drag(1:1) /= 'x') &
     237             :          call define_hist_field(n_Cdn_ocn_keel,"Cdn_ocn_keel","none", &   ! LCOV_EXCL_LINE
     238             :             tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     239             :             "Cdn_ocn_keel: neutral keel ice-ocn drag coefficient", &   ! LCOV_EXCL_LINE
     240             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     241           0 :             ns, f_drag)
     242             : 
     243           0 :        if (f_drag(1:1) /= 'x') &
     244             :          call define_hist_field(n_Cdn_atm_ratio,"Cdn_atm_ratio", &   ! LCOV_EXCL_LINE
     245             :             "none",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     246             :             "Cdn_atm_ratio: ratio total drag / neutral drag (atm)", &   ! LCOV_EXCL_LINE
     247             :             "none", c1, c0,            &   ! LCOV_EXCL_LINE
     248           0 :             ns, f_drag)
     249             : 
     250             :       enddo ! nstreams
     251             : 
     252             :       endif ! formdrag
     253             : 
     254          37 :       end subroutine init_hist_drag_2D
     255             : 
     256             : !=======================================================================
     257             : 
     258             : ! accumulate average ice quantities or snapshots
     259             : 
     260       23104 :       subroutine accum_hist_drag (iblk)
     261             : 
     262             :       use ice_history_shared, only: a2D, accum_hist_field
     263             :       use ice_arrays_column, only: hfreebd, hdraft, hridge, distrdg, hkeel, &
     264             :           dkeel, lfloe, dfloe, Cdn_atm, Cdn_atm_skin, Cdn_atm_floe, &   ! LCOV_EXCL_LINE
     265             :           Cdn_atm_pond, Cdn_atm_rdg, Cdn_atm_ratio, Cdn_ocn_skin, &   ! LCOV_EXCL_LINE
     266             :           Cdn_ocn_keel, Cdn_ocn_floe, Cdn_ocn
     267             : 
     268             :       integer (kind=int_kind), intent(in) :: &
     269             :            iblk                 ! block index
     270             :       logical (kind=log_kind) :: formdrag
     271             :       character(len=*), parameter :: subname = '(accum_hist_drag)'
     272             : 
     273             :       !---------------------------------------------------------------
     274             :       ! increment field
     275             :       !---------------------------------------------------------------
     276             : 
     277       23104 :       call icepack_query_parameters(formdrag_out=formdrag)
     278       23104 :       call icepack_warnings_flush(nu_diag)
     279       23104 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     280           0 :          file=__FILE__, line=__LINE__)
     281             : 
     282       23104 :       if (formdrag) then
     283             : 
     284             :       ! 2D fields
     285             : 
     286           0 :       if (allocated(a2D)) then
     287             : 
     288           0 :       if (f_Cdn_atm     (1:1) /= 'x') &
     289           0 :         call accum_hist_field(n_Cdn_atm, iblk, Cdn_atm(:,:,iblk), a2D)
     290           0 :       if (f_Cdn_ocn     (1:1) /= 'x') &
     291           0 :         call accum_hist_field(n_Cdn_ocn, iblk, Cdn_ocn(:,:,iblk), a2D)
     292           0 :       if (f_drag     (1:1) /= 'x') then
     293           0 :         call accum_hist_field(n_hfreebd, iblk, hfreebd(:,:,iblk), a2D)
     294           0 :         call accum_hist_field(n_hdraft, iblk, hdraft(:,:,iblk), a2D)
     295           0 :         call accum_hist_field(n_hridge, iblk, hridge(:,:,iblk), a2D)
     296           0 :         call accum_hist_field(n_distrdg, iblk, distrdg(:,:,iblk), a2D)
     297           0 :         call accum_hist_field(n_hkeel, iblk, hkeel(:,:,iblk), a2D)
     298           0 :         call accum_hist_field(n_dkeel, iblk, dkeel(:,:,iblk), a2D)
     299           0 :         call accum_hist_field(n_lfloe, iblk, lfloe(:,:,iblk), a2D)
     300           0 :         call accum_hist_field(n_dfloe, iblk, dfloe(:,:,iblk), a2D)
     301             :         call accum_hist_field(n_Cdn_atm_rdg, &
     302           0 :                               iblk, Cdn_atm_rdg(:,:,iblk), a2D)
     303             :         call accum_hist_field(n_Cdn_atm_floe, &
     304           0 :                               iblk, Cdn_atm_floe(:,:,iblk), a2D)
     305             :         call accum_hist_field(n_Cdn_atm_pond, &
     306           0 :                               iblk, Cdn_atm_pond(:,:,iblk), a2D)
     307             :         call accum_hist_field(n_Cdn_atm_skin, &
     308           0 :                               iblk, Cdn_atm_skin(:,:,iblk), a2D)
     309             :         call accum_hist_field(n_Cdn_atm_ratio, &
     310           0 :                               iblk, Cdn_atm_ratio(:,:,iblk), a2D)
     311             :         call accum_hist_field(n_Cdn_ocn_keel, &
     312           0 :                               iblk, Cdn_ocn_keel(:,:,iblk), a2D)
     313             :         call accum_hist_field(n_Cdn_ocn_floe, &
     314           0 :                               iblk, Cdn_ocn_floe(:,:,iblk), a2D)
     315             :         call accum_hist_field(n_Cdn_ocn_skin, &
     316           0 :                               iblk, Cdn_ocn_skin(:,:,iblk), a2D)
     317             :       end if
     318             : 
     319             :       endif ! if(allocated(a2D))
     320             :       endif ! formdrag
     321             : 
     322       23104 :       end subroutine accum_hist_drag
     323             : 
     324             : !=======================================================================
     325             : 
     326             :       end module ice_history_drag
     327             : 
     328             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd