MRG Interactive Developments

Mesoscale Research Group, McGill University


Patches for the Canadian Mesoscale Compressible Community Model

  • Patch Background
  • Patch Generation
  • Dynamic Initialization Patch - download it! (left shift and click for download)
  • Dyamic Initialization Stepping Patch - download it! (left shift and click for download)
  • RPN Standard File Cascade Patch - downloat it! (left shift and click for download)
  • Relative Humidity Initialization Patch - download it! (left shift and click for download)



  • General Patch Information

    The patches provided on this page have been developed by MRG Interactive and tested for basic functionality. However, they do not represent features incorporated into the MC2 model, and should be applied only when specifically required. To apply a patch, follow the instructions particular to the patchfile. In general, you will have to extract a certain number of MC2 subprograms and common declaration files into you "experience" directory before applying the patch. To generated the patched files, simply type patch -p 0 -b -z .orig < patchfileName. Always double check that the patch has been properly applied using the diff utility.

    Generating a Patch for the MC2

    The patches provided on this page were all created using a universal form of the diff command: diff -Naur oldDir newDir > patchFile. Recursive patching scripts makepatch.sh and getdiff.sh written by Ranjit Mathew, and modified for enhanced functionality by Ron McTaggart-Cowan provide a simple, self-explanatory way of generating patches for multiple files.

    Dynamic Initialization Patch

    This patch was originally produced for version 4.9.7 of the MC2, although it has also been sucessfully applied to versions 4.9.6 and 4.9.8. The patch corrects errors in the argument list for the dynamic initialization that result in immediate segementaion (memory) faults in the stock version of the model. Note that the re-release of version 4.9.8 in the fall of 2004 contains the functionality of this patch (it should therefore not be applied to the updated version of the mc2). Local versions of the mc2dm.ftn and initdyn9.ftn subprograms are required in the local "experience" directory. To apply this patch:

    1. extract local versions of mc2dm.ftn and initdyn9.ftn if they do not already exist in your directory
    2. download the slowstart patch
    3. apply the patch using patch < slowstart-patch
    4. double-check the correct application of the patch by diffing the modified files.

    Once this procedure is complete, you should be able to use the dynamic intialization capabilities of the MC2 without fear of memory faults.

    $> omd_exp mc2dm.ftn initdyn9.ftn
    $> patch -p 0 -b -z .orig < slowstart-patch
    $> make objloc; make mc2; make clean

    Dynamic Initialization Stepping Patch

    This patch was produced for version 4.9.8 of the MC2 in order to implement a forwards-backwards mass-based stepping during the dynamic initialization procedure. The stock version of the mc2 dynamic initialization uses the dynamical core of the model to integrate forwards in time for gndtini steps of grninit seconds. Thereafter, them model reverses its timestep and integrates backwards to the initial time, thus balancing the initial state. This patch changes the balancing procedure by doing a series of gndtini forwards-backwards steps at time zero. After each step, the mass field is redefined to its original value. Thus, the end result of this patch is to force the balancing of the winds to the analyzed mass field. Depending on the scale of the systems to be balanced, this balancing may take numerous steps since the geostrophic adjustment process for smaller-scale systems is generally dominated by the flow field. This patch is not beautifully implemented, and appears to have problems when initialization steps are too large or too numerous; however, it is included here it the hopes that it may be useful. To apply this patch:

    1. extract a local version of initdyn9.ftn if it does not already exist in your directory
    2. download the Stepping Patch
    3. apply the patch using patch -p 0 -b -z .orig < initStep.diff
    4. double-check the correct application of the patch by diffing the modified files
    5. build the objects in the working directory
    6. rebuild the mc2

    Once this procedure is complete, the forwards-backwards mass-based initialization will be used for the dynamic initialization steps of the model. No other aspects of the model are modified by this patch. An example of the patching procedure is: $> omd_exp initdyn9.ftn
    $> patch -p 0 -b -z .orig < initStep.diff
    $> make objloc; make mc2 make clean

    RPN Standard File Cascade Patch

    This patch was produced for version 4.9.8 of the MC2 in order to maintain potentially useful (but dangerous) functionality involving the production of self-nesting (cascade) grids in RPN Standard File (FST) format. Before proceeding with the application of the patch, the user must understand that the cascade output files produced by the MC2 should not be modified. That being said, it may - on rare occasions - be useful to be able to view and access these files using standard ARMNLIB utilities such as 'X-Reveur en Couleurs' (xrec). This patch implements an additional parameter (fst_casc) in the &mc2_cfgs namelist in the mc2_settings.nml file. By default, RPN Standarad files are not produced, even after patching - as described below, the user must insert the fst_casc=.true. in the &mc2_cfgs namelist to access the functionality of this patch. To apply this patch:

    1. extract local versions of grd.cdk, mc2ctrl.ftn, mc2nml.cdk, out_dyn.ftn and out_phy.ftn if they do not already exist in your directory
    2. download the Cascade Patch
    3. apply the patch using patch -p 0 -b -z .orig < fst_casc.diff
    4. double-check the correct application of the patch by diffing the modified files
    5. build the objects in the working direcctory
    6. rebuild the mc2
    7. add fst_casc=.true. to the &mc2_cfgs namelist of mc2_settings.nml

    Once this procedure is complete, you will be able to use the fst_casc switch to specify the cascade file type. An example of the patching procedure up to the mc2_settings.nml editing step is (assuming that you have downloaded the Cascade Patch into your working directory): $> omd_exp grd.cdk mc2ctrl.ftn mc2nml.cdk out_dyn.ftn out_phy.ftn
    $> patch -p 0 -b -z .orig < fst_casc.diff
    $> make objloc; make mc2; make clean

    Relative Humidity Initialization Patch

    This patch was produced for version 4.9.8 of the MC2 in order to allow for the reading of relative humidity data in the initial conditions. Although the CMC does not routinely store relative humidity (HR) data in their analysis files, grids produced by other centres often contain these fields as moisture specification. Adding this patch allows the user to read directly from HR data since the conversion to specific humidity is included explicitly in the initial setup of the MC2 using the conversion forumlated by Gill (1982). Additionally, this patch allows for missing humidity data at levels above the bottom layer of the analysis. This is particularly useful for NCEP analysis and reanalysis data that often only has moisture fields available to 100 and 300 hPa respectively. Any moisture field above the bottom layer is automatically initialized to zero if it is not found in the analysis. The functionality of this patch is enitrely transparent, and its application will not affect any other components of the MC2 mode. To apply this patch:

    1. extract local versions of doninip.ftn, rsdata.ftn and s_rdvint.ftn if they do not already exist in your directory
    2. download the Relative Humidity Initialization Patch
    3. apply the patch using patch -p 0 -b -z .orig < hrel.diff
    4. double-check the corrrect application of the patch by diffing the modified files
    5. build the objects in the working directory
    6. rebuild the mc2

    Once this procedure is complete, you will be able to initialize the MC2 model using analyses containing the relative humidity field. An example of the patching procedure is (assuming that you have downloaded the Relative Humidity Initialization Patch into your working directory: $> omd_exp doninip.ftn rsdata.ftn s_rdvint.ftn
    $> patch -p 0 -b -z .orig < hrel.diff
    $> make objloc; make mc2; make clean


    MRG Interactive is a supporter of open source initiatives and,

    SourceForge.net Logo

    Questions or Comments? Contact our WebMaster.