module m_CAL06_initializecfmod use mod_CAL06_calnusparticles use mod_xc ! HYCOM communication interface use mod_year_info contains subroutine initializecfmod(rt,nflt,rungen,fltflg) implicit none type(year_info), intent(in) :: rt character(len=3), intent(in) :: rungen integer, intent(in) :: nflt,fltflg integer :: i,t,b,j,newpop,x,rpop,ye,cd(6,1992:2000) real :: nevn,ze,norm,expo,rand,nmax,cum,sd integer :: iostat, nfl real, parameter :: ER = 6378135.0 real :: tmp iostat=0 if (fltflg.eq.1) then print*, 'New output files for calanus are generated' open(801,file='calanus_out',status='replace',form='formatted') close(801) open(801,file='mortality_out',status='replace',form='formatted') close(801) open(801,file='Biol_mortality.dat',status='replace',form='unformatted') close(801) endif call td(0,cmort) do nfl=1,nflt if (nfl.gt.mpop) then print*, 'Dimension for floats array is too small' print*, 'mpop:',mpop, 'nfl:',nfl call xcstop('(initializecfmod)') end if !fix cfs(nfl)%physprop=flts(nfl) !done in mode_floats cfs(nfl)%mirr=0 cfs(nfl)%fi=0 end do close(41) newpop = mpop*0.4 !pop !predation density call preddens if (readpop==0) then ! initilize new population !Create chromosomes for copepods ! Set to reasonable values do nfl=1,nflt call random_number(rand) !AS cfs(nfl)%sv(1) = calasc + 2.0*(rand - 0.5)*calstd ! Ascent day tmp=(2.0*(exp(-(rand-0.5)**2.0/(2.0*(0.42**2.0)))-0.5)) call random_number(rand) cfs(nfl)%sv(1)=calasc + 2.0*(rand-0.5)*calstd*tmp cfs(nfl)%sv(2) = 0.4 ! Fat-soma-rato of descent cfs(nfl)%sv(3) = 144.0 ! Overwinter moulting cfs(nfl)%sv(4) = cfs(nfl)%pos(3) ! Overwintering depth AS0707, changed from 780 cfs(nfl)%sv(5) = 13.0 ! Ny: 13.0 Old: 30.0 !Overwintering depth cfs(nfl)%sv(6) = 20500.0 ! Ny: 20500 Old: 158.0 !Overwintering depth enddo !Create attributes of super-individuals do nfl = 1,nflt cfs(nfl)%age=150.0 cfs(nfl)%av(0) = 1.0 cfs(nfl)%av(1) = 12.0 cfs(nfl)%av(2) = maxegg*0.5 cfs(nfl)%av(3) = 120.0 !in microgram C !120 cfs(nfl)%av(4) = 150.0 !150. cfs(nfl)%av(5) = 20. cfs(nfl)%av(6) = 0. cfs(nfl)%av(7) = 0. cfs(nfl)%av(8) = cfs(nfl)%pos(3) !cfs(nfl)%sv(4) cfs(nfl)%av(9) = cfs(nfl)%pos(1) cfs(nfl)%av(10) = cfs(nfl)%pos(2) cfs(nfl)%av(11) = 0. cfs(nfl)%av(12) = 0. cfs(nfl)%av(13) = 0. cfs(nfl)%av(14) = cfs(nfl)%num cfs(nfl)%av(18) = cfs(nfl)%av(2) cfs(nfl)%av(19) = 0.0 cfs(nfl)%nsip = 0 cfs(nfl)%generation = 0 ! make sure gender is the same in both inner and outer model call random_number(rand) if (rand.gt.0.5) then cfs(nfl)%gender = 1 else cfs(nfl)%gender = 0 end if totbio = totbio + cfs(nfl)%av(2)*(cfs(nfl)%av(5) + cfs(nfl)%av(3)*4.) !Convert to wet weight enddo call print_calanus_info(cfs(1)) totbio = totbio*1.E-18 !Convert to millions of tonnes print*, 'Totbio: ',totbio ! call biomass #if defined (NOMODEL) if (initfl==0) then !fix call write_boundary_calanus(rt,rungen) end if #endif ! /* NOMODEL */ elseif(readpop==1) then !Read adapted population from file open(17, file = 'library/'//'sv_all.txt') open(188, file = 'library/'//'av_all.txt') open(199, file = 'library/'//'bsv_all.txt') read(188,*)rpop pop = min(rpop,mpop) print*,'Number of released super individuals:',pop newpop = pop do i = 1,pop read(17,*) (cfs(i)%sv(i), j = 1,maxs) !sv_all.txt read(188,*)(cfs(i)%av(j), j = 0,maxa) !av_all.txt ! read(199,*)(cfs(i)%bsv(j),j = 1,3) !bsv_all.txt enddo close(17) close(188) close(199) endif pop = newpop !Cumulative normal distribution sd = 0.2*maxt nevn = sqrt(6.28318*sd) norm = (1./nevn) nmax = 0. cum = 0. do t = 1,maxt ze = ((t-int(0.18*maxt))**2.)/(2*sd**2.) expo = exp(-ze) npar(t) = norm*expo cum = cum + npar(t) cumn(t) = cum if(npar(t)>nmax) nmax = npar(t) enddo !Print !open(27, file = 'out/'//'hormon.txt') ! do t = 1,maxt ! npar(t) = npar(t)/nmax ! cumn(t) = cumn(t)/cum ! !write(27,*)t,npar(t),cumn(t) ! enddo !close(27) do x = 0,13 avpred(x) = 0. numpred(x) = 0. agemolt(x) = 0. molters(x) = 0. enddo pop=nflt !Calculate mackerel predation probability ! open(27, file = 'in/'//'makrelldatoer.txt') !! do ye = 1992,2000 ! read(27,*)cd(1:6,ye) ! enddo ! close(27) ! do ye = 1992,2000 ! sd = 0.2*cd(4,ye) ! nevn = sqrt(6.28318*sd) ! norm = (1./nevn) ! nmax = 0. ! do t = cd(2,ye),cd(3,ye) !! ze = ((t-cd(5,ye))**2.)/(2*sd**2.) ! expo = exp(-ze) ! npar(t) = norm*expo ! if(npar(t)>nmax) nmax = npar(t) ! enddo ! do t = 1,365 ! if(t