create_file_metada Subroutine

subroutine create_file_metada()

create_file_metada – Create the file metada using PFIO methods and the file collection identifier

Arguments

None

Calls

proc~~create_file_metada~~CallsGraph proc~create_file_metada create_file_metada none~add_attribute~2 Variable%add_attribute proc~create_file_metada->none~add_attribute~2 none~add_const_value Variable%add_const_value proc~create_file_metada->none~add_const_value none~add_dimension FileMetadata%add_dimension proc~create_file_metada->none~add_dimension none~add_hist_collection~2 ClientManager%add_hist_collection proc~create_file_metada->none~add_hist_collection~2 none~add_variable FileMetadata%add_variable proc~create_file_metada->none~add_variable proc~add_fvar add_fvar proc~create_file_metada->proc~add_fvar none~add_attribute_1d Variable%add_attribute_1d none~add_attribute~2->none~add_attribute_1d interface~mapl_assert MAPL_Assert none~add_const_value->interface~mapl_assert none~get_rank UnlimitedEntity%get_rank none~add_const_value->none~get_rank proc~mapl_return MAPL_Return none~add_const_value->proc~mapl_return insert insert none~add_dimension->insert none~add_dimension->proc~mapl_return none~add_hist_collection ClientThread%add_hist_collection none~add_hist_collection~2->none~add_hist_collection none~at~141 ClientThreadVector%at none~add_hist_collection~2->none~at~141 none~add_hist_collection~2->proc~mapl_return at at none~add_variable->at begin begin none~add_variable->begin get get none~add_variable->get none~add_variable->interface~mapl_assert next next none~add_variable->next none~get_const_value Variable%get_const_value none~add_variable->none~get_const_value none~get_dimensions Variable%get_dimensions none~add_variable->none~get_dimensions none~get_shape UnlimitedEntity%get_shape none~add_variable->none~get_shape none~insert~104 StringVariableMap%insert none~add_variable->none~insert~104 none~is_empty UnlimitedEntity%is_empty none~add_variable->none~is_empty none~add_variable->proc~mapl_return push_back push_back none~add_variable->push_back proc~add_fvar->none~add_attribute~2 proc~add_fvar->none~add_variable proc~mapl_abort MAPL_abort proc~add_fvar->proc~mapl_abort proc~mapl_verify MAPL_Verify proc~add_fvar->proc~mapl_verify

Called by

proc~~create_file_metada~~CalledByGraph proc~create_file_metada create_file_metada program~main~8 main program~main~8->proc~create_file_metada

Source Code

   subroutine create_file_metada()
      !--------------------------------------------------------------
      ! ---> Define dimensions and create variables for a netCDF file
      !--------------------------------------------------------------

      !fmd = FileMetadata()

      ! Define dimensions
      !----------------------
      call fmd%add_dimension('lon', IM_WORLD, rc=status)
      call fmd%add_dimension('lat', JM_WORLD, rc=status)
      call fmd%add_dimension('lev', KM_WORLD, rc=status)
      call fmd%add_dimension('time', pFIO_UNLIMITED, rc=status)

      ! Define variables
      !-----------------
      hh = (lon_max - lon_min)/(IM_WORLD)
      do i = 1, IM_WORLD
         lons(i) = lon_min + (i-1)*hh
      enddo

      v = Variable(type=PFIO_REAL32, dimensions='lon')
      call v%add_attribute('long_name', 'Longitude')
      call v%add_attribute('units', 'degrees_east')
      call v%add_const_value(UnlimitedEntity(lons))
      call fmd%add_variable('lon', v)

      hh = (lat_max - lat_min)/(JM_WORLD-1)
      do j = 1, JM_WORLD
         lats(j) = lat_min + (j-1)*hh
      enddo

      v = Variable(type=PFIO_REAL32, dimensions='lat')
      call v%add_attribute('long_name', 'Latitude')
      call v%add_attribute('units', 'degrees_north')
      call v%add_const_value(UnlimitedEntity(lats))
      call fmd%add_variable('lat', v)

      levs = (/(k, k=1,KM_WORLD)/)

      v = Variable(type=PFIO_REAL32, dimensions='lev')
      call v%add_attribute('long_name', 'Vertical level')
      call v%add_attribute('units', 'layer')
      call v%add_attribute('positive', 'down')
      call v%add_attribute('coordinate', 'eta')
      call v%add_attribute('standard_name', 'model_layers')
      call v%add_const_value(UnlimitedEntity(levs))
      call fmd%add_variable('lev', v)

      v = Variable(type=PFIO_REAL32, dimensions='time')
      call v%add_attribute('long_name', 'time')
      call v%add_attribute('units', 'minutes since 2010-01-03 00:00:00')
      call v%add_attribute('time_increment', 30000)
      call v%add_attribute('begin_date', 20100103)
      call v%add_attribute('begin_time', 0)
      call fmd%add_variable('time', v)

      var_name = "temperature"
      call add_fvar(fmd, TRIM(var_name), PFIO_REAL32, 'lon,lat,lev,time', &
                          units     = 'K', &
                          long_name = TRIM(var_name), &
                          rc        = status)

      var_name = "tracer"
      call add_fvar(fmd, TRIM(var_name), PFIO_REAL32, 'lon,lat,time', &
                          units     = 'mol mol-1', &
                          long_name = TRIM(var_name), &
                          rc        = status)

      ! Set File attributes
      call fmd%add_attribute('Convention', 'COARDS')
      call fmd%add_attribute('Source', 'GMAO')
      call fmd%add_attribute('Title', 'Sample code to test PFIO')
      call fmd%add_attribute('HISTORY', 'File writtem by PFIO vx.x.x')

      hist_id = o_clients%add_hist_collection(fmd)
   end subroutine create_file_metada