create_file_metada
– Create the file metada using PFIO methods and the file collection identifier
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