A: Architecture The main program can run one or more "cases", which are normally independent except for retaining the input parameters that are not explicitly changed. However, `"linking'" runs that transfer forward the current conditions (layer temperatures, frost budget, atmospheric temperature) is possible. The main program, KRC calls TDAY,1 once with a flag that precomputes everything possible about the subsurface numerical scheme, and then for each season calls: TSEAS: which loops over seasons, determining the distance and Mars-declination of the Sun, and then calls TLATS: which loops over latitudes, calculating insolation and atmospheric parameters for one latitude and calling TDAY,2: which does the layer calculations for each time step and each `"day'" needed to reach convergence. In addition to the FORTRAN version, IDL interfaces to KRC exist. A.1: Main program, KRC KRC explicitly sets all common areas to zero (not necessary on most modern computers), defines all logical units, sets physical constants, and asks for the input file name and the output log file name. It calls TCARD,1}to read the input file through complete definition of the first case. If TCARD reports having detected the one-point mode; the 1-point flag is set in common, the initial input file is closed, and the both the file containing the input list of points and the output table file are opened. TCARD,2 is called to get the first OnePoint values. KRC now starts a case and calls TSEAS. The remainder of KRC is logic and looping control for seasons or OnePoints, additional cases, and control of optional printing and binary output files. A.2: Input: TCARD All input other than the initial two file names is handled by one routine, TCARD}, which reads lines from the input file[s]. The first integer on a line controls the action to be taken, there are 13 possibilities, described in Appendix E, which allow changing all integer, real, logical input parameters, the latitude set, the elevations set, temperature-dependent properties, titles and file names, and OnePoint sets. TCARD also tests for formal errors on array sizes, loop limits and some physical constants. A sample input file is shown in Appendix B A.3: Seasons: TSEAS This routine initializes or increments the season counter and computes the current Modified Julian Date (offset from 2,440,000). If LSC true (rare), it calls TCARD,2}to read any parameter changes and then TDAY,1 to set up the subsurface model. The Sun-planet geometry is obtained from PORB [Planet ORBit] and the Ls computed; the same geometry is used throughout a "season". Notification of execution time thus far will be sent to the terminal if LNOTIF is True and the season count is a multiple of NMOD. If SVALB if True, then at each season the soil albedo will be derived by linear interpolation in Ls of the albedo table. A similar seasonal variation for atmospheric opacity is available by setting SVTAU True. The routine TLATS is called to do calculations for all latitudes, after which there are options to print a diurnal surface temperature table and layer minimum/maximum temperature table by calling the routine TPRINT, which handles nearly all printout. At the end of each season beginning with season count JDISK, TDISK is called to either write season results as one record in a direct-access binary file (K4OUT}=0 or save them in one of several formats in a large memory array which is written to a binary file after the last season of the last case. A.4: Latitude calculations: TLATS . TLATS is called once per season. Using solar geometry information in Common, it calculates insolation-related values that are constant across latitude. It sets the reference-level surface pressure; if based on polar cap mass, then the routine TINT is called to do the global integration of frost amount which in turn controls the global atmospheric pressure. There is an option for TPRINT,8 to print the global properties. Looping over latitude, the local surface pressure is calculated. The solar radiation absorbed at the surface and in the atmosphere are calculated for every time-of-day step, including consideration of insolation-dependent frost albedo if that was specified. There is an option to print the values for each hour. The equilibrium temperature conditions are computed; and starting conditions are set to the ending conditions for the prior season, if any. The routine TDAY,2 is called to do the diurnal calculations for one latitude. Based on the number of sols required to reach convergence, temperatures at midnight for all layers, the surface, the bottom, and the atmosphere, along with the amount of frost, are predicted to the end of the season. There are options to print a convergence summary and hourly radiation conditions. A.5: Diurnal calculations: TDAY The routine TDAY continues the inner loops for depth, time of day, and days to convergence; most of the execution time is in this routine. It is coded to minimize the computation time. There are two major sections; TDAY,1 sets up the subsurface layer and time grid, checking for stability. It computes and saves values that are independent of surface conditions. TDAY,2 solves the boundary conditions and the diffusion equation, including atmospheric temperature. TDAY,2 has an outer loop for days-to-convergence; this resets some summations and for the last day sets the time steps for print and disk output. A middle loop runs over time-of-day; it interpolates the upper two layers to the surface temperature, implements the lower boundary condition, and sets the number of layers to be used for this time step. There are two inner loops to solve the diffusion equation. For temperature-independent properties they have a total of 10 indexing (2 with fixed offsets) and 6 floating-point operations per layer; if temperature-dependent properties are invoked, these numbers become 17 (3 with offsets) and 33, and involve two subroutines calls. The total execution time is about four times greater for temperature-dependent properties. After the inner loops, the middle loop finds the new surface heat flow, solves the boundary conditions, computes the new atmospheric temperature and checks for saturation, and modifies any frost amount. If frost appears new or disappears entirely, the frost flag is set appropriately and surface albedo and emissivity reset. If the current day is the last to be computed this season, and the time is on an Hour, then hourly conditions are saved and optionally printed. In the outer loop, midnight conditions and daily averages are saved. Convergence conditions and iteration counts are checked to see if a jump should be done or if the next day can be the last or if the routine is finished. A.6: Disk Output: TDISK TDISK handles all binary input/output. It can write a variety of contents for each season, specified by K4OUT as listed in bold at the beginning of items below. These have been developed over time to address various research issues. A.6.1: Direct Access files Direct access files contain a record for each season [-1] KRCCOM plus LATCOM. Only this version supports restarting from a specific season. [0] One record of KRCCOM, latitudes and elevations; then records each season of hourly surface kinetic and planetary brightness temperatures for every latitude. This has been used for most large model sets. [1] KRCCOM and DAYCOM for the last latitude A.6.2: Packed binary files Called "types", these consist of one multi-dimensional array for all seasons, latitudes and cases, with KRCCOM loaded into a "virtual" part of the array. The number of cases that can be accommodated depends upon number of layers, latitudes and seasons and is computed dynamically. The memory assigned to store the array is firm coded; the default is adequate for one case of Type 52, with 48 hours, 37 latitudes and 84 seasons. TDISK computes the number of cases that it can store for the requested type; if this is less than one, then it will refuse to open an output file. `"Date'" is Julian date offset from 2,444,000. [51] Surface and planetary temperatures for every hour, latitude and season. Plus, for every season, the date, Ls, PZREF}, dust opacity and total global frost. \item [52] For each latitude; surface, planetary and atmosphere hourly temperature and diurnal layer extremes and NDJ4, DTM4, TTA4, FROST4, AFRO4, HEATMM. Plus, for every season, the date, Ls, PZREF}, dust opacity and total frost. \item [54] Surface temperature at 1 and 13 Hours, diurnal-average upward heat flow, midnight frost amount and bottom temperature. \item [55] For one latitude, 10 items related to temperatures, frost and heat-flow. Useful for a large number of seasons. \item [56] Designed for seasonal cap studies; hourly surface and planetary temperatures, plus several parameters at midnight for each latitude, plus several global parameters each season. A.7: Commons Each common is contained in a separate file that is included into routines at compilation as needed. KRCCOM contains constants that set the sizes of arrays in all commons, all input parameters, most physical constants, and all the major loop indices. LATCOM contains results for latitudes. DAYCOM contains layer temperature extremes and the values at midnight, several conditions at the end of each iteration day, radiation and surface temperature values at each time step, and indices of time-doubling layers. HATCOM contains arrays related to heat flow and irradiance, converged-but-not-predicted atmosphere conditions. UNITS contains logical unit assignments, open/closed flags and error message indices. FILCOM contains all file names PORBCM contains planetary geometry and rotation matrices A.8: Options at compilation Nearly all size limits are contained in krccom.inc PARAMETER (MAXN1 =30) ! dimension of layers PARAMETER (MAXN2 =384*4) ! dimension of times of day: 384=24*16 PARAMETER (MAXN3 =16) ! dimension of iteration days PARAMETER (MAXN4 =37) ! dimension of latitudes PARAMETER (MAXN5 =161) ! dimension of saved seasons PARAMETER (MAXN6 =6) ! dimension of saved years PARAMETER (MAXNH =48) ! dimension of saved times of day PARAMETER (MAXBOT=6) ! dimension of time doublings PARAMETER (KOMMON=10000000) ! Storage for a binary file Size of FFF(KOMMON) will accommodate type 52 for 9 cases of 48 hours, 37 latitudes, and 84 seasons. If one case exceeds KOMMON, TDISK will refuse to open an output file. In readtxt360.f, seasalb.f and seastau.f PARAMETER (MROW=362) ! max number of table entries