Introduction to CISM code base
CISM coding style
CISM is written almost entirely in Fortran 90 and makes extensive use of "modules" in an attempt to parcel off related pieces of the code and box them up into relatively self contained units. Larger pieces of code are then constructed by accessing the relevant parts of different modules (variables, subroutines, functions, etc.) through the "use" statement.
Newer parts of CISM attempt to follow the general coding style used in most other components of the Community Earth System Model (see the talks and exercises on Thursday for more discussion). In general, there are three parts to any procedure that one might want to implement or add to the code:
- an initialization step
- allocate arrays, variables
- define constants
- read input
- anything else that only needs to be done once, at the start of the procedure
- a call to a "driver" subroutine
- pass relevant arguments from the main code to the procedure
- do the procedure
- pass the results back out to the main code
- a finalization step
- de-allocate arrays, variables
- write output
In the third exercise. you will work through a detailed example that should give you a better feel for this process.
To give you a very generic feel for which modules control the important parts of the code, refer to the following list. Also, see the code "flow" diagrams here and here, which will be discussed in more detail in the lecture.
libglimmer/ glimmer_physcon.F90 - physical constants (e.g. flow law rate factor, power-law exponent) libglimmer/ glimmer_paramets.F90 - other model parameters, such as scales for non-dimensionalization - libglide/ glide_types.F90 - general model data structure and default settings for run time parameter settings libglide/ glide_setup.F90 - configuration file parser libglide/ glide.F90 - module containing most high level calls to subroutines dealing with glacier thermodynamics (heat, momentum, and mass conservation) - libglide/ glide_temp.F90 - module containing most driver and work subroutines dealing with heat balance equation - libglide/ isostasy.F90 - module containing most driver and work subroutines dealing with isostacy equation - libglide/ glam.F90 - module containing high level driver subroutines for HO momentum balance and thickness evolution using incremental remapping libglide/ fo_upwind_advect.F90 - module containing high level driver subroutines for HO momentum balance and thickness evolution using first-order upwinding libglide/ glide_velo_higher.F90 - module containing driver subroutines for HO momentum balance calculations libglide/ glam_strs2.F90 - module containing work subroutines for HO momentum balance calculation libglide/ remap_glamutils.F90 - module containing driver subroutines for thickness evolution using incremental remapping - example-drivers/simple_glide/src/ simple_glide.F90 - high level time stepping driver subroutine; contains primarily calls to driver subroutines in glide.F90