module m_get_regions contains subroutine get_regions(lon_region,lat_region,numpoints_region,name_region,nregion,maxpoints) implicit none integer, intent(out) :: nregion,maxpoints character(len=20),pointer, dimension(:) :: name_region real, pointer, dimension(:,:) :: lon_region real, pointer, dimension(:,:) :: lat_region integer, pointer, dimension(:) :: numpoints_region character(len=*), parameter :: infile_RMS = 'regiondefs.in' integer, parameter :: l_maxpoints=10 character(len=20) :: tmpchar logical :: ex integer :: ios, region_counter,numpoints, point_counter real :: v1,v2 print * ! This specifies regions for computing the RMS over inquire(exist=ex,file=infile_RMS) if (.not. ex) then print '(a)','You must specify regions to use in' print '(a)','the file called '//infile_RMS stop '(get_regions)' endif ! Start reading maxpoints=l_maxpoints ios=0 region_counter=1 open(10,file=infile_RMS,form='formatted') read(10,*,iostat=ios) nregion print '(i3,a)',nregion,' Regions:' allocate(name_region(nregion)) allocate(lon_region (nregion,maxpoints)) allocate(lat_region (nregion,maxpoints)) allocate(numpoints_region(nregion)) do while (region_counter<=nregion .and. ios==0 ) read (10,*,iostat=ios) numpoints, tmpchar if (ios==0) then name_region(region_counter)=trim(tmpchar) if (numpoints>maxpoints) then print *,'To many points for region number ',region_counter stop '(get_regions)' end if if (numpoints<3) then print *,'To few points for region number ',region_counter stop '(get_regions)' end if numpoints_region(region_counter)=numpoints write(*,*) 'Number of points in region no ',region_counter,': ',numpoints point_counter=1 do while (point_counter<=numpoints .and. ios==0) read (10,*,iostat=ios) v1,v2 if (ios==0) then lon_region(region_counter,point_counter)=v1 lat_region(region_counter,point_counter)=v2 print '(a,2f10.2)', 'lon lat:', & lon_region(region_counter,point_counter), & lat_region(region_counter,point_counter) point_counter=point_counter+1 else print *,'An error occured when reading reguion info' stop '(get_regions)' end if end do end if region_counter=region_counter+1 end do if (ios/=0) then print *,'An error occured when reading reguion info' stop '(get_regions)' end if end subroutine get_regions end module m_get_regions