#include "SDDAS_types.h" /******************************************************************************* * * * KEY_TO_FIELDS SUBROUTINE * * * * DESCRIPTION * * This routine returns the project, mission, experiment, instrument and * * virtual instrument numbers associated with the specified data key. * * * * INPUT VARIABLES * * SDDAS_ULONG new_key key which uniquely identifies the data set * * being processed * * SDDAS_SHORT *params pointer to the area in which the numbers * * are returned * * * * USAGE * * key_to_fields (new_key, ¶ms) * * * * NECESSARY SUBPROGRAMS * * None * * * * EXTERNAL VARIABLES * * None * * * * INTERNAL VARIABLES * * SDDAS_SHORT project the project value * * SDDAS_SHORT mission the mission value * * SDDAS_SHORT exper the experiment value * * SDDAS_SHORT inst the instrument value * * SDDAS_SHORT vinst the virtual instrument value * * * * SUBSYSTEM * * Display Level * * * ******************************************************************************/ void key_to_fields (SDDAS_ULONG new_key, SDDAS_SHORT *params) { SDDAS_USHORT project, mission, exper, inst, vinst; /***********************************************************************/ /* The values used in the equations are explained as follows: */ /* 127 used as mask to retrieve 7 bits set for VIRTUAL INST. */ /* 8064 used as mask to retrieve 6 bits set for INSTRUMENT */ /* 516096 used as mask to retrieve 6 bits set for EXPERIMENT */ /* 7864320 used as mask to retrieve 4 bits set for MISSION */ /* 4286578688 for PROJECT sets top 9 bits of the 32 bit uns long. */ /***********************************************************************/ project = (new_key & 4286578688UL) >> 23; mission = (new_key & 7864320) >> 19; exper = (new_key & 516096) >> 13; inst = (new_key & 8064) >> 7; vinst = (new_key & 127); *(params) = project; *(params + 1) = mission; *(params + 2) = exper; *(params + 3) = inst; *(params + 4) = vinst; }