program f90_COLCIRC implicit none real(4),parameter::pi=3.141592654 integer::RR(1:360),GG(1:360),BB(1:360) integer::hh ! Hue (0/359) integer::ss ! satiration (0/255) integer::vv ! Value (0/255) integer::R,G,B ! Converted RGB from HSV integer::i,da real(4)::r1,r2,theta1,theta2 real(4)::xx,yy character(len=3)::dum1,dum2,dum3 character(len=3)::dumr1,dumr2 character(len=10)::dumx,dumy character(len=200)::dummy call getarg(1,dum1) call getarg(2,dum2) call getarg(3,dum3) read(dum1,*) da read(dum2,*) ss read(dum3,*) vv r1=3.0 r2=6.0 call DEFHUE(RR,GG,BB) do i=0,360-da,da hh=i call HSVtoRGB(hh,ss,vv,R,G,B) theta1=real(i)-0.5*real(da) theta2=real(i)+0.5*real(da) write(dumr1,'(f3.1)') r1 write(dumr2,'(f3.1)') r2 write(dumx,'(f7.3)') theta1 write(dumy,'(f7.3)') theta2 write(dum1,'(i3)') R write(dum2,'(i3)') G write(dum3,'(i3)') B dummy='echo 0 0 '//trim(adjustl(dumr2))//' '//trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' | psxy -SW -R -J -G' & & //trim(adjustl(dum1))//'/' & & //trim(adjustl(dum2))//'/' & & //trim(adjustl(dum3))//' -K -O >> %fig%' write(6,*) trim(adjustl(dummy)) end do write(6,*) 'echo 0 0 | psxy -R -J -SC'//trim(adjustl(dumr1))//' -G255/255/255 -K -O >> %fig%' write(dum1,'(i3)') da write(dum2,'(i3)') ss write(dum3,'(i3)') vv open(13,file='_text.txt',status='replace') write(13,*) '0 1 14 0 0 MC H.inc='//trim(adjustl(dum1)) write(13,*) '0 0 14 0 0 MC S='//trim(adjustl(dum2)) write(13,*) '0 -1 14 0 0 MC V='//trim(adjustl(dum3)) if(da==60)then call COORD(0.0,r1+0.9,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 0 0 MC Red' call COORD(60.0,r1+0.9,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 -60 0 MC Yellow' call COORD(120.0,r1+0.9,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 60 0 MC Lime' call COORD(180.0,r1+0.9,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 0 0 MC Cyan' call COORD(240.0,r1+0.9,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 -60 0 MC Blue' call COORD(300.0,r1+0.9,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 60 0 MC Magenta' call COORD(0.0,r1+2.0,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 0 0 MC (255,0,0)' call COORD(60.0,r1+2.0,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 -60 0 MC (255,255,0)' call COORD(120.0,r1+2.0,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 60 0 MC (0,255,0)' call COORD(180.0,r1+2.0,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 0 0 MC (0,255,255)' call COORD(240.0,r1+2.0,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 -60 0 MC (0,0,255)' call COORD(300.0,r1+2.0,xx,yy) write(dumx,'(e10.3)') xx write(dumy,'(e10.3)') yy write(13,*) trim(adjustl(dumx))//' '//trim(adjustl(dumy))//' 10 60 0 MC (255,0,255)' end if close(13) stop contains subroutine DEFHUE(RR,GG,BB) integer,intent(out)::RR(1:360),GG(1:36),BB(1:36) integer::hue,i do hue=0,59 i=hue+1 RR(i)=255 GG(i)=real(255)/real(60)*hue BB(i)=0 end do do hue=60,119 i=hue+1 RR(i)=255-real(255)/real(60)*(hue-60) GG(i)=255 BB(i)=0 end do do hue=120,179 i=hue+1 RR(i)=0 GG(i)=255 BB(i)=real(255)/real(60)*(hue-120) end do do hue=180,239 i=hue+1 RR(i)=0 GG(i)=255-real(255)/real(60)*(hue-180) BB(i)=255 end do do hue=240,299 i=hue+1 RR(i)=real(255)/real(60)*(hue-240) GG(i)=0 BB(i)=255 end do do hue=300,359 i=hue+1 RR(i)=255 GG(i)=0 BB(i)=255-real(255)/real(60)*(hue-300) end do end subroutine DEFHUE subroutine HSVtoRGB(hh,ss,vv,R,G,B) integer,intent(in)::hh,ss,vv integer,intent(out)::R,G,B real(4)::ff integer::ii,pp,qq,tt ii = mod(real(hh)/60.0,6.0) ff = real(hh)/60.0-real(int(real(hh)/60.0)) pp = nint(vv*(1.0-(ss/255.0))) qq = nint(vv*(1.0-(ss/255.0)*ff)) tt = nint(vv*(1.0-(ss/255.0)*(1.0-ff))) R=0; G=0; B=0 select case (ii) case(0) R=vv; G=tt; B=pp case(1) R=qq; G=vv; B=pp case(2) R=pp; G=vv; B=tt case(3) R=pp; G=qq; B=vv case(4) R=tt; G=pp; B=vv case(5) R=vv; G=pp; B=qq end select end subroutine HSVtoRGB subroutine COORD(ang,rr,xx,yy) real(4),parameter::pi=3.141592654 real(4),intent(in)::ang,rr real(4),intent(out)::xx,yy if(-90.0<=ang.and.ang<90.0)then xx=rr*sin(ang*pi/180.0) yy=rr*cos(ang*pi/180.0) else if(90.0<=ang.and.ang<180.0)then xx= rr*cos((ang-90.0)*pi/180.0) yy=-rr*sin((ang-90.0)*pi/180.0) else if(180.0<=ang.and.ang<270.0)then xx=-rr*sin((ang-180.0)*pi/180.0) yy=-rr*cos((ang-180.0)*pi/180.0) else if(270.0<=ang.and.ang<360.0)then xx=-rr*cos((ang-270.0)*pi/180.0) yy= rr*sin((ang-270.0)*pi/180.0) end if end subroutine COORD end program f90_COLCIRC