instant_field_init Subroutine

private subroutine instant_field_init()

Arguments

None

Calls

proc~~instant_field_init~~CallsGraph proc~instant_field_init instant_field_init p p proc~instant_field_init->p proc~define_nc define_nc proc~instant_field_init->proc~define_nc proc~instant_validate_output_vars instant_validate_output_vars proc~instant_field_init->proc~instant_validate_output_vars proc~ncinfo ncinfo proc~instant_field_init->proc~ncinfo proc~open_nc open_nc proc~instant_field_init->proc~open_nc proc~register_derived register_derived proc~instant_field_init->proc~register_derived proc~writestat_dims_nc writestat_dims_nc proc~instant_field_init->proc~writestat_dims_nc pup pup proc~instant_field_init->pup pvp pvp proc~instant_field_init->pvp pwp pwp proc~instant_field_init->pwp nf90_def_var nf90_def_var proc~define_nc->nf90_def_var nf90_enddef nf90_enddef proc~define_nc->nf90_enddef nf90_inq_dimid nf90_inq_dimid proc~define_nc->nf90_inq_dimid nf90_inq_varid nf90_inq_varid proc~define_nc->nf90_inq_varid nf90_put_att nf90_put_att proc~define_nc->nf90_put_att nf90_redef nf90_redef proc~define_nc->nf90_redef proc~nchandle_error nchandle_error proc~define_nc->proc~nchandle_error mpi_abort mpi_abort proc~instant_validate_output_vars->mpi_abort nf90_create nf90_create proc~open_nc->nf90_create nf90_def_dim nf90_def_dim proc~open_nc->nf90_def_dim proc~open_nc->nf90_def_var proc~open_nc->nf90_enddef nf90_get_var nf90_get_var proc~open_nc->nf90_get_var proc~open_nc->nf90_inq_dimid proc~open_nc->nf90_inq_varid nf90_inquire nf90_inquire proc~open_nc->nf90_inquire nf90_inquire_dimension nf90_inquire_dimension proc~open_nc->nf90_inquire_dimension nf90_open nf90_open proc~open_nc->nf90_open proc~open_nc->nf90_put_att nf90_sync nf90_sync proc~open_nc->nf90_sync proc~writestat_dims_nc->nf90_inq_varid proc~writestat_dims_nc->nf90_inquire_dimension nf90_put_var nf90_put_var proc~writestat_dims_nc->nf90_put_var nf90_strerror nf90_strerror proc~nchandle_error->nf90_strerror

Called by

proc~~instant_field_init~~CalledByGraph proc~instant_field_init instant_field_init proc~instant_prepare instant_prepare proc~instant_prepare->proc~instant_field_init proc~instant_main instant_main proc~instant_main->proc~instant_prepare program~udales uDALES program~udales->proc~instant_main

Source Code

    subroutine instant_field_init
      implicit none
      integer :: ilow, ihigh, jlow, jhigh, klow, khigh
      integer :: n, ydimtot
      logical :: lhalos_out

      if (.not. lfielddump) return

      call instant_validate_output_vars(nfieldvars, fieldvars, 'fieldvars', 'lfielddump')

      allocate(fldVars(nfieldvars,4))

      lhalos_out = .false.

      if (lhalos_out) then
        ilow  = ib - ih
        ihigh = ie + ih
        jlow  = jb - jh
        jhigh = je + jh
        klow  = kb - kh
        khigh = ke + kh
        ydimtot = jtot + 2*jh
      else
        ilow  = ib
        ihigh = ie
        jlow  = jb
        jhigh = je
        klow  = kb
        khigh = ke
        ydimtot = jtot
      end if

      xdimfield = ihigh - ilow + 1
      ydimfield = jhigh - jlow + 1
      zdimfield = khigh - klow + 1

      call ncinfo(fieldtimeVar(1,:), 'time', 'Time', 's', 'time')

      ! Set up variable descriptions and field pointers
      if (lhalos_out) then

        do n = 1, nfieldvars
          select case(fieldvars(3*n-2:3*n-1))
          case('u0')
            call ncinfo(fldVars(n,:), 'u', 'West-East velocity', 'm/s', 'mttt')
            pfields(n)%point => um(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case('v0')
            call ncinfo(fldVars(n,:), 'v', 'South-North velocity', 'm/s', 'tmtt')
            pfields(n)%point => vm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case('w0')
            call ncinfo(fldVars(n,:), 'w', 'Vertical velocity', 'm/s', 'ttmt')
            pfields(n)%point => wm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case('th')
            call ncinfo(fldVars(n,:), 'thl', 'Liquid water potential temperature', 'K', 'tttt')
            pfields(n)%point => thlm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case('ta')
            call ncinfo(fldVars(n,:), 'tha', 'Air temperature', 'K', 'tttt')
          case('rh')
            call ncinfo(fldVars(n,:), 'rh', 'Relative humidity', '%', 'tttt')
          case('pa')
            call ncinfo(fldVars(n,:), 'pabs', 'Hydrostatic absolute pressure', 'Pa', 'tttt')
          case('ql')
            call ncinfo(fldVars(n,:), 'ql', 'Liquid-water specific humidity', 'kg/kg', 'tttt')
            pfields(n)%point => ql0(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case('qt')
            call ncinfo(fldVars(n,:), 'qt', 'Total water specific humidity', 'kg/kg', 'tttt')
            pfields(n)%point => qtm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case('s1')
            call ncinfo(fldVars(n,:), 's1', 'scalar concentration field 1', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh, 1)
          case('s2')
            call ncinfo(fldVars(n,:), 's2', 'scalar concentration field 2', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh, 2)
          case('s3')
            call ncinfo(fldVars(n,:), 's3', 'scalar concentration field 3', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh, 3)
          case('s4')
            call ncinfo(fldVars(n,:), 's4', 'scalar concentration field 4', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh, 4)
          case('s5')
            call ncinfo(fldVars(n,:), 's5', 'scalar concentration field 5', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh, 5)
          case('p0')
            call ncinfo(fldVars(n,:), 'p', 'Kinematic pressure field', 'm^2/s^2', 'tttt')
            pfields(n)%point => pres0(ib-ih:ie+ih, jb-jh:je+jh, kb-kh:ke+kh)
          case default
            print *, "Invalid field variables name. Check namoptions setting for 'fieldvars'. &
                      &The variables can be only from the list: u0,v0,w0,p0,pa,th,ta,rh,qt,ql,s1,s2,s3,s4,s5. &
                      &There should not be any space in the string."
            STOP 1
          end select
        end do

      else

        do n = 1, nfieldvars
          select case(fieldvars(3*n-2:3*n-1))
          case('u0')
            call ncinfo(fldVars(n,:), 'u', 'West-East velocity', 'm/s', 'mttt')
            pfields(n)%point => um(ib:ie, jb:je, kb:ke)
          case('v0')
            call ncinfo(fldVars(n,:), 'v', 'South-North velocity', 'm/s', 'tmtt')
            pfields(n)%point => vm(ib:ie, jb:je, kb:ke)
          case('w0')
            call ncinfo(fldVars(n,:), 'w', 'Vertical velocity', 'm/s', 'ttmt')
            pfields(n)%point => wm(ib:ie, jb:je, kb:ke)
          case('th')
            call ncinfo(fldVars(n,:), 'thl', 'Liquid water potential temperature', 'K', 'tttt')
            pfields(n)%point => thlm(ib:ie, jb:je, kb:ke)
          case('ta')
            call ncinfo(fldVars(n,:), 'tha', 'Air temperature', 'K', 'tttt')
          case('rh')
            call ncinfo(fldVars(n,:), 'rh', 'Relative humidity', '%', 'tttt')
          case('pa')
            call ncinfo(fldVars(n,:), 'pabs', 'Hydrostatic absolute pressure', 'Pa', 'tttt')
          case('ql')
            call ncinfo(fldVars(n,:), 'ql', 'Liquid-water specific humidity', 'kg/kg', 'tttt')
            pfields(n)%point => ql0(ib:ie, jb:je, kb:ke)
          case('qt')
            call ncinfo(fldVars(n,:), 'qt', 'Total water specific humidity', 'kg/kg', 'tttt')
            pfields(n)%point => qtm(ib:ie, jb:je, kb:ke)
          case('s1')
            call ncinfo(fldVars(n,:), 's1', 'scalar concentration field 1', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib:ie, jb:je, kb:ke, 1)
          case('s2')
            call ncinfo(fldVars(n,:), 's2', 'scalar concentration field 2', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib:ie, jb:je, kb:ke, 2)
          case('s3')
            call ncinfo(fldVars(n,:), 's3', 'scalar concentration field 3', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib:ie, jb:je, kb:ke, 3)
          case('s4')
            call ncinfo(fldVars(n,:), 's4', 'scalar concentration field 4', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib:ie, jb:je, kb:ke, 4)
          case('s5')
            call ncinfo(fldVars(n,:), 's5', 'scalar concentration field 5', 'g/m^3', 'tttt')
            pfields(n)%point => svm(ib:ie, jb:je, kb:ke, 5)
          case('p0')
            call ncinfo(fldVars(n,:), 'p', 'Kinematic pressure field', 'm^2/s^2', 'tttt')
            pfields(n)%point => pres0(ib:ie, jb:je, kb:ke)
          case('tx')
            call ncinfo(fldVars(n,:), 'tau_x', 'stress x', 'M', 'mttt')
            pfields(n)%point => tau_x(ib:ie, jb:je, kb:ke)
          case('ty')
            call ncinfo(fldVars(n,:), 'tau_y', 'stress y', 'M', 'tmtt')
            pfields(n)%point => tau_y(ib:ie, jb:je, kb:ke)
          case('tz')
            call ncinfo(fldVars(n,:), 'tau_z', 'stress z', 'M', 'ttmt')
            pfields(n)%point => tau_z(ib:ie, jb:je, kb:ke)
          case('hf')
            call ncinfo(fldVars(n,:), 'thl_flux', 'heat flux', 'M', 'tttt')
            pfields(n)%point => thl_flux(ib:ie, jb:je, kb:ke)
          case('mu')
            call ncinfo(fldVars(n,:), 'mask_u', 'mask u', 'M', 'mttt')
            pfields(n)%point => mask_u(ib:ie, jb:je, kb:ke)
          case('mv')
            call ncinfo(fldVars(n,:), 'mask_v', 'mask v', 'M', 'tmtt')
            pfields(n)%point => mask_v(ib:ie, jb:je, kb:ke)
          case('mw')
            call ncinfo(fldVars(n,:), 'mask_w', 'mask w', 'M', 'ttmt')
            pfields(n)%point => mask_w(ib:ie, jb:je, kb:ke)
          case('mc')
            call ncinfo(fldVars(n,:), 'mask_c', 'mask c', 'M', 'tttt')
            pfields(n)%point => mask_c(ib:ie, jb:je, kb:ke)
          case('pd')
            call ncinfo(fldVars(n,:), 'p', 'pressure correction of the last substep', 'm2/s2', 'tttt')
            pfields(n)%point => p(ib:ie, jb:je, kb:ke)
          case('pu')
            call ncinfo(fldVars(n,:), 'pup', 'predicted u of the last substep', 'm/s2', 'mttt')
            pfields(n)%point => pup(ib:ie, jb:je, kb:ke)
          case('pv')
            call ncinfo(fldVars(n,:), 'pvp', 'predicted v of the last substep', 'm/s2', 'tmtt')
            pfields(n)%point => pvp(ib:ie, jb:je, kb:ke)
          case('pw')
            call ncinfo(fldVars(n,:), 'pwp', 'predicted w of the last substep', 'm/s2', 'ttmt')
            pfields(n)%point => pwp(ib:ie, jb:je, kb:ke)
          ! Computed at dump time (see compute_derived); the model stores none of these.
          case('rs')
            call ncinfo(fldVars(n,:), 'rhs', 'rhs of the Poisson equation (divergence of the predicted velocity)', '1/s2', 'tttt')
            call register_derived(n, DERIV_PRHS)
          case('du')
            call ncinfo(fldVars(n,:), 'dpupdx', 'x-term of the Poisson rhs', '1/s2', 'tttt')
            call register_derived(n, DERIV_PDX)
          case('dv')
            call ncinfo(fldVars(n,:), 'dpvpdy', 'y-term of the Poisson rhs', '1/s2', 'tttt')
            call register_derived(n, DERIV_PDY)
          case('dw')
            call ncinfo(fldVars(n,:), 'dpwpdz', 'z-term of the Poisson rhs', '1/s2', 'tttt')
            call register_derived(n, DERIV_PDZ)
          case('di')
            call ncinfo(fldVars(n,:), 'div', 'Divergence after pressure correction', '1/s', 'tttt')
            call register_derived(n, DERIV_DIV)
          case('ux')
            call ncinfo(fldVars(n,:), 'dudx', 'du/dx after pressure correction', '1/s', 'tttt')
            call register_derived(n, DERIV_DUDX)
          case('vy')
            call ncinfo(fldVars(n,:), 'dvdy', 'dv/dy after pressure correction', '1/s', 'tttt')
            call register_derived(n, DERIV_DVDY)
          case('wz')
            call ncinfo(fldVars(n,:), 'dwdz', 'dw/dz after pressure correction', '1/s', 'tttt')
            call register_derived(n, DERIV_DWDZ)
          case default
            print *, "Invalid field variables name. Check namoptions setting for 'fieldvars'. &
                      &The variables can be only from the list: u0,v0,w0,p0,pa,th,ta,rh,qt,ql,s1,s2,s3,s4,s5,tx,ty,tz,hf,mu,mv,mw,mc, &
                      &pd,pu,pv,pw,rs,du,dv,dw,di,ux,vy,wz. &
                      &There should not be any space in the string."
            STOP 1
          end select
        end do

      end if

      if (nderived > 0) then
        allocate(dbuf(ib:ie,jb:je,kb:ke,nderived)); dbuf = 0.
        do n = 1, nfieldvars
          if (derived_kind(n) /= 0) pfields(n)%point => dbuf(:,:,:,derived_slot(n))
        end do
      end if

      ! Create NetCDF file: ins_field.xxx.xxx.nc (one per x-processor column)
      filenamefield = 'ins_field.xxx.xxx.nc'
      filenamefield(11:13) = cmyidx
      filenamefield(15:17) = cexpnr

      nrecfield = 0
      if (myidy == 0) then
        call open_nc(filenamefield, ncidfield, nrecfield, n1=xdimfield, n2=ydimtot, n3=zdimfield)
        if (nrecfield == 0) then
          call define_nc(ncidfield, 1, fieldtimeVar)
          call writestat_dims_nc(ncidfield)
        end if
        call define_nc(ncidfield, nfieldvars, fldVars)
      end if

    end subroutine instant_field_init