Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Fri Nov 04, 2011 9:04 am Post subject: |
|
|
May be like this?
Code: | WINAPP
OPTIONS(INTL)
PROGRAM TEST
IMPLICIT NONE
real*8 alfa
character*1 A,B
character*7 string
c read data. alfa is converted to 0 ... 360 degrees
open(10,err=200,file='input.dat',status='old')
read(10,'(A)',err=200,end=200)string
call upcase@(string)
A = string(1:1)
B = string(7:7)
read(string(2:6),*,err=200)alfa
if (A .eq. 'S' .and. B .eq. 'E') then
alfa = alfa+90.D0
else if (A .eq. 'S' .and. B .eq. 'W') then
alfa = alfa+180.D0
else if (A .eq. 'N' .and. B .eq. 'W') then
alfa = alfa+270.D0
end if
print*,alfa
200 close(10)
c write data. example:
alfa = 127.D0
open(20,err=400,file='output.dat',status='unknown')
if (alfa .gt. 0.D0 .and. alfa .le. 90.D0) then
A = 'N'
B = 'E'
else if (alfa .gt. 90.D0 .and. alfa .le. 180.D0) then
A = 'S'
B = 'E'
alfa = alfa-90.D0
else if (alfa .gt. 180.D0 .and. alfa .le. 270.D0) then
A = 'S'
B = 'W'
alfa = alfa-180.D0
else
A = 'N'
B = 'W'
alfa = alfa-270.D0
end if
string(1:1) = A
string(7:7) = B
write(string(2:6),'(F5.2)',err=400)alfa
write(20,'(A)',err=400)string
print*,string
400 close(20)
end |
Regards - Wilfried |
|