Replace Cray conditional vector merge functions

Make your code more portable and extend its life . . .

rule

Dick Valent
by Dick Valent


Contents

Search

Index

Home

Subscribe

ConsultWeb

SCD

We are providing this article in response to many recent user questions regarding conditional vector merge functions.


In order to make your Cray code more portable to other systems and to extend its life on the Crays, the SCD Technical Consulting Office suggests that you replace your conditional vector merge functions. The functions in question are CVMGM, CVMGN, CVMGP, CVMGZ, CVMGT.


Historical background

Some years ago, Cray Research (now SGI/Cray) provided conditional vector merge functions as extensions to the Fortran 77 language. These functions were a vectorizable alternative to the then-non-vectorizable IF-THEN-ELSE blocks.

This is no longer the situation. Cray's vectorizable loops include IF-THEN-ELSE blocks, and this has been true for some time. So the CVMGx functions are no longer necessary. Worse, they are not portable.

Because of this, SGI/Cray cannot guarantee how long conditional vector merge functions will remain available on their computers. While they have no intention to immediately remove the functions, it is in your best interest to begin replacing CVMGx function calls in your codes and to avoid using them in new applications.

We suggest that you replace CVMGx functions by IF-THAN-ELSE instances, or more simply, by using Fortran 90's MERGE function.


A conversion template

We recommend that you replace each invokation of CVMGM, CVMGN, CVMGP, CVMGZ, and CVMGT in-line, rather than writing external functions for this purpose. This is because the CVM functions are typically called many times, and it is far more efficient at runtime when you make the in-line replacement.

Here is a template to follow in making your conversion:

        REAL ::    R, TR, FR, MR
        LOGICAL :: L, TL, FL, ML

        R = CVMGM(TR,FR,MR)
        R = MERGE(TR,FR,MR< 0.0)

        R = CVMGN(TR,FR,MR)
        R = MERGE(TR,FR,MR/=0.0)

        R = CVMGP(TR,FR,MR)
        R = MERGE(TR,FR,MR>=0.0)

        R = CVMGZ(TR,FR,MR)
        R = MERGE(TR,FR,MR==0.0)

        L = CVMGT(TL,FL,ML)
        L = MERGE(TL,FL,ML)
If you are using the older CF77 compiler, you will need to replace the relational operators in the above MERGE invokations with .LT., .NE., .GE., and .EQ. respectively.


Thanks and a tip of the hat to . . .

Thanks go to Bryan Hardy of SGI/Cray for informing us of the vendor's intention, and to Jeff Kuehn of SCD for giving his historical perspective regarding the CVMGx functions.

Please direct questions and concerns to Dick Valent (valent@ucar.edu).

rule

Contents || Search || Index || Home || Subscribe || ConsultWeb || SCD