Ignore:
Timestamp:
Jan 31, 2012 12:13:39 PM (11 years ago)
Author:
srkline
Message:

Changes to the XOP code to upgrade to ToolKit? v6. Changes are the ones outlined in the Appendix A of the TK6 manual. SOme of the XOP support routines and the #pragma for 2-byte structures have changed. Per Howard Rodstein, there is no need to change the c files to cpp. c should work and compile just fine.

These changes work correctly on my mac. Next is to make sure that they work correctly on the two build machines.

Location:
sans/XOP_Dev/MonteCarlo
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sans/XOP_Dev/MonteCarlo/DebyeSpheres.c

    r815 r834  
    1010 
    1111// Prototypes 
    12 HOST_IMPORT void main(IORecHandle ioRecHandle); 
     12HOST_IMPORT int main(IORecHandle ioRecHandle); 
    1313 
    1414// Custom error codes 
    15 #define REQUIRES_IGOR_200 1 + FIRST_XOP_ERR 
     15//#define REQUIRES_IGOR_200 1 + FIRST_XOP_ERR 
    1616#define NON_EXISTENT_WAVE 2 + FIRST_XOP_ERR 
    1717#define REQUIRES_SP_OR_DP_WAVE 3 + FIRST_XOP_ERR 
     
    107107// 
    108108    npt = (int) WavePoints(p->xwavH);   //wavePoints returns long, number of XYZ points 
    109         xv = WaveData(p->xwavH);                //xyz locations 
    110         yv = WaveData(p->ywavH); 
    111         zv = WaveData(p->zwavH); 
    112         rv = WaveData(p->rhowavH); 
     109        xv = (double*)WaveData(p->xwavH);               //xyz locations 
     110        yv = (double*)WaveData(p->ywavH); 
     111        zv = (double*)WaveData(p->zwavH); 
     112        rv = (double*)WaveData(p->rhowavH); 
    113113     
    114114         
     
    204204        // 
    205205    npt = (int) WavePoints(p->xwavH);   //wavePoints returns long, number of XYZ points 
    206         xv = WaveData(p->xwavH);                //xyz locations 
    207         yv = WaveData(p->ywavH); 
    208         zv = WaveData(p->zwavH); 
     206        xv = (double*)WaveData(p->xwavH);               //xyz locations 
     207        yv = (double*)WaveData(p->ywavH); 
     208        zv = (double*)WaveData(p->zwavH); 
    209209         
    210210        p1 = (int) p->p1; 
     
    290290         
    291291         
    292         xv = WaveData(p->xwavH);                //xyz locations 
    293         yv = WaveData(p->ywavH); 
    294         zv = WaveData(p->zwavH); 
    295         bv = WaveData(p->bwavH); 
     292        xv = (double*)WaveData(p->xwavH);               //xyz locations 
     293        yv = (double*)WaveData(p->ywavH); 
     294        zv = (double*)WaveData(p->zwavH); 
     295        bv = (double*)WaveData(p->bwavH); 
    296296         
    297297        grid = p->grid; 
     
    420420    numBins = (int) WavePoints(p->bwavH);       //wavePoints returns long, number of points in bin wave 
    421421         
    422         xv = WaveData(p->xwavH);                //xyz locations 
    423         yv = WaveData(p->ywavH); 
    424         zv = WaveData(p->zwavH); 
    425         rho = WaveData(p->rhowavH); 
    426         SLDLook = WaveData(p->SLDLookH); 
    427         PSFid = WaveData(p->PSFidH);                    //this one is 2D 
     422        xv = (double*)WaveData(p->xwavH);               //xyz locations 
     423        yv = (double*)WaveData(p->ywavH); 
     424        zv = (double*)WaveData(p->zwavH); 
     425        rho = (double*)WaveData(p->rhowavH); 
     426        SLDLook = (double*)WaveData(p->SLDLookH); 
     427        PSFid = (double*)WaveData(p->PSFidH);                   //this one is 2D 
    428428         
    429429        p1 = (int) p->p1; 
     
    517517        return kExpectedNT_FP64; 
    518518    } 
    519         x = WaveData(p->bwavH); 
     519        x = (double*)WaveData(p->bwavH); 
    520520        n = (int)(p->nIn);                      // not sure that the negative input will be properly cast to int 
    521521         
  • sans/XOP_Dev/MonteCarlo/DebyeSpheres.h

    r815 r834  
    1010 
    1111// All structures passed to Igor are two-byte aligned. 
    12 #include "XOPStructureAlignmentTwoByte.h" 
     12#pragma pack(2) 
    1313 
    1414// Parameters passed from Igor to the function, in reverse order of the parameter list 
     
    8585 
    8686 
    87 #include "XOPStructureAlignmentReset.h" 
     87#pragma pack()          // return to default structure packing 
    8888 
    8989 
  • sans/XOP_Dev/MonteCarlo/MonteCarlo.c

    r825 r834  
    5757        waveHndl wavH; 
    5858//      int waveType,hState; 
    59         long numDimensions; 
    60         long dimensionSizes[MAX_DIMENSIONS+1]; 
     59        //changed for TK6 
     60        int numDimensions; 
     61        CountInt dimensionSizes[MAX_DIMENSIONS+1]; 
    6162//      char* dataStartPtr; 
    6263//      long dataOffset; 
     
    109110        p->retVal = 0.0; 
    110111         
    111 // trusting that all inputs are DOUBLE PRECISION WAVES!!! 
    112         inputWave = WaveData(p->inputWaveH); 
    113         ran_dev = WaveData(p->ran_devH); 
    114         nt = WaveData(p->ntH); 
    115         j1 = WaveData(p->j1H); 
    116         j2 = WaveData(p->j2H); 
    117         nn = WaveData(p->nnH); 
    118 //      MC_linear_data = WaveData(p->MC_linear_dataH); 
    119         results = WaveData(p->resultsH); 
     112// trusting that all inputs are double PRECISION WAVES!!! 
     113        inputWave = (double*)WaveData(p->inputWaveH); 
     114        ran_dev = (double*)WaveData(p->ran_devH); 
     115        nt = (double*)WaveData(p->ntH); 
     116        j1 = (double*)WaveData(p->j1H); 
     117        j2 = (double*)WaveData(p->j2H); 
     118        nn = (double*)WaveData(p->nnH); 
     119//      MC_linear_data = (double*)WaveData(p->MC_linear_dataH); 
     120        results = (double*)WaveData(p->resultsH); 
    120121         
    121122        seed = (long)results[0]; 
     
    160161        if (wavH == NIL) 
    161162                return NOWAV; 
    162  
    163 //      waveType = WaveType(wavH); 
    164 //      if (waveType & NT_CMPLX) 
    165 //              return NO_COMPLEX_WAVE; 
    166 //      if (waveType==TEXT_WAVE_TYPE) 
    167 //              return NUMERIC_ACCESS_ON_TEXT_WAVE; 
    168 //      if (retVal = MDGetWaveDimensions(wavH, &numDimensions, dimensionSizes)) 
    169 //              return retVal; 
    170 //      numRows = dimensionSizes[0]; 
    171 //      numColumns = dimensionSizes[1]; 
    172          
    173 //      if (retVal = MDAccessNumericWaveData(wavH, kMDWaveAccessMode0, &dataOffset)) 
    174 //              return retVal; 
    175                  
    176 //      hState = MoveLockHandle(wavH);          // So wave data can't move. Remember to call HSetState when done. 
    177 //      dataStartPtr = (char*)(*wavH) + dataOffset; 
    178 //      dp0 = (double*)dataStartPtr;                    // Pointer to the start of the 2D wave data. 
    179163         
    180164//scattering power and maximum qvalue to bin 
     
    502486 
    503487 
    504 //      HSetState((Handle)wavH, hState);                //release the handle of the 2D data wave 
    505488//      WaveHandleModified(wavH);                       // Inform Igor that we have changed the wave. (CALLBACK! needed, but not allowed in Threading) 
    506489         
  • sans/XOP_Dev/MonteCarlo/MonteCarlo.h

    r812 r834  
    2020  
    2121/* Prototypes */ 
    22 HOST_IMPORT void main(IORecHandle ioRecHandle); 
     22// for TK6 
     23HOST_IMPORT int main(IORecHandle ioRecHandle); 
    2324 
    2425  
    25 #define OLD_IGOR 1 + FIRST_XOP_ERR 
     26//#define OLD_IGOR 1 + FIRST_XOP_ERR 
    2627#define NON_EXISTENT_WAVE 2 + FIRST_XOP_ERR 
    2728#define NEEDS_2D_WAVE 3 + FIRST_XOP_ERR 
     
    2930 
    3031// All structures passed to Igor are two-byte aligned. 
    31 #include "XOPStructureAlignmentTwoByte.h" 
     32#pragma pack(2) 
    3233 
    3334struct MC_Params {     // This structure must be 2-byte-aligned because it receives parameters from Igor. 
     
    4647typedef struct MC_Params *MC_ParamsPtr; 
    4748 
    48 #include "XOPStructureAlignmentReset.h" 
    49  
     49#pragma pack()          // return to default structure packing 
    5050 
    5151// function prototypes 
  • sans/XOP_Dev/MonteCarlo/MonteCarlo2.c

    r825 r834  
    6060        waveHndl wavH; 
    6161//      int waveType,hState; 
    62         long numDimensions; 
    63         long dimensionSizes[MAX_DIMENSIONS+1]; 
     62        //changed for TK6 
     63        int numDimensions; 
     64        CountInt dimensionSizes[MAX_DIMENSIONS+1]; 
    6465//      char* dataStartPtr; 
    6566//      long dataOffset; 
     
    112113        p->retVal = 0; 
    113114         
    114 // trusting that all inputs are DOUBLE PRECISION WAVES!!! 
    115         inputWave = WaveData(p->inputWaveH); 
    116         ran_dev = WaveData(p->ran_devH); 
    117         nt = WaveData(p->ntH); 
    118         j1 = WaveData(p->j1H); 
    119         j2 = WaveData(p->j2H); 
    120         nn = WaveData(p->nnH); 
    121 //      MC_linear_data = WaveData(p->MC_linear_dataH); 
    122         results = WaveData(p->resultsH); 
     115// trusting that all inputs are double PRECISION WAVES!!! 
     116        inputWave = (double*)WaveData(p->inputWaveH); 
     117        ran_dev = (double*)WaveData(p->ran_devH); 
     118        nt = (double*)WaveData(p->ntH); 
     119        j1 = (double*)WaveData(p->j1H); 
     120        j2 = (double*)WaveData(p->j2H); 
     121        nn = (double*)WaveData(p->nnH); 
     122//      MC_linear_data = (double*)WaveData(p->MC_linear_dataH); 
     123        results = (double*)WaveData(p->resultsH); 
    123124         
    124125        seed = (long)results[0]; 
     
    164165                return NOWAV; 
    165166 
    166 //      waveType = WaveType(wavH); 
    167 //      if (waveType & NT_CMPLX) 
    168 //              return NO_COMPLEX_WAVE; 
    169 //      if (waveType==TEXT_WAVE_TYPE) 
    170 //              return NUMERIC_ACCESS_ON_TEXT_WAVE; 
    171 //      if (retVal = MDGetWaveDimensions(wavH, &numDimensions, dimensionSizes)) 
    172 //              return retVal; 
    173 //      numRows = dimensionSizes[0]; 
    174 //      numColumns = dimensionSizes[1]; 
    175          
    176 //      if (retVal = MDAccessNumericWaveData(wavH, kMDWaveAccessMode0, &dataOffset)) 
    177 //              return retVal; 
    178                  
    179 //      hState = MoveLockHandle(wavH);          // So wave data can't move. Remember to call HSetState when done. 
    180 //      dataStartPtr = (char*)(*wavH) + dataOffset; 
    181 //      dp0 = (double*)dataStartPtr;                    // Pointer to the start of the 2D wave data. 
    182167         
    183168//scattering power and maximum qvalue to bin 
     
    502487                return retVal; 
    503488 
    504 //      HSetState((Handle)wavH, hState);                //release the handle of the 2D data wave 
    505489//      WaveHandleModified(wavH);                       // Inform Igor that we have changed the wave. (CALLBACK! needed, but not allowed in Threading) 
    506490         
  • sans/XOP_Dev/MonteCarlo/MonteCarlo3.c

    r825 r834  
    5858        waveHndl wavH; 
    5959        //      int waveType,hState; 
    60         long numDimensions; 
    61         long dimensionSizes[MAX_DIMENSIONS+1]; 
     60        //changed for TK6 
     61        int numDimensions; 
     62        CountInt dimensionSizes[MAX_DIMENSIONS+1]; 
    6263        //      char* dataStartPtr; 
    6364        //      long dataOffset; 
     
    110111        p->retVal = 0; 
    111112         
    112         // trusting that all inputs are DOUBLE PRECISION WAVES!!! 
    113         inputWave = WaveData(p->inputWaveH); 
    114         ran_dev = WaveData(p->ran_devH); 
    115         nt = WaveData(p->ntH); 
    116         j1 = WaveData(p->j1H); 
    117         j2 = WaveData(p->j2H); 
    118         nn = WaveData(p->nnH); 
    119         //      MC_linear_data = WaveData(p->MC_linear_dataH); 
    120         results = WaveData(p->resultsH); 
     113        // trusting that all inputs are double PRECISION WAVES!!! 
     114        inputWave = (double*)WaveData(p->inputWaveH); 
     115        ran_dev = (double*)WaveData(p->ran_devH); 
     116        nt = (double*)WaveData(p->ntH); 
     117        j1 = (double*)WaveData(p->j1H); 
     118        j2 = (double*)WaveData(p->j2H); 
     119        nn = (double*)WaveData(p->nnH); 
     120        //      MC_linear_data = (double*)WaveData(p->MC_linear_dataH); 
     121        results = (double*)WaveData(p->resultsH); 
    121122         
    122123        seed = (long)results[0]; 
     
    162163                return NOWAV; 
    163164         
    164         //      waveType = WaveType(wavH); 
    165         //      if (waveType & NT_CMPLX) 
    166         //              return NO_COMPLEX_WAVE; 
    167         //      if (waveType==TEXT_WAVE_TYPE) 
    168         //              return NUMERIC_ACCESS_ON_TEXT_WAVE; 
    169         //      if (retVal = MDGetWaveDimensions(wavH, &numDimensions, dimensionSizes)) 
    170         //              return retVal; 
    171         //      numRows = dimensionSizes[0]; 
    172         //      numColumns = dimensionSizes[1]; 
    173          
    174         //      if (retVal = MDAccessNumericWaveData(wavH, kMDWaveAccessMode0, &dataOffset)) 
    175         //              return retVal; 
    176          
    177         //      hState = MoveLockHandle(wavH);          // So wave data can't move. Remember to call HSetState when done. 
    178         //      dataStartPtr = (char*)(*wavH) + dataOffset; 
    179         //      dp0 = (double*)dataStartPtr;                    // Pointer to the start of the 2D wave data. 
    180165         
    181166        //scattering power and maximum qvalue to bin 
     
    498483                return retVal; 
    499484         
    500         //      HSetState((Handle)wavH, hState);                //release the handle of the 2D data wave 
    501485        //      WaveHandleModified(wavH);                       // Inform Igor that we have changed the wave. (CALLBACK! needed, but not allowed in Threading) 
    502486         
  • sans/XOP_Dev/MonteCarlo/MonteCarlo4.c

    r825 r834  
    5959        waveHndl wavH; 
    6060        //      int waveType,hState; 
    61         long numDimensions; 
    62         long dimensionSizes[MAX_DIMENSIONS+1]; 
     61        //changed for TK6 
     62        int numDimensions; 
     63        CountInt dimensionSizes[MAX_DIMENSIONS+1]; 
    6364        //      char* dataStartPtr; 
    6465        //      long dataOffset; 
     
    111112        p->retVal = 0; 
    112113         
    113         // trusting that all inputs are DOUBLE PRECISION WAVES!!! 
    114         inputWave = WaveData(p->inputWaveH); 
    115         ran_dev = WaveData(p->ran_devH); 
    116         nt = WaveData(p->ntH); 
    117         j1 = WaveData(p->j1H); 
    118         j2 = WaveData(p->j2H); 
    119         nn = WaveData(p->nnH); 
    120         //      MC_linear_data = WaveData(p->MC_linear_dataH); 
    121         results = WaveData(p->resultsH); 
     114        // trusting that all inputs are double PRECISION WAVES!!! 
     115        inputWave = (double*)WaveData(p->inputWaveH); 
     116        ran_dev = (double*)WaveData(p->ran_devH); 
     117        nt = (double*)WaveData(p->ntH); 
     118        j1 = (double*)WaveData(p->j1H); 
     119        j2 = (double*)WaveData(p->j2H); 
     120        nn = (double*)WaveData(p->nnH); 
     121        //      MC_linear_data = (double*)WaveData(p->MC_linear_dataH); 
     122        results = (double*)WaveData(p->resultsH); 
    122123         
    123124        seed = (long)results[0]; 
     
    163164                return NOWAV; 
    164165         
    165         //      waveType = WaveType(wavH); 
    166         //      if (waveType & NT_CMPLX) 
    167         //              return NO_COMPLEX_WAVE; 
    168         //      if (waveType==TEXT_WAVE_TYPE) 
    169         //              return NUMERIC_ACCESS_ON_TEXT_WAVE; 
    170         //      if (retVal = MDGetWaveDimensions(wavH, &numDimensions, dimensionSizes)) 
    171         //              return retVal; 
    172         //      numRows = dimensionSizes[0]; 
    173         //      numColumns = dimensionSizes[1]; 
    174          
    175         //      if (retVal = MDAccessNumericWaveData(wavH, kMDWaveAccessMode0, &dataOffset)) 
    176         //              return retVal; 
    177          
    178         //      hState = MoveLockHandle(wavH);          // So wave data can't move. Remember to call HSetState when done. 
    179         //      dataStartPtr = (char*)(*wavH) + dataOffset; 
    180         //      dp0 = (double*)dataStartPtr;                    // Pointer to the start of the 2D wave data. 
    181166         
    182167        //scattering power and maximum qvalue to bin 
     
    499484                return retVal; 
    500485         
    501         //      HSetState((Handle)wavH, hState);                //release the handle of the 2D data wave 
    502486        //      WaveHandleModified(wavH);                       // Inform Igor that we have changed the wave. (CALLBACK! needed, but not allowed in Threading) 
    503487         
  • sans/XOP_Dev/MonteCarlo/MonteCarlo_Main.c

    r812 r834  
    415415 main() does any necessary initialization and then sets the XOPEntry field of the 
    416416 ioRecHandle to the address to be called for future messages. 
     417  
     418 changed for TK6 30JAN2012 SRK 
    417419 */ 
    418 HOST_IMPORT void 
     420HOST_IMPORT int 
    419421main(IORecHandle ioRecHandle) 
    420422{        
     
    422424        SetXOPEntry(XOPEntry);                                                  // Set entry point for future calls. 
    423425         
    424         if (igorVersion < 600)                          // Requires Igor Pro 6.00 or later. 
    425                 SetXOPResult(OLD_IGOR);                 // OLD_IGOR is defined in WaveAccess.h and there are corresponding error strings in WaveAccess.r and WaveAccessWinCustom.rc. 
    426         else 
    427                 SetXOPResult(0L); 
    428 } 
     426        if (igorVersion < 600)  {                                       // Requires Igor Pro 6.00 or later. 
     427                SetXOPResult(IGOR_OBSOLETE);     
     428                return EXIT_FAILURE; 
     429        } 
     430 
     431        SetXOPResult(0); 
     432        return EXIT_SUCCESS; 
     433         
     434} 
Note: See TracChangeset for help on using the changeset viewer.