Layout of routine setup_dout

SUBROUTINE SETUP_DOUT ..... #include "netcdf.inc" PARAMETER (JPNCDF=6) INTEGER IDIMID1(1),IDIMID2(2),IDIMID3(3),IDIMID4(4),IPOS(JPNCDF) CHARACTER*10 CUNITS CHARACTER*100 CAVER REAL*4 ZMISS ZMISS=RMISS !* -- open NetCDF files and store unit numbers in IPOS(..) NPOSEFL = NCCRE('o_efl.nc', NCCLOB, IERR) WRITE(NULOUT,*)'NETCDF-FILE o_efl.nc OPENED ON UNIT ',NPOSEFL NPOSWAT = NCCRE('o_wat.nc', NCCLOB, IERR) WRITE(NULOUT,*)'NETCDF-FILE o_wat.nc OPENED ON UNIT ',NPOSWAT NPOSSUS = NCCRE('o_sus.nc', NCCLOB, IERR) WRITE(NULOUT,*)'NETCDF-FILE o_sus.nc OPENED ON UNIT ',NPOSSUS NPOSSUB = NCCRE('o_sub.nc', NCCLOB, IERR) WRITE(NULOUT,*)'NETCDF-FILE o_sub.nc OPENED ON UNIT ',NPOSSUB NPOSEVA = NCCRE('o_eva.nc', NCCLOB, IERR) WRITE(NULOUT,*)'NETCDF-FILE o_eva.nc OPENED ON UNIT ',NPOSEVA NPOSCLD = NCCRE('o_cld.nc', NCCLOB, IERR) WRITE(NULOUT,*)'NETCDF-FILE o_cld.nc OPENED ON UNIT ',NPOSCLD IPOS(1)=NPOSEFL IPOS(2)=NPOSWAT IPOS(3)=NPOSSUS IPOS(4)=NPOSSUB IPOS(5)=NPOSEVA IPOS(6)=NPOSCLD !* -- output accuracy IF (NACCUR.EQ.1) THEN IACCUR=NCFLOAT ELSEIF (NACCUR.EQ.2) THEN IACCUR=NCDOUBLE ENDIF CUNITS='kg/m^2/s' CAVER='average over past output interval' ILUNITS=LNBLNK(CUNITS) ILAVER=LNBLNK(CAVER) !* -- create dimensions DO J=1,JPNCDF NPOS=IPOS(J) NLATID = NCDDEF(NPOS, 'y', NLAT, IERR) NLONID = NCDDEF(NPOS, 'x', NLON, IERR) IF(NPOS.EQ.NPOSSUB)THEN NLEVSID = NCDDEF(NPOS, 'nlevs', NCSS, IERR) ENDIF NTIMID = NCDDEF(NPOS, 'time', NCUNLIM, IERR) !* -- create variables ! latitude IDIMID1(1) = NLATID NVARID = NCVDEF (NPOS, 'lat', NCDOUBLE, 1, IDIMID1, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 13, + 'degrees_north', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 8, + 'latitude', IERR) ! longitude IDIMID1(1) = NLONID NVARID = NCVDEF (NPOS, 'lon', NCDOUBLE, 1, IDIMID1, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 12, + 'degrees_east', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 9, + 'longitude', IERR) ! soil levels IF(NPOS.EQ.NPOSSUB)THEN IDIMID1(1) = NLEVSID NLEVSLID = NCVDEF (NPOS, 'nlevs', NCDOUBLE, 1, IDIMID1, IERR) CALL NCAPTC (NPOS, NLEVSLID, 'units', NCCHAR, 1, + 'm', IERR) CALL NCAPTC (NPOS, NLEVSLID, 'long_name', NCCHAR, 17, + 'soil level bottom', IERR) ENDIF ! time IDIMID1(1) = NTIMID NVARID = NCVDEF (NPOS, 'time', NCDOUBLE, 1, IDIMID1, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 7, + 'seconds', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 16, + 'Time in seconds', IERR) CALL NCAPTC (NPOS, NVARID, 'Time_label', NCCHAR, 24, + 'Start of output interval', IERR) ! timestep IDIMID1(1) = NTIMID NVARID = NCVDEF (NPOS, 'timestp', NCLONG, 1, IDIMID1, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 1, + '-', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 15, + 'model time step', IERR) CALL NCAPTC (NPOS, NVARID, 'Time_label', NCCHAR, 24, + 'Start of output interval', IERR) ! model identification CALL NCAPTC (NPOS, NCGLOBAL, 'modelID', NCCHAR, 20, + CMODID, IERR) ! run version CALL NCAPTC (NPOS, NCGLOBAL, 'versionID', NCCHAR, 20, + CVERID, IERR) ! model startup CALL NCAPT (NPOS, NCGLOBAL, 'start_day', NCLONG, 1, + NINDAT, IERR) CALL NCAPT (NPOS, NCGLOBAL, 'start_hour', NCLONG, 1, + NSSSSS, IERR) ! sign convention CALL NCAPTC (NPOS, NCGLOBAL, 'SurfSgn_convention', NCCHAR, 12, + 'Mathematical', IERR) IDIMID3(1) = NLONID IDIMID3(2) = NLATID IDIMID3(3) = NTIMID !* -- Surface energy balance !****************************************************************** IF(NPOS.EQ.NPOSEFL)THEN ! Net shortwave CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SWnet','W/m^2', & 'Net shortwave radiation','time y x',ZMISS,RMISS) ! Net longwave CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'LWnet','W/m^2', & 'Net longwave radiation','time y x',ZMISS,RMISS) ! Latent heat flux CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qle','W/m^2', & 'Average latent heat flux','time y x',ZMISS,RMISS) ! Sensible heat flux CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qh','W/m^2', & 'Average sensible heat flux','time y x',ZMISS,RMISS) ! Soil heat flux CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qg','W/m^2', & 'Average soil heat flux','time y x',ZMISS,RMISS) ! Soil freezing flux CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qf','W/m^2', & 'Average soil fusion flux','time y x',ZMISS,RMISS) ! Soil heat content change CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'DelSoilHeat','W/m^2', & 'Average soil heat content change','time y x',ZMISS,RMISS) ! Snow heat content change CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'DelColdHeat','W/m^2', & 'Average snow heat content change','time y x',ZMISS,RMISS) !* -- Surface water balance !****************************************************************** ELSEIF(NPOS.EQ.NPOSWAT)THEN !* -- snowfall rate CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Snowf',CUNITS, & 'Snowfall rate','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- rainfall rate CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Rainf',CUNITS, & 'Rainfall rate','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- evapotranspiration rate CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Evap',CUNITS, & 'Total evapotranspiration','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- surface runoff CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qs',CUNITS, & 'Surface runoff','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Subsurface runoff CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qsb',CUNITS, & 'Subsurface runoff','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Snowmelt CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Qsm',CUNITS, & 'Snowmelt','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Soil water storage change CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'DelSoilMoist','kg/m^2', & 'Soil water storage change','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Snow water storage change CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'DelSWE','kg/m^2', & 'Snow water storage change','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- interception water storage change CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'DelIntercept','kg/m^2', & 'Interception storage change','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- surface state variables !****************************************************************** ELSEIF(NPOS .EQ. NPOSSUS)THEN !* -- Snow temperature CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SnowT','K', & 'Snow temperature','time y x',ZMISS,RMISS) !* -- Average vegetation temperature CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'VegT','K', & 'Skin temperature low vegetation','time y x',ZMISS,RMISS) !* -- Bare ground temperature CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'BaresoilT','K', & 'Skin temperature bare soil','time y x',ZMISS,RMISS) !* -- Average surface temperature CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'AvgSurfT','K', & 'Average surface temperature','time y x',ZMISS,RMISS) !* -- Surface radiative temperature CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'RadT','K', & 'Surface radiative temperature','time y x',ZMISS,RMISS) !* -- Albedo CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Albedo','-', & 'Average albedo','time y x',ZMISS,RMISS) !* -- Snow water CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SWE','kg/m^2', & 'Snow water equivalent','time y x',ZMISS,RMISS) !* -- sub-surface state variables !****************************************************************** ELSEIF(NPOS .EQ. NPOSSUB)THEN ! soil temperature IDIMID4(1) = NLONID IDIMID4(2) = NLATID IDIMID4(3) = NLEVSID IDIMID4(4) = NTIMID NVARID = NCVDEF (NPOS, 'SoilTemp', IACCUR, 4, IDIMID4, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 1, + 'K', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 16, + 'soil temperature', IERR) CALL NCAPTC (NPOS, NVARID, 'associate', NCCHAR, 14, + 'time nlevs y x', IERR) IF(IACCUR.EQ.NCFLOAT)THEN CALL NCAPT (NPOS, NVARID, 'missing_value',IACCUR, + 1,ZMISS, IERR) ELSE CALL NCAPT (NPOS, NVARID, 'missing_value',IACCUR, + 1,RMISS, IERR) ENDIF ! soil water content NVARID = NCVDEF (NPOS, 'SoilMoist', IACCUR, 4, + IDIMID4, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 6, + 'kg/m^2', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 31, + 'soil moisture content per layer', IERR) CALL NCAPTC (NPOS, NVARID, 'associate', NCCHAR, 14, + 'time nlevs y x', IERR) IF(IACCUR.EQ.NCFLOAT)THEN CALL NCAPT (NPOS, NVARID, 'missing_value',IACCUR, + 1,ZMISS, IERR) ELSE CALL NCAPT (NPOS, NVARID, 'missing_value',IACCUR, + 1,RMISS, IERR) ENDIF ! liquid soil water content NVARID = NCVDEF (NPOS, 'LSoilMoist', IACCUR, 4, + IDIMID4, IERR) CALL NCAPTC (NPOS, NVARID, 'units', NCCHAR, 6, + 'kg/m^2', IERR) CALL NCAPTC (NPOS, NVARID, 'long_name', NCCHAR, 49, + 'diagnostic liquid soil moisture content per layer', + IERR) CALL NCAPTC (NPOS, NVARID, 'associate', NCCHAR, 14, + 'time nlevs y x', IERR) IF(IACCUR.EQ.NCFLOAT)THEN CALL NCAPT (NPOS, NVARID, 'missing_value',IACCUR, + 1,ZMISS, IERR) ELSE CALL NCAPT (NPOS, NVARID, 'missing_value',IACCUR, + 1,RMISS, IERR) ENDIF ! soil wetness CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SoilWet','-', & 'Total soil wetness','time y x',ZMISS,RMISS) !* -- evaporation components !****************************************************************** ELSEIF(NPOS .EQ. NPOSEVA)THEN !* -- Interception evaporation CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'ECanop',CUNITS, & 'Interception evaporation','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Vegetation evaporation CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'TVeg',CUNITS, & 'Vegetation transpiration','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Bare soil evaporation CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'ESoil',CUNITS, & 'Bare soil evaporation','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- Root zone soil moisture CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'RootMoist','kg/m^2', & 'Root zone soil moisture','time y x',ZMISS,RMISS) !* -- Canopy interception CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'CanopInt','kg/m^2', & 'Canopy interception depth','time y x',ZMISS,RMISS) !* -- Snow sublimation CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SubSnow',CUNITS, & 'Snow sublimation','time y x',ZMISS,RMISS) CALL NCAPTC (NPOS, NVARID, 'time_representation', NCCHAR, + ILAVER,CAVER, IERR) !* -- cold season processes !****************************************************************** ELSEIF(NPOS .EQ. NPOSCLD)THEN !* -- Snow covered fraction of grid cell CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SnowFrac','-', & 'Snow covered gridbox fraction','time y x',ZMISS,RMISS) !* -- Ice covered fraction of grid cell CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'IceFrac','-', & 'Ice covered gridbox fraction','time y x',ZMISS,RMISS) !* -- Frozen soil depth CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Fdepth','m', & 'Frozen soil depth','time y x',ZMISS,RMISS) !* -- Depth to soil thaw CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'Tdepth','m', & 'Depth to soil thaw','time y x',ZMISS,RMISS) !* -- Snow albedo CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SAlbedo','-', & 'Snow albedo','time y x',ZMISS,RMISS) !* -- Snow depth CALL CDF_ENCODE(NPOS,IACCUR,IDIMID3,'SnowDepth','m', & 'Depth of snow layer','time y x',ZMISS,RMISS) ENDIF !* -- return to data mode !****************************************************************** CALL NCENDF(NPOS, IERR) ENDDO RETURN END SUBROUTINE SETUP_DOUT