Modify start Files

From Planets
Revision as of 17:49, 7 November 2023 by Martin.turbet (talk | contribs) (Using newstart.e routine)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here we present a simple tutorial to change the initial conditions used in the Generic PCM. The initial conditions are stored in the start.nc and startfi.nc netCDF files, which are read by the Generic PCM. To modify the initial conditions, you thus must modify the start.nc and startfi.nc files.

In the examples below, we modify the start.nc and startfi.nc file to apply fixed (= isothermal) temperatures across the planet.

Two options are available to do that:

Using Python scripts

We have developed simple Python routines to easily modify start.nc and startfi.nc files. This requires the use of the xarray library.

In the simple example below, we modify the surface temperatures (stored in the startfi.nc file) to arbitrarily fix them to 350K in the North hemisphere, and 250K in the South hemisphere of the planet.

from    numpy import *
import  numpy                 as        np
import  matplotlib.pyplot     as        mpl
import  math
import xarray as xr

# 1. WE GET THE SURFACE TOPOGRAPHY DATA
nc = xr.open_dataset('startfi.nc',decode_times=False)

# 2. WE READ THE VARIABLES
physical_points=nc['physical_points']
lat=nc['latitude']
lon=nc['longitude']
tsurf=nc['tsurf']

# BELOW THE VARIABLES WE WANT TO UPDATE
new_tsurf = np.empty(len(physical_points))

# LOOP TO MODIFY THE VARIABLES
# EXAMPLE - FIXED TEMPERATURES IN THE NORTH AND SOUTH HEMISPHERES
for i in range(0,len(physical_points),1):
    if(lat[i]*180./np.pi >= 0.):
        new_tsurf[i]=350. # north hemisphere
    else:
        new_tsurf[i]=250. # south hemisphere

# CREATE THE NEW NETCDF TOPOGRAPHY FILE

nc['tsurf'].values = new_tsurf
nc.to_netcdf('restartfi.nc')

The routine creates a restartfi.nc that can be copied into a startfi.nc and used as a new initial condition for the model.

However, to make more advanced modifications, it is sometimes necessary to switch to another, more advanced method (see below). For instance, to modify the 3D atmospheric temperature field, it is necessary to compute and modify the potential temperature, which requires the use of the Exner function. As this operation is not trivial, we recommend to use the newstart.e routine (see below).

Using newstart.e routine

Newstart is an interactive tool to modify the start files (start.nc and startfi.nc). See https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Tool_Box#newstart:_a_fortran_program_to_modify_start_files for a tutorial on how to generate the executable file.

In the example below, we show how to fix all temperatures (atmosphere, surface, subsurface) to isothermal conditions, to a fixed temperature of 300K.

Once newstart.e is generated, you can execute the routine:

./newstart_XXX.e # with XXX depending on the options used at the compilation stage

and then type

1 # to modify start.nc and startfi.nc files
n
 # press enter to pass
isotherm # this selects the option to fix all temperatures to isothermal conditions
300. # value of temperature
 # press enter to validate

This routine creates restart.nc and restartfi.nc files that can be copied into start.nc and startfi.nc, respectively, and used as a new initial conditions for the Generic PCM.

Note 1: we invite you to go through all existing options of newstart.e to get an idea of which variables can be modified. Note 2: if the option you want does not exist, you can create your own in the newstart.e routine by modifying the LMDZ.GENERIC/libf/dynphy_lonlat/phystd/newstart.F fortran file. You can easily copy and adapt existing examples. Once the changes have been made, you need to recompile the newstart.e routine and run it!