Skip to content

Commit

Permalink
added missing location routines
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvand committed Jul 1, 2024
1 parent 86b7f7f commit 085f2bf
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ OBJECTS = \
write_output.o\
gradient.o\
tides.o\
get_location.o\
user.o

OBJECTS_EXE = main.o ${OBJECTS} ${MODULES}
Expand Down
74 changes: 74 additions & 0 deletions src/get_location.f90
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,80 @@ subroutine LocationIndex(LonFind, LatFind, iiBlock, iiLon, iiLat, rLon, rLat)

end subroutine LocationIndex

subroutine LocationProcIndex(LonFind, LatFind, AltFind, iiBlock, iiLon, iiLat, iAlt, rLon, rLat, rAlt, iiProc)

use ModGITM

real, intent(in) :: LonFind, LatFind
integer, intent(out) :: iiBlock, iiLon, iiLat, iiProc, iAlt
real, intent(out) :: rLon, rLat, rAlt

integer iBlock, iLon, iLat, jAlt

iiProc = -1
iiBlock = -1
iiLon = -1
iiLat = -1
iAlt = -1
rAlt = -1.0

do iBlock=1,nBlocks

if((Longitude(0,iBlock)+Longitude(1,iBlock))/2 <=LonFind .and. &
(Longitude(nLons,iBlock)+Longitude(nLons+1,iBlock))/2 >LonFind) then

if((Latitude(0,iBlock)+Latitude(1,iBlock))/2 <=LatFind .and. &
(Latitude(nLats,iBlock)+Latitude(nLats+1,iBlock))/2 >LatFind) then

!if((Altitude_GB(0,iBlock)+Altitude_GB(1,iBlock))/2 <=AltFind .and. &
! (Altitude_GB(nAlts,iBlock)+Altitude_GB(nAlts+1,iBlock))/2 >AltFind) then
if((minval(Altitude_GB) <=AltFind) .and. &
(maxval(Altitude_GB) >AltFind)) then

iiBlock = iBlock
iiProc = iProc

do iLon = 0,nLons
if(Longitude(iLon,iBlock) <= LonFind .and. &
Longitude(iLon+1,iBlock) > LonFind) then
iiLon = iLon
rLon = 1.0 - (LonFind - Longitude(iLon,iBlock)) / &
(Longitude(iLon+1,iBlock) - Longitude(iLon,iBlock))
exit
endif
enddo

do iLat = 0,nLats
if(Latitude(iLat,iBlock) <= LatFind .and. &
Latitude(iLat+1,iBlock) > LatFind) then
iiLat = iLat
rLat = 1.0 - (LatFind - Latitude(iLat,iBlock)) / &
(Latitude(iLat+1,iBlock) - Latitude(iLat,iBlock))
exit
endif
enddo

do jAlt = 0,nAlts
if (Altitude_GB(iLon, iLat, jAlt, iBlock) <= AltFind .and. &
Altitude_GB(iLon, iLat, jAlt+1,iBlock) > AltFind) then
iAlt = jAlt
rAlt = 1.0 - (AltFind - Altitude_GB(iLon, iLat, iAlt, iBlock)) &
/ (Altitude_GB(iLon, iLat, iAlt+1, iBlock) &
- Altitude_GB(iLon, iLat, iAlt, iBlock))
exit
endif
enddo

if(iiLon >= 0 .and. iiLat >= 0 .and. iAlt >= 0) then
exit
end if
end if
end if
end if
end do

end subroutine LocationProcIndex

subroutine BlockLocationIndex(LonFind,LatFind,iBlock,iiLon,iiLat,rLon,rLat)

use ModGITM
Expand Down

0 comments on commit 085f2bf

Please sign in to comment.