program SwarmL2_MLI_SHA_Read_Test c Program to test the Fortran SHA reading routine for MLI_SHA files c The SHA coefficients are placed in coeffs, the degree and order in c degord. If n_min is not equal to 1, the coeffs are still placed at c their respective places, i.e., from n_min*(n_min+2)+1 to c n_max*(n_max+2) implicit none character filnam*100 integer n_degree_max,n_time_max parameter (n_time_max=100,n_degree_max=150) integer n_max,n_min,n_time,spline_order,n_step,i,j 1 ,degord(2,n_degree_max*(n_degree_max+2)) real*8 coeffs(n_time_max,n_degree_max*(n_degree_max+2)) 1 ,time(n_time_max) filnam='IGRF11.shc' call read_SHC(filnam,n_degree_max,n_time_max,n_min,n_max, 1 n_time,spline_order,n_step,coeffs,time,degord) open(1,file='test_read_shc.out') write(1,'(i3,4i4)') n_min,n_max,n_time,spline_order,n_step write(1,'(8x,100f13.3)') (time(j),j=1,n_time) do i=n_min**2,n_max*(n_max+2) write(1,'(i3,i5,100f13.5)') 1 (degord(j,i),j=1,2),(coeffs(j,i),j=1,n_time) enddo close(1) end subroutine read_shc 1 (filnam,n_degree_max,n_time_max,n_min,n_max, 1 n_time,spline_order,n_step,coeffs,time,degord) c subroutine for reading SwarmL2 SHA files c The SHA coefficients are placed in coeffs, the degree and order in c degord. If n_min is not equal to 1, the coeffs are still placed at c their respective places, i.e., from n_min*(n_min+2)+1 to c n_max*(n_max+2) implicit none character filnam*(*),dummy*1 integer n_degree_max,n_time_max integer n_max,n_min,n_time,spline_order,n_step,i,j,id 1 ,degord(2,n_degree_max*(n_degree_max+2)) real*8 coeffs(n_time_max,n_degree_max*(n_degree_max+2)) 1 ,time(n_time_max) do i=1,n_time_max do j=1,n_degree_max*(n_degree_max+2) coeffs(i,j)=9 enddo enddo id=45 open(id,file=filnam,status='old',err=100) 1 read(id,'(a1)') dummy if(dummy .eq. "#") goto 1 backspace(id) read(id,*) n_min,n_max,n_time,spline_order,n_step if(n_max .gt. n_degree_max) then write(*,*) 'File ',filnam,' contains degrees up to',n_max write(*,*) 'This is higher than calling program.' write(*,*) 'Only reading ',n_degree_max,' degrees.' n_max=n_degree_max endif if(n_time .gt. n_time_max) then write(*,*) 'File ',filnam,' contains',n_time,'timesteps' write(*,*) 'This is higher than calling program.' write(*,*) 'Only reading ',n_time_max,' times.' n_time=n_time_max endif read(id,*) (time(j),j=1,n_time) do i=n_min**2,n_max*(n_max+2) read(id,*) (degord(j,i),j=1,2),(coeffs(j,i),j=1,n_time) enddo close(id) return 100 write(*,*) 'Problems opening file: ',filnam end