C***********************************************************************        
      SUBROUTINE GRDTRP(AM,AG,IM,JM,DIM,DJM,LG,LM,IMAXG,JMAXG,IMAXM,            
     1JMAXM)                                                                    
C     ****                                                                      
C     ****     SUBROUTINE TRANSFORMS SCALAR FIELD GIVEN ON GEOMAGNETIC          
C     ****     GRID TO GEOGRAPHIC GRID USING COEFFICIENTS FOR BILINEAR          
C     ****     INTERPOLATION PREVIOUSLY GENERATED BY CALL TO GRDSET.            
C     ****                                                                      
C     ****     GEOGRAPHIC GRID:                                                 
C     ****       IMAXG EQUALLY SPACED LONGITUDE POINTS.  RANGE                  
C     ****         -PI TO PI.                                                   
C     ****       JMAXG LATITUDE POINTS, NOT NECESSARILY EQUALLY                 
C     ****         SPACED.  RANGE -PI/2 TO P/2.                                 
C     ****                                                                      
C     ****     GEOMAGNETIC GRID:                                                
C     ****       IMAXM EQUALLY SPACED LONGITUDE POINTS.  RANGE                  
C     ****         -PI TO PI.                                                   
C     ****       JMAXM LATITUDE POINTS, NOT NECESSARILY EQUALLY                 
C     ****         SPACED.  RANGE -PI/2 TO P/2.  MUST INCLUDE                   
C     ****         POLES                                                        
C     ****                                                                      
C     ****     INPUT:                                                           
C     ****                                                                      
C     ****       AM(LM,JMAXM) IS 2-DIM SCALAR FIELD GIVEN ON GEOMAGNETIC
C     ****         LATITUDE/LONGITUDE GRID.                                     
C     ****         NB.  PERIODIC POINT IS REPEATED SO THAT                      
C     ****         AM(IMAXM+1,JM) = AM(1,JM)                                    
C     ****         (LM.GE.IMAXM+1)                                              
C     ****                                                                      
C     ****       IMAXG, JMAXG  DIMENSIONS OF GEOGRAPHIC GRID                    
C     ****                                                                      
C     ****       IMAXM, JMAXM  DIMENSIONS OF GEOMAGNETIC GRID                   
C     ****                                                                      
C     ****       LM IS FIRST DIMENSION OF ARRAY AM INCALLING PROGRAM            
C     ****         (LM.GE.IMAXM+1)                                              
C     ****                                                                      
C     ****       IM(LG,JMAXG) GIVES ROUNDED DOWN GEOMAGNETIC LONGITUDE
C     ****         INDEX FOR EACH GEOGRAPHIC GRID POINT                         
C     ****                                                                      
C     ****       JM(LG,JMAXG) GIVES ROUNDED DOWN GEOMAGNETIC LATITUDE
C     ****         INDEX FOR EACH GEOGRAPHIC GRID POINT                         
C     ****                                                                      
C     ****       DIM(LG,JMAXG) IS FRACTIONAL GEOMAGNETIC LONGITUDE INDEX
C     ****         FOR EACH GEOGRAPHIC GRID POINT.  USED FOR BILINEAR           
C     ****         INTERPOLATION WITHINGRID CELL.                               
C     ****                                                                      
C     ****       DJM(LG,JMAXG) IS FRACTIONAL GEOMAGNETIC LATITUDE INDEX
C     ****         FOR EACH GEOGRAPHIC GRID POINT.  USED FOR BILINEAR           
C     ****         INTERPOLATION WITHINGRID CELL.                               
C     ****                                                                      
C     ****       LG IS FIRST DIMENSION OF ARRAYS AM,IM,JM,DIM,DJM IN            
C     ****         CALLING PROGRAM.                                             
C     ****         (LG.GE.IMAXG)                                                
C     ****                                                                      
C     ****       NOTE:  IM, JM, DIM, DJM ARE PRODUCED BY PREVIOUS CALL          
C     ****         TO GRDSET.                                                   
C     ****                                                                      
C     ****     OUTPUT:                                                          
C     ****                                                                      
C     ****       AG(LG,JMAXG) IS 2-DIM SCALAR FIELD TRANSFORMED TO
C     ****         GEOGRAPHIC LATITUDE/LONGITUDE GRID.                          
C     ****         (LG.GE.IMAXG)                                                
C     ****                                                                      
C     ****     PERFORM BILINEAR INTERPOLATION                                   
C     ****                                                                      
      DIMENSION AM(LM,JMAXM),AG(LG,JMAXG),IM(LG,JMAXG),JM(LG,JMAXG),
     | DIM(LG,JMAXG),DJM(LG,JMAXG)
      DO 1 JG = 1,JMAXG                                                         
        DO 1 IG = 1,IMAXG                                                       
          AG(IG,JG) =                                                           
     1    AM(IM(IG,JG),JM(IG,JG))*(1.-DIM(IG,JG))*(1.-DJM(IG,JG))+              
     2    AM(IM(IG,JG)+1,JM(IG,JG))*DIM(IG,JG)*(1.-DJM(IG,JG))+                 
     3    AM(IM(IG,JG),JM(IG,JG)+1)*(1.-DIM(IG,JG))*DJM(IG,JG)+                 
     2    AM(IM(IG,JG)+1,JM(IG,JG)+1)*DIM(IG,JG)*DJM(IG,JG)                     
    1 CONTINUE                                                                  
      RETURN                                                                    
      END                                                                       
C***********************************************************************        
